필터 지우기
필터 지우기

Display probability/certainty of classification model

조회 수: 18 (최근 30일)
Jan
Jan 2023년 7월 12일
댓글: Jan 2023년 7월 12일
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.

답변 (1개)

Vishnu
Vishnu 2023년 7월 12일
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
Jan
Jan 2023년 7월 12일
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 2023년 7월 12일
[pre, ~, pst] = predict(model,Testdata, 'Posterior', true);

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Statistics and Machine Learning Toolbox에 대해 자세히 알아보기

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by