Search code examples
matlabsvmquadratic-programming

how to use QP=Quadratic Programming in svm


I am using svm for anomaly detection as follow

svmStruct = svmtrain(tr,label,'kernel_function','rbf','ShowPlot',true);
ok1 = svmclassify(svmStruct,test1,'ShowPlot',true);

default separating hyperplane method is SMO but I want to use QP i.e. Quadratic programming . how to use it in above code.


Solution

  • You can set the 'method' property of svmtrain to 'QP' explained in the documentation of svmtrain

    svmStruct = svmtrain(tr,label,'kernel_function','rbf','ShowPlot',true,'method','QP');
    

    Section of the documentation:

    'QP' — Quadratic programming (requires an Optimization Toolbox™ license). The classifier is a 2-norm soft-margin support vector machine. Give quadratic programming options with the options name-value pair, and create options with optimset.

    svmtrain will be removed in future Matlab releases so if your planning to use it in the future consider using fitcsvm.