# How do I get the confusion matrix for all trained data

7 visualizzazioni (ultimi 30 giorni)
Mohamed Elbeialy il 2 Mag 2021
Risposto: Jon Cherrie il 3 Mag 2021
How do I get the confusion matrix for all trained data at one set instead of finding a confusion matrix for each set ( training, validation, test) seperatly?
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Risposte (2)

Jon Cherrie il 3 Mag 2021
You can use the confusionmat command
When you call it, make sure that you pass the data from all sets that you want to combine.
For example, if you're using patternnet to train a network,
[x,t] = iris_dataset;
net = patternnet(10);
net = train(net,x,t);
y = net(x);
% Decode the predictions from "one hot" to classes
species = ["Setosa" "Versicolour" "Virginica"];
t = onehotdecode(t,species,1,"categorical");
y = onehotdecode(y,species,1,"categorical");
% Compute the confusion matrix and display -- note that 't' and 'y' contain
% results from all three sets
cm = confusionmat(t,y)
confusionchart(cm)
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

Image Analyst il 2 Mag 2021
It should be pretty straightforward. Just determine the predicted class, and the actual class, where each class is identified by an integer. Then just increment the confusion matrix there
trueClass = 5; % Whatever
estimatedClass = 4; % For example
% Increment the count.
confusionMatrix(trueClass, estimatedClass) = confusionMatrix(trueClass, estimatedClass) + 1;
Note : you cannot determine a confusion matrix for test data since you don't know the true class - you only know the estimated class. You only know the true class for the training data and validation data, not the test data.
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Categorie

Scopri di più su Get Started with Statistics and Machine Learning Toolbox in Help Center e File Exchange

R2019a

### Community Treasure Hunt

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

Start Hunting!

Translated by