【发布时间】:2017-10-04 14:16:59
【问题描述】:
我尝试了所有可能的解决方案,但仍然出现此错误,已经安装了所有依赖库。
import numpy as np
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import LabelEncoder
from tqdm import tqdm
import xgboost as xgb
d_train = xgb.DMatrix(X_train, label=y_train)
AttributeError: 'module' object has no attribute 'DMatrix'
【问题讨论】:
-
xgboost未正确导入。如果您在同一目录中有 xgboost.py 文件,请尝试重命名它。 -
已经尝试过但仍然出现错误。
-
您是否尝试使用
pip卸载并重新安装xgboost?还有你的xgboost是什么版本的? -
我在重新安装 xgboost 时解决了这个问题,谢谢
-
我遇到了同样的问题。我也可以通过简单地重新安装 xgboost 来解决这个问题。
标签: python python-2.7 machine-learning xgboost