调整XGBranker会为组产生错误

发布于 2025-01-29 05:51:41 字数 1016 浏览 2 评论 0原文

我有一个简单的排名问题,我使用:

from xgboost import XGBRanker

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

工作正常。作为机器学习流的一步,现在我想照常调整模型的超参数。我尝试了:

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)

我收到以下错误:

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.

我用rancomexearchcv of scikit尝试了此错误,并发生了相同的错误。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文