MATLAB Answers

Get Posterior Probability for multi-class Linear SVM function from Classification Learner

1 view (last 30 days)
QI YANG
QI YANG on 2 Mar 2021
Answered: Pratyush Roy on 5 Mar 2021
Hi Everyone,
I trained a multi-class model using Matlab Classification Learner App and turned it into a function. I got predicted class and fit score from the observations.
[fitClass, fitScore]= trained_model.predictFcn(observation);
I wish to get posterior probability score for each class rather than fit scores, which are always negative.
I found this documentation https://www.mathworks.com/help/stats/fitsvmposterior.html, but when I fit in my SVM model from the learner, the function fitSVMPosterior(SVMModel) gives me the error that
ScoreSVMModel = fitSVMPosterior(SVMModel)
Error: You must pass OBJ as an SVM model or a cross-validated SVM model.
My understanding is that fitSVMPosterior function belongs to another libary, which is not compatible with the model from he Learner App. I wonder if there is a method to get poserior probability for the model trianed from Classification learner App? Or should I use other methods that have posterior probability function to train my model Thank you for your hints!

Answers (1)

Pratyush Roy
Pratyush Roy on 5 Mar 2021
Hi,
The multi-class SVM in Classification Learner uses the fitecoc method to fit multiple binary SVMs to solve a multiple class classification problem.
After obtaining the classification model using the fitecoc method, one can use the predict function to obtain the posterior probabilities.
Hope this helps!

Community Treasure Hunt

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

Start Hunting!