Kaggle competition: Car loan default
<SOS> metric: auc Kaggle data source: car-loan-default<feature_engineering>
import pandas as pd
import numpy as np
from datetime import timedelta, date
from sklearn.model_selection import train_test_split, GridSearchCV, KFold
from sklearn.metrics import roc_auc_score
from sklearn.linear_model import LogisticRegression
from sklearn.preprocessing import StandardScaler, OneHotEncoder, LabelEncoder
from lightgbm import LGBMClassifier
feature_day = [1,20,50,100,200,500,1000]
def CreateInput(data):
feature = []
for day in feature_day:
data.loc[:,'Number day from ' + str(day)+ ' case'] = 0
if(train[(train['Country_Region'] == country)&(train['Province_State'] == province)&(train['ConfirmedCases'] < day)]['Date'].count() > 0):
fromday = train[(train['Country_Region'] == country)&(train['Province_State'] == province)&(train['ConfirmedCases'] < day)]['Date'].max()
else:
fromday = train[(train['Country_Region'] == country)&(train['Province_State'] == province)]['Date'].min()
for i in range(0, len(data)) :
if(data['Date'].iloc[i] > fromday):
day_denta = data['Date'].iloc[i] - fromday
data['Number day from ' + str(day)+ ' case'].iloc[i] = day_denta.days
feature = feature + ['Number day from ' + str(day)+ ' case']
return data[feature]
pred_data_all = pd.DataFrame()
for country in train['Country_Region'].unique() :
for province in train[(train['Country_Region'] == country)]['Province_State'].unique() :
df_train = train[(train['Country_Region'] == country)&(train['Province_State'] == province)]
df_test = test[(test['Country_Region'] == country)&(test['Province_State'] == province)]
X_train = CreateInput(df_train)
 y_train_confirmed = df_train['ConfirmedCases'].ravel()
y_train_fatalities = df_train['Fatalities'].ravel()
X_pred = CreateInput(df_test)
 for day in sorted(feature_day,reverse = True):
feature_use = 'Number day from ' + str(day)+ ' case'
idx = X_train[X_train[feature_use] == 0].shape[0]
if(X_train[X_train[feature_use] > 0].shape[0] >= 20):
break
adjusted_X_train = X_train[idx:][feature_use].values.reshape(-1, 1)
 adjusted_y_train_confirmed = y_train_confirmed[idx:]
adjusted_y_train_fatalities = y_train_fatalities[idx:]
idx = X_pred[X_pred[feature_use] == 0].shape[0]
adjusted_X_pred = X_pred[idx:][feature_use].values.reshape(-1, 1)
 pred_data = test[(test['Country_Region'] == country)&(test['Province_State'] == province)]
max_train_date = train[(train['Country_Region'] == country)&(train['Province_State'] == province)]['Date'].max()
min_test_date = pred_data['Date'].min()
model = SARIMAX(adjusted_y_train_confirmed, order=(1,1,0),
measurement_error=True ).fit(disp=False)
 y_hat_confirmed = model.forecast(pred_data[pred_data['Date'] > max_train_date].shape[0])
 y_train_confirmed = train[(train['Country_Region'] == country)&(train['Province_State'] == province)&(train['Date'] >= min_test_date)]['ConfirmedCases'].values
y_hat_confirmed = np.concatenate(( y_train_confirmed,y_hat_confirmed), axis = 0)
 model = SARIMAX(adjusted_y_train_fatalities, order=(1,1,0),
measurement_error=True ).fit(disp=False)
 y_hat_fatalities = model.forecast(pred_data[pred_data['Date'] > max_train_date].shape[0])
 y_train_fatalities = train[(train['Country_Region'] == country)&(train['Province_State'] == province)&(train['Date'] >= min_test_date)]['Fatalities'].values
y_hat_fatalities = np.concatenate(( y_train_fatalities,y_hat_fatalities), axis = 0)
 pred_data['ConfirmedCases_hat'] = y_hat_confirmed
