【发布时间】:2017-02-21 15:19:42
【问题描述】:
我正在尝试使用 spyder 和 python 运行 xgboost,但我不断收到此错误:
AttributeError:模块“xgboost”没有属性“XGBRegressor”
代码如下:
import xgboost as xgb
xgb.XGBRegressor(max_depth=3, learning_rate=0.1, n_estimators=100, silent=True,
objective='reg:linear', gamma=0, min_child_weight=1,
max_delta_step=0, subsample=1, colsample_bytree=1,
seed=0, missing=None)
错误是
Traceback (most recent call last):
File "<ipython-input-33-d257a9a2a5d8>", line 1, in <module>
xgb.XGBRegressor(max_depth=3, learning_rate=0.1, n_estimators=100, silent=True,
AttributeError: module 'xgboost' has no attribute 'XGBRegressor'
我有 Python 3.5.2 :: Anaconda 4.2.0 (x86_64)
我该如何解决这个问题?
【问题讨论】:
-
如果你把
print(dir(xgb))放在你的import语句之后,你会得到什么? -
print(dir(xgb)) ['doc', 'loader', 'name', ' 包'、'路径'、'规范']
标签: python machine-learning regression spyder xgboost