Confusion Matrix Results Issue

1 vue (au cours des 30 derniers jours)
Mr X
Mr X le 27 Déc 2014
Commenté : Shoaibur Rahman le 28 Déc 2014
I need to determine the misclassified rate of a machine learning algorithm. However, when I use the confusion function over the actual dataset and the predicted dataset (using the algorithm) the error rate is 0 whereas when I iterate through each element and compare them the error rate is 33.3%. What is wrong with the confusion matrix?
outputs = [1, 1, 1, 100, 10, 100];
predictedOutput = [1, 1, 1, 10,100, 100];
[c,cm] = confusion(outputs,predictedOutput);
fprintf('Percentage Correct Classification : %f%%\n', 100*(1-c));
counter =0;
for i = 1: size (predictedOutput,2)
if (predictedOutput(1,i) ~= outputs(1,i))
counter = counter + 1;
end
end
fprintf('Percentage Correct Classification : %f%%\n', 100*(1-(counter/(size(predictedOutput,2)))));

Réponse acceptée

Shoaibur Rahman
Shoaibur Rahman le 27 Déc 2014
The input arguments of confusion, (in this case, outputs and predictedOutput) should be in range of [0 1]. So, instead of 100 and 10, use 1 and 0, for example.
outputs = [1, 1, 1, 1, 0, 1];
predictedOutput = [1, 1, 1, 0, 1, 1];
[c,cm] = confusion(outputs,predictedOutput);
fprintf('Percentage Correct Classification : %f%%\n', 100*(1-c));
counter =0;
for i = 1: size (predictedOutput,2)
if (predictedOutput(1,i) ~= outputs(1,i))
counter = counter + 1;
end
end
fprintf('Percentage Correct Classification : %f%%\n', 100*(1-(counter/(size(predictedOutput,2)))));
  2 commentaires
Mr X
Mr X le 27 Déc 2014
I to classify the dataset into 3 different classes so I cannot use 1 and 0 only. Does this mean that I need to create three rows to represent each class and then select it by setting the element to 1?
Shoaibur Rahman
Shoaibur Rahman le 28 Déc 2014
That could be one way, given it serves your purpose. Another way is to analyze the confusion matrix (user your original outputs,predictedOutput).
cmat = confusionmat(outputs,predictedOutput);
This will allow you to determine the misclassification for each group separately.

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by