Another Japan in the World

Jun Aruga's blog, who lived in Japan, Singapore, live in Czech Republic. Mainly about IT and travel.

Install Python library for machine learning: Scikit-learn on Mac

I installed Python library for machine learning: Scikit-learn to my Mac PC.
Python is popular language for statistics.
So, there is helpful library to implement machine learning logic.

I am using python version2 because version3 is still not supported for several programs.


$ python --version
Python 2.7.10
$ pip install -U numpy scipy scikit-learn

$ pip list | grep -E '(numpy|scipy|learn)'
numpy (1.9.2)
scikit-learn (0.16.1)
scipy (0.16.0)

I installed Python graphics library: matplotlib too to run scikit-learn sample code.

$ pip2 install matplotlib

$ pip list | grep matplotlib
matplotlib (1.4.3)

How to use

After checking sample code and API for Support Vector Classification, and Decision Tree, I found there are 3 processes in general.

  1. Create instance by one learning logic.
  2. Run fit method: Set learned data (both input and output) for Learning to the instance.
  3. Run predict method: Predict the output value from one given input data.

For example I will introduce API document URL for Support Vector Classification.
You can see SVC method to create the instance. and fit and predict methods from the page.

Remove all ads