How can I plot a confusion matrix for a multi-class or non-binary classification problem?
Mostra commenti meno recenti
I want to make a plot similar to the confusion matrix created in the Classification Learner app. This can make a confusion matrix for a multi-class or non-binary classification problem. In addition, it can plot things such as a True Positive or False Negative rates.
How can I do this?
Risposta accettata
Più risposte (1)
David Franco
il 23 Gen 2018
Modificato: MathWorks Support Team
il 16 Mar 2018
Implementation code:
Confusion Matrix
function [] = confusion_matrix(T,Y)
M = size(unique(T),2);
N = size(T,2);
targets = zeros(M,N);
outputs = zeros(M,N);
targetsIdx = sub2ind(size(targets), T, 1:N);
outputsIdx = sub2ind(size(outputs), Y, 1:N);
targets(targetsIdx) = 1;
outputs(outputsIdx) = 1;
% Plot the confusion matrix
plotconfusion(targets,outputs)
Categorie
Scopri di più su Classification Ensembles in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!