Kaggle competition: IEEE-CIS Fraud Detection
rfModel_ca = RandomForestRegressor(n_estimators=1000 ,
oob_score=True, random_state = 42)
 rfModel_ca.fit(X_train_ca , y_train_ca)
 rfModel_re = RandomForestRegressor(n_estimators=1000 ,
oob_score=True, random_state = 42)
 rfModel_re.fit(X_train_re , y_train_re)
 rfModel = RandomForestRegressor(n_estimators=1000 ,
oob_score=True, random_state = 42)
 rfModel.fit(X_train , y_train )<compute_train_metric>
sub_path = ".. /input/ieeesubmissions"
all_files = os.listdir(sub_path)
 all_files
preds_train_ca = rfModel_ca.predict(X = X_train_ca)
 rmsle_casual_train = sqrt(mean_squared_log_error(y_train_ca, preds_train_ca))
preds_valid_ca = rfModel_ca.predict(X = X_valid_ca)
 rmsle_casual_valid = sqrt(mean_squared_log_error(y_valid_ca, preds_valid_ca))
print('Casual train rmsle : %.5f, valid rmsle : %.5f' %(rmsle_casual_train,
rmsle_casual_valid))
preds_train_re = rfModel_re.predict(X = X_train_re)
 rmsle_registered_train = sqrt(mean_squared_log_error(y_train_re, preds_train_re))
preds_valid_re = rfModel_re.predict(X = X_valid_re)
 rmsle_registered_valid = sqrt(mean_squared_log_error(y_valid_re, preds_valid_re))
print('Registered train rmsle : %.5f,valid rmsle : %.5f' %(rmsle_registered_train,
rmsle_registered_valid))<compute_train_metric>
outs = [pd.read_csv(os.path.join(sub_path, f), index_col=0)for f in all_files]
concat_sub = pd.concat(outs, axis=1)
 cols = list(map(lambda x: "ieee" + str(x), range(len(concat_sub.columns))))
concat_sub.columns = cols
concat_sub.reset_index(inplace=True)
 concat_sub.head()
ncol = concat_sub.shape[1]
preds_train = rfModel.predict(X = X_train)
 rmsle_count_train = sqrt(mean_squared_log_error(y_train, preds_train))
preds_valid = rfModel.predict(X = X_valid)
 rmsle_count_valid = sqrt(mean_squared_log_error(y_valid, preds_valid))
print('Count train rmsle : %.5f, valid rmsle : %.5f' %(rmsle_count_train,
rmsle_count_valid))<compute_test_metric>
concat_sub['ieee_max'] = concat_sub.iloc[:, 1:ncol].max(axis=1)
 concat_sub['ieee_min'] = concat_sub.iloc[:, 1:ncol].min(axis=1)
 concat_sub['ieee_mean'] = concat_sub.iloc[:, 1:ncol].mean(axis=1)
 concat_sub['ieee_median'] = concat_sub.iloc[:, 1:ncol].median(axis=1 )
preds_train_merge_count = preds_train_re + preds_train_ca
preds_valid_merge_count = preds_valid_re + preds_valid_ca
rmsle_merge_train = sqrt(mean_squared_log_error(y_train,preds_train_merge_count))
rmsle_merge_valid = sqrt(mean_squared_log_error(y_valid,preds_valid_merge_count))
print('(merge)Count train rmsle : %.5f, valid rmsle : %.5f'%(rmsle_merge_train,
rmsle_merge_valid))<create_dataframe>
cutoff_lo = 0.90
cutoff_hi = 0.30
<feature_engineering><EOS> 
concat_sub['isFraud'] = concat_sub['ieee_median']
concat_sub[['TransactionID', 'isFraud']].to_csv('ieee.csv',
index=False, float_format='%.6f' )