title: At least one label specified must be in y_true, target vector is numerical
body: <p>I am implementing an SVM project with this <a href="https://s3-api.us-geo.objectstorage.softlayer.net/cf-courses-data/CognitiveClass/ML0101ENv3/labs/loan_train.csv" rel="nofollow noreferrer">data</a></p>
  
  <p>here is how I extract the features:</p>
  
  <pre><code>import itertools
  import matplotlib.pyplot as plt
  import pandas as pd
  import numpy as np
  from sklearn.model_selection import train_test_split
  from sklearn import svm
  from sklearn.metrics import classification_report, confusion_matrix
  
  df = pd.read_csv('loan_train.csv')
  df['due_date'] = pd.to_datetime(df['due_date'])
  df['effective_date'] = pd.to_datetime(df['effective_date'])
  df['dayofweek'] = df['effective_date'].dt.dayofweek
  df['weekend'] = df['dayofweek'].apply(lambda x: 1 if (x&gt;3)  else 0)
  Feature = df[['Principal','terms','age','Gender','weekend']]
  Feature = pd.concat([Feature,pd.get_dummies(df['education'])], axis=1)
  Feature.drop(['Master or Above'], axis = 1,inplace=True)
  
  X = Feature
  y = df['loan_status'].replace(to_replace=['PAIDOFF','COLLECTION'], value=[0,1],inplace=False)
  </code></pre>
  
  <p>creating model and prediction:</p>
  
  <pre><code>clf = svm.SVC(kernel='rbf')
  clf.fit(X_train_svm, y_train_svm)
  yhat_svm = clf.predict(X_test_svm)
  </code></pre>
  
  <p>evaluation phase:</p>
  
  <pre><code>def plot_confusion_matrix(cm, classes,
                            normalize=False,
                            title='Confusion matrix',
                            cmap=plt.cm.Blues):
      """
      This function prints and plots the confusion matrix.
      Normalization can be applied by setting `normalize=True`.
      """
      if normalize:
          cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]
          print("Normalized confusion matrix")
      else:
          print('Confusion matrix, without normalization')
  
      print(cm)
  
      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)
  
      fmt = '.2f' if normalize else 'd'
      thresh = cm.max() / 2.
      for i, j in itertools.product(range(cm.shape[0]), range(cm.shape[1])):
          plt.text(j, i, format(cm[i, j], fmt),
                   horizontalalignment="center",
                   color="white" if cm[i, j] &gt; thresh else "black")
  
      plt.tight_layout()
      plt.ylabel('True label')
      plt.xlabel('Predicted label')
      plt.show()
  
  
  cnf_matrix = confusion_matrix(y_test_svm, yhat_svm, labels=[2,4])
  np.set_printoptions(precision=2)
  
  print (classification_report(y_test_svm, yhat_svm))
  
  # Plot non-normalized confusion matrix
  plt.figure()
  plot_confusion_matrix(cnf_matrix, classes=['Benign(2)','Malignant(4)'],normalize= False,  title='Confusion matrix')
  </code></pre>
  
  <p>here is the error:</p>
  
  <blockquote>
    <p>Traceback (most recent call last):</p>
    
    <p>File "E:/python/classification_project/classification.py", line 229,in </p>
    
    <p>cnf_matrix = confusion_matrix(y_test_svm, yhat_svm, labels=[2,4])</p>
    
    <p>File "C:\Program Files(x86)\Python38-32\lib\site-packages\sklearn\metrics_classification.py", line 277, in confusion_matrix</p>
    
    <p>raise ValueError("At least one label specified must be in y_true")</p>
    
    <p>ValueError: At least one label specified must be in y_true</p>
  </blockquote>
  
  <p>I checked this <a href="https://stackoverflow.com/questions/52250821/at-least-one-label-specified-must-be-in-y-true/52258815">question</a> which was like mine and I changed the <code>y</code> from <code>categorical</code> to <code>numerical</code> but the error is still there!</p>