Kaggle competition: COVID19 Global Forecasting (Week 1)
<SOS> metric: MCRMSLE Kaggle data source: covid19-global-forecasting-(week-1)<set_options>
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from scipy.optimize import curve_fit
from statsmodels.tsa.statespace.sarimax import SARIMAX
from statsmodels.tsa.arima_model import ARIMA
from random import random
plt.style.use('ggplot')
 plt.rcParams['figure.figsize'] = [20, 8]
warnings.filterwarnings('ignore' )<load_from_csv>
df=pd.read_csv("/kaggle/input/covid19-global-forecasting-week-1/train.csv",usecols=['Lat','Province/State','Country/Region','Date','ConfirmedCases','Fatalities'])
 df.fillna(' ',inplace=True)
 df['Lat']=df['Province/State']+df['Country/Region']
df.drop('Province/State',axis=1,inplace=True)
 df.drop('Country/Region',axis=1,inplace=True)
 countries_list=df.Lat.unique()
df1=[]
for i in countries_list:
df1.append(df[df['Lat']==i])
 print("we have "+ str(len(df1)) +" regions in our dataset" )
train = pd.read_csv('/kaggle/input/covid19-global-forecasting-week-1/train.csv',
parse_dates=['Date'] ).drop(['Lat', 'Long'], axis=1)
 test = pd.read_csv('/kaggle/input/covid19-global-forecasting-week-1/test.csv',
parse_dates=['Date'] ).drop(['Lat', 'Long'], axis=1)
 submission = pd.read_csv('/kaggle/input/covid19-global-forecasting-week-1/submission.csv',
index_col='ForecastId' )<feature_engineering>
submit_confirmed=[]
submit_fatal=[]
for i in df1:
data = i.ConfirmedCases.astype('int32' ).tolist()
try:
model = SARIMAX(data, order=(2,1,0), seasonal_order=(1,1,0,12))
model_fit = model.fit(disp=False)
 predicted = model_fit.predict(len(data), len(data)+34)
 new=np.concatenate(( np.array(data),np.array([int(num)for num in predicted])) ,axis=0)
 submit_confirmed.extend(list(new[-43:]))
except:
submit_confirmed.extend(list(data[-10:-1]))
for j in range(34):
submit_confirmed.append(data[-1]*2)
 data = i.Fatalities.astype('int32' ).tolist()
try:
model = SARIMAX(data, order=(2,1,0), seasonal_order=(1,1,0,12))
model_fit = model.fit(disp=False)
 predicted = model_fit.predict(len(data), len(data)+34)
 new=np.concatenate(( np.array(data),np.array([int(num)for num in predicted])) ,axis=0)
 submit_fatal.extend(list(new[-43:]))
except:
submit_fatal.extend(list(data[-10:-1]))
for j in range(34):
submit_fatal.append(data[-1]*2)
 df_submit=pd.concat([pd.Series(np.arange(1,1+len(submit_confirmed))),pd.Series(submit_confirmed),pd.Series(submit_fatal)],axis=1 )
<find_best_params><EOS> 
df_submit=df_submit.fillna(method='pad' ).astype(int)
 df_submit.to_csv('submission.csv',header=['ForecastId','ConfirmedCases','Fatalities'],index=False )