Kaggle competition: COVID19 Global Forecasting (Week 4)
<SOS> metric: MCRMSLE Kaggle data source: covid19-global-forecasting-(week-4)<categorify>
warnings.filterwarnings('ignore')
%%time
train = data_transform(train )<categorify>
covid_cases = pd.read_csv('.. /input/novel-corona-virus-2019-dataset/covid_19_data.csv')
 covid_cases.head()
test = data_transform(test,False )<prepare_x_and_y>
training_data = pd.read_csv(".. /input/covid19-global-forecasting-week-4/train.csv")
 testing_data = pd.read_csv(".. /input/covid19-global-forecasting-week-4/test.csv" )
X_train = train[FEATURE_COLS]
y_train = train[TARGET_COL]
X_test = test[FEATURE_COLS]
y_test = test[TARGET_COL]<create_dataframe>
print(training_data.isnull().sum())
 print(testing_data.isnull().sum())
 print(training_data.dtypes)
 print(testing_data.dtypes)
 training_data['Province_State'].fillna("",inplace = True)
 testing_data['Province_State'].fillna("",inplace = True )
params = {
'objective': 'binary',
'seed': 42,
'metric': 'auc',
'learning_rate': 0.05,
'max_bin': 1000,
'num_leaves': 80,
'num_iterations' : 20
}
lgb_train = lgb.Dataset(X_train.iloc[:,1:],y_train)
 lgb_val = lgb.Dataset(X_test.iloc[:,1:],y_test )<set_options>
country_list = covid_cases['Country/Region'].unique()
country_grouped_covid = covid_cases[0:1]
for country in country_list:
test_data = covid_cases['Country/Region'] == country
test_data = covid_cases[test_data]
country_grouped_covid = pd.concat([country_grouped_covid, test_data], axis=0)
 country_grouped_covid.reset_index(drop=True)
 country_grouped_covid.head()
country_grouped_covid.drop('Last Update', axis=1, inplace=True)
 country_grouped_covid['Province/State'].replace(np.nan, "Not Reported", inplace=True)
 country_grouped_covid.head()
del X_train,y_train
gc.collect()<train_model>
latest_data = country_grouped_covid['ObservationDate'] == '04/10/2020'
country_data = country_grouped_covid[latest_data]
country_list = country_data['Country/Region'].unique()
print("The total number of countries with COVID-19 Confirmed cases = {}".format(country_list.size))
model = lgb.train(
 params,
lgb_train,
valid_sets=[lgb_train,lgb_val],
verbose_eval=1,
num_boost_round=100,
early_stopping_rounds=10
)<predict_on_test>
py.init_notebook_mode(connected=True)
 formated_gdf = covid_cases.groupby(['ObservationDate', 'Country/Region'])['Confirmed', 'Deaths', 'Recovered'].max()
formated_gdf = formated_gdf.reset_index()
formated_gdf['Date'] = pd.to_datetime(formated_gdf['ObservationDate'])
 formated_gdf['Date'] = formated_gdf['Date'].dt.strftime('%m/%d/%Y')
 formated_gdf['log_ConfirmedCases'] = np.log(formated_gdf.Confirmed + 1)
 formated_gdf['log_Fatalities'] = np.log(formated_gdf.Deaths + 1)
 fig = px.choropleth(formated_gdf, locations="Country/Region", locationmode='country names',
color="log_ConfirmedCases", hover_name="Country/Region",projection="mercator",
animation_frame="Date",width=1000, height=800,
color_continuous_scale=px.colors.sequential.Viridis,
title='The Spread of COVID-19 Cases Across World')
 fig.update(layout_coloraxis_showscale=True)
 py.offline.iplot(fig)
%%time
predictions = pd.DataFrame(model.predict(X_test.iloc[:,1:]),index=X_test.index )<compute_test_metric>
py.init_notebook_mode(connected=True)
 formated_gdf = covid_cases.groupby(['ObservationDate', 'Country/Region'])['Confirmed', 'Deaths', 'Recovered'].max()
