Borrar filtros
Borrar filtros

Display probability/certainty of classification model

18 visualizaciones (últimos 30 días)
Jan
Jan el 12 de Jul. de 2023
Comentada: Jan el 12 de Jul. de 2023
Hello there,
I have trained a classification model with the function fitcdiscr() and fitcnet() and would like to get an output of the certainty (in %) of every prediction made by my model. So basically how convinced my model is that the given datapoint can be classified in the predicted class.
Thanks in advance for your help.

Respuestas (1)

Vishnu
Vishnu el 12 de Jul. de 2023
Hi Jan,
To obtain the certainty or confidence level of predictions made by a classification model trained using the fitcdiscr() or fitcnet() functions, you can use the predict() function with the 'Posterior' option.
Below code is an example of how you can use the predict() function to obtain the certainty of predictions:
% Train your classification model using fitcdiscr() or fitcnet()
model = fitcdiscr(X, Y);
% Make predictions on new data
X_new = [prediction, ~, posterior] = predict(model, X_new, 'Posterior', true);
% Get the certainty (in %) for each prediction
certainty = max(posterior, [], 2) * 100;
% Display the certainty for each prediction
disp(certainty);
X represents the training data features, Y represents the corresponding class labels, and X_new represents the new data on which you want to make predictions.
The predict() function returns the predicted class labels in the prediction variable and the posterior probabilities of each class in the posterior variable.
  2 comentarios
Jan
Jan el 12 de Jul. de 2023
Hi Vishnu,
thanks for the quick response! When I try to implement your suggestion I simply recieve the Error:
"using classreg.learning.classif/CompactClassificationDiscriminant/predict
Too many input arguments."
How can I solve this issue?
Regards Jan
Jan
Jan el 12 de Jul. de 2023
[pre, ~, pst] = predict(model,Testdata, 'Posterior', true);

Iniciar sesión para comentar.

Categorías

Más información sobre Statistics and Machine Learning Toolbox en Help Center y File Exchange.

Productos


Versión

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by