Want to use SVM to classify inputs into groups

2 views (last 30 days)
Ray
Ray on 17 Aug 2015
Answered: Ilya on 17 Aug 2015
I have a 4 sets of data which i wish to classify into 4 groups. each group have 100 sets of data.
This can be done easily using nprtool, where i load the input, assign the target, and it train and give me the classification accuracy. i can then give new data to test and see the classification accuracy
But i'm having trouble doing it with svm. i've read numerous concept of svm, about the hyperplane, kernel function etc. but when comes to the actual implementation, not much information or working example on it. matlab built in help file only shows example for binary classification using
SVMstruct=svmtrain(input,target,'kernel function','rbf');
newClasses=svmclassify(SVMstruct,test_input)
There are many .m file available online, but they are never as simple as: assign input, assign target, train, insert test input, receive classification output
After looking around, i found a toolbox from http://cmp.felk.cvut.cz/cmp/software/stprtool/ it's a toolbox for matlab with svm inside. it has a GUI demo, but after loading data, it will have this error when training.
Undefined function 'smo_mex' for input arguments of type 'double'.
Error in smo (line 90)
[model.Alpha, model.b, model.nsv, model.kercnt, model.trnerr,
model.margin]...
Error in demo_svm>svm_train (line 635)
model = smo( trn, options);
Error in demo_svm (line 358)
[Alpha,bias] = svm_train( data, trn, ker, arg, C );
Error while evaluating uicontrol Callback
From that website, it has a user manual with some example, even when i tried their examples, the same error occur, seems like the function SMO has some error and can't accept double.
Is there a way to make it work? Or is there a working .m file or toolbox that does the classification correctly without error? Please help.

Answers (1)

Ilya
Ilya on 17 Aug 2015
If you have 14b or later, use the fitcecoc function from the Statistics and Machine Learning Toolbox.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!