在浏览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标签
发布于 2020-12-02 21:55:04
pred_leaf参数设置为True的LightGBM predict的输出是包含int32值的形状(nsample、ntree)数组。
矩阵中的每个整数条目指示每个树中每个样本的预测叶索引。
由于每棵树的叶索引是唯一的,因此您可能会在许多不同的列中找到相同的叶编号。
至于它的行为,这个LightGBM预测函数模仿了XGBoost (https://xgboost.readthedocs.io/en/latest/python/python_api.html)中存在的类似函数。
https://stackoverflow.com/questions/60064997
复制相似问题