Getting the accurate percent of the predicted classes using predictFCN
13 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Lama Moualla
el 11 de Abr. de 2023
Comentada: Lama Moualla
el 12 de Abr. de 2023
Dear All
I am using MATLAB 2022 to train a dataset that has two classes 0 and 1.
First of all, I used the classificationLearner then I exported the model to get the predicted classes of the test set.
The predicted classes were either 0 or 1 using predictFCN.
Is there a way to get the percent of the predicted class instead of getting them as integers please?.
I mean for example: if possible to get a prediction of 0.01 for class 0 instead of just 0 and a prediction of 0.89 for the class 1.
Hope I could explain my inquiry.
Thanks in advance.
0 comentarios
Respuesta aceptada
Drew
el 11 de Abr. de 2023
Editada: Drew
el 11 de Abr. de 2023
Editing this answer based on the comments below:
Ok, so it sounds like, for each test observation, you want the score of each output class, and you want those output class scores to be in the form of a probability.
Two steps:
(1) To get the scores, see https://www.mathworks.com/help/stats/export-classification-model-for-use-with-new-data.html#bu4764j-1
[yfit,scores] = C.predictFcn(T)
(2) Whether those scores represent probabilities depends on the type of classifier you have trained, and some other settings. See https://www.mathworks.com/matlabcentral/answers/395526-how-do-i-obtain-scores-as-probabilistic-estimates-using-the-predict-function-on-a-fitcensemble-model for more info for ensembles. Or, refer to the doc pages for the classifier that you have trained.
The initial answer: This appears to not be what you were asking, but if you want to get measures of accuracy over the test set on a per-class basis, you can use the confusionchart command https://www.mathworks.com/help/stats/confusionchart.html. You can use use the "ColumnSummary", "RowSummary" and "Normalization" name-value arguments to confusionchart to get absoluate counts or percentages with your choice of normalization.
3 comentarios
Drew
el 11 de Abr. de 2023
Ok, so it sounds like, for each test observation, you want the score of each output class, and you want those output class scores to be in the form of a probability.
Two steps:
(1) To get the scores, see https://www.mathworks.com/help/stats/export-classification-model-for-use-with-new-data.html#bu4764j-1
[yfit,scores] = C.predictFcn(T)
(2) Whether those scores represent probabilities depends on the type of classifier you have trained, and some other settings. See https://www.mathworks.com/matlabcentral/answers/395526-how-do-i-obtain-scores-as-probabilistic-estimates-using-the-predict-function-on-a-fitcensemble-model for more info for ensembles. Or, refer to the doc pages for the classifier that you have trained.
Más respuestas (0)
Ver también
Categorías
Más información sobre Classification Learner App en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!