Building XGBoost for Python on Windows

Windows is so evil that consumes extra energy to make the things running.



The XGBoost library thunders at all machine learning competitions and helps to win prizes. However, becoming the owner of this package for Python on Windows is not so simple.

The installation process is poorly described on GitHub and slightly wider on the Kaggle forum . Therefore, I will try to describe step by step and in more detail. Hope this helps save a lot of time for inexperienced users.

Let's say you already have Python installed. In my case, this is an Anaconda build with Python 3.4.

1. Install the JDK from Oracle. Because for compilation we need the JNI library.

2. InstallVisual Studio 2013 using the link highlighted in the screenshot. Later versions ask to edit the solution code, so they are not suitable for ordinary people. The xgboost solution itself, published on GitHub, was built in Visual Studio 2010.



3. Download the entire XGBoost library from GitHub :



4. Unpack the archive, we get the folder C: \ xgboost-master .

5. Using Visual Studio, open the solution file C: \ xgboost-master \ windows \ xgboost.sln . We select Release and the platform option for which we will collect. Next Build -> Build Solution. The result should be “4 succeeded”:



Already at this stage you can collect problems.

“Could Not Detect CL.exe” - C # / Visual C ++ was not selected during installation. Install the components.

“Cannot open include file: 'corecrt.h'” - look for the file by searching, most likely it is here: ProgramFiles (x86) \ Windows Kits \ 10 \ Include \ 10.0.10150.0 \ ucrt and add the directory to $ IncludePath, or you’ll do it roughly and copy all * .h files somewhere to a prominent place, for example, in Program Files \ Microsoft Visual Studio 12.0 \ VC \ include .

“Cannot open include file: 'jni.h'” - there should be no error after installing the JDK.

However, everything can go smoothly and there will be no problems. I did it both ways, on different computers.

Further.

6. From the folder C: \ xgboost-master \ windows \ Release we need filesxgboost.exe and xgboost_wrapper.dll .
Copy them into the package folder for Python: C: \ xgboost-master \ python-package.

7. Open the console (cmd), change the directory: 8. There we run the installer: That's all. Run the Python environment that is convenient for you and write the traditional one:
cd "C:\xgboost-master\python-package"



python setup.py install




import xgboost as xgb

Also popular now: