diff options
| author | Priyansh <[email protected]> | 2021-12-09 02:11:56 -0500 |
|---|---|---|
| committer | Priyansh <[email protected]> | 2021-12-09 02:11:56 -0500 |
| commit | 941d302b39e63c7bca496eff22a79e3e2a89d369 (patch) | |
| tree | 9b21f874d6bf8f5d492826be9224cbfdf82e0b82 | |
| parent | 6f2b27a0467b20e94be3892ef9726621f4880b1b (diff) | |
| download | temp_pred_arima-941d302b39e63c7bca496eff22a79e3e2a89d369.tar.xz temp_pred_arima-941d302b39e63c7bca496eff22a79e3e2a89d369.zip | |
After building the model, now the script compresses the arima file for VCS
| -rw-r--r-- | time_series_model.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/time_series_model.py b/time_series_model.py index 3fca7c0..6528ac0 100644 --- a/time_series_model.py +++ b/time_series_model.py @@ -2,6 +2,9 @@ import pandas as pd from sql_functions import execute_sql_statement import pmdarima as pm import pickle +import zlib +from os.path import exists +from os import remove sql_stmt = "select date, city_id, cast(avg_temperature as real) as temp from temperature where date is not null and temp is not null" @@ -24,3 +27,13 @@ ts_model = pm.auto_arima(data.temp, start_p=1, start_q=1, with open('arima.pkl', 'wb') as pkl: pickle.dump(ts_model, pkl) + +filename_in = "arima.pkl" +filename_out = "arima.compressed" +if exists(filename_out): + remove(filename_out) +with open(filename_in, mode="rb") as fin, open(filename_out, mode="wb") as fout: + data = fin.read() + print("Compressing Pickle File for Version Control...") + compressed_data = zlib.compress(data, zlib.Z_BEST_COMPRESSION) + fout.write(compressed_data)
\ No newline at end of file |
