Kaggle competition: Don't Overfit! II
<SOS> metric: AUC Kaggle data source: dont-overfit!-ii<prepare_output>
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from sklearn.preprocessing import StandardScaler
from sklearn.metrics import accuracy_score
from sklearn.linear_model import LinearRegression,LogisticRegression
from sklearn import model_selection
bayes_results = evaluate(results, name = 'Bayesian')
 bayes_results<train_model>
train = pd.read_csv(".. /input/train.csv")
 print(train.shape)
 test = pd.read_csv(".. /input/test.csv")
 print(test.shape )
MAX_EVALS = 10
best = fmin(fn = objective, space = space, algo = tpe.suggest, trials = trials,
max_evals = MAX_EVALS )<load_from_csv>
train_x = train.iloc[:,2:]
train_y_ = train.iloc[:,1]
train_y = []
for i in train_y_:
train_y.append(i)
 test_x = test.iloc[:,1:]
bayes_results = pd.read_csv('.. /input/home-credit-model-tuning/bayesian_trials_1000.csv' ).sort_values('score', ascending = False ).reset_index()
random_results = pd.read_csv('.. /input/home-credit-model-tuning/random_search_trials_1000.csv' ).sort_values('score', ascending = False ).reset_index()
random_results['loss'] = 1 - random_results['score']
bayes_params = evaluate(bayes_results, name = 'Bayesian')
 random_params = evaluate(random_results, name = 'random' )<prepare_output>
scaler = StandardScaler()
train_x = scaler.fit_transform(train_x)
scores = pd.DataFrame({'ROC AUC': random_params['score'], 'iteration': random_params['iteration'], 'search': 'Random'})
 scores = scores.append(pd.DataFrame({'ROC AUC': bayes_params['score'], 'iteration': bayes_params['iteration'], 'search': 'Bayesian'}))
scores['ROC AUC'] = scores['ROC AUC'].astype(np.float32)
 scores['iteration'] = scores['iteration'].astype(np.int32)
 scores.head()<find_best_params>
regression = LogisticRegression(class_weight='balanced', solver='liblinear', penalty ='l1', C= 0.1, max_iter=10000)
 regression.fit(train_x,train_y)
 scores = model_selection.cross_val_score(regression,train_x,train_y,scoring="accuracy",cv=50)
 test_y_ = regression.predict_proba(test_x)
 print("Training Accuracy score: ",regression.score(train_x,train_y))
test_y = []
print(( test_y_[:,1]))
<load_from_csv><EOS> 
submission = pd.DataFrame({"id":test["id"],"target":test_y_[:,1]})
 submission.head()
filename = 'submission.csv'
submission.to_csv(filename,index=False)
 print('Saved file: ' + filename )