# This Python 3 environment comes with many helpful analytics libraries installed
# It is defined by the kaggle/python docker image: https://github.com/kaggle/docker-python
# For example, here's several helpful packages to load in
import numpy as np # linear algebra
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
# Input data files are available in the "../input/" directory.
# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory
import os
for dirname, _, filenames in os.walk('/kaggle/input'):
for filename in filenames:
print(os.path.join(dirname, filename))
train = pd.read_csv('../input/covid19-local-us-ca-forecasting-week-1/ca_train.csv')
test = pd.read_csv('../input/covid19-local-us-ca-forecasting-week-1/ca_test.csv')
sub = pd.read_csv('../input/covid19-local-us-ca-forecasting-week-1/ca_submission.csv')
from sklearn.linear_model import LinearRegression
train=train[train.ConfirmedCases>0]
model_cc= LinearRegression()
x1=np.array(train.Id).reshape(-1,1)
y1=np.log(train.ConfirmedCases)
model_cc.fit(x1,y1)
model_fc= LinearRegression()
x2=np.array(train.ConfirmedCases).reshape(-1,1)
y2=train.Fatalities
model_fc.fit(x2,y2)
test["Id"]=50+test.ForecastId
test.head()
test["LogConf"]=model_cc.predict(np.array(test.Id).reshape(-1,1))
test["ConfirmedCases"]=np.exp(test.LogConf)//1
test["Fatalities"]=model_fc.predict(np.array(test.ConfirmedCases).reshape(-1,1))//1
for id in train.Id:
test.ConfirmedCases[test.Id==id]=train.ConfirmedCases[train.Id==id].sum()
test.Fatalities[test.Id==id]=train.Fatalities[train.Id==id].sum()
test
sub.ConfirmedCases=test.ConfirmedCases
sub.Fatalities=test.Fatalities
sub.to_csv("submission.csv", index=False)