I am passing a custom evaluation metric function to XGB fit(), but the Python API discards callable (i.e., custom) functions. Why? How are we supposed to pass in this function? Or is this functionality not supported by the Python/Scikit API?
model = XGBClassifier(scale_pos_weight=scale_pos_weight)
model.fit(X_train, y_train, eval_metric=xgb_f1)
In sklearn.py (line 755):
def fit(self, X, y, sample_weight=None, base_margin=None,
eval_set=None, eval_metric=None,
early_stopping_rounds=None, verbose=True, xgb_model=None,
sample_weight_eval_set=None, callbacks=None):
...
feval = eval_metric if callable(eval_metric) else None
if eval_metric is not None:
if callable(eval_metric):
eval_metric = None # <<<<<<<<<< If eval_metric is callable, it's discarded
else:
xgb_options.update({"eval_metric": eval_metric})