title: Using evaluation functions with parameter in XGBoost (f_beta)
body: <p>I'm working on a classification problem where I have an unbalanced dataset and I am interested in having high precision.  </p>
  
  <p>Therefore, I would like to change the objective function for XGBoost to something that allows me to put more weight on precision. <a href="http://scikit-learn.org/stable/modules/generated/sklearn.metrics.fbeta_score.html" rel="nofollow noreferrer">F_beta score</a> seems to be doing just that, but I have a problem with it: </p>
  
  <pre><code>model_xgbm = XGBClassifier(objective=fbeta_score)
  random_search = RandomizedSearchCV(model_xgbm, param_distributions=param_dist, n_iter=n_iter_search,
                                 scoring='average_precision')
  </code></pre>
  
  <p>This works, but I didn't supply a beta (I'm not even sure how does it work since beta is n obligatory parameter...)</p>
  
  <pre><code>model_xgbm = XGBClassifier(objective=fbeta_score(beta=0.5))
  random_search = RandomizedSearchCV(model_xgbm, param_distributions=param_dist,
                                     n_iter=n_iter_search,
                                     scoring='average_precision')
  </code></pre>
  
  <p>This simply doesn't work ("TypeError: fbeta_score() takes at least 3 arguments (1 given)"). However, I can't really supply it with the other 2 arguments  here.</p>
  
  <p>Is there a solution without copying or wrapping the function and pasting as a custom objective?</p>
  
  <p><strong>EDIT :</strong>
  I found a function that might be useful: <a href="http://scikit-learn.org/stable/modules/generated/sklearn.metrics.make_scorer.html" rel="nofollow noreferrer">make_param</a>, but unfortunately I can't seem to get it to work:</p>
  
  <pre><code>model_xgbm = XGBClassifier(objective=make_scorer(fbeta_score, beta=0.5))
  random_search = RandomizedSearchCV(model_xgbm, param_distributions=param_dist,
                                     n_iter=n_iter_search,
                                     scoring='precision')
  </code></pre>
  
  <p>But this does not work either: "TypeError: __call__() takes at least 4 arguments (3 given)"
  Note that I don't want to use it for model selection: I want it to be the objective function of my XGBoost estimator! Thus, the example at the bottom of the aforementioned link does not work for me.</p>
  
  <p><strong>EDIT2 :</strong> OK, so in fact the problem seems to be that XGBoost Classifier expects me to provide as the objective a function that returns a gradient and a hessian... does anyone know a wrapper that would do that for me?</p>