text_plain_output_1.png
from sklearn.metrics import f1_score ,accuracy_score

from sklearn.model_selection import GridSearchCV

from xgboost import XGBClassifier

xgb = XGBClassifier()
model1 = xgb.fit(X_train, y_train)
y_hat = model1.predict(X_test)
f1 = f1_score(y_test, y_hat)
acc = accuracy_score(y_test, y_hat)
(f1, acc)

parameters = {'booster': ['gbtree', 'gblinear', 'dart'], 'learning_rate': [0.1, 0.3, 0.6, 0.9, 1], 'n_estimators': [0.1, 1, 10, 15]}
grid = GridSearchCV(xgb, param_grid=parameters, cv=5, verbose=0)
grid.fit(X_train, y_train)
print(grid.best_params_)