pred_data['Fatalities_hat'] = y_hat_fatalities
pred_data_all = pred_data_all.append(pred_data)
 df_val = pd.merge(pred_data_all,train[['Date','Country_Region','Province_State','ConfirmedCases','Fatalities']],on=['Date','Country_Region','Province_State'], how='left')
 df_val.loc[df_val['Fatalities_hat'] < 0,'Fatalities_hat'] = 0
df_val.loc[df_val['ConfirmedCases_hat'] < 0,'ConfirmedCases_hat'] = 0
df_val_3 = df_val.copy()<compute_test_metric>
warnings.filterwarnings('ignore' )
method_list = ['Poly Bayesian Ridge','Exponential Smoothing','SARIMA']
method_val = [df_val_1,df_val_2,df_val_3]
for i in range(0,3):
df_val = method_val[i]
method_score = [method_list[i]] + [RMSLE(df_val[(df_val['ConfirmedCases'].isnull() == False)]['ConfirmedCases'].values,df_val[(df_val['ConfirmedCases'].isnull() == False)]['ConfirmedCases_hat'].values)] + [RMSLE(df_val[(df_val['Fatalities'].isnull() == False)]['Fatalities'].values,df_val[(df_val['Fatalities'].isnull() == False)]['Fatalities_hat'].values)]
print(method_score )<save_to_csv>
train = pd.read_csv('/kaggle/input/car-loan/car_loan_train.csv')
 test = pd.read_csv('/kaggle/input/car-loan/car_loan_test.csv')
 train.columns = ["".join(c if c.isalnum() else "_" for c in str(x)) for x in train.columns]
test.columns = ["".join(c if c.isalnum() else "_" for c in str(x)) for x in test.columns]
df_val = df_val_3
submission = df_val[['ForecastId','ConfirmedCases_hat','Fatalities_hat']]
submission.columns = ['ForecastId','ConfirmedCases','Fatalities']
submission.to_csv('submission.csv', index=False)
 submission<filter>
train = train.fillna('other')
 test = test.fillna('other' )
df_worldinfor[df_worldinfor['Country'] == 'Vietnam']<set_options>
train = train.replace({'PERFORM_CNS_SCORE_DESCRIPTION':{'C-Very Low Risk':'Low', 'A-Very Low Risk':'Low',
'B-Very Low Risk':'Low', 'D-Very Low Risk':'Low',
'F-Low Risk':'Low', 'E-Low Risk':'Low', 'G-Low Risk':'Low',
'H-Medium Risk': 'Medium', 'I-Medium Risk': 'Medium',
'J-High Risk':'High', 'K-High Risk':'High','L-Very High Risk':'High',
'M-Very High Risk':'High','Not Scored: More than 50 active Accounts found':'Not Scored',
'Not Scored: Only a Guarantor':'Not Scored','Not Scored: Not Enough Info available on the customer':'Not Scored',
'Not Scored: No Activity seen on the customer(Inactive)':'Not Scored','Not Scored: No Updates available in last 36 months':'Not Scored',
'Not Scored: Sufficient History Not Available':'Not Scored', 'No Bureau History Available':'Not Scored'
}})
 test = test.replace({'PERFORM_CNS_SCORE_DESCRIPTION':{'C-Very Low Risk':'Low', 'A-Very Low Risk':'Low',
'B-Very Low Risk':'Low', 'D-Very Low Risk':'Low',
'F-Low Risk':'Low', 'E-Low Risk':'Low', 'G-Low Risk':'Low',
'H-Medium Risk': 'Medium', 'I-Medium Risk': 'Medium',
'J-High Risk':'High', 'K-High Risk':'High','L-Very High Risk':'High',
'M-Very High Risk':'High','Not Scored: More than 50 active Accounts found':'Not Scored',
'Not Scored: Only a Guarantor':'Not Scored','Not Scored: Not Enough Info available on the customer':'Not Scored',
'Not Scored: No Activity seen on the customer(Inactive)':'Not Scored','Not Scored: No Updates available in last 36 months':'Not Scored',
'Not Scored: Sufficient History Not Available':'Not Scored', 'No Bureau History Available':'Not Scored'
}} )
plt.style.use('ggplot')
 font = {'family' : 'meiryo'}
