Created
January 13, 2022 22:57
-
-
Save marcosan93/ccd350391ea483cc3e2d806245d132ec to your computer and use it in GitHub Desktop.
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 fbpTrainPredict(df, forecast_hours): | |
| """ | |
| Uses FB Prophet and fits to a appropriately formatted DF. Makes a prediction N days into | |
| the future based on given forecast period. Returns predicted values as a DF. | |
| """ | |
| # Setting up prophet | |
| m = Prophet( | |
| yearly_seasonality=False, | |
| weekly_seasonality=False, | |
| daily_seasonality=False | |
| ) | |
| # Fitting to the prices | |
| m.fit(df[['ds', 'y']]) | |
| # Future DF | |
| future = m.make_future_dataframe( | |
| periods=forecast_hours, | |
| freq="H", | |
| include_history=False | |
| ) | |
| # Predicting values | |
| forecast = m.predict(future) | |
| # Returning a set of predicted values | |
| return forecast[['ds', 'yhat', 'yhat_lower', 'yhat_upper']] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment