Kaggle competition: Don't Overfit! II
cc, cat_cols = one_hot_encoder(cc, nan_as_category= True)
 cc.drop(columns = ['SK_ID_PREV'], inplace = True)
 cc_agg = cc.groupby('SK_ID_CURR' ).agg(['min', 'max', 'mean', 'sum', 'var'])
 cc_agg.columns = pd.Index(['CC_' + e[0] + "_" + e[1].upper() for e in cc_agg.columns.tolist() ])
 cc_agg['CC_COUNT'] = cc.groupby('SK_ID_CURR' ).size()
del cc
gc.collect()<train_model>
train = pd.read_csv('.. /input/train.csv')
 train.head()
print("End credit_card_balance................ " )<merge>
train.pop('id')
 target = train.pop('target' ).astype(int)
 test = pd.read_csv('.. /input/test.csv')
 ids = test.pop('id' )
with timer("Process bureau and bureau_balance"):
print("Bureau df shape:", bureau_agg.shape)
 df = df.join(bureau_agg, how='left',on='SK_ID_CURR')
 gc.collect()
with timer("Process previous_applications"):
print("Previous applications df shape:", prev_agg.shape)
 df = df.join(prev_agg, how='left', on='SK_ID_CURR')
 gc.collect()
with timer("Process POS-CASH balance"):
print("Pos-cash balance df shape:", pos_agg.shape)
 df = df.join(pos_agg, how='left', on='SK_ID_CURR')
 gc.collect()
with timer("Process installments payments"):
print("Installments payments df shape:", ins_agg.shape)
 df = df.join(ins_agg, how='left', on='SK_ID_CURR')
 gc.collect()
with timer("Process credit card balance"):
print("Credit card balance df shape:", cc_agg.shape)
 df = df.join(cc_agg, how='left', on='SK_ID_CURR')
 gc.collect()
del bureau_agg,prev_agg,pos_agg,ins_agg,cc_agg
gc.collect()<train_model>
code =
<split><EOS> 
data = {
'N': 250,
'N2': 19750,
'K': 300,
'y': target,
'X': train,
'new_X': test,
}
sm = ps.StanModel(model_code=code)
 fit = sm.sampling(data=data, seed=1234)
 ex = fit.extract(permuted=True)
 target = np.mean(ex['y_pred'], axis=0)
 df = pd.DataFrame({'id': ids, 'target': target})
 df[['id', 'target']].to_csv('submission.csv', index=False )