What do the "scores" mean that result from application of a model from the Classification Learner App to new data?

9 views (last 30 days)
What do the "scores" mean that result from application of a model from the Classification Learner App to new data? They really don't seem to make any sense. The class selected doesn't equate to the highest or lowest score in the resulting scores matrix so I am wondering what they mean in some substantive sense?

Answers (1)

Drew
Drew on 2 Oct 2023
I'll assume you are following the workflow here: https://www.mathworks.com/help/stats/export-classification-model-for-use-with-new-data.html and running something like
[yfit,scores] = C.predictFcn(T)
The precise meaning of the scores depends on the type of classifier that you have trained. For most classifier types, the predicted class will correspond to the class with the highest score. However, the KNN, Naive Bayes, and Discrimant classifiers can be different when non-default misclassification costs are provided. For example, for a KNN classifier, the scores correspond to posterior probabilities which do not yet take misclassification costs into account. For a KNN classifier, the class with the minimum expected cost (rather than the maximum posterior probability score) will correspond to the predicted class. See https://www.mathworks.com/help/stats/classificationknn.predict.html , which indicates that the KNN predict function provides a third output which constains the expected cost after taking into account the misclassification costs:
% Example of predict function for KNN, with third output, the expected cost
[label,score,cost] = predict(mdl,X)
So, in the case of a KNN classifier, you will want to add a third output to your predict function in order to look at the expected costs.
If this doesn't answer your question, perhaps you can provide more details such as the classifier type that you trained and an example result.
If this answer helps you, please remember to accept the answer.
  4 Comments
William
William on 4 Oct 2023
That works if the titles of classes are rearranged for the scores into a more-or-less alphabetic order rather than the order in which they were input. I.e., for this example, if they're arranged: Above MB, Below MB, Foreign Stones, Hematitic, MB Tailings, Marker Band, Meteorites, Veins Bright . Is that what is expected? For the results to come out in a rearranged order?
Drew
Drew on 6 Oct 2023
The order of the output scores is indicated in the ClassNames property of the model.
For example, for a CubicSVM trained on fisheriris in Classification Learner, then exported as "trainedModel", here is the ClassNames property:
>> trainedModel.ClassificationSVM.ClassNames
ans =
3×1 cell array
{'setosa' }
{'versicolor'}
{'virginica' }

Sign in to comment.

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!