You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
def_metric_decorator(func: Callable) ->Metric:
"""Decorate a metric function from sklearn. Converts an metric function that uses the typical sklearn metric signature so that it is compatible with :py:func:`train` """definner(y_score: np.ndarray, dmatrix: DMatrix) ->Tuple[str, float]:
y_true=dmatrix.get_label()
weights=dmatrix.get_weight()
returnfunc.__name__, func(y_true, y_score, sample_weight=weightsiflen(weights) elseNone)
returninner
The text was updated successfully, but these errors were encountered:
Yikes, after rechecking the code I linked I realized this was already fixed (#8706). I was running xgboost==1.7.5 in my local environment which is why I was having issues. Sorry 😬
I guess the question still stands about propagating weights for custom objective functions as well if its not handled internally.
Weights arent propagated when specifying custom eval metrics. Example below:
I believe this also true for providing a custom objective function, although I'm not sure if the gradient,hess is weighted internally instead.
I think a simple fix could be as follows (here):
The text was updated successfully, but these errors were encountered: