Created
April 28, 2021 15:30
-
-
Save jiobu1/6ae972dcc006b937b719d94c9779b0ab to your computer and use it in GitHub Desktop.
prophet forecast model
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
def run_prophet(series): | |
model = Prophet(daily_seasonality=False, | |
weekly_seasonality=False, | |
yearly_seasonality=False) | |
model.fit(series) | |
forecast = model.make_future_dataframe(periods=10, freq='Y') | |
forecast = model.predict(forecast) | |
forecast = forecast[['ds', 'yhat', 'yhat_lower', 'yhat_upper']] | |
forecast['City,State'] = series['City,State'].iloc[0] | |
forecast = forecast[['City,State','ds', 'yhat', 'yhat_lower', 'yhat_upper']] | |
forecast['ds'] = pd.DatetimeIndex(forecast['ds']).year | |
forecast[['yhat', 'yhat_lower', 'yhat_upper']] = forecast[['yhat', 'yhat_lower', 'yhat_upper']].astype(float) | |
forecast[['yhat', 'yhat_lower', 'yhat_upper']] = forecast[['yhat', 'yhat_lower', 'yhat_upper']].apply(np.ceil) | |
return forecast | |
for i in range(len(series)): | |
f = run_prophet(series[i]) | |
f.to_csv('csv/population_prediction.csv', mode='a', index='False') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment