Installing XGBoost on Windows

XGBoost is widely used in Kaggle competitions. For those who prefer to use Windows, installing xgboost could be a painstaking process. Therefore I wrote this note to save your time.

Building XGBoost

To be fair, there is nothing wrong about the official guide for installing XGBoost on Windows. But still, I’d love to stress several points here.

git clone --recursive https://github.com/dmlc/xgboost  
cd xgboost  
wget https://cdn.linghao.now.sh/assets/install-xgboost/Makefile.win
cp Makefile.win Makefile
cp make/mingw64.mk config.mk
mingw32-make  

Note that:

  1. Makefile.win is a modified version (thanks to Zhou Xiyou) of the original Makefile to suit the building process on Windows. You can wget it or download it here.
  2. Be sure to use a UNIX shell because Windows CMD has issue with mkdir -p command. Git Bash is recommended.
  3. Be sure to use --recursive option with git clone.
  4. Be sure to use a proper MinGW. TDM-GCC is recommended. Note that by default it wouldn’t install OpenMP for you. You need to specifiy it otherwise the building would fail.

TDM-GCC OpenMP

Installing Python Bindings

This should be straightforward enough.

cd python-package  
python setup.py install  

Done! Enjoy!

Buy me an Asahi beer :)