title: Hyperparameter Grid Search with XGBoost - Scoring function vs Evaluation Metric
body: <p>Dealing with an imbalance dataset problem (7% vs 93%), I want to find out the best structure of my xgboost model using <a href="https://scikit-learn.org/stable/modules/generated/sklearn.model_selection.GridSearchCV.html" rel="nofollow noreferrer">grid search cross-validation</a>. <em>Note: I am using stratified k-fold cross-validation to make sure each fold has the correct proportion of the minority class.</em> </p>
  
  <p>My situation is the following, I noticed GridSearchCV has a parameter called 'scoring' to which I can pass even more than one <a href="https://scikit-learn.org/stable/modules/classes.html#module-sklearn.metrics" rel="nofollow noreferrer">sklearn.metrics</a> as shown <a href="https://scikit-learn.org/stable/auto_examples/model_selection/plot_multi_metric_evaluation.html" rel="nofollow noreferrer">here.</a> However, xgboost has also a parameter called 'eval_metric' and I am a bit confused between the two. Could you explain me the difference if any? Where is the correct place to specify it?</p>
  
  <p>I will attach a little bit of code to illustrate it: </p>
  
  <pre><code>params_grid = {
  'n_estimators': [100, 300],
  'learning_rate': [0.01, 0.1, 0.3],
  'colsample_bytree': [0.3, 0.5],
  }
  
  params_fixed = {
      'objective':'binary:logistic',
      'silent':1,
      'eval_metric':'auc'
  }
  
  
  n_folds = 5
  skf = StratifiedKFold(n_splits=n_folds,random_state=seed,shuffle=True)
  
  # create xgboost classifier
  xgb = XGBClassifier(**params_fixed, seed=seed)
  
  grid_search = GridSearchCV(estimator=xgb, param_grid=params_grid, 
                                 cv=skf.split(X_train, y_train), scoring='balanced_accuracy')
  </code></pre>
  
  <p>In addition, which function would you then recommend to use in my case? It can be from skearn.metrics or even a custom-one but I do not know yet how to write it. Note, my problem is a trade-off problem between recall and precision but recall is to me the most important since I would like to detect the minority class in 99% cases. </p>