Kaggle competition: COVID19 Global Forecasting (Week 3)
train_data['Color'].fillna(value='Color_Unknown',inplace=True)
 test_data['Color'].fillna(value='Color_Unknown',inplace=True )<count_missing_values>
df_train = pd.read_csv('/kaggle/input/covid19-global-forecasting-week-3/train.csv')
 df_test = pd.read_csv('/kaggle/input/covid19-global-forecasting-week-3/test.csv')
 df_sub = pd.read_csv('/kaggle/input/covid19-global-forecasting-week-3/test.csv' )
print("Number of null values in Color column "+str(train_data['Color'].isnull().sum()))
print("Number of null values in Color column "+str(test_data['Color'].isnull().sum()))<count_values>
df_train['Date'] = pd.to_datetime(df_train['Date'], infer_datetime_format=True)
 df_test['Date'] = pd.to_datetime(df_test['Date'], infer_datetime_format=True)
 df_train.loc[:, 'Date'] = df_train.Date.dt.strftime("%m%d")
 df_train["Date"] = df_train["Date"].astype(int)
 df_test.loc[:, 'Date'] = df_test.Date.dt.strftime("%m%d")
 df_test["Date"] = df_test["Date"].astype(int )
train_data['Transmission'].value_counts()<count_values>
df_train['ConfirmedCases'] = df_train['ConfirmedCases'].apply(int)
 df_train['Fatalities'] = df_train['Fatalities'].apply(int )
test_data['Transmission'].value_counts()<filter>
df_train['Province_State'] = df_train['Province_State'].fillna('unknown')
 df_test['Province_State'] = df_test['Province_State'].fillna('unknown' )
train_data[train_data['Transmission']=='Manual']<rename_columns>
import xgboost as xgb
from xgboost import XGBRegressor
train_data['Transmission'].replace("Manual","MANUAL",inplace=True )<count_values>
features = ['Date']
submission = pd.DataFrame(columns=['ForecastId', 'ConfirmedCases', 'Fatalities'])
 for i in tqdm(df_train.Country_Region.unique()):
c_train = df_train[df_train['Country_Region'] == i]
c_test = df_test[df_test['Country_Region'] == i]
for j in c_train.Province_State.unique() :
p_train = c_train[c_train['Province_State'] == j]
p_test = c_test[c_test['Province_State'] == j]
x_train = p_train[features]
y_train_cc = p_train['ConfirmedCases']
y_train_ft = p_train['Fatalities']
model = xgb.XGBRegressor(n_estimators=1000)
 model.fit(x_train, y_train_cc)
 y_pred_cc = model.predict(p_test[features])
 model.fit(x_train, y_train_ft)
 y_pred_ft = model.predict(p_test[features])
 p_test['ConfirmedCases'] = y_pred_cc
p_test['Fatalities'] = y_pred_ft
submission = pd.concat([submission, p_test[['ForecastId', 'ConfirmedCases', 'Fatalities']]], axis=0 )
train_data['Transmission'].value_counts()<data_type_conversions>
submission.to_csv('submission.csv', index=False )
train_data['Transmission'].fillna(value="Transmission_unk",inplace=True)
 test_data['Transmission'].fillna(value="Transmission_unk",inplace=True )<count_values>
submission.to_csv('submission.csv', index=False )