Probabilities from using predict function for fitcsvm

19 views (last 30 days)
When I fit a model with fitcsvm, and use predict for new data, I get a score for the predictions as one of the outputs.
The function has two columns, one for both classes of this binary classification.
The probabilities make no sense to me. For example, the 5th "score," or probabiliy, is +0.2431. Doesn't this mean the probability that it is NOT in the positive class is 1-.2431 = .7569 ? Why, if its only .2431, does it predict +1 as the class?
If I add the transformation Score=(1+Score)/2, would I then get a probability distribution for the probability that a label is +1, with probability between 0 and 1?
Thank you

Answers (2)

Peter Krammer
Peter Krammer on 28 Aug 2020
  • Your Score, (shown in column 3) is not representing the probablity. Probability is usually represents from 0 to 1 (Or 0 to 100 %). However your Score attribute contains negative numbers.
  • 5-th row of your table, with score 0.2431 is classified as class +1, because distance of |1 - 0.2431| = 0.7569; is smaller than distance of class -1, which distance is |-1 - 0.2431| = 1.2431; (smaller distance indicates higher similarity)
  • Your calculation NewScore=(1+Score)/2; looks very logical, and this NewScore could be a solid approximation of probability. However, from mathematical aspect, it is not exact probability. So , it could be used in some practical applications, but it is necessary to be careful.

Vishal Bhutani
Vishal Bhutani on 9 Jan 2019
From the documentation of "predict" function:
"[label,score] = predict(SVMModel,X) returns a matrix of scores (score) indicating the likelihood that a label comes from a particular class. For SVM, likelihood measures are either classification scores or class posterior probabilities. For each observation in X, the predicted class label corresponds to the maximum score among all classes."
For details regarding "classification scores" and "posterior probabilities" you can refer to section: More About->Classification score.
Hope it helps.



Community Treasure Hunt

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

Start Hunting!