Python导入LightGBM错误

B_M*_*ner 5 python opencv

我已经按照Linux上的说明安装了lightGBM:

https://github.com/Microsoft/LightGBM/wiki/Installation-Guide#linux-2

我能够使用CLI成功运行GPU训练(和CPU):https : //github.com/Microsoft/LightGBM/blob/master/docs/GPU-Tutorial.md#run-your-first-learning-task -gpu

但是,当我尝试导入python包(python 3.6)时,出现以下错误:

OSError: /home/anaconda3/lib/python3.6/site-packages/lightgbm-0.2-py3.6.egg/lightgbm/lib_lightgbm.so: symbol clCreateCommandQueueWithProperties, version OPENCL_2.0 not defined in file libOpenCL.so.1 with link time reference
Run Code Online (Sandbox Code Playgroud)

我对理解链接和其他可能是问题的事物还很陌生。有人能够提供一些易于遵循的建议吗?

Nic*_*k M 0

要在 python 中使用 LGBM,您需要安装 CLI 的 python 包装器。也许是这样的然后您需要将此包装器指向 CLI。您可以查找 GBMClassifier/ Regressor,其中有一个名为 exec_path 的变量。您应该在这里设置绝对路径。

希望这会有所帮助,我将举一个这个包装器的例子 ,这是示例:`

import numpy as np
from sklearn import datasets, metrics, model_selection
from pylightgbm.models import GBMClassifier
exec = "~/Documents/apps/LightGBM/lightgbm"
X, Y = datasets.make_classification(n_samples=200, n_features=10)
x_train, x_test, y_train, y_test = model_selection.train_test_split(X, Y, test_size=0.2)
clf = GBMClassifier(exec_path=exec, min_data_in_leaf=1)
clf.fit(x_train, y_train, test_data=[(x_test, y_test)])
y_pred = clf.predict(x_test)
print("Accuracy: ", metrics.accuracy_score(y_test, y_pred))
Run Code Online (Sandbox Code Playgroud)

`