plt.rc('font', **font )<load_from_csv>
train['Date_of_Birth'] = pd.to_datetime(train['Date_of_Birth'])
 train['DisbursalDate'] = pd.to_datetime(train['DisbursalDate'])
 test['Date_of_Birth'] = pd.to_datetime(test['Date_of_Birth'])
 test['DisbursalDate'] = pd.to_datetime(test['DisbursalDate'])
 now = pd.Timestamp('now')
 future = train['Date_of_Birth'] > date(year=2050,month=1,day=1)
 train.loc[future, 'Date_of_Birth'] -= timedelta(days=365.25*100)
 future = test['Date_of_Birth'] > date(year=2050,month=1,day=1)
 test.loc[future, 'Date_of_Birth'] -= timedelta(days=365.25*100)
 train['birth_year'] = train['Date_of_Birth'].apply(lambda ts: ts.year)
 train['birth_month'] = train['Date_of_Birth'].apply(lambda ts: ts.month)
 train['birth_day'] = train['Date_of_Birth'].apply(lambda ts: ts.day)
 train['birth_dayofweek'] = train['Date_of_Birth'].apply(lambda ts: ts.dayofweek)
 train['Disbursal_month'] = train['DisbursalDate'].apply(lambda ts: ts.month)
 train['Disbursal_day'] = train['DisbursalDate'].apply(lambda ts: ts.day)
 train['Disbursal_dayofweek'] = train['DisbursalDate'].apply(lambda ts: ts.dayofweek)
 train['Age'] =(now - train['Date_of_Birth'] ).dt.days
train['DaysSinceDisbursal'] =(now - train['DisbursalDate'] ).dt.days
test['birth_year'] = test['Date_of_Birth'].apply(lambda ts: ts.year)
 test['birth_month'] = test['Date_of_Birth'].apply(lambda ts: ts.month)
 test['birth_day'] = test['Date_of_Birth'].apply(lambda ts: ts.day)
 test['birth_dayofweek'] = test['Date_of_Birth'].apply(lambda ts: ts.dayofweek)
 test['Disbursal_month'] = test['DisbursalDate'].apply(lambda ts: ts.month)
 test['Disbursal_day'] = test['DisbursalDate'].apply(lambda ts: ts.day)
 test['Disbursal_dayofweek'] = test['DisbursalDate'].apply(lambda ts: ts.dayofweek)
 test['Age'] =(now - test['Date_of_Birth'] ).dt.days
test['DaysSinceDisbursal'] =(now - test['DisbursalDate'] ).dt.days
train = train.drop(['Date_of_Birth', 'DisbursalDate'], axis=1)
 test = test.drop(['Date_of_Birth', 'DisbursalDate'], axis=1 )
train_df = pd.read_csv(".. /input/covid19-global-forecasting-week-2/train.csv" )<correct_missing_values>
def get_nmbr(text):
return int(text[0:text.find('y')])* 12 + int(text[text.find(' ')+1:text.find('m')])
 train['AVERAGE_ACCT_AGE'] = train['AVERAGE_ACCT_AGE'].apply(get_nmbr)
 train['CREDIT_HISTORY_LENGTH'] = train['CREDIT_HISTORY_LENGTH'].apply(get_nmbr)
 test['AVERAGE_ACCT_AGE'] = test['AVERAGE_ACCT_AGE'].apply(get_nmbr)
 test['CREDIT_HISTORY_LENGTH'] = test['CREDIT_HISTORY_LENGTH'].apply(get_nmbr )
