application_vnd.jupyter.stderr_output_3.png text_plain_output_2.png application_vnd.jupyter.stderr_output_1.png
from sklearn.metrics import confusion_matrix

from sklearn.model_selection import GridSearchCV

from sklearn.model_selection import train_test_split, StratifiedKFold

from sklearn.pipeline import Pipeline

import matplotlib.pyplot as plt

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

import seaborn as sn

import xgboost as xgb

dataset = pd.read_csv('../input/predictnav-beta/dataset_beta.csv')
dataset.drop(['ip_hash', 'fecha', 'lang', 'country'], axis=1, inplace=True)
X, y = (dataset.iloc[:, 0:-1].values, dataset.iloc[:, -1].values)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=0)
from sklearn.metrics import confusion_matrix
import seaborn as sn
import matplotlib.pyplot as plt
def showConfusionMat(pipe, X_test, y_test):
    y_pred = pipe.predict(X_test)
    confmat = confusion_matrix(y_true=y_test, y_pred=y_pred)
    df_cm = pd.DataFrame(confmat, ['F', 'T'], ['F', 'T'])
    sn.set(font_scale=1.4)

import xgboost as xgb
gbm = xgb.XGBClassifier(max_depth=4, n_estimators=300, learning_rate=0.1)
gbm.fit(X_train_res, y_train_res)

from sklearn.model_selection import GridSearchCV
pipe = Pipeline([('gbm', xgb.XGBClassifier())])
param_grid = [{'gbm__max_depth': [3, 4, 5], 'gbm__n_estimators': [250, 300, 350], 'gbm__learning_rate': [0.2, 0.1, 0.5]}]
gs = GridSearchCV(estimator=pipe, param_grid=param_grid, scoring='accuracy', cv=5, n_jobs=-1)
gs = gs.fit(X_train_res, y_train_res)

showConfusionMat(gs, X_test, y_test)