Kaggle competition: Don't Overfit! II
<SOS> metric: AUC Kaggle data source: dont-overfit!-ii<choose_model_class>
%matplotlib inline
rf = RandomForestRegressor(max_depth= 6, min_samples_leaf= 2, min_samples_split= 30, n_estimators= 50 )<train_on_grid>
plt.rcParams['figure.figsize'] = [10, 5]
plt.rcParams['font.size'] = 12
gridParams = {
'max_depth': [3,6,7],
'n_estimators': [10,50,100],
'min_samples_leaf' : [2,10],
'min_samples_split' : [10,30,60]
} 
<choose_model_class>
train = pd.read_csv('.. /input/train.csv')
 test = pd.read_csv('.. /input/test.csv')
 submit = pd.read_csv('.. /input/sample_submission.csv')
 print(train.shape, test.shape, submit.shape )
model_lgb = lgb.LGBMRegressor(feature_fraction= 1, lambda_l1= 0, learning_rate= 0.05, max_depth= 3, min_data_in_leaf= 50, n_estimators= 500, num_leaves= 4 )<choose_model_class>
print(train.target.value_counts() / train.shape[0] * 100 )
KRR = KernelRidge(kernel='polynomial', alpha = 1, coef0=3, degree = 2 )<train_on_grid>
train_corr.iloc[[0],:]
gridParams = {
'alpha': [1,2,3],
'degree': [2,3,4],
'coef0' : [1,2,3],
} 
<set_options>
target = train_selected["target"].values
train_selected.drop(["target"], axis=1, inplace=True )
svr = SVR(C= 1, gamma= 0.001 )<choose_model_class>
N_FOLDS = 10
features = train_selected.columns.tolist()
lasso = Lasso(alpha =0.0005, random_state=1 )<find_best_params>
folds = StratifiedKFold(n_splits=N_FOLDS, shuffle=True, random_state=42)
 oof = np.zeros(len(train_selected))
sub = np.zeros(len(test_selected))
score = [0 for _ in range(folds.n_splits)]
for fold_,(trn_idx, val_idx)in enumerate(folds.split(train_selected.values, target)) :
X_train, y_train = train_selected.iloc[trn_idx][features], target[trn_idx]
X_val, y_val = train_selected.iloc[val_idx][features], target[val_idx]
X_test = test_selected.values
clf = LogisticRegression(penalty="l1", C=0.1, solver="liblinear", random_state=42)
 clf.fit(X_train, y_train)
 oof[val_idx] = clf.predict_proba(X_val)[:, 1]
sub += clf.predict_proba(X_test)[:, 1] / folds.n_splits
score[fold_] = roc_auc_score(target[val_idx], oof[val_idx])
 print("Fold {}: {}".format(fold_+1, round(score[fold_],5)))
 print("CV score(auc): {:<8.5f},(std: {:<8.5f})".format(roc_auc_score(target, oof), np.std(score)) )
<choose_model_class><EOS> 
submit = pd.read_csv('.. /input/sample_submission.csv')
 submit["target"] = sub
submit.to_csv("submission.csv", index=False)
 submit.head(20 )