【问题标题】:xgboost properties are not working after being installed properly正确安装后 xgboost 属性不起作用
【发布时间】:2018-01-29 15:14:04
【问题描述】:

我尝试通过pip安装xgboost,但是由于egg文件的一些问题,出现了错误。然后我尝试了以下方法:

git clone --recursive https://github.com/dmlc/xgboost cd xgboost; make -j4

运行良好。现在 pip 说 xgboost 和 sklearn 已正确安装。但是,当我尝试从不同的 xgboost 示例(例如:https://machinelearningmastery.com/develop-first-xgboost-model-python-scikit-learn/ 或其他几个网页)重复一些基本代码时,我遇到了一些问题

  • 将 xgboost 导入为 xgb
  • 从 xgboost 导入 *
  • 将 sklearn 导入为 skl
  • 从 sklearn 导入 *
  • 从 sklearn.preprocessing 导入 LabelEncoder

工作正常(只是返回 DepreciationWarning),但有几个属性不起作用,例如:

booster = xgb.Booster()

回馈:

AttributeError: 模块 'xgboost' 没有属性 'Booster'

model = XGBClassifier()自带:

NameError:名称“XGBClassifier”未定义

有人知道我的错误是什么吗?

【问题讨论】:

  • 使用from module import * 通常是不好的做法。尝试不使用第二行和第四行,看看会发生什么。
  • 谢谢,我终于通过重新安装ubuntu和python包解决了这个问题。

标签: python xgboost


【解决方案1】:

您可能使用了错误的版本。版本 0.6.x 包含增强功能,但后者 (0.7.x) 不再包含它们。可以做以前的所有事情,但访问不同的功能......

【讨论】:

    猜你喜欢
    • 2017-04-24
    • 1970-01-01
    • 2016-05-01
    • 2017-04-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-29
    • 2018-05-15
    相关资源
    最近更新 更多