formated_gdf = formated_gdf.reset_index()
formated_gdf['Date'] = pd.to_datetime(formated_gdf['ObservationDate'])
 formated_gdf['Date'] = formated_gdf['Date'].dt.strftime('%m/%d/%Y')
 formated_gdf['log_ConfirmedCases'] = np.log(formated_gdf.Confirmed + 1)
 formated_gdf['log_Fatalities'] = np.log(formated_gdf.Deaths + 1)
 fig = px.choropleth(formated_gdf, locations="Country/Region", locationmode='country names',
color="log_Fatalities", hover_name="Country/Region",projection="mercator",
animation_frame="Date",width=1000, height=800,
color_continuous_scale=px.colors.sequential.Viridis,
title='The Deaths because of COVID-19 Cases')
 fig.update(layout_coloraxis_showscale=True)
 py.offline.iplot(fig)
roc_auc_score(y_test,predictions[0] )<predict_on_test>
folder_name = '.. /input/covcsd-covid19-countries-statistical-dataset'
file_type = 'csv'
seperator =','
dataframe = pd.concat([pd.read_csv(f, sep=seperator)for f in glob.glob(folder_name + "/*."+file_type)],ignore_index=True,sort=False )
env = riiideducation.make_env()
iter_test = env.iter_test()
iter_nb = 0
for(current_df, sample_prediction_df)in iter_test:
print(current_df)
 if(iter_nb != 0):
prior_df = add_answers_to_prior_df(current_df,prior_df)
 question_df = build_question_df(prior_df,question_df)
 user_df = build_user_df(prior_df,user_df,question_df)
 prior_df = current_df.copy()
current_df = data_transform(current_df,False,False)
 current_df['answered_correctly'] = model.predict(current_df.iloc[:,1:])
 iter_nb = 1
env.predict(current_df.loc[:, ['row_id', 'answered_correctly']] )<set_options>
covid_data = dataframe[['Date', 'State', 'Country', 'Cumulative_cases', 'Cumulative_death',
'Daily_cases', 'Daily_death', 'Latitude', 'Longitude', 'Temperature',
'Min_temperature', 'Max_temperature', 'Wind_speed', 'Precipitation',
'Fog_Presence', 'Population', 'Population Density/km', 'Median_Age',
'Sex_Ratio', 'Age%_65+', 'Hospital Beds/1000', 'Available Beds/1000',
'Confirmed Cases/1000', 'Lung Patients(F)', 'Lung Patients(M)',
'Life Expectancy(M)', 'Life Expectancy(F)', 'Total_tests_conducted',
'Out_Travels(mill.) ', 'In_travels(mill.) ', 'Domestic_Travels(mill.) ']]
pd.options.display.max_rows=200
pd.set_option('mode.chained_assignment', None)
 simplefilter("ignore", category=ConvergenceWarning)
 simplefilter("ignore", category=RuntimeWarning)
 plt.style.use('fivethirtyeight' )<load_from_csv>
training_data['Country_Region'] = training_data['Country_Region'] + ' ' + training_data['Province_State']
testing_data['Country_Region'] = testing_data['Country_Region'] + ' ' + testing_data['Province_State']
del training_data['Province_State']
del testing_data['Province_State']
def split_date(date):
date = date.split('-')
 date[0] = int(date[0])
 if(date[1][0] == '0'):
date[1] = int(date[1][1])
 else:
date[1] = int(date[1])
 if(date[2][0] == '0'):
date[2] = int(date[2][1])
 else:
date[2] = int(date[2])
 return date
training_data.Date = training_data.Date.apply(split_date)
 testing_data.Date = testing_data.Date.apply(split_date )
train = pd.read_csv('/kaggle/input/house-prices-advanced-regression-techniques/train.csv')
 test = pd.read_csv('/kaggle/input/house-prices-advanced-regression-techniques/test.csv' )<drop_column>
