如何在Python中安装xgboost包(Windows平台)?

http://xgboost.readthedocs.org/en/latest/python/python_intro.html

在xgboost的主页(上面的链接)上,它说:要安装XGBoost,请执行以下步骤:

  1. 您需要在项目的根目录下运行make

  2. 在python-package目录下运行

    python setup.py install

然而,当我执行时,在第一步出现了以下错误:make : 术语 ‘make’ 未被识别为 cmdlet、函数、脚本文件或可操作程序的名称。请检查名称的拼写,或者如果包含了路径,请验证路径是否正确,然后重试。

然后我跳过了第一步,直接执行了第二步,又出现了另一个错误:

Traceback (most recent call last):  File "setup.py", line 19, in <module>    LIB_PATH = libpath['find_lib_path']()  File "xgboost/libpath.py", line 44, in find_lib_path    'List of candidates:\n' + ('\n'.join(dll_path)))__builtin__.XGBoostLibraryNotFound: 在候选路径中找不到XGBoost库,您是否安装了编译器并在根路径下运行了build.sh?

有谁知道如何在Windows10平台上为Python安装xgboost?感谢您的帮助!


回答:

我在Windows 8 64位,Python 2.7和Visual Studio 2013上成功安装了XGBoost(不需要mingw64)

更新于2017年2月15日

对于较新版本的XGBoost,以下是我的步骤

步骤1. 安装cmake https://cmake.org/download/

验证cmake是否已成功安装

$ cmakeUsagecmake [options] <path-to-source>cmake [options] <path-to-existing-build>...

步骤2. 克隆xgboost源码

$ git clone https://github.com/dmlc/xgboost xgboost_dir

步骤3. 创建Visual Studio项目

$ cd xgboost_dir$ mkdir build$ cd build$ cmake .. -G"Visual Studio 12 2013 Win64"

步骤4. 构建Visual Studio 2013项目

  • 使用Visual Studio 2013打开文件xgboost_dir/build/ALL_BUILD.vcxproj
  • 在Visual Studio 2013中,打开BUILD > Configuration Manager...
    • 在活动解决方案配置中选择Release
    • 在活动解决方案平台中选择x64
  • 点击BUILD > 构建解决方案(Ctrl + Shift +B)

构建解决方案后,会在xgboost_dir/lib文件夹中创建两个新文件libxgboost.dllxgboost.exe

步骤5. 构建Python包

  • 将文件libxgboost.dll复制到xgboost_dir/python-package
  • 将目录更改为xgboost_dir/python-package文件夹
  • 运行命令python setup.py install

验证xgboost是否已成功安装

$ python -c "import xgboost"

旧答案

以下是我的步骤:

  1. git clone https://github.com/dmlc/xgboost
  2. git checkout 9bc3d16
  3. 使用Visual Studio 2013打开xgboost/windows中的项目
  4. 在Visual Studio 2013中,打开BUILD > Configuration Manager...,
    • 在活动解决方案配置中选择Release
    • 在活动解决方案平台中选择x64
  5. 重新构建xgboostxgboost_wrapper
  6. xgboost/windows/x64/Release文件夹中的所有文件复制到xgboost/wrapper
  7. 转到xgboost/python-package,运行命令python setup.py install
  8. 通过运行命令python -c "import xgboost"检查xgboost

Related Posts

使用LSTM在Python中预测未来值

这段代码可以预测指定股票的当前日期之前的值,但不能预测…

如何在gensim的word2vec模型中查找双词组的相似性

我有一个word2vec模型,假设我使用的是googl…

dask_xgboost.predict 可以工作但无法显示 – 数据必须是一维的

我试图使用 XGBoost 创建模型。 看起来我成功地…

ML Tuning – Cross Validation in Spark

我在https://spark.apache.org/…

如何在React JS中使用fetch从REST API获取预测

我正在开发一个应用程序,其中Flask REST AP…

如何分析ML.NET中多类分类预测得分数组?

我在ML.NET中创建了一个多类分类项目。该项目可以对…

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注