Install LibSVM in Matlab, GNU Octave and Python

Matlab and Octave are popular for machine learning prototypes due to their easier to learn (vs. R) interface. Python via scikit-learn is also a top choice for machine learning. Here’s how to install LibSVM for Matlab and GNU Octave.

Prereqs:

apt install make git g++

Compile LibSVM

git clone https://github.com/cjlin1/libsvm

cd libsvm

make

Creates executables svm-train svm-predict svm-scale. Compile the Matlab/Octave and Python modules, for which the API is similar.

Compile LibSVM Matlab/Octave module

cd libsvm/matlab

Open Matlab or Octave, and from that internal Terminal, type (this uses make.m)

make

which creates a few .mex files. See the matlab/README for examples of using LibSVM from Matlab and Octave.

Compile LibSVM Python module

cd libsvm/python

make

See the python/README for examples of using LibSVM from Python.