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.
Install
$ 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.
- Create instance by one learning logic.
- Run fit method: Set learned data (both input and output) for Learning to the instance.
- 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.
http://scikit-learn.org/stable/modules/generated/sklearn.svm.SVC.html#sklearn.svm.SVC
References
scikit-learn document including API is here.
Documentation scikit-learn: machine learning in Python — scikit-learn 0.16.1 documentation
matplotlib document is here.
Overview — Matplotlib 1.4.3 documentation