Tuning XGBRanker produces error for groups

412 Views Asked by At

I have a simple ranking problem, and i use:

from xgboost import XGBRanker

model = XGBRanker(
    min_child_weight=10,
    subsample=0.5,
    tree_method='hist',
)
model.fit(X_train, y_train, group=groups)

Works fine. As an step of machine learning flow, now I want to tune the hyperparameters of the model as usual. I tried:

from skopt import BayesSearchCV
from skopt.space import Real, Categorical, Integer


opt = BayesSearchCV(
    model,
    {
        'min_child_weight': Real(.05, .5, prior='log-uniform'),
        'subsample': Real(.05, .5, prior='log-uniform'),
        #'n_estimators ': Integer(1,50),
    },
    n_iter=32,
    random_state=0,
    scoring='accuracy'
)

# executes bayesian optimization
_ = opt.fit(X_train, y_train, group=groups)

and I receive the following error:

Check failed: group_ptr_.back() == num_row_ (5740832 vs. 4592665) : Invalid group structure.  Number of rows obtained from groups doesn't equal to actual number of rows given by data.

I tried this with RandomizedSearchCV of scikit and the same error occurred.

0

There are 0 best solutions below