train_df = train_df[train_df["Date"] < "2020-03-19"]
train_df = train_df.fillna("No State" )<normalization>
categ_cols = ['branch_id', 'manufacturer_id', 'Employment_Type', 'State_ID', 'PERFORM_CNS_SCORE_DESCRIPTION',
'Aadhar_flag', 'PAN_flag', 'VoterID_flag', 'Driving_flag', 'Passport_flag']
test_rate = 0.05
maxlen = 20
train_date_count = len(set(train_df["Date"]))
X, Y = [],[]
scaler = StandardScaler()
train_df["ConfirmedCases_std"] = scaler.fit_transform(train_df["ConfirmedCases"].values.reshape(len(train_df["ConfirmedCases"].values),1))
for state,country in train_df.groupby(["Province_State","Country_Region"] ).sum().index:
df = train_df[(train_df["Country_Region"] == country)&(train_df["Province_State"] == state)]
if df["ConfirmedCases"].sum() != 0:
for i in range(len(df)- maxlen):
if df[['ConfirmedCases']].iloc[i+maxlen].values != 0:
X.append(df[['ConfirmedCases_std']].iloc[i:(i+maxlen)].values)
 Y.append(df[['ConfirmedCases_std']].iloc[i+maxlen].values)
 X=np.array(X)
 Y=np.array(Y)
 X_train, X_test, Y_train, Y_test = train_test_split(X, Y, test_size=test_rate, shuffle = True ,random_state = 0 )<compute_test_metric>
for col in ['supplier_id', 'Current_pincode_ID', 'Employee_code_ID']:
train.loc[train[col].value_counts() [train[col]].values < 2, col] = -9999
test.loc[test[col].value_counts() [test[col]].values < 2, col] = -9999
def huber_loss(y_true, y_pred, clip_delta=1.0):
error = y_true - y_pred
cond = tf.keras.backend.abs(error)< clip_delta
squared_loss = 0.5 * tf.keras.backend.square(error)
 linear_loss = clip_delta *(tf.keras.backend.abs(error)- 0.5 * clip_delta)
 return tf.where(cond, squared_loss, linear_loss)
 def huber_loss_mean(y_true, y_pred, clip_delta=1.0):
return tf.keras.backend.mean(huber_loss(y_true, y_pred, clip_delta))
def rmsle(y, y_pred):
assert len(y)== len(y_pred)
 terms_to_sum = [(math.log(y_pred[i] + 1)- math.log(y[i] + 1)) ** 2.0 for i,pred in enumerate(y_pred)]
return(sum(terms_to_sum)*(1.0/len(y)))** 0.5<choose_model_class>
train.drop("UniqueID", axis=1, inplace=True)
 test.drop("UniqueID", axis=1, inplace=True )
epochs_num = 20
n_hidden = 300
n_in = 1
model = Sequential()
model.add(GRU(n_hidden,
batch_input_shape=(None, maxlen, n_in),
kernel_initializer='random_uniform',
return_sequences=False))
model.add(Dense(n_in, kernel_initializer='random_uniform'))
model.add(Activation("linear"))
opt = Adagrad(lr=0.01, epsilon=1e-08, decay=1e-4)
 model.compile(loss = huber_loss_mean, optimizer=opt )<train_model>
train = pd.get_dummies(train)
 test = pd.get_dummies(test )
early_stopping = EarlyStopping(monitor='loss', patience=5, verbose=1)
 hist = model.fit(X_train, Y_train, batch_size=10, epochs=epochs_num,
callbacks=[early_stopping],shuffle=False )<predict_on_test>
def prod_det(x):
for i in range(x.shape[1]):
max = np.max(x[:,i])
 x[:,i] = x[:,i] / max
return abs(np.linalg.det(np.dot(x.T, x)) )
predicted_std = model.predict(X_test)
 result_std= pd.DataFrame(predicted_std)
 result_std.columns = ['predict']
result_std['actual'] = Y_test<normalization>
train_cols = train.drop(['target', 'MobileNo_Avl_Flag'], axis=1 ).columns
predicted = scaler.inverse_transform(predicted_std)
 Y_test = scaler.inverse_transform(Y_test )<create_dataframe>
