Installing XGBoost For Anaconda on Windows
JeanFrancoisPuget 2700028FGP Visits (176328)
Update on June, 12, 2017. Guido Tapia builds xgboost executables for WIndows every night: http
XGBoost is a recent implementation of Boosted Trees. It is a machine learning algorithm that yields great results on recent Kagg
In order to install and use XGBoost with Python you need three software on your windows machine:
I assume you have Anaconda up and running. I am using Anaconda for Python 3.5.
Git installation is quite easy. There are several options, one is to use Git for Windows. Just download and save the installer file on your disk, then launch it by double clicking it. You may need to authorize this operation. Then follow the installer instructions.
Once the installation has completed look for a program called Git Bash in your start menu. Launch it. It starts a terminal running the Bash shell. This is different from the regular Windows terminal, but it is more handy for what we need to do. First, go to the directory where you want to save XGBoost code by typing the cd command in the bash terminal. I used the following.
Then download XGBoost by typing the following commands.
$ git clone --recursive http
Next step is to build XGBoost on your machine, i.e. compile the code we just downloaded. For this we need a full fledged 64 bits compiler provided with MinGW-W64. I downloaded the installer from this link. Save the file on your disk, then launch it by double clicking it. You may need to authorize this operation. Then click next on the first screen:
Then select the x86_64 item in the architecture menu. Do not modify the other settings.
Then click Next and follow the instructions. On my machine, it installed the compiler in the C:\Program File
Use these instructions, depending on your Windows version, to add the above to the Path system variable.
Then close the Git Bash terminal, and launch it again. This will take into account the new Path variable. To check you are fine, type the following
It should return something like:
To make our life easier, let us alias it as follows:
We can now build XGBoost. We first go back to the directory where we downloaded it:
The command given in the instructions does not work as I write this blog entry. Until this is fixed, we need to compile each sub module explicitly with the following commands. Wait until each make command is completed before typing the next command.
Once the last command completes the build is done.
We can now install the Python module. What follows depends on the Python distribution you are using. For Anaconda, I will simply use the Anaconda prompt, and type the following in it (after the prompt, in my case [Anaconda3] C:\U
The point is to move to the python-package directory of XGBoost. Then type:
We are almost done. Let's launch a notebook to test XGBoost. Importing it directly causes an error. In order to avoid it we must add the path to the g++ runtime libraries to the os environment path variable with:
import os mingw_path = 'C:\\Program File
We can then import xgboost and run a small example.
import xgboost as xgb import numpy as np data = n
We are all set!
Update on April, 15, 2016. The OSX installation is a bit more complex that I wrote here if we want to be able to use XGBoost in a multi-threaded mode. I provide instructions for it in Inst