
<SYSTEM_TASK:>
Given the following text problem statement, write Python code to implement the functionality described below in problem statement
<END_TASK>
<USER_TASK:>
Problem:
Tuning XGBoost Hyperparameters with Grid Search

<ASSISTANT_TASK:>
Python Code::
from sklearn.model_selection import GridSearchCV
import xgboost as xgb
# create a dictionary containing the hyperparameters
# to tune and the range of values to try
PARAMETERS = {"subsample":[0.75, 1],
              "colsample_bytree":[0.75, 1],
              "max_depth":[2, 6],
              "min_child_weight":[1, 5],
              "learning_rate":[0.1, 0.01]}
# create a validation set which will be used for early stopping
eval_set = [(X_val, y_val)]
# initialise an XGBoost classifier, set the number of estimators,
# evaluation metric & early stopping rounds
estimator = xgb.XGBClassifier(n_estimators=100, 
                              n_jobs=-1, 
                              eval_metric='logloss',
                              early_stopping_rounds=10)
# initialise GridSearchCV model by passing the XGB classifier we
# initialised in the last step along with the dictionary of parameters
# and values to try. We also set the number of folds to validate over
# along with the scoring metic to use
model = GridSearchCV(estimator=estimator,
                    param_grid=PARAMETERS,
                    cv=3,
                    scoring="neg_log_loss")
# fit model
model.fit(X_train,
          y_train,
          eval_set=eval_set,
          verbose=0)
# print out the best hyperparameters
print(model.best_params_)

<END_TASK>
