Kaggle competition: Home Credit Default Risk
<SOS> metric: AUC Kaggle data source: home-credit-default-risk<split>
import numpy as np
import pandas as pd
import os
train, valid = train_test_split(df, random_state=42 )<split>
app_train = pd.read_csv('.. /input/home-credit-simple-featuers/simple_features_train.csv')
 app_test = pd.read_csv('.. /input/home-credit-simple-featuers/simple_features_test.csv' )
train, valid = train_test_split(df, random_state=42 )<define_search_space>
sk_id = pd.read_csv('.. /input/home-credit-default-risk/application_test.csv' )
<train_on_grid>
train = app_train.drop(columns = ['TARGET'])
 train_labels = app_train['TARGET']
<define_search_space>
X_train, X_test, y_train, y_test = train_test_split(
 train, train_labels, test_size=0.2 )
param_grid = {
'bootstrap': [True],
'max_depth': [80, 90, 100, 110],
'max_features': [2, 3],
'min_samples_leaf': [3, 4, 5],
'min_samples_split': [8, 10, 12],
'n_estimators': [100, 200, 300, 1000]
}
rf = RandomForestRegressor()
grid_search = GridSearchCV(estimator = rf, param_grid = param_grid,
cv = 3, n_jobs = -1, verbose = 2 )<train_on_grid>
clf = LGBMClassifier(nthread=4,n_estimators=10000,learning_rate=0.02,num_leaves=34,colsample_bytree=0.9497036,subsample=0.8715623,max_depth=8,reg_alpha=0.041545473,reg_lambda=0.0735294,min_split_gain=0.0222415,min_child_weight=39.3259775,silent=-1,verbose=-1)
 clf.fit(X_train, y_train, eval_set=[(X_train, y_train),(X_test, y_test)],
eval_metric= 'auc', verbose= 100, early_stopping_rounds= 200)
grid_search.fit(train[feats], train['nota_mat'] )<find_best_params>
<import_modules><EOS> 
y_pred = clf.predict_proba(app_test, num_iteration=clf.best_iteration_)[:, 1]
submit = sk_id[['SK_ID_CURR']]
submit['TARGET'] = y_pred
submit.to_csv('sub1.csv', index = False)