Python 模块';xgboost';没有属性';DMatrix';

Python 模块';xgboost';没有属性';DMatrix';,python,machine-learning,xgboost,Python,Machine Learning,Xgboost,我提取了一些在kaggle(linux)上运行的ML代码,并尝试在windows机器上的jupyter笔记本上运行它。以下是代码(部分代码): 收到以下错误: --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) <ipython-input-

我提取了一些在kaggle(linux)上运行的ML代码,并尝试在windows机器上的jupyter笔记本上运行它。以下是代码(部分代码):

收到以下错误:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-7-a63b74bc35c6> in <module>()
     17 #### These lines were causing the folloing error on 9/1/2017:
     18 # AttributeError: module 'xgboost' has no attribute 'DMatrix'
---> 19 dtrain = xgb.DMatrix(x_train.values, y_train.values)
     20 dtest = xgb.DMatrix(x_test)
     21 

AttributeError: module 'xgboost' has no attribute 'DMatrix'
---------------------------------------------------------------------------
AttributeError回溯(最近一次呼叫上次)
在()
17######这些行在2017年9月1日导致以下错误:
18#AttributeError:模块“xgboost”没有属性“DMatrix”
--->19 dtrain=xgb.DMatrix(x_列值,y_列值)
20数据测试=xgb.DMatrix(x_测试)
21
AttributeError:模块“xgboost”没有属性“DMatrix”

这很奇怪,因为我一直把xgboost模型从linux机器拉到windows。我在互联网上找不到任何关于如何修复的信息,所以我想知道是否有人知道如何修复

我们可能也有同样的问题

我明确地告诉Python在哪里可以找到xgboost库,从而解决了这个问题

原因是我有多个名为xgboost.py的脚本。Python可能错误地导入了其中之一,因此无法找到“DMatrix”的定义

以下是我使用的命令:

export PYTHONPATH=~/xgboost/python-package

您应该将“~/xgboost/python package”更改到/xgboost/python package/setup.py文件所在的文件夹中。

解决了这个问题。虽然代码在我看来完好无损,但我有一个问题-
xgb.Dmatrix()
在这里的作用是什么?
export PYTHONPATH=~/xgboost/python-package