Borrar filtros
Borrar filtros

How to create a confusion matrix?

1 visualización (últimos 30 días)
Emmy Bechtold
Emmy Bechtold el 30 de Sept. de 2020
Respondida: Pankhuri Kasliwal el 8 de Oct. de 2020
I am trying to use the example from mathworks, identifying significant features and classifying protein profiles, to create a confusion matrix. I am having difficulties identifying what the true values and predicted would be when looking at the PCA-LDA. Can someone help me identify them?
Link below:
https://www.mathworks.com/help/bioinfo/ug/identifying-significant-features-and-classifying-protein-profiles.html#d122e20387

Respuestas (1)

Pankhuri Kasliwal
Pankhuri Kasliwal el 8 de Oct. de 2020
Hi,
This can be done using the "plotconfusion" function. By default, this command will also plot the True Positive, False Negative, Positive Predictive, and False Discovery rates in they grey-colored boxes. Please refer to the following example:
targetsVector = [1 2 1 1 3 2]; % True classes
outputsVector = [1 3 1 2 3 1]; % Predicted classes
% Convert this data to a [numClasses x 6] matrix
targets = zeros(3,6);
outputs = zeros(3,6);
targetsIdx = sub2ind(size(targets), targetsVector, 1:6);
outputsIdx = sub2ind(size(outputs), outputsVector, 1:6);
targets(targetsIdx) = 1;
outputs(outputsIdx) = 1;
% Plot the confusion matrix for a 3-class problem
plotconfusion(targets,outputs)
The class labels can be customized by setting that 'XTickLabel' and 'YTickLabel' properties of the axis:
h = gca;
h.XTickLabel = {'Class A','Class B','Class C',''};
​​h.YTickLabel = {'Class A','Class B','Class C',''};
h.YTickLabelRotation = 90;
To know more about true values and predicted values, refer to the following links -

Categorías

Más información sobre Dimensionality Reduction and Feature Extraction en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by