# Confusion matrix doesn't display properly

I am trying to plot a confusion matrix using the Logistic Regression for a multi-class dataset.

But the problem is when I plot the confusion matrix it only plot a confusion matrix for binary classification.

Here is where I am plotting it.

%matplotlib inline
import matplotlib.pyplot as plt
import pandas as pd


from sklearn.linear_model import LogisticRegression

LRModel = LogisticRegression(C=100, max_iter=5500)

LRModel.fit(X_train, y_train)

predicted_values_ = LRModel.predict(X_test)
from sklearn.metrics import confusion_matrix

cm = confusion_matrix(y_test, predicted_values_)

misclassified = (y_test != predicted_values_).sum()
misclassified

import seaborn as sn

# plt.figure()
sn.heatmap(cm, annot=True)
plt.xlabel("Predicted")
plt.ylabel("Actual")


And I get this matrix as shown below.

Can someone tell me where I am doing wrong?

This is where I am using Logistic Regression for multi-class scenario

• Did you check the number of classes in y_test? – BlackCurrant May 23 '20 at 14:55
• How can I check that? – Escort Personal Adz May 23 '20 at 15:14

Please check how many classes y_test has.

if Y is array-

np.unique(y_test)


If y is DataFrame column,

y_test.unique()


Looks like y_test has only 2 classes.

As far as I know HR-Employee-Attrition.csv dataset has only 2 classes.