import pandas as pd
from fbprophet import Prophet
df = pd.read_csv('https://raw.githubusercontent.com/danielcaraway/data/master/ca_train.csv')
df.head()
sm = df[['Date', 'ConfirmedCases']]
sm.columns = ['ds','y']
m = Prophet()
m.fit(sm)
future = m.make_future_dataframe(periods=365)
future.tail()
forecast = m.predict(future)
fig1 = m.plot(forecast)
def get_prof_preds_for(df, n):
m = Prophet()
m.fit(df)
future = m.make_future_dataframe(periods=n)
forecast = m.predict(future)
fig1 = m.plot(forecast)
get_prof_preds_for(sm, 60)
get_prof_preds_for(sm, 30)
get_prof_preds_for(sm, 10)
sm
get_prof_preds_for(sm[20:],10)
def get_prof_preds_for(df, n):
m = Prophet(daily_seasonality=True)
m.fit(df)
future = m.make_future_dataframe(periods=n)
forecast = m.predict(future)
fig1 = m.plot(forecast)
get_prof_preds_for(sm[20:],10)
get_prof_preds_for(sm[40:],10)
get_prof_preds_for(sm[40:],60)
get_prof_preds_for(sm[47:],30]
get_prof_preds_for(sm[47:],20)
sm = df[['Date', 'Fatalities']]
sm.columns = ['ds','y']
get_prof_preds_for(sm, 20)
sm
get_prof_preds_for(sm[47:], 20)
(using the mess we made above for fodder)
df.head()
cc = df[['Date', 'ConfirmedCases']] # cc = Confirmed Cases
fc = df[['Date', 'Fatalities']] # fc = Fatal Cases
def get_prof_preds_for(df, n):
df.columns = ['ds', 'y']
m = Prophet()
m.fit(df)
future = m.make_future_dataframe(periods=n)
forecast = m.predict(future)
fig1 = m.plot(forecast)
return forecast
pred_cc_1 = get_prof_preds_for(cc, 40)
pred_fc_1 = get_prof_preds_for(fc, 40)
pred_cc_1.tail()['yhat']
pred_fc_1.tail()['trend']
pred_fc_1.tail()
pred_cc_2 = get_prof_preds_for(cc[40:], 40)
pred_fc_2 = get_prof_preds_for(fc[40:], 40)
pred_cc_2.tail()['yhat']
pred_fc_2.tail()['yhat']
pred_fc_2.tail()
pred_cc_3 = get_prof_preds_for(cc[47:], 40)
pred_fc_3 = get_prof_preds_for(fc[47:], 40)
pred_cc_3.tail()
pred_fc_3.tail()