Description
I tried a custom ranking objective function for LGBMRanker but LGBMRanker does not call the custom loss function with the group argument, which is mandatory for learning to rank.
Reproducible example
import lightgbm as lgbm
import numpy as np
# fake data
N, p, gsize = 1000, 10, 5
X = np.random.randn(N, p)
y = np.random.randint(0, 4, N)
groups = [gsize] * (N//gsize)
# fake loss to trace inputs
_args = None
_kwargs = None
def loss(*args, **kwargs):
global _args, _kwargs
_args = args
_kwargs = kwargs
return 0, 0
lgbm_ranker = lgbm.LGBMRanker(n_estimators=10, learning_rate=0.1, objective=loss)
try:
lgbm_ranker.fit(X, y, group=groups)
except Exception as e:
print(e)
print(len(_args))
print(_kwargs)
_args nor _kwargs contain reference to the groups I used as ranking group size.
Environment info
LightGBM version or commit hash: 4.6.0
Command(s) you used to install LightGBM