【问题标题】:Hyperparameter tuning with XGBRanker使用 XGBRanker 进行超参数调优
【发布时间】:2022-01-03 21:18:10
【问题描述】:

我正在尝试使用 XGBRanker 模型通过 RandomizedSearchCV 调整我的超参数。

我可以将数据分组,将其输入模型并进行预测。但是我不确定如何设置 Search 对象,即 2 个具体的东西 - 如何通知它关于组以及我需要提供什么样的分数。

model = xg.XGBRanker(
    tree_method='exact',
    booster='gbtree',
    objective='rank:pairwise',
    random_state=42,
    learning_rate=0.06,
    max_depth=5,
    n_estimators=700,
    subsample=0.75,
    #colsample_bytree=0.9,
    #subsample=0.75
    min_child_weight=0.06
    )

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

这很好用。 这是我需要帮助的地方

param_dist = {'n_estimators': stats.randint(40, 1000),
              'learning_rate': stats.uniform(0.01, 0.59),
              'subsample': stats.uniform(0.3, 0.6),
              'max_depth': [3, 4, 5, 6, 7, 8, 9],
              'colsample_bytree': stats.uniform(0.5, 0.4),
              'min_child_weight': [0.05, 0.1, 0.02]
              }
clf = RandomizedSearchCV(model,
                         param_distributions=param_dist,
                         cv=5,
                         n_iter=5,  
                         scoring=???, #
                         error_score=0,
                         verbose=3,
                         n_jobs=-1)
#also what about the groups?

【问题讨论】:

    标签: xgboost ranking hyperparameters lightgbm


    【解决方案1】:

    我尝试过类似的方法。但是,我使用了 sklearn 的 ndcg_scorer 进行评分。 我加了

    scoring = sklearn.metrics.make_scorer(sklearn.metrics.ndcg_score, greater_is_better=True)
    

    对于您可以添加到 RandomizedSearchCV 中的 fit_params 的组。

    fit_params = {"model__groups": group}
    
    clf = RandomizedSearchCV(model,
                             param_distributions=param_dist,
                             cv=5,
                             n_iter=5,  
                             scoring=scoring,
                             error_score=0,
                             verbose=3,
                             n_jobs=-1,fit_params = fit_params)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-09-10
      • 1970-01-01
      • 2021-07-18
      • 2018-09-01
      • 1970-01-01
      • 2023-01-31
      • 2020-05-21
      • 2020-01-20
      相关资源
      最近更新 更多