如何在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

L1-L2正则化的不同系数

我想对网络的权重同时应用L1和L2正则化。然而,我找不…

使用scikit-learn的无监督方法将列表分类成不同组别,有没有办法?

我有一系列实例,每个实例都有一份列表,代表它所遵循的不…

f1_score metric in lightgbm

我想使用自定义指标f1_score来训练一个lgb模型…

通过相关系数矩阵进行特征选择

我在测试不同的算法时,如逻辑回归、高斯朴素贝叶斯、随机…

可以将机器学习库用于流式输入和输出吗?

已关闭。此问题需要更加聚焦。目前不接受回答。 想要改进…

在TensorFlow中,queue.dequeue_up_to()方法的用途是什么?

我对这个方法感到非常困惑,特别是当我发现这个令人费解的…

发表回复

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