XGBRanker with cross validation gives inconsistent group error

Hello everyone,

I’m trying to build an XGBRanker model with RandomizedSearchCV. It works fine when I run the code without cross validation but gives the error below when I try to perform CV. Thank you for your help.

The error:
Check failed: gptr.size() != 0 && gptr.back() == info.labels_.Size(): group structure not consistent with #rows

Below code works fine:
model = xgb.XGBRanker(n_estimators=3)

model.fit(X_train, y_train, group=train_groups, verbose=True)

Below code gives an error:
params_grid = {‘n_estimators’: [1, 3],
‘num_leaves’: [20],
‘max_depth’: [4,5],
‘learning_rate’: [0.01],
}
est = xgb.XGBRanker()
model = RandomizedSearchCV(est, params_grid, n_iter=3, cv=3, verbose=1, scoring = ‘average_precision’)
model.fit(X_train, y_train, group=train_groups)