【问题标题】:Pred_leaf in lightgbmlightgbm 中的 Pred_leaf
【发布时间】:2020-05-20 17:31:33
【问题描述】:

在查看LightGBM docs 时,我发现predict 支持pred_leaf 参数。文档说

pred_leaf (bool, optional (default=False)) – Whether to predict
leaf index.

但是,当做一个

data := (1, 28)
gbm := num_boost_round = X

embedding = gbm.predict(data, pred_leaf=True)
embedding.shape  # [1, X]
print(embedding[0, :])  # [29,  2,  8, 26,  2,  2, 16, 18, 25, 30, 16, 25,  0, 17, 15]

我不明白为什么它输出的是一个填充的数组,而不是一个单热向量或标量值?它说它预测叶子索引?这可以用作另一个模型的“嵌入”吗?

Ps:我会在stats-stackexchange 中发布此内容,但看起来这是 1)特定于 lightgbm 和 2)他们没有 lightgbm 标签

【问题讨论】:

    标签: python lightgbm boosting


    【解决方案1】:

    pred_leaf 参数设置为 True 的 LightGBM predict 的输出是一个包含 int32 值的 shape(nsample, ntrees) 数组。

    矩阵中的每个整数项表示每棵树中每个样本的预测叶索引。

    由于每棵树的叶子索引是唯一的,因此您可能会在许多不同的列中找到相同的叶子编号。

    至于它的行为,这个 LightGBM 预测函数模仿了 XGBoost (https://xgboost.readthedocs.io/en/latest/python/python_api.html) 中存在的类似函数。

    【讨论】:

      猜你喜欢
      • 2019-06-24
      • 2019-07-30
      • 2018-03-09
      • 2018-07-01
      • 2018-11-30
      • 1970-01-01
      • 2020-06-28
      • 2021-10-10
      • 2018-01-27
      相关资源
      最近更新 更多