Class label prediction in keras sequential model showing different results in confusion matrix With Keras Sequential Model Prediction
To get Class Labels
we can do
yhat_classes1 = Keras_model.predict_classes(predictors)[:, 0] #this shows deprecated warning in tf==2.3.0

WARNING:tensorflow:From &lt;ipython-input-54-226ad21ffae4&gt;:1: Sequential.predict_classes (from tensorflow.python.keras.engine.sequential) is deprecated and will be removed after 2021-01-01.
Instructions for updating:
Please use instead:* `np.argmax(model.predict(x), axis=-1)`,   if your model does multi-class classification   (e.g. if it uses a `softmax` last-layer activation).* `(model.predict(x) &gt; 0.5).astype(&quot;int32&quot;)`,   if your model does binary classification   (e.g. if it uses a `sigmoid` last-layer activation).


or
yhat_classes2 = np.argmax(Keras_model.predict(predictors), axis=1)

With the first class labels if i create confusion matrix, i get
matrix = confusion_matrix(actual_y, yhat_classes1)
 [[108579   8674]
 [  1205  24086]]

But with the second class labels with the confusion matrix, i get 0 for True Positive and False Positive
matrix = confusion_matrix(actual_y, yhat_classes2)
 [[117253      0]
 [ 25291      0]]

May I know whats the issue here?
Model.predict_classes gives you the most likely class only (highest probability value), therefore it is of dimension (samples,), for every input in sample there is one output - the class.
To be more precise  Model.predict_classes calls argmax on the output of predict. See the code (of predict_classes below)
def predict_classes(self, X, batch_size=128, verbose=1):
  proba = self.predict(X, batch_size=batch_size, verbose=verbose)
        if self.class_mode == 'categorical':
            return proba.argmax(axis=-1)
        else:
            return (proba &gt; 0.5).astype('int32')

As the warning suggest, Please use instead:

np.argmax(model.predict(x), axis=-1),   if your model does multi-class classification   (e.g. if it uses a softmax last-layer activation).
(model.predict(x) &gt; 0.5).astype(&quot;int32&quot;),   if your model does binary classification   (e.g. if it uses a sigmoid last-layer activation).