Kaggle competition: Santander Customer Transaction Prediction
<SOS> metric: AUC Kaggle data source: santander-customer-transaction-prediction<import_modules>
import numpy as np
import pandas as pd
from sklearn.model_selection import StratifiedKFold
from sklearn.metrics import roc_auc_score
import xgboost as xgb
import lightgbm as lgb
import numpy as np
import pandas as pd<save_to_csv>
train = pd.read_csv('.. /input/ct-datasets/final_train(1 ).csv')
 test = pd.read_csv('.. /input/ct-datasets/final_test(1 ).csv')
 y = train['target']
train = train.iloc[:, :-1]
remaining_test = pd.read_csv('.. /input/test-ctr/fake_test.csv')[['ID_code']]
remaining_test['target'] = 0
test_index = test.ID_code
test = test.drop('ID_code', axis=1 )
directory="/kaggle/input/covid19-global-forecasting-week-4/"
v1 = pd.read_csv('/kaggle/input/covid-w4-sub-v1/submission.csv')
 v1.to_csv("v1.csv", index=False)
 v2 = pd.read_csv('/kaggle/input/lightgbm-lead-model-week-4/submission.csv')
 v2.to_csv('v2.csv', index=False)
 v3 = pd.read_csv('/kaggle/input/covid-w4-sub-v3-lightgbm/submission.csv')
 v3.to_csv('v3.csv', index=False )<data_type_conversions>
lgb_params = {
"objective" : "binary",
"metric" : "auc",
"boosting": 'gbdt',
"max_depth" : 1,
"num_leaves" : 13,
"learning_rate" : 0.03,
"bagging_freq": 5,
"bagging_fraction" : 0.4,
"feature_fraction" : 0.05,
"min_data_in_leaf": 80,
"min_sum_hessian_in_leaf": 10,
"tree_learner": "serial",
"boost_from_average": "false",
"bagging_seed" : 42,
"verbosity" : 1,
"seed": 42
}
submission =(v1*0 + v2*1)/ 1
submission = submission.astype({"ForecastId": int} )<feature_engineering>
folds = StratifiedKFold(n_splits=5, shuffle=True, random_state=44000)
 oof = np.zeros(len(train))
predictions = np.zeros(len(test))
for fold_,(trn_idx, val_idx)in enumerate(folds.split(train.values, y.values)) :
print("Fold {}".format(fold_))
trn_data = lgb.Dataset(train.iloc[trn_idx], label=y.iloc[trn_idx])
 val_data = lgb.Dataset(train.iloc[val_idx], label=y.iloc[val_idx])
 num_round = 15000
clf = lgb.train(lgb_params, trn_data, num_round, valid_sets = [trn_data, val_data],
verbose_eval=1000, early_stopping_rounds = 200)
 oof[val_idx] = clf.predict(train.iloc[val_idx], num_iteration=clf.best_iteration)
 predictions += clf.predict(test, num_iteration=clf.best_iteration)/ folds.n_splits
print("CV score: {:<8.5f}".format(roc_auc_score(y, oof)) )
pp = [4683, 74877, 94, 1512]
for idx in range(6119,6149):
row = submission.iloc[idx]
pp[0],pp[1] = pp[0] + pp[2], pp[1] + pp[3]
submission.loc[idx,'Fatalities'] = pp[0]
submission.loc[idx,'ConfirmedCases'] = pp[1]
pp[2] = pp[2] - 1
pp[3] = pp[3] - 20<save_to_csv>
sub_file = pd.read_csv('/kaggle/input/santander-customer-transaction-prediction/sample_submission.csv' )
submission.to_csv("submission.csv", index=False )<import_modules>
sub = pd.DataFrame()
sub['ID_code'] = test_index
sub['target'] = predictions
final_sub = pd.merge(sub_file, sub, on='ID_code', how='left')[['ID_code', 'target_y']]
final_sub = final_sub.fillna(0 ).rename(columns={'target_y': 'target'})
 final_sub
<load_from_csv><EOS> 
final_sub.to_csv('Finalsub.csv', index=False )