0
$\begingroup$

I am trying to understand the code here.

The output [12] shows that the model accuracy is above 90% even for the validation set, but the confusion matrix in [16] ca not even achieve 50% accuracy, and it is also on the validation set, so I do not understand this low accuracy on the confusion matrix. I think it may be due to data augmentation, but I would be thankful if someone could explain it to me and tell me how I could then have a confusion matrix in adequacy with the learning curves. Thanks in advance.

$\endgroup$
6
  • 1
    $\begingroup$ The 90%+ accuracy is an evaluation based on Keras' model.evaluate_generator method and NOT on validation set, where accuracy is that as shown in confusion matrix $\endgroup$
    – Nikos M.
    May 28, 2021 at 16:56
  • $\begingroup$ @NikosM. Thank you for your answer, but how to interpret this ? If we rely on the curves, the model seems good, but if we rely on the confusion matrix the model is bad. How should I interpret these results ? $\endgroup$
    – Waitbng
    May 28, 2021 at 17:35
  • $\begingroup$ The confusion matrix (and other metrics like precision/recall/etc..) is what counts and all those agree that the model is average $\endgroup$
    – Nikos M.
    May 28, 2021 at 17:37
  • $\begingroup$ But if we rely on the confusion matrix, we don't even have 50% of accuracy, so classifying randomly would be better. I don't really understand how this model could be so bad after fine-tuning. $\endgroup$
    – Waitbng
    May 28, 2021 at 17:53
  • $\begingroup$ Me neither, but as it seems this is the case, it is hardly better than random guessing $\endgroup$
    – Nikos M.
    May 28, 2021 at 17:54

1 Answer 1

1
$\begingroup$

I found the answer in https://stackoverflow.com/questions/55868975/keras-how-to-evaluate-model-accuracy-evaluate-generator-vs-predict-generator/57630536#57630536

I just had to add shuffle = False in the test_datagen.flow_from_dataframe, and the confusion matrix was good

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.