var_sets = dict()
result= pd.DataFrame(predicted)
 result.columns = ['predict']
result['actual'] = Y_test
result.plot(figsize=(25,6))
plt.show()<load_from_csv>
for num, col in enumerate(train_cols):
cols_list = [col]
i = 0
while i <= 20:
dict_det = dict()
for col_to_add in train_cols:
if col_to_add not in cols_list:
df_aux = np.array(train[cols_list])
 dict_det[col_to_add] = prod_det(df_aux)
 cols_list.append(sorted(dict_det.items() , key=lambda x: -x[1])[0][0])
 i += 1
var_sets[num] = cols_list
test_df = pd.read_csv(".. /input/covid19-global-forecasting-week-2/test.csv")
 test_df<load_from_csv>
var_set = dict()
for i in range(len(var_sets.items())) :
var_set[i] = set(var_sets[i])
submission_c = pd.read_csv(".. /input/covid19-global-forecasting-week-2/submission.csv" )<filter>
list_of_sets = [i[1] for i in list(var_set.items())]
temp =(datetime.datetime.strptime("2020-03-18", '%Y-%m-%d')- datetime.timedelta(days=maxlen)).strftime('%Y-%m-%d')
 test_df = train_df[train_df["Date"] > temp]<load_from_csv>
list_of_sets = np.unique(list_of_sets )
check_df = pd.read_csv(".. /input/covid19-global-forecasting-week-2/train.csv" ).query("Date>'2020-03-18'and Date<='2020-03-31'")
 check_df["ConfirmedCases_std"] = scaler.transform(check_df["ConfirmedCases"].values.reshape(len(check_df["ConfirmedCases"].values),1))<predict_on_test>
def test_var_sets(train):
cat_cols = [i for i in train.columns if i in categ_cols]
hot = OneHotEncoder(handle_unknown='ignore')
 train_tr = pd.DataFrame(hot.fit_transform(train[cat_cols] ).toarray() , columns=hot.get_feature_names())
 train = pd.concat([train.drop(cat_cols, axis=1), train_tr], axis=1)
 del(train_tr)
 y = train['target']
train = train.drop(['target', 'MobileNo_Avl_Flag'], axis=1)
 X_train, X_valid, y_train, y_valid = train_test_split(train, y, test_size=0.3, random_state = 42)
 lgbt = LGBMClassifier(max_depth=4, learning_rate=0.03, n_estimators=1000, random_state=42)
 lgbt.fit(X_train, y_train)
 y_pred = lgbt.predict_proba(X_valid)[:, 1]
return roc_auc_score(y_valid, y_pred )
confirmedCases_pred = []
for i in range(0,294*maxlen,maxlen):
temp_array = np.array(test_df["ConfirmedCases_std"][i:i+maxlen])
 for j in range(43):
if j<13:
temp_array = np.append(temp_array,np.array(check_df["ConfirmedCases_std"])[int(i*13/maxlen)+j])
 elif np.array(test_df["ConfirmedCases"][i:i+maxlen] ).sum() == 0:
temp_array = np.append(temp_array,temp_array[-1])
 else:
temp_array = np.append(temp_array,model.predict(temp_array[-maxlen:].reshape(1,maxlen,1)))
 confirmedCases_pred.append(temp_array[-43:] )<normalization>
var_sets_auc = dict()
submission_c["ConfirmedCases"] = np.abs(scaler.inverse_transform(np.array(confirmedCases_pred ).reshape(294*43)))
 submission_c["ConfirmedCases_std"] = np.array(confirmedCases_pred ).reshape(294*43)
 submission_c<save_to_csv>
for varset in list_of_sets:
trainset = train[list(varset)+ ['target', 'MobileNo_Avl_Flag']]
auc = test_var_sets(trainset)
 var_sets_auc[auc] = varset
