Tuesday, 16 October 2018

SVM Classification code in Matlab


 Hi All,

See a simple SVM training and testing module

// Here a student performance prediction is done

//Three inputs are marks for series1, series2 and attendance percentage

//1 indicates pass and 0 indicates fail
//Testing with [25 30 and 35

//result will be stored in classes

train1=[75 81 82 ; 30 21 40];  // Training Data

test1=[25 30 35]; // Testing Data

G=[1 0];   // Label for Training data

G=G'; // Converting to column vector

svmStruct = svmtrain(train1,G,'Kernel_Function','rbf','Method','QP');  // Create an SVM model with training data

classes = svmclassify(svmStruct,test1);  // Classification using Test data

classes  // Display output label

No comments:

Post a Comment