Kaggle competition: Santander Value Prediction Challenge
<SOS> metric: RMSLE Kaggle data source: santander-value-prediction-challenge<drop_column>
import numpy as np
import pandas as p
from matplotlib import pyplot as plt
import seaborn as sns
from math import sqrt
from sklearn import metrics
remove = []
c = df_train.columns
for i in range(len(c)-1):
v = df_train[c[i]].values
for j in range(i+1,len(c)) :
if np.array_equal(v,df_train[c[j]].values):
remove.append(c[j])
 df_train.drop(remove, axis=1, inplace=True)
 df_test.drop(remove, axis=1, inplace=True )<prepare_x_and_y>
df_base0 = p.read_csv('.. /input/1a2a3a/final_submission/1a.csv',names=["ID","target"], skiprows=[0],header=None)
 df_base1 = p.read_csv('.. /input/1a2a3a/final_submission/2a.csv',names=["ID","target"], skiprows=[0],header=None)
 df_base2 = p.read_csv('.. /input/1a2a3a/final_submission/3a.csv',names=["ID","target"], skiprows=[0],header=None )
y_train = df_train['TARGET'].values
X_train = df_train.drop(['ID','TARGET'], axis=1 ).values
id_test = df_test['ID']
X_test = df_test.drop(['ID'], axis=1 ).values
len_train = len(X_train)
 len_test = len(X_test)
<train_model>
df_base = p.merge(df_base0,df_base1,how='inner',on='ID')
 df_base = p.merge(df_base,df_base2,how='inner',on='ID' )
clf = xgb.XGBClassifier(
 missing=np.nan,
max_depth=5,
n_estimators=350,
learning_rate=0.02,
nthread=4,
subsample=0.95,
colsample_bytree=0.85,
seed=4242)
 X_fit, X_eval, y_fit, y_eval= train_test_split(X_train, y_train, test_size=0.3)
<train_model>
M = np.zeros([df_base.iloc[:,1:].shape[1],df_base.iloc[:,1:].shape[1]])
 for i in np.arange(M.shape[1]):
for j in np.arange(M.shape[1]):
M[i,j] = sqrt(metrics.mean_squared_error(df_base.iloc[:,i+1], df_base.iloc[:,j+1]))
clf.fit(X_train, y_train, early_stopping_rounds=20, eval_metric="auc", eval_set=[(X_eval, y_eval)])
<save_to_csv>
df_base['target'] = df_base.iloc[:,1:].mean(axis=1 )
y_pred= clf.predict_proba(X_test)[:,1]
submission = pd.DataFrame({"ID":id_test, "TARGET":y_pred})
 submission.to_csv("submission.csv", index=False)
 print('Completed!' )<train_on_grid>
df_base[['ID','target']].to_csv("latest.csv",index=False )