title: How to get to know the order of actual labels for Confusion Matrix?
body: <p>I'm confused that how do I come to know the actual labels in Confusion Matrix? I know to pass the labels but my main question is how we come to know I which sequence I've to pass the label?</p>
  
  <pre><code>from sklearn.metrics import confusion_matrix
  
  cm = confusion_matrix(y_test,y_pred_classes)
  </code></pre>
  
  <p>This returns the result of the confusion_matrix() function:</p>
  
  <p><img src="https://i.stack.imgur.com/AvnD2.png" alt="Result of confusion_matrix() function"></p>
  
  <p>Then I declared labels and pass the labels to plot the confusion matrix:</p>
  
  <pre><code>import itertools
  
  def plotConfusionMatrix(cm, classes, normalize=False, title='Confusion Matrix', cmap = plt.cm.Blues):
  
      plt.figure(figsize = (10,7))
      plt.imshow(cm, interpolation='nearest', cmap=cmap)
      plt.title(title)
      plt.colorbar()
      tick_marks = np.arange(len(classes))
      plt.xticks(tick_marks, classes, rotation=45)
      plt.yticks(tick_marks, classes)
  
      if normalize:
          cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]
          print('Normalized Confusion Matrix')
      else:
          print('Un-normalized Confusion Matrix')
  
      print(cm)
  
      thresh = cm.max()/2
  
      for i,j in itertools.product(range(cm.shape[0]), range(cm.shape[1])):
          plt.text(j,i, cm[i,j], horizontalalignment='center', color='white' if cm[i,j] &gt; thresh else 'black', fontsize=25, fontweight='bold')
          plt.tight_layout()
          plt.ylabel('Actual Class')
          plt.xlabel('Predicted Class')
  </code></pre>
  
  <p>Then called the function and passed the labels:</p>
  
  <pre><code>classes = ['climbingdown','climbingup','jumping','lying','running','sitting','standing','walking']
  plotConfusionMatrix(cm, classes)
  </code></pre>
  
  <p>The output for the plotted confusion matrix was:</p>
  
  <p><img src="https://i.stack.imgur.com/GM0IW.png" alt="Plotted Confusion Matrix"></p>
  
  <p>Now, my exact question is, I've passed the labels of each class but how will I will come to know the order in which I've to pass?</p>