year = []
month = []
day = []
for i in training_data.Date:
year.append(i[0])
 month.append(i[1])
 day.append(i[2])
 training_data['Year'] = year
training_data['Month'] = month
training_data['Day'] = day
del training_data['Date']
year = []
month = []
day = []
for i in testing_data.Date:
year.append(i[0])
 month.append(i[1])
 day.append(i[2])
 testing_data['Year'] = year
testing_data['Month'] = month
testing_data['Day'] = day
del testing_data['Date']
del training_data['Id']
del testing_data['ForecastId']
del testing_data['Year']
del training_data['Year']
train.drop('Id', axis=1, inplace=True)
 test.drop('Id', axis=1, inplace=True )<prepare_x_and_y>
latest_data = covid_data['Date'] == '30-03-2020'
country_data_detailed = covid_data[latest_data]
country_data_detailed.drop(['Daily_cases','Daily_death','Latitude','Longitude'],axis=1,inplace=True)
 country_data_detailed.head(3 )
X_train = train.drop('SalePrice', axis=1)
 y_train = np.log1p(train.SalePrice)
 X_test = test<define_variables>
country_data_detailed['Lung Patients(F)'].replace('Not reported',np.nan,inplace=True)
 country_data_detailed['Lung Patients(F)'] = country_data_detailed['Lung Patients(F)'].astype("float" )
def missing_value_imputation(X):
numerical_features = [feature for feature in X.columns if X[feature].dtype !='O']
ordinal_features = ['LotShape', 'LandSlope', 'ExterQual', 'ExterCond', 'BsmtQual', 'BsmtCond', 'BsmtExposure',
'BsmtFinType1', 'BsmtFinType2', 'HeatingQC', 'KitchenQual', 'Functional', 'FireplaceQu',
'GarageFinish', 'GarageQual', 'GarageCond', 'PoolQC']
categorical_features = [feature for feature in X.columns if feature not in ordinal_features and
feature not in numerical_features]
for feature in numerical_features:
X[feature] = X[feature].fillna(X.groupby('Neighborhood')[feature].transform('median'))
X['MSZoning'].replace({'RL':'R', 'RM':'R', 'RP':'R', 'RM':'R', 'I':'O', 'A':'O', 'C(all)':'O', 'FV':'O'}, inplace=True)
 X['Alley'].replace({np.nan : 'No', 'Grvl':'Yes', 'Pave':'Yes'}, inplace=True)
 X['LandContour'].replace({'Lvl':'Lvl', 'HLS':'Slope', 'Bnk':'Slope', 'Low':'Slope'}, inplace=True)
 X['Condition1'].where(X['Condition1'] == 'Norm', 'Other', inplace=True)
 X['HouseStyle'].where(( X['HouseStyle'] == '1Story')|(X['HouseStyle'] == '2Story')|(X['HouseStyle'] == '1.5Fin'),
'rare', inplace=True)
 X['RoofStyle'].where(( X['RoofStyle'] == 'Gable')|(X['RoofStyle'] == 'Hip'), 'rare', inplace=True)
 X['MasVnrType'].where(X['MasVnrType'] == 'None', 'yes', inplace=True)
 X['MasVnrType'].replace({np.nan : 'None'}, inplace=True)
 X['Exterior1st'].where(( X['Exterior1st'] == 'VinylSd')|(X['Exterior1st'] == 'HdBoard')| 
(X['Exterior1st'] == 'MetalSd')|(X['Exterior1st'] == 'Wd Sdng')| 
(X['Exterior1st'] == 'Plywood'), 'rare', inplace=True)
 X['PavedDrive'].where(X['PavedDrive'] == 'Y', 'N', inplace=True)
 X['Fence'].replace({'MnPrv':'Yes', 'GdPrv':'Yes', 'GdWo':'Yes', 'MnWw':'Yes', np.nan:'No'}, inplace=True)
 X['SaleType'].where(X['SaleType'] == 'WD', 'other', inplace=True)
 X['SaleCondition'].where(( X['SaleCondition'] == 'Normal')|(X['SaleCondition'] == 'Partial')| 
(X['SaleCondition'] == 'Abnorml'), 'other', inplace=True)
 X['Neighborhood'].replace({'Blmngtn':'rare', 'BrDale':'rare', 'Veenker':'rare', 'NPkVill':'rare',
'Blueste':'rare', 'ClearCr':'rare'},
inplace=True)
 for feature in categorical_features:
val = X[feature].value_counts().index[0]
X[feature] = X[feature].fillna(val)
 X['LotShape'].replace({'Reg':1, 'IR1':0, 'IR2':0, 'IR3':0}, inplace=True)
 X['LandSlope'].replace({'Gtl':3, 'Mod':2, 'Sev':1}, inplace=True)
 X['ExterQual'].replace({'Po':1, 'Fa':2, 'TA':3, 'Gd':4, 'Ex':5}, inplace=True)
 X['ExterCond'].replace({'Po':1, 'Fa':2, 'TA':3, 'Gd':4, 'Ex':5}, inplace=True)
 X['BsmtQual'].replace({np.nan:0, 'Po':1, 'Fa':2, 'TA':3, 'Gd':4, 'Ex':5}, inplace=True)
 X['BsmtCond'].replace({np.nan:0, 'Po':1, 'Fa':2, 'TA':3, 'Gd':4, 'Ex':5}, inplace=True)
 X['BsmtExposure'].replace({np.nan:0, 'No':1, 'Mn':2, 'Av':3, 'Gd':4}, inplace=True)
 X['BsmtFinType1'].replace({np.nan:0, 'Unf':1, 'LwQ':2, 'Rec':3, 'BLQ':4, 'ALQ':5, 'GLQ':6}, inplace=True)
 X['BsmtFinType2'].replace({np.nan:0, 'Unf':1, 'LwQ':2, 'Rec':3, 'BLQ':4, 'ALQ':5, 'GLQ':6}, inplace=True)
 X['HeatingQC'].replace({'Po':1, 'Fa':2, 'TA':3, 'Gd':4, 'Ex':5}, inplace=True)
 X['KitchenQual'].replace({np.nan:3, 'Po':1, 'Fa':2, 'TA':3, 'Gd':4, 'Ex':5}, inplace=True)
 X['Functional'].replace({np.nan:8, 'Sal':1, 'Sev':2, 'Maj2':3, 'Maj1':4,
'Mod':5, 'Min2':6, 'Min1':7, 'Typ':8}, inplace=True)
 X['FireplaceQu'].replace({np.nan:0, 'Po':1, 'Fa':2, 'TA':3, 'Gd':4, 'Ex':5}, inplace=True)
 X['GarageFinish'].replace({np.nan:0, 'Unf':1, 'RFn':2, 'Fin':3}, inplace=True)
 X['GarageQual'].replace({np.nan:0, 'Po':1, 'Fa':2, 'TA':3, 'Gd':4, 'Ex':5}, inplace=True)
 X['GarageCond'].replace({np.nan:0, 'Po':1, 'Fa':2, 'TA':3, 'Gd':4, 'Ex':5}, inplace=True)
 X['PoolQC'].replace({np.nan:0, 'Fa': 1, 'Gd':2, 'Ex':3}, inplace=True)
 categorical_features = [feature for feature in X.columns if X[feature].dtype == 'O']