submission_c.to_csv('./submission_c.csv')
 submission_c.to_csv('.. \output\kaggle\working\submission_c.csv' )<normalization>
best_set = sorted(var_sets_auc.items() , key=lambda x: -x[0])[0][1]
test_rate = 0.05
maxlen = 20
train_date_count = len(set(train_df["Date"]))
X, Y = [],[]
scaler = StandardScaler()
train_df["Fatalities_std"] = scaler.fit_transform(train_df["Fatalities"].values.reshape(len(train_df["Fatalities"].values),1))
ss = StandardScaler()
train_df["ConfirmedCases_std"] = ss.fit_transform(train_df["ConfirmedCases"].values.reshape(len(train_df["ConfirmedCases"].values),1))
for state,country in train_df.groupby(["Province_State","Country_Region"] ).sum().index:
df = train_df[(train_df["Country_Region"] == country)&(train_df["Province_State"] == state)]
if df["Fatalities"].sum() != 0 or df["ConfirmedCases"].sum() != 0:
for i in range(len(df)- maxlen):
if(df[['ConfirmedCases']].iloc[i+maxlen].values != 0 or df[['Fatalities']].iloc[i+maxlen].values != 0):
X.append(df[['Fatalities_std','ConfirmedCases_std']].iloc[i:(i+maxlen)].values)
 Y.append(df[['Fatalities_std']].iloc[i+maxlen].values)
 X=np.array(X)
 Y=np.array(Y)
 X_train, X_test, Y_train, Y_test = train_test_split(X, Y, test_size=test_rate, shuffle = True ,random_state = 0 )<choose_model_class>
train_best = train[best_set]
test_best = test[best_set]
cat_cols = [i for i in train_best.columns if i in categ_cols]
epochs_num = 25
n_hidden = 300
n_in = 2
model = Sequential()
model.add(GRU(n_hidden,
batch_input_shape=(None, maxlen, n_in),
kernel_initializer='random_uniform',
return_sequences=False))
model.add(Dense(1, kernel_initializer='random_uniform'))
model.add(Activation("linear"))
opt = Adagrad(lr=0.01, epsilon=1e-08, decay=1e-4)
 model.compile(loss = huber_loss_mean, optimizer=opt )<train_model>
train_best.nunique()
early_stopping = EarlyStopping(monitor='loss', patience=5, verbose=1)
 hist = model.fit(X_train, Y_train, batch_size=8, epochs=epochs_num,
callbacks=[early_stopping],shuffle=False )<predict_on_test>
hot = OneHotEncoder(handle_unknown='ignore')
 train_tr = pd.DataFrame(hot.fit_transform(train_best[cat_cols] ).toarray() , columns=hot.get_feature_names())
 test_tr = pd.DataFrame(hot.transform(test_best[cat_cols] ).toarray() , columns=hot.get_feature_names())
 train_best = pd.concat([train_best.drop(cat_cols, axis=1), train_tr], axis=1)
 test_best = pd.concat([test_best.drop(cat_cols, axis=1), test_tr], axis=1)
 del(train_tr, test_tr )
predicted_std = model.predict(X_test)
 result_std= pd.DataFrame(predicted_std)
 result_std.columns = ['predict']
result_std['actual'] = Y_test<normalization>
y = train['target']
predicted = scaler.inverse_transform(predicted_std)
 Y_test = scaler.inverse_transform(Y_test )<normalization>
X_train, X_valid, y_train, y_valid = train_test_split(train_best, y, test_size=0.3, random_state = 42 )
X_test_ = scaler.inverse_transform(X_test)
 X_test_[9]<prepare_output>
lgbm_params = {'max_depth': [3,5,7],
'learning_rate':[0.05, 0.01, 0.03],
'n_estimators':[1000, 1200, 1400]}
lgbt = LGBMClassifier(random_state=42)
 cv = KFold(n_splits=5, shuffle=True, random_state=42)
 lgbm_grid = GridSearchCV(lgbt, lgbm_params, cv=cv, scoring='roc_auc', verbose=1, n_jobs=-1)
 lgbm_grid.fit(X_train, y_train )
