Reputation: 11
I have a question about the SVM MATLAB toolbox 2009b! the question is:
How I can train SVM classifier for classifying multi-classes datasets in MATLAB toolbox 2009b?
I just want to work with MATLAB toolbox, so please answer it if there is a way to implement it. For example, the below code is for classifying two classes datasets:
svmtrain( training data, ...
labels of training data, ...
'Kernel_Function', ...
'rbf', ...
'RBF_Sigma', ...
sigma value, ...
'Method', ...
'LS', ...
'BoxConstraint', ...
C ...
);
I want to know is there a way for training SVM for multi-classes dataset with writing a code such as above code, or should I write some code for training a SVM for each class versus the other classes?
It means, should I consider 1
for the label of the selected class and set the label of the other classes to 0
, and train a SVM with above code, and do it for all classes!?
Thanks for your consideration :-)
Upvotes: 1
Views: 4241
Reputation: 39389
If you have MATLAB release R2014b or later you can use the fitcecoc function in the Statistics and Machine Learning Toolbox to train a multi-class SVM.
Upvotes: 1
Reputation: 3935
Yup, the way for solving your problem - is to implement one vs all strategy. One of the SVM's lacks is that it has no direct multiclassification implementation. But you can implement it through the binary classification. I didn't see any function for svm multi classification in matlab. But i think it is not hard to implement it by yourself
Upvotes: 0
Reputation: 18091
I have not used SVM in Matlab, so other people can likely provide a more informed response, but I will share what I have learned.
From reading the documentation, the SVM in the Bioinformatics Toolbox appears to only support binary classification. As suggested in the question, a binary classifier can, with some effort, be used to classify into multiple classes. There is some discussion on approaches for doing this in the context of SVM here.
LIBSVM does support multi-class classification and comes with a Matlab interface. You could try installing and using it.
Additionally, while looking into this, I did come across several other Matlab toolboxes with SVM implementations. If LIBSVM is not a good option for you, it may be worth looking around to see if a different SVM implementation fits your needs.
Upvotes: 1