diff options
| author | Priyansh <[email protected]> | 2021-12-09 03:01:49 -0500 |
|---|---|---|
| committer | Priyansh <[email protected]> | 2021-12-09 03:01:49 -0500 |
| commit | 3b48c04470e2c368ba18716bb789b40942d6989f (patch) | |
| tree | 1cb97d5271f2233fbf9d0ef864b91fc8a61efb17 /model_builder.py | |
| parent | 22e1d761027501bfa59b92776cf1c13eef3a0004 (diff) | |
| download | temp_pred_arima-3b48c04470e2c368ba18716bb789b40942d6989f.tar.xz temp_pred_arima-3b48c04470e2c368ba18716bb789b40942d6989f.zip | |
changed project structure
Diffstat (limited to 'model_builder.py')
| -rw-r--r-- | model_builder.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/model_builder.py b/model_builder.py new file mode 100644 index 0000000..b12897a --- /dev/null +++ b/model_builder.py @@ -0,0 +1,27 @@ +import pandas as pd +from functions.sql_functions import execute_sql_statement +import pmdarima as pm +import pickle + +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" + +result = execute_sql_statement(sql_stmt) +data = pd.DataFrame(result, columns=["date", "city_id", "temp"]) +data.set_index(["date", "city_id"], inplace=True) +ts_model = pm.auto_arima(data.temp, start_p=1, start_q=1, + test='adf', + max_p=3, max_q=3, + m=5, + d=None, + seasonal=False, + start_P=0, + D=0, + trace=True, + error_action='ignore', + suppress_warnings=True, + stepwise=True) +# Best model: ARIMA(3,0,3)(0,0,0)[0] + +with open('arima.pkl', 'wb') as pkl: + pickle.dump(ts_model, pkl) + |
