Why donate?

- Tutorials, follow the NBT course

**Follow us **

You are here: Frontpage : Introduction » Tutorials » How to run least-square support vector machine in Matlab

Table of Contents

This tutorial describes how you can run a least-square support vector machine (LS-SVM) classification using the LS-SVM toolbox (http://www.esat.kuleuven.be/sista/lssvmlab/)

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.