Win64+anaconda+xgboost (EXT)

Source: Internet
Author: User
Tags posix xgboost python xgboost

Installation of the Python version of Xgboost (Anaconda) Xgboost is a popular machine learning algorithm in recent years, proposed by the University of Washington Chen Tianchi, in many competitions at home and abroad to obtain a very good position, to specifically understand the model, you can go to GitHub,     This article describes the installation method of the Git-based Python version under the Widows system. Three software is required:
    • Python software (This article is based on Anaconda, because it comes with a lot of libraries, more convenient)
    • Git for Windows
    • MINGW
Assuming all have been installed Anaconda, it is recommended to install Python2 version, although Python3 can, but python2 more mainstream. Install git again, then open git Bash in the Start menu, create a new folder Xgboostcode to store the code and download the file, and then enter the following command in the Bash terminal you just opened to locate the directory.
$ cd/c/users/xgboostcode/

Note: There are spaces behind the CD.

Then download xgboost from GitHub using the following command.

$ git clone--recursive https://github.com/dmlc/xgboost  $ cd xgboost  $ git submodule init  $ git submodule Update

You also need to download the 64-bit compiler mingw-w64 to compile the downloaded code, which is already available. The installation interface is as follows:

Then select x86_64 Architecture, the other options are default.

Follow the instructions to complete the installation, My Computer installation path is C:\Program files\mingw-w64\x86_64-5.3.0-posix-seh-rt_v4-rev0. Then add the path of the C:\Program Files\mingw-w64\x86_64-5.3.0-posix-seh-rt_v4-rev0\mingw64\bin this folder to your computer's environment variables, the specific steps.
Close the GIT bash terminal, open it again, the path variable you just added takes effect, and enter the following command to check the effect:

$ which mingw32-make

If you get a result similar to the following, it means that the configuration was successful.

/c/program Files/mingw-w64/x86_64-5.3.0-posix-seh-rt_v4-rev0/mingw64/bin/mingw32-make

Then enter the following command:

$ alias make='mingw32-make'

Here you can install Xgboost, first navigate to the path to download it:

$ cd/c/users/xgboostcode/xgboost

The official installation instructions may not be successful and we need to compile the submodule one by one with the following command:

$ cd dmlc-core  -J4  $ cd . /rabit  $ make lib/librabit_empty.a-J4  $ cd  . $ CPmake/mingw64.mk config.mk  -j4  

You can install the Xgboost Python module in Anaconda after execution is complete. In the Start menu of your computer, open Anaconda Prompt, and enter the following command:

Then enter the installation command: Python setup.py install
The installation is complete, but before calling Xgboost, you should also import the g++ runtime path into the OS environment path variable, open the Ipython in Anaconda, or enter the following command in the Python command line, respectively:
Import OS   ' C:\\Program Files\\mingw-w64\\x86_64-5.3.0-posix-seh-rt_v4-rev0\\mingw64\\bin '   os.environ['PATH'; ' + os.environ['PATH']  

Create a new Python file below, import xgboost, and test the following code:

ImportNumPy as NPImportxgboost as XGB data= Np.random.rand (5,10)#5 entities, each contains featuresLabel = Np.random.randint (2, size=5)#binary TargetDtrain = XGB. Dmatrix (data, label=label) Dtest=dtrain param= {'bst:max_depth': 2,'Bst:eta': 1,'Silent': 1,'Objective':'binary:logistic'} param['Nthread'] = 4param['Eval_metric'] ='AUC'evallist= [(Dtest,'Eval'), (Dtrain,'Train')] Num_round= 10BST=xgb.train (param, Dtrain, Num_round, evallist) Bst.dump_model ('Dump.raw.txt')

Output:

[0]    eval-auc:0.5    train-auc:0.5[1]    eval-auc:0.5    train-auc:0.5[2]    eval-auc:0.5    train-auc:0.5[3]    eval-auc:0.5    train-auc:0.5[4]    eval-auc:0.5    train-auc:0.5[5]    eval-auc:0.5    train-auc:0.5[6]    eval-auc:0.5    train-auc:0.5[7]    eval-auc:0.5    train-auc:0.5[8]    eval-auc:0.5    train-auc:0.5[9]    eval-auc:0.5    train-auc:0.5

If it works, congratulations! Installation Successful ~

Transferred from: http://blog.csdn.net/leo_xu06/article/details/52300869

Win64+anaconda+xgboost (EXT)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.