Created
September 23, 2021 18:32
-
-
Save marcosan93/c820749031e12d1913297e67dfc33046 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_period): | |
""" | |
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( | |
daily_seasonality=True, | |
yearly_seasonality=True, | |
weekly_seasonality=True | |
) | |
# Fitting to the prices | |
m.fit(df[['ds', 'y']]) | |
# Future DF | |
future = m.make_future_dataframe(periods=forecast_period) | |
# 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