加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

Python导入LightGBM时出错

发布时间:2020-12-20 13:17:48 所属栏目:Python 来源:网络整理
导读:我在 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-learnin
我在 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-on-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

我很了解链接和其他可能存在问题的事情.有人能提供一些易于遵循的建议吗?

解决方法

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

希望这有帮助,
我将以this wrapper为例
这是一个例子:
`

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,test_data=[(x_test,y_test)])
y_pred = clf.predict(x_test)
print("Accuracy: ",metrics.accuracy_score(y_test,y_pred))

`

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读