import pandas as pd
from google.colab import files
train_file = "https://raw.githubusercontent.com/danielcaraway/COVID19/master/WK4_0413/train.csv"
train = pd.read_csv(train_file)
## Just looking at CA
ca = train[train['Province_State'] == 'California']
ca['Date'] = pd.to_datetime(ca['Date'])
ca = ca[ca['ConfirmedCases'] > 0 ]
ca
import matplotlib.pyplot as plt
import seaborn as sns
ca.plot(x="Date", y=["ConfirmedCases", "Fatalities"])
plt.title('California')
plt.show()
++ Heading back to WEEK ONE
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)
df = df[df['ConfirmedCases'] > 0]
sm = df[['Date', 'ConfirmedCases']]
sm.columns = ['ds','y']
m = Prophet()
m.fit(sm)
future = m.make_future_dataframe(periods=30)
forecast = m.predict(future)
fig1 = m.plot(forecast)
forecast.head()
ca['ds'] = ca['Date']
m1 = forecast.copy()
m2 = ca.copy()
df_merged = pd.merge(m1, m2, how='left', on='ds', suffixes=('_v1', '_v2'))
df_merged.head()
sm_merge = df_merged[['ds','yhat_lower', 'yhat_upper', 'yhat', 'ConfirmedCases']]
sm_merge.plot(x="ds", y=["yhat", "yhat_lower", "yhat_upper", "ConfirmedCases"])
plt.title('California: Prophet vs Actual')
plt.show()