Created
March 6, 2020 09:18
-
-
Save jamesmcm/dce39e62228e710b8d5853c963941630 to your computer and use it in GitHub Desktop.
SARIMAX_example.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
model = SARIMAX(data1, exog=data2, order=(1, 1, 2), seasonal_order=(1, 1, 1, 52)) | |
model_fit = model.fit(disp=False) | |
print(f"Global: {model_fit.summary()}") | |
for site in sites: | |
# make prediction | |
newdfinner = df_site.loc[df_site.site == site, :].fillna(0).reset_index(drop=True) | |
exog2 = newdfinner.loc[ | |
newdfinner["start_week_dt"] >= last_sunday, ["exog1", "exog2"] | |
].astype("float64") | |
yhat = model_fit.predict( | |
newdfinner[newdfinner["start_week_dt"] == last_sunday].index[0], | |
newdfinner.iloc[len(newdfinner) - 1, :].name, | |
exog=exog2, | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment