Kaggle competition: Don't Overfit! II
def merge_dataframes(dfs, merge_keys):
dfs_merged = reduce(lambda left,right: pd.merge(left, right, on=merge_keys), dfs)
 return dfs_merged<create_dataframe>
import numpy as np
import pandas as pd
from sklearn.model_selection import KFold
from sklearn.metrics import roc_auc_score
import matplotlib.pyplot as plt
import xgboost as xgb
from sklearn.linear_model import ElasticNet
from sklearn.ensemble import AdaBoostClassifier
from sklearn.model_selection import train_test_split
from sklearn.neighbors import KNeighborsClassifier
from sklearn.tree import DecisionTreeClassifier
from sklearn.ensemble import RandomForestClassifier
from sklearn.naive_bayes import GaussianNB
from sklearn.linear_model import LogisticRegression
dfs = [M1,M2,M3,M4,M5]
merge_keys=['SK_ID_CURR']
df = merge_dataframes(dfs, merge_keys=merge_keys )<rename_columns>
train = pd.read_csv(".. /input/train.csv")
 test = pd.read_csv(".. /input/test.csv")
 sub = pd.read_csv(".. /input/sample_submission.csv")
 sub['id'] = test['id']
df.columns = ['SK_ID_CURR','T1','T2','T3','T4','T5']
df.head()<define_variables>
train_X = train.drop(['id','target'], axis=1)
 train_y = train['target']
test = test.drop(labels = 'id', axis = 1 )
pred_prob = 0.5 * df['T2'] + 0.5 * df['T1']
pred_prob.head()<prepare_output>
x = train.drop(labels = 'target', axis=1)
 y = train["target"]
sub = pd.DataFrame()
sub['SK_ID_CURR'] = df['SK_ID_CURR']
sub['target']= pred_prob<save_to_csv>
from sklearn.model_selection import train_test_split
sub.to_csv('ldit.csv', index=False )<define_variables>
d_train = lgb.Dataset(train_X, label=train_y)
 params = {}
params['alpha'] = 0.2
params['l1_ratio'] = 0.31
params['precompute'] = True
params['selection'] = 'random'
params['tol'] = 0.001
params['random_state'] = 2
clf = lgb.train(params, d_train, 100 )
B_prob = 0.6 * df['T1'] + 0.2 * df['T3'] + 0.2 * df['T4']<save_to_csv>
sub["target"] = abs(clf.predict(test))
SUB = pd.DataFrame()
SUB['SK_ID_CURR'] = df['SK_ID_CURR']
SUB['TARGET'] = B_prob
SUB.to_csv('Blendss.csv', index=False )<define_variables>
sub.to_csv("sub.csv",index= False)