submission_df = submission_c<filter>
lgbm_grid.best_params_
temp =(datetime.datetime.strptime("2020-03-18", '%Y-%m-%d')- datetime.timedelta(days=maxlen)).strftime('%Y-%m-%d')
 test_df = train_df[train_df["Date"] > temp]<normalization>
lgbt = LGBMClassifier(max_depth=3, learning_rate=0.05, n_estimators=1000, random_state=42)
 lgbt.fit(X_train, y_train)
 y_pred = lgbt.predict_proba(X_valid)[:, 1]
y_pred =(y_pred - np.min(y_pred)) /(np.max(y_pred)- np.min(y_pred))
roc_auc_score(y_valid, y_pred )
check_df["Fatalities_std"] = scaler.transform(check_df["Fatalities"].values.reshape(len(check_df["Fatalities"].values),1))
check_df<concatenate>
y = train['target']
train = train.drop(['target', 'MobileNo_Avl_Flag'], axis=1)
 test = test.drop(['MobileNo_Avl_Flag'], axis=1)
 X_train, X_valid, y_train, y_valid = train_test_split(train, y, test_size=0.3, random_state = 42)
 lgbm_params = {'max_depth': [4],
'learning_rate':np.arange(0.03, 0.06, 0.01),
'n_estimators':[500, 1000, 1500, 2000]}
lgbt = LGBMClassifier(random_state=42)
 cv = KFold(n_splits=5, shuffle=True, random_state=42)
 lgbm_grid = GridSearchCV(lgbt, lgbm_params, cv=cv, scoring='roc_auc')
 lgbm_grid.fit(X_train, y_train )
fatalities_pred = []
for i in range(0,294*maxlen,maxlen):
temp_array = np.array(test_df[["Fatalities_std","ConfirmedCases_std"]][i:i+maxlen])
 for j in range(43):
if j<13:
temp_array = np.append(temp_array,np.append(np.array(check_df["Fatalities_std"])[int(i*13/maxlen)+j],np.array(check_df["ConfirmedCases_std"])[int(i*13/maxlen)+j] ).reshape(1,2),axis=0)
 elif np.array(test_df[["Fatalities","ConfirmedCases"]][i:i+maxlen] ).sum() == 0:
temp_array = np.append(temp_array,np.array(temp_array[-1] ).reshape(1,2),axis=0)
 else:
temp_array = np.append(temp_array,np.append(model.predict(temp_array[-maxlen:].reshape(1,maxlen,2)) ,submission_df["ConfirmedCases_std"][i/maxlen*43+j] ).reshape(1,2),axis=0)
 fatalities_pred.append(temp_array[-43:] )<normalization>
lgbt = LGBMClassifier(max_depth=4, learning_rate=0.03, n_estimators=1000)
 lgbt.fit(X_train, y_train)
 y_pred = lgbt.predict_proba(X_valid)[:, 1]
roc_auc_score(y_valid, y_pred )
submission_df["Fatalities"] = np.abs(scaler.inverse_transform([i[0] for i in np.array(fatalities_pred ).reshape(294*43,2)]))
submission_df<data_type_conversions>
lgbt = LGBMClassifier(max_depth=4, learning_rate=0.03, n_estimators=1000)
 lgbt.fit(train, y )
submission_df[["ConfirmedCases","Fatalities"]] = submission_df[["ConfirmedCases","Fatalities"]].round().astype(int)
 submission_df<drop_column>
answer_1 = lgbt.predict_proba(test)[:, 1]
answer_1
submission_df = submission_df.drop("ConfirmedCases_std",axis=1 )<drop_column>
answer1 = pd.DataFrame(columns=['ID', 'Predicted'])
 answer1['ID'] = test.index
answer1['Predicted'] = answer_1
<save_to_csv><EOS> 
answer1.to_csv('answer228.csv', index=None )