lightgbm.Booster 中缺少方法
Missing method in lightgbm.Booster
似乎缺少 lightgbm.Booster
对象上的 trees_to_dataframe
方法。
https://lightgbm.readthedocs.io/en/latest/pythonapi/lightgbm.Booster.html#lightgbm.Booster.trees_to_dataframe.
以下代码在最后一行引发了一个 AttributeError
。
import numpy as np
import pandas as pd
import lightgbm as lgb
number_of_classes = 5
x = np.random.random((100, 100))
y = np.random.randint(low=0, high=number_of_classes, size=100)
data = lgb.Dataset(x, y)
parameters = {
'objective' : 'multiclass',
'num_class' : number_of_classes,
'metric' : ['multi_logloss', ],
}
bst = lgb.train(parameters, data)
assert type(bst) == lgb.Booster
bst.trees_to_dataframe()
他们最近更新了尚未发布到 public 的 2.3.2 版本的文档。
您有 2 个选择:等待下一个版本或从源代码构建。
git clone --recursive https://github.com/Microsoft/LightGBM
cd LightGBM && mkdir build && cd build
cmake ..
# cmake -DUSE_GPU=1 .. # build for GPU
make -j12
pip uninstall lightgbm
cd ../python-package/
python setup.py install
似乎缺少 lightgbm.Booster
对象上的 trees_to_dataframe
方法。
https://lightgbm.readthedocs.io/en/latest/pythonapi/lightgbm.Booster.html#lightgbm.Booster.trees_to_dataframe.
以下代码在最后一行引发了一个 AttributeError
。
import numpy as np
import pandas as pd
import lightgbm as lgb
number_of_classes = 5
x = np.random.random((100, 100))
y = np.random.randint(low=0, high=number_of_classes, size=100)
data = lgb.Dataset(x, y)
parameters = {
'objective' : 'multiclass',
'num_class' : number_of_classes,
'metric' : ['multi_logloss', ],
}
bst = lgb.train(parameters, data)
assert type(bst) == lgb.Booster
bst.trees_to_dataframe()
他们最近更新了尚未发布到 public 的 2.3.2 版本的文档。
您有 2 个选择:等待下一个版本或从源代码构建。
git clone --recursive https://github.com/Microsoft/LightGBM
cd LightGBM && mkdir build && cd build
cmake ..
# cmake -DUSE_GPU=1 .. # build for GPU
make -j12
pip uninstall lightgbm
cd ../python-package/
python setup.py install