主要分爲四個步驟:
1.首先下載安裝mingw64
2.安裝Anaconda及git
3.下載xgboost,我參考的是 https://blog.csdn.net/leo_xu06/article/details/52300869
4.安裝xgboost
具體如下:
1.首先下載安裝mingw64
(1)下載地址爲http://mingw-w64.org/doku.php/download
往下拉看到:
點擊進去,進入頁面如下:https://sourceforge.net/projects/mingw-w64/files/mingw-w64/mingw-w64-release/
點擊最上面的綠色下載,https://sourceforge.net/projects/mingw-w64/files/latest/download?source=files
開始安裝
注意藍色標記部分
恭喜安裝成功!
(2)將mingw32-make.exe的路徑加到 用戶path:C:\Program Files\mingw-w64\x86_64-7.2.0-posix-seh-rt_v5-rev1\mingw64\bin
像我這種小白,不熟悉的安裝都會默認C盤,哈哈
不會加路徑變量?我要嘲笑你啦!
(3)然後,打開cmd,輸入mingw32-make,如果輸出如下,說明成功了
2.安裝python ,git
強烈推薦Anaconda,https://www.anaconda.com/
你百度一下就知道它的好了
git的安裝:在Anaconda Prompt中輸入
conda install git
3.下載xgboost
在開始菜單裏打開Git Bash,首先在c/Users新建一個文件夾xgboostCode用於存放代碼和下載文件,然後在剛剛打開的Bash終端中輸入下面命令,定位目錄
$ cd /c/Users/xgboostCode/
然後用下面的命令從GitHub下載XGBoost。(我自己單獨下載過,但是不知道怎麼安裝,捂臉~)
$ git clone --recursive https://github.com/dmlc/xgboost
$ cd xgboost
$ git submodule init
$ git submodule update
64位的編譯器MinGW-W64來編譯下載的代碼,上面已經提供下載地址
4.安裝xgboost
(1)利用windows的程序搜索打開“git bash”,長得和cmd差不多,但是要用到一個cmd中不支持的命令。打開之後輸入:
$ cd /c/Users/xgboostCode/xgboost #定位到文件夾
$ cd dmlc-core
$ make -j4
$ cd ../rabit
$ make lib/librabit_empty.a -j4
$ cd ..
$ cp make/mingw64.mk config.mk
$ make -j4
#編譯完成
(2)執行完成之後就可以在Anaconda中安裝XGBoost的python模塊了。在電腦的開始菜單中打開Anaconda Prompt,輸入下面命令:
cd xgboostCode\xgboost\python-package
(3)然後輸入安裝命令:
python setup.py install
在python中輸入import xgboost如果沒有提示錯誤,恭喜啦