The Neurophysiological Biomarker Toolbox (NBT)

How to run least-square support vector machine in Matlab

This tutorial describes how you can run a least-square support vector machine (LS-SVM) classification using the LS-SVM toolbox (

You can read more about support vector machines and least-square support vector machines on Wikipedia.

We here just show a simple way to run the LS-SVM - the LS-SVM toolbox has many more options.

You first need to create:

X - a Datamatrix with your data. The data vector (Subjects) along the rows (1st dimesion), and biomarkers (features) along the columns (2nd dimension).

Outcome - a vector with 1 or 0 for each data vector indicating whether that data vector belongs to either class 1 or class 2. (Class 1 could, e.g., be 'patient', and class 2 “healthy control”).

The LS-SVM is then calculated by typing:

[pp, alpha, b,gam,sig2,mode] = lssvm(X,Outcome); 

The important output parameter is here 'model', which can be used to classify another datamatrix using the fitted LS-SVM model. Let us assume we have another datamatrix named X2 (the columns of this matrix should obviously contain the same biomarkers as X above), we can then classify this data by typing

pp = simlssvm(model,X2); 

pp is a vector containing the predicted class for each data vector.

tutorial/how_to_run_least-square_support_vector_machine_in_matlab.txt · Last modified: 2013/06/06 17:03 by Simon-Shlomo Poil
The NBTwiki platform - version 2.8 - 9 May 2013
Copyright (C) 2008-2015