confusion matrix for multinational regression analysis

3 views (last 30 days)
I am a new user of MATLAB and I don't know much about it. recently, I have started with mnrfit. But now I have a problem with the output data of multinomial regression analysis that I need to have the output to use for confusion matrix:
confusionchart(trueLabels,predictedLabels)
I want to show confusion matrix. for multinomial regression results but this regression gives data such as B, P and errors.
I don't underestand now what should I put as input and output variables for confusion matrix. I have read the relevant information but still I don't know what to do
Thx

Answers (1)

Aditya Patil
Aditya Patil on 13 Jul 2020
You can use mnrval to get the probabilities of each class. These probabilities can then be used to get class prediction, and those to get confusion matrix. Here's an example code.
% Load data
load fisheriris;
sp = nominal(species);
sp = double(sp); % We need labels for confusion matrix
% Fit and predict
[B,dev,stats] = mnrfit(meas,sp);
yhat = mnrval(B,meas,stats);
% convert probabilities to class output
[val, index] = max(yhat, [], 2);
confusionchart(sp, index)

Community Treasure Hunt

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

Start Hunting!