for feature in categorical_features:
value_counts = X[feature].value_counts()
for val in value_counts[value_counts / len(X)< 0.015].index:
X[feature].loc[X[feature] == val] = 'rare'
return X
class FeatureEngineering(BaseEstimator, TransformerMixin):
def __init__(self, combined_features=True, drop_underlying_features=True, drop_features=True, correlation_threshold=0.05,
polynomial_features=True, outlier_threshold=1.5, empty_column_dropping_threshold=0.99,
final_correlation_threshold=0.05, test=False):
self.combined_features = combined_features
self.drop_underlying_features = drop_underlying_features
self.drop_features = drop_features
self.correlation_threshold = correlation_threshold
self.polynomial_features = polynomial_features
self.polynomial_features_list = []
self.outlier_threshold = outlier_threshold
self.empty_column_dropping_threshold = empty_column_dropping_threshold
self.low_correlation_drop_list = []
self.one_hot_features_to_drop = []
self.final_low_correlation_drop_list = []
self.final_correlation_threshold = final_correlation_threshold
self.test = test
def fit(self, X, y=None):
return self
def transform(self, X, y=None):
ordinal_features = ['LotShape', 'LandSlope', 'ExterQual', 'ExterCond', 'BsmtQual', 'BsmtCond', 'BsmtExposure',
'BsmtFinType1', 'BsmtFinType2', 'HeatingQC', 'KitchenQual', 'Functional', 'FireplaceQu',
'GarageFinish', 'GarageQual', 'GarageCond', 'PoolQC']
numerical_features = [feature for feature in X.columns if X[feature].dtype !='O' and feature not in ordinal_features]
categorical_features = [feature for feature in X.columns if feature not in ordinal_features and
feature not in numerical_features]
X['GarageYrBlt'] = 2020 - X['GarageYrBlt']
X['YrSold'] = 2020 - X['YrSold']
X['YearBuilt'] = 2020 - X['YearBuilt']
X['YearRemodAdd'] = 2020 - X['YearRemodAdd']
if self.combined_features:
X['OverallGrade'] = X['OverallQual'] * X['OverallCond']
X['ExterGrade'] = X['ExterQual'] * X['ExterCond']
X['BsmtGrade'] = X['BsmtQual'] * X['BsmtCond']
X['BsmtFinType'] = X['BsmtFinType1'] + X['BsmtFinType2']
X['BsmtFinSF'] = X['BsmtFinSF1'] + X['BsmtFinSF2']
X['FlrSF'] = X['1stFlrSF'] + X['2ndFlrSF']
X['BsmtBath'] = X['BsmtFullBath'] + X['BsmtHalfBath']
X['Bath'] = X['FullBath'] + X['HalfBath']
X['GarageGrade'] = X['GarageQual'] * X['GarageCond']
X['Porch'] = X['OpenPorchSF'] + X['EnclosedPorch'] + X['3SsnPorch'] + X['ScreenPorch']
numerical_features.extend(['OverallGrade', 'ExterGrade', 'BsmtGrade', 'BsmtFinType', 'BsmtFinSF', 'FlrSF',
'BsmtBath', 'Bath', 'GarageGrade', 'Porch'])
 if self.combined_features and self.drop_underlying_features:
to_drop = [ 'BsmtFinType1','BsmtFinType2', 'BsmtFinSF1', '1stFlrSF', 'BsmtFullBath',
'BsmtHalfBath', 'FullBath', 'HalfBath', 'GarageCond',
'OpenPorchSF', 'BsmtFinSF2', '2ndFlrSF', 'EnclosedPorch',
'3SsnPorch', 'ScreenPorch']
X.drop(to_drop, axis=1, inplace=True)
 if self.drop_features:
to_drop = ['Utilities', 'PoolQC', 'MiscFeature', 'Street',
'Condition2', 'MasVnrType', 'LowQualFinSF', 'Alley', 'MiscVal', 'Fence',
'KitchenAbvGr', 'PoolArea', 'Street', 'RoofMatl', 'Exterior2nd', 'Heating']
X.drop(to_drop, axis=1, inplace=True)
 ordinal_features = [feature for feature in X.columns if X[feature].dtype != 'O' and feature not in numerical_features]
