Kaggle competition: Santander Customer Transaction Prediction
<SOS> metric: AUC Kaggle data source: santander-customer-transaction-prediction<feature_engineering>
print(dt.datetime.now() , 'python version:')
 print(sys.version)
 print(dt.datetime.now() , 'pandas version:', pd.__version__ )
date_block_total["year"]=date_block_total.date_block_num.apply(lambda x:(( x//12)+2013))
date_block_total["month"]=date_block_total.date_block_num.apply(lambda x:(x%12))
date_block_total.head()<data_type_conversions>
print(dt.datetime.now() , 'start reading data...')
 dirc = '.. /input/'
train = pd.read_csv(dirc + 'train.csv')
 test = pd.read_csv(dirc + 'test.csv')
 submission = pd.read_csv(dirc + 'sample_submission.csv')
 x = train.drop(['ID_code', 'target'], axis=1)
 y = train.target
print('train shape', train.shape)
 print('test shape', test.shape)
 print(dt.datetime.now() , 'finish reading data')
 test.drop('ID_code', axis=1, inplace=True )
train["year"]=train.date_block_num.apply(lambda x:(( x//12)+2013))
train["month"]=train.date_block_num.apply(lambda x:(x%12))
train["year"]=train["year"].astype(np.int16)
 train["month"]=train["month"].astype(np.int8)
 train.head()<data_type_conversions>
n_sp = 5
sfk = StratifiedKFold(n_splits=n_sp)
 pred_train_mtx = np.zeros(len(train))
pred_test_mtx = np.zeros(( len(test), n_sp))
i = 0
for train_idx, val_idx in sfk.split(x, y):
train_x = x.iloc[train_idx, :]
val_x = x.iloc[val_idx, :]
train_y = y.iloc[train_idx]
val_y = y.iloc[val_idx]
print(dt.datetime.now() , 'cycle', i, 'start training...')
 model = XGBClassifier(n_estimators=100000, n_jobs=32, tree_method='gpu_hist',
learning_rate=0.01,
max_delta_step=2, colsample_bylevel=0.6, colsample_bytree=0.1,
gamma=0.004, max_bin=256, max_depth=8, max_leaves=27, min_child_weight=96,
reg_alpha=0.003, reg_lambda=0.060, subsample=0.4)
 model.fit(train_x, train_y, eval_set=[(val_x, val_y)],
verbose=500,
eval_metric='auc', early_stopping_rounds=2500)
 pred_temp = model.predict_proba(val_x)[:, 1]
print('roc_auc_score:', roc_auc_score(val_y, pred_temp))
pred_train_mtx[val_idx] = pred_temp
pred_test_mtx[:, i] = model.predict_proba(test)[:, 1]
print(dt.datetime.now() , 'finish cycle', i, 'training')
 print()
i += 1
print('final auc score:', roc_auc_score(y, pred_train_mtx))
pred = pred_test_mtx.mean(axis = 1 )
test_df=pd.read_csv(".. /input/competitive-data-science-predict-future-sales/test.csv")
 test_df["date_block_num"]=34
test_df["year"]=(( 34//12)+2013)
 test_df["month"]=(34%12)
 test_df["date_block_num"]=test_df["date_block_num"].astype(np.int8)
 test_df["shop_id"]=test_df["shop_id"].astype(np.int8)
 test_df["item_id"]=test_df["item_id"].astype(np.int16)
 test_df["year"]=test_df["year"].astype(np.int16)
 test_df["month"]=test_df["month"].astype(np.int8)
 test_df.head()<define_variables>
submission['target'] = pred
submission.to_csv('submission.csv', index=False )