Kaggle competition: COVID19 Global Forecasting (Week 4)
<SOS> metric: MCRMSLE Kaggle data source: covid19-global-forecasting-(week-4)<train_model>
for dirname, _, filenames in os.walk('/kaggle/input'):
for filename in filenames:
print(os.path.join(dirname, filename))
train = pd.read_csv('/kaggle/input/covid19-global-forecasting-week-4/train.csv')
 test = pd.read_csv('/kaggle/input/covid19-global-forecasting-week-4/test.csv' )
learn.fit_one_cycle(5,2.5e-4 )<train_model>
def fixData(input_set):
input_set.rename(columns={'Country_Region':'Country'}, inplace=True)
 input_set.rename(columns={'Province_State':'State'}, inplace=True)
 input_set['Date'] = pd.to_datetime(input_set['Date'], infer_datetime_format=True)
 input_set['Date'] = input_set.Date.dt.strftime("%m%d")
 input_set['Date'] = input_set['Date'].astype(int)
 input_set["State"].fillna("",inplace=True)
 input_set["CountryState"] = input_set["Country"] + input_set["State"]
return input_set
train = fixData(train)
 test = fixData(test )
learn.fit_one_cycle(5,2.5e-4 )<train_model>
filterwarnings('ignore')
 label = LabelEncoder()
sub = pd.DataFrame({'ForecastId': [], 'ConfirmedCases': [], 'Fatalities': []})
 CountryState = train.CountryState.unique()
for CS in CountryState:
train2 = train[train["CountryState"] == CS]
test2 = test[test["CountryState"] == CS]
train2.CountryState = label.fit_transform(train2.CountryState)
 X = train2[['CountryState', 'Date']]
Y = train2[['ConfirmedCases']]
eval_set = [(X,Y)]
model1 = boostmodel(learning_rate=0.3,silent=0, n_estimators=1000)
 model1.fit(X, Y,eval_set=eval_set,early_stopping_rounds=100)
 testX = test2[['CountryState', 'Date']]
testX.CountryState = label.fit_transform(testX.CountryState)
 ConfirmedCases_Pred = model1.predict(testX)
 X = train2[['CountryState', 'Date']]
Y = train2[['Fatalities']]
eval_set = [(X,Y)]
model2 = boostmodel(learning_rate=0.3,silent=0, n_estimators=1020)
 model2.fit(X, Y,eval_set=eval_set,early_stopping_rounds=100)
 testX = test2[['CountryState', 'Date']]
testX.CountryState = label.fit_transform(testX.CountryState)
 Fatalities_Pred = model2.predict(testX)
 XForecastId = test2.loc[:, 'ForecastId']
output = pd.DataFrame({'ForecastId': XForecastId, 'ConfirmedCases': ConfirmedCases_Pred, 'Fatalities': Fatalities_Pred})
 sub = pd.concat([sub, output], axis=0)
learn.fit_one_cycle(5,2.5e-5 )<train_model>
sub.ConfirmedCases.apply(math.floor)
 sub.ForecastId = sub.ForecastId.astype('int')
 sub.ConfirmedCases = round(sub.ConfirmedCases,1)
 sub.Fatalities = round(sub.Fatalities,1)
 sub = sub[['ForecastId','ConfirmedCases','Fatalities']]
learn.fit_one_cycle(5,1e-6 )<categorify>
sub.to_csv("submission.csv",index=False )