Kaggle competition: Santander Customer Satisfaction
<SOS> metric: AUC Kaggle data source: santander-customer-satisfaction<predict_on_test>
%matplotlib inline
train_df = pd.read_csv('.. /input/train.csv')
 test_df = pd.read_csv('.. /input/test.csv')
 sns.countplot(x="TARGET", data=train_df)
 for feat in train_df.columns:
if train_df[feat].dtype == 'float64':
train_df[feat][np.isnan(train_df[feat])] = train_df[feat].mean()
test_df[feat][np.isnan(test_df[feat])] = test_df[feat].mean()
elif train_df[feat].dtype == 'object':
train_df[feat][train_df[feat] != train_df[feat]] = train_df[feat].value_counts().index[0]
test_df[feat][test_df[feat] != test_df[feat]] = test_df[feat].value_counts().index[0]
for feat in train_df.columns:
if train_df[feat].dtype == 'object':
lbl = preprocessing.LabelEncoder()
lbl.fit(np.unique(list(train_df[feat].values)+ list(test_df[feat].values)))
 train_df[feat] = lbl.transform(list(train_df[feat].values))
test_df[feat] = lbl.transform(list(test_df[feat].values))
X_train = train_df.drop(["ID","TARGET"],axis=1)
 Y_train = train_df["TARGET"]
X_test = test_df.drop("ID",axis=1 ).copy()
y_predict = regressor.predict(input_fn=lambda: input_fn_new(testing_sub, training = False))
to_submit(y_predict, "submission_shallow" )<import_modules>
xgtrain = xgb.DMatrix(X_train, Y_train)
 xgtest = xgb.DMatrix(X_test )
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import random
from keras.models import Sequential
from keras.layers.core import Dense
from keras.optimizers import adam
from keras.wrappers.scikit_learn import KerasClassifier
from sklearn.model_selection import GridSearchCV
from sklearn.preprocessing import MinMaxScaler
from sklearn.neural_network import MLPClassifier
from sklearn.model_selection import train_test_split
from sklearn.model_selection import cross_val_score
from sklearn.metrics import precision_score,confusion_matrix, recall_score, f1_score, roc_auc_score, accuracy_score, classification_report 
<load_from_csv>
x_train, x_eval, y_train, y_eval = train_test_split(X_train, Y_train, test_size=0.33, stratify=Y_train, random_state=1)
 dtrain = xgb.DMatrix(x_train, y_train)
 deval = xgb.DMatrix(x_eval, y_eval)
 watchlist = [(dtrain, 'train'),(deval, 'eval')]
train_titanic = pd.read_csv(".. /input/titanic/train.csv")
 real_test_titanic = pd.read_csv(".. /input/titanic/test.csv")
<count_missing_values>
xgboost_params = {
'objective': 'multi:softprob',
'booster': 'gbtree',
'eval_metric': 'auc',
'eta': 0.3,
'subsample': 0.75,
'colsample_bytree': 0.75,
}
num_rounds = 1000
cv = xgb.cv(xgboost_params, xgtrain, metrics='auc', num_boost_round=num_rounds, nfold=5, stratified=True, seed=1, early_stopping_rounds=25, verbose_eval=True,show_stdv=False )
train_titanic.isnull().sum()<define_variables>
bst = xgb.train(
 xgboost_params,
dtrain,
num_boost_round=num_rounds,
evals=watchlist,
early_stopping_rounds=25,
verbose_eval=True )
<count_missing_values><EOS> 
preds = bst.predict(xgtest, ntree_limit=bst.best_iteration)
 submission = pd.DataFrame()
submission["ID"] = test_df["ID"]
submission["TARGET"] = preds[:,1]
submission.to_csv('santander.csv', index=False )