This file has been truncated, but you can view the full file.
This file contains hidden or 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
| <html> | |
| <head><meta charset="utf-8" /></head> | |
| <body> | |
| <div> <script type="text/javascript">window.PlotlyConfig = {MathJaxConfig: 'local'};</script> | |
| <script type="text/javascript">/** | |
| * plotly.js v1.56.0 | |
| * Copyright 2012-2020, Plotly, Inc. | |
| * All rights reserved. | |
| * Licensed under the MIT license | |
| */ |
This file contains hidden or 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
| df_es = df_test.copy() | |
| df_es['preds'] = 0 | |
| p = len(df_test) | |
| model = ExponentialSmoothing(np.asarray(df_train['Page.Loads']),seasonal_periods=365, seasonal='add', trend='add') | |
| model_fit = model.fit() | |
| preds = model_fit.forecast(p) | |
| df_es['preds'] = preds |
This file contains hidden or 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
| def rolling_forecast_es(df, df_test, p): | |
| """ | |
| Does rolling training and forecast for one week at a time | |
| """ | |
| df_test['preds'] = 0 | |
| for k in range(0, int(len(df_test)/p)): | |
| model = ExponentialSmoothing(np.asarray(df['Page.Loads'].iloc[:ix2 + (k)*p]),seasonal_periods=365, seasonal='add', trend='add') | |
| model_fit = model.fit() | |
| preds = model_fit.forecast(p) |
This file contains hidden or 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
| from statsmodels.tsa.api import ExponentialSmoothing seasonal_decompose | |
| import statsmodels | |
| import pandas as pd | |
| import numpy as np | |
| import datetime | |
| from sklearn import metrics | |
| def preprocess(df): | |
| """ | |
| Preprocess the dataframe to required timeseries format |
NewerOlder