Install XGBoost on Mac

Master R

By Guangming Lang Comment

XGBoost is probably the most cutting-edge and optimized implementation of the gradient boosting algorithms. If you’re a R user, you probably used GBM in the past. XGBoost is generally over 10 times faster than GBM. Unfortunately, its official installation document for R users on a Mac OS isn’t clear. In this post, I’m going to walk you through how to install the multi-thread version of the XGBoost R package on a Mac OS X El Capitan. You want the multi-thread version because you want to have the option of using more than 1 core of your machine simultaneously to run the algorithms in parallel.

Step 1. Open up your terminal and run the following cmd.

  1. install gcc-6.x.x with openmp. This can take a while (~ 30 minutes).

brew install gcc --without-multilib

  1. clone the repository.

git clone --recursive

  1. build xgboost.

cd xgboost; cp make/ ./; make -j4

  1. make an empty Makevars file and open it.
mkdir ~/.R
touch ~/.R/Makevars
open -a TextEdit ~/.R/Makevars
  1. paste the following into the Makevars file
CC = gcc-6
CXX = g++-6
CXX1X = g++-6

  1. save and close the file.

Step 2. Open Rstudio and install the xgboost package.


Done! Now you can start with some tutorials.

If you enjoyed this post, get updates. It's FREE