使用Spyder时同样的事情发生在我身上。 我能够使用终端(有折旧警告)将其导入即:

[email protected]:~$ python

Python 3.6.1 |Anaconda custom (64-bit)| (default, May 11 2017, 13:09:58)

[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux

Type "help", "copyright", "credits" or "license" for more information.

>>> from xgboost import XGBClassifier

/home/pinaki/anaconda3/lib/python3.6/site-packages/sklearn/cross_validation.py:44: DeprecationWarning: This module was deprecated in version 0.18 in favor of the model_selection module into which all the refactored classes and functions are moved. Also note that the interface of the new CV iterators are different from that of this module. This module will be removed in 0.20.

"This module will be removed in 0.20.", DeprecationWarning)

>>>

但试图运行使用的Spyder相同的代码得到了以下错误:

from xgboost import XGBClassifier

Traceback (most recent call last):

File "", line 1, in

from xgboost import XGBClassifier

File "/media/pinaki/MyStuff/Work/Machine Learning A-Z Template Folder/Part 10 - Model Selection & Boosting/Section 49 - XGBoost/XGBoost/xgboost.py", line 30, in

from xgboost import XGBClassifier

ImportError: cannot import name 'XGBClassifier'

和PIP安装xgboost返回以下输出:

Requirement already satisfied: xgboost in /home/pinaki/xgboost/python-package

Requirement already satisfied: numpy in /home/pinaki/anaconda3/lib/python3.6/site-packages (from xgboost)

Requirement already satisfied: scipy in /home/pinaki/anaconda3/lib/python3.6/site-packages (from xgboost)

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