Libsvm for python
Happy new year!! Feel blue but still have to work.
I am gonna introduce the application of a famous package namely libsvm, which realizes the support vector machin (SVM) based algorithms and supports multiple programming languages. I have designed SVM based approaches for machine-learning tasks on MATLAB by the libsvm, which is very awsome. Now, it’s time to try it on python, though it has been encapsulated in the SciPy.
To use libsvm on python, you may follow the coming steps.
Download the package
1$ wget -O libsvm.tar.gz http://www.csie.ntu.edu.tw/~cjlin/cgi-bin/libsvm.cgi?+http://www.csie.ntu.edu.tw/~cjlin/libsvm+tar.gzunzip the package
1$ tar -xvf libsvm.tar.gzInstallization
12$ cd libsvm-3.22$ make
If it generates four svm-
prefixed files as well as the library libsvm.so.2
, then the installization is completed.
Now you can take a trial with provided python based utilities in the folder ./python
. For instance,
Note
As introduced by the README
in the ./python
folder, two .py
scripts are provided, of which svm.py
and svmutil.py
are corresponding to low-level and high-level use of the interface. In my opinion, I suggest the users to directly use svmutil.py
.
In addition, the python scripts rely on the libsvm.so.2
, which should be added into the LD_LIBRARY_PATH
or a package not find
exception will be raised when import svm.
Now, time to do your machine learning work.