title: Inaccurate confusion matrix for a model with 98% test accuracy
body: <p>I trained a model for binary classification and received 98% of test accuracy and 99% of training accuracy.</p>
  
  <p>Today I wanted to calculate the confusion matrix and used below code to calculate them.</p>
  
  <pre><code>model = load_model("model.h5")
  
  testGenerator = ImageDataGenerator(rotation_range=5,
                                  width_shift_range=0.2,
                                  height_shift_range=0.2,
                                  horizontal_flip=False,
                                  fill_mode='nearest'
                                  )   
  
  testData = testGenerator.flow_from_directory(
                                  'Location', 
                                  target_size=(74,448),                                                 
                                  batch_size=15,
                                  class_mode='binary',
                                  shuffle=False
                                  )
  
  proba = model.predict_generator(testData,steps=3000//15)
  y_true = np.array([0] * 1482 + [1] * 1482 )
  y_pred = proba &gt; 0.5
  print(confusion_matrix(y_true, y_pred))
  </code></pre>
  
  <p>And I received this confusion matrix :</p>
  
  <p><a href="https://i.stack.imgur.com/443gp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/443gp.png" alt="Confusion Matrix"></a></p>
  
  <p>As sklearn says : </p>
  
  <p><a href="https://i.stack.imgur.com/E8t9Q.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/E8t9Q.png" alt="enter image description here"></a></p>
  
  <p>Which says here false negative and false positive are so high. How is that even possible since I had 98% of testing accuracy? Also I've used that model few times to generate predictions (using model.predict() fuction) and manually checked them. But each time it gave me correct classifications.</p>
  
  <p>Any Ideas how to get accurate results?</p>