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.

  1. prereqs:

    apt install make git g++ 
  2. Compile LibSVM

    git clone
    cd libsvm 

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

  3. Compile LibSVM Matlab/Octave module

    cd libsvm/matlab

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


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

  4. Compile LibSVM Python module

    cd libsvm/python

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