numerical_features = [feature for feature in X.columns if X[feature].dtype != 'O' and feature not in ordinal_features]
categorical_features = [feature for feature in X.columns if X[feature].dtype == 'O']
if self.polynomial_features:
if len(X)> 800 and not self.test:
y = train['SalePrice'].iloc[X.index].to_frame()
saleprice = pd.concat([X, y], axis=1 ).corr() ['SalePrice']
self.polynomial_features_list = list(saleprice.sort_values(ascending=False ).index[1:self.polynomial_features + 2])
 for feature in self.polynomial_features_list:
for i in [2, 3]:
X[f'{feature} - sq{i}'] = X[feature] ** i
else:
for feature in self.polynomial_features_list:
for i in [2, 3]:
X[f'{feature} - sq{i}'] = X[feature] ** i
if self.outlier_threshold:
numerical_features = [feature for feature in X.columns
if feature not in ordinal_features and X[feature].dtype != 'O' ]
for feature in numerical_features:
unique_vals = X[feature].nunique()
if unique_vals > 10:
q1 = np.percentile(X[feature], 25)
 q3 = np.percentile(X[feature], 75)
 iqr = q3 - q1
if not iqr:
iqr = 1
cut_off = iqr * self.outlier_threshold
lower, upper = q1 - cut_off, q3 + cut_off
X[feature].where(~(X[feature] > upper), upper, inplace=True)
 X[feature].where(~(X[feature] < lower), lower, inplace=True)
 if self.correlation_threshold:
if len(X)> 800 and not self.test:
self.low_correlation_drop_list = []
y = train['SalePrice'].iloc[X.index].to_frame()
saleprice = pd.concat([X, y], axis=1 ).corr() ['SalePrice']
corr_dict = saleprice.sort_values(ascending=False ).to_frame().to_dict() ['SalePrice']
for key, value in corr_dict.items() :
if value < self.correlation_threshold and value > - self.correlation_threshold:
self.low_correlation_drop_list.append(key)
 X = X.drop(self.low_correlation_drop_list, axis=1)
 else:
X = X.drop(self.low_correlation_drop_list, axis=1)
 numerical_features = [feature for feature in X.columns if X[feature].dtype != 'O']
categorical_features = [feature for feature in X.columns if feature not in numerical_features]
X.replace({0 : 1e-5}, inplace=True)
 X_index = X.index
num_pipeline = Pipeline([('scale', MinMaxScaler(feature_range=(1e-5, 1))), 
('power_transform', PowerTransformer(method='box-cox')) ])
 transformer = ColumnTransformer([('num_pipeline', num_pipeline, numerical_features)])
 numerical_features_transformed = transformer.fit_transform(X)
 numerical_df = pd.DataFrame(numerical_features_transformed, columns=numerical_features, index=X.index)
 X = pd.concat([numerical_df, X.loc[:, categorical_features]], axis=1)
 if not self.test:
X_total = pd.concat([X, X_train_imputed.loc[:, categorical_features].loc[~(X_train_imputed.index.isin(X.index)) ]])
 X_total = pd.get_dummies(X_total)
 one_hot_features = [feature for feature in X_total.columns if feature not in numerical_features]
else:
X = pd.get_dummies(X)
 if self.empty_column_dropping_threshold:
if len(X)> 800 and not self.test:
self.one_hot_features_to_drop = []
for feature in one_hot_features:
zero_count = X_total[feature].value_counts() [0] / len(X_total)
 if zero_count > self.empty_column_dropping_threshold:
self.one_hot_features_to_drop.append(feature)
 X_total.drop(feature, axis=1, inplace=True)
 elif not self.test:
X_total.drop(self.one_hot_features_to_drop, axis=1, inplace=True)
 else:
X.drop(self.one_hot_features_to_drop, axis=1, inplace=True)
 if not self.test:
