How to install Xgboost on Mac OSX

Source: Internet
Author: User
Tags abs git clone xgboost

I heard that xgboost effect is very good, so prepare to learn, but found that most of the information is about how to install Xgboost under Windows or Linux, and according to official documents are not properly installed multi-threaded xgboost. Finally, the method was found from there.

1. Mac OSX system usually comes with Python, open the terminal input python can write Python code, so the Python environment already has.

2. Installing Homebrew , similar to the Apt-get in Ubuntu and the Yum in CentOS, is a very useful software installation tool in OSX.

/usr/bin/ruby-e "$ (curl-fssl https://raw.githubusercontent.com/Homebrew/install/master/install)"

Paste the above code directly into the terminal to install. (The purpose of installing this software is to update the GCC version, as the official documentation says only the latest GCC version will enable xgboost to support multithreading)

3. Install the latest version of GCC (gcc-6)

Brew Install GCC--without-multilib   

This step is time consuming and takes nearly 1 hours.

4. Download the source code from git

CD into the directory you want to install, and enter the following code. (I am directly in the directory to open the terminal)

git clone--recursive https://

5. The most critical step is to compile the Xgboost source code. (why not just post a compiled one, because there is too much difference for each computer)

This step is not a clear step in the official documentation, the official documents in the 4th step after the start of compiling the source code, but in fact, the GCC is only downloaded, the system did not use just download the latest GCC. Then

  cd/usr/bin  rm cc GCC c+ +  g++ -s/usr/local/bin/gcc-6  cc-s/usr/local/bin/ gcc-6 gcc  -s/usr/local/bin/c++-6 c  + +-s/usr/local/bin/g++-6 g++

The above code is to the effect of using the latest gcc-6 instead of the previous GCC

Then there's the normal compilation.

CD before installing the Xgboost directory/xgboostcpmake/-j4

If you do not always warn that GCC does not support multi-threading, this step is completed successfully.

6. No accident, the last step of the compilation process will be an error: Std::abs (XXX) is wrong.

This error is caused because the compiler has changed.

So just change Std::abs (XXX) to

Xxx>=0?xxx:-xxx

That is to say a question mark to solve the problem. Fortunately, only two errors, are the same. So just change these two codes on the line.

Then compile, succeed!

7. Verify that the installation is successful.

In Python, enter

import Xgboost as XGB

and press ENTER, if there is no error, then it is possible to correctly import the Xgboost package in the Python program! Such as:

How to install Xgboost on Mac OSX

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.