accuracy calculation in machine learning
19 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
The accuracy formula is (TP+TN)/(TP+TN+FP+FN). I can't understand why in all the implementation the accuracy is calculated in one of the following way:
accuracy_tmp = sum(test_labels == predicted_labels, 'all')/numel(predicted_labels);
or in the following way:
accuracy_tmp = sum(diag(confMat)) / sum(confMat, 'all'); %confMat is the confusion matrix
In my opinion, the calculation made in that way doesn't consider the TN value. Seems that only the TP are considered.
Could someone help me to understand?
0 comentarios
Respuestas (1)
the cyclist
el 23 de Abr. de 2023
I'm not sure where your misunderstanding is, but let's take a look at the second formula you wrote for accuracy_tmp:
accuracy_tmp = sum(diag(confMat)) / sum(confMat, 'all'); %confMat is the confusion matrix
The numerator of that fraction is the sum of the diagonal elements of the confusion matrix. The diagonal elements of the confusion matrix are the true positive and the true negative counts. So, the numerator is TP + TN.
The denominator is the sum of all the elements of the confusion matrix, which contains counts for all cases: TP + TN + FP + FN.
All seems right with the world.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!