X = X_total.dropna()
if self.final_correlation_threshold:
if len(X)> 800 and not self.test:
self.final_low_correlation_drop_list = []
y = train['SalePrice'].iloc[X.index].to_frame()
saleprice = pd.concat([X, y], axis=1 ).corr() ['SalePrice']
corr_dict = saleprice.sort_values(ascending=False ).to_frame().to_dict() ['SalePrice']
for key, value in corr_dict.items() :
if value < self.final_correlation_threshold and value > - self.final_correlation_threshold:
self.final_low_correlation_drop_list.append(key)
 X = X.drop(self.final_low_correlation_drop_list, axis=1)
 else:
X = X.drop(self.final_low_correlation_drop_list, axis=1)
 return X<count_missing_values>
temperature_data = pd.read_csv('.. /input/covcsd-covid19-countries-statistical-dataset/temperature_data.csv')
 temperature_data.head()
X_train_imputed = missing_value_imputation(X_train.copy() )<init_hyperparams>
sample = temperature_dataset['Temperature'].sample(n=250)
 test = temperature_dataset['Temperature']
stat, p = ttest_ind(sample, test)
 print('Statistics=%.3f, p=%.3f' %(stat, p))
param_grid = {'feature_engineering__combined_features':[True],
'feature_engineering__drop_features':[True],
'feature_engineering__drop_underlying_features':[True],
'feature_engineering__polynomial_features':[9],
'feature_engineering__correlation_threshold': [0.07],
'feature_engineering__outlier_threshold':[1.5],
'feature_engineering__empty_column_dropping_threshold':[0.99],
'feature_engineering__final_correlation_threshold':[False]
} 
<train_on_grid>
training_data['ConfirmedCases'] = training_data['ConfirmedCases'].apply(int)
 training_data['Fatalities'] = training_data['Fatalities'].apply(int)
 cases = training_data.ConfirmedCases
fatalities = training_data.Fatalities
del training_data['ConfirmedCases']
del training_data['Fatalities']
lb = LabelEncoder()
training_data['Country_Region'] = lb.fit_transform(training_data['Country_Region'])
 testing_data['Country_Region'] = lb.transform(testing_data['Country_Region'])
 scaler = MinMaxScaler()
x_train = scaler.fit_transform(training_data.values)
 x_test = scaler.transform(testing_data.values )
linreg = Pipeline([('feature_engineering', FeatureEngineering()), 
('linreg', Ridge())])
 grid = GridSearchCV(linreg, param_grid, cv=5, scoring='neg_mean_squared_error', verbose=2, n_jobs=-1)
 grid.fit(X_train_imputed.copy() , y_train )<find_best_params>
rf = XGBRegressor(n_estimators = 1500 , max_depth = 15, learning_rate=0.1)
 rf.fit(x_train,cases)
 cases_pred = rf.predict(x_test)
 rf = XGBRegressor(n_estimators = 1500 , max_depth = 15, learning_rate=0.1)
 rf.fit(x_train,fatalities)
 fatalities_pred = rf.predict(x_test )
grid.best_params_<choose_model_class>
cases_pred = np.around(cases_pred)
 fatalities_pred = np.around(fatalities_pred)
 cases_pred[cases_pred < 0] = 0
fatalities_pred[fatalities_pred < 0] = 0
fe = FeatureEngineering(**{'combined_features': True,
'correlation_threshold': 0.07,
'drop_features': True,
'drop_underlying_features': True,
'empty_column_dropping_threshold': 0.99,
'final_correlation_threshold':False,
'outlier_threshold': 1.5,
'polynomial_features': 9} )<count_missing_values>
submission_dataset = pd.read_csv(".. /input/covid19-global-forecasting-week-4/submission.csv")
 submission_dataset['ConfirmedCases'] = cases_pred
submission_dataset['Fatalities'] = fatalities_pred
submission_dataset.head()
X_train_imputed = missing_value_imputation(X_train.copy())
 X_test_imputed = missing_value_imputation(X_test.copy() )<categorify>
submission_dataset.to_csv("submission.csv" , index = False )