Skip to content
Advertisement

Keras Confusion Matrix does not look right

I am running a Keras model on the Breast Cancer dataset. I got around 96% accuracy with it, but the confusion matrix is completely off. Here are the graphs:

enter image description here

enter image description here

And here is my confusion matrix:

enter image description here

The matrix is saying that I have no true negatives and they’re actually false negatives, when I believe that it’s the reverse. Another thing that I noticed is that when the amount of true values are added up and divided by the length of the testing set, the result does not reflect the score that is calculated from the model. Here is the whole code:

JavaScript

Am I doing something wrong here? Am I missing something?

Advertisement

Answer

Check the confusion matrix values from the sklearn.metrics.confusion_matrix official documentation. The values are so organized:

  • TN: upper left corner
  • FP: upper right corner
  • FN: lower left corner
  • TP: lower right corner

You’re getting 53 true negatives and 90 false negatives from the current confusion matrix.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement