2

I have been trying to follow Francois example of a binary image classifier of cats and dogs. I have attempted to follow his example in another similar set in kaggle (https://www.kaggle.com/playlist/men-women-classification) and I want to achieve the following

  • Visualise the predictions that are wrong
  • Come out with the classification report

I already have a model with around 85% accuracy on the validation set but I want to know roughly what kind of images my model is getting wrong as well as coming up with a classification report with sklearn.metric's classification report.

However I do not know how does the image generator works and have a big problem trying to know how to pair the predictions with the labels of the test images.

from sklearn.metrics import classification_report

new_test_datagen = test_datagen.flow_from_directory(
    directory = test_dir,
    target_size=(150,150),
    batch_size=1,
    class_mode='binary',
    seed = 42,
)

train_image = new_train_generator.next()
plt.imshow(train_image[0].reshape(150,150,-1))
print(train_image[1])
#I want to output images but I am not sure if this is the most efficient way of doing it

predictions = model.predict(test_generator)
predictions.shape

#The predictions is a numpy array of length 476 but I do not know what are the 'correct' labels found in my test set to validate it against this output.

model.evaluate(test_generator)
# [0.3109202980995178, 0.8886554837226868]
desertnaut
  • 57,590
  • 26
  • 140
  • 166
Randy Chng
  • 103
  • 5

0 Answers0