title: inconsistent shape error MultiLabelBinarizer on y_test, sklearn multi-label classification
body: <pre><code>import numpy as np
  import pandas as pd
  from sklearn.pipeline import Pipeline
  from sklearn.feature_extraction.text import CountVectorizer
  from sklearn.svm import LinearSVC
  from sklearn.linear_model import SGDClassifier
  from sklearn.feature_extraction.text import TfidfTransformer
  from sklearn.multiclass import OneVsRestClassifier
  from sklearn.metrics import accuracy_score, classification_report, confusion_matrix
  from sklearn.model_selection import train_test_split
  from sklearn import preprocessing
  from sklearn.svm import SVC
  
  data = r'C:\Users\...\Downloads\news_v1.xlsx'
  
  df = pd.read_excel(data)
  df = pd.DataFrame(df.groupby(["id", "doc"]).label.apply(list)).reset_index()
  
  X = np.array(df.doc)
  y = np.array(df.label)
  
  X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33, random_state=42)
  
  mlb = preprocessing.MultiLabelBinarizer()
  Y_train = mlb.fit_transform(y_train)
  
  classifier = Pipeline([
  ('vectorizer', CountVectorizer()),
  ('tfidf', TfidfTransformer()),
  ('clf', OneVsRestClassifier(LinearSVC()))])
  
  classifier.fit(X_train, Y_train)
  predicted = classifier.predict(X_test)
  
  Y_test = mlb.fit_transform(y_test)
  
  print("Y_train: ", Y_train.shape)
  print("Y_test: ", Y_test.shape)
  print("Predicted: ", predicted.shape)
  print("Accuracy Score: ", accuracy_score(Y_test, predicted))
  </code></pre>
  
  <p>I can't seems to do any measurements since Y_test gives a different matrix dimension after fit_transform with MultiLabelBinarizer.</p>
  
  <p>Results and error: </p>
  
  <pre><code>Y_train:  (1278, 49)
  Y_test:  (630, 42)
  Predicted:  (630, 49)
  Traceback (most recent call last):
    File "C:/Users/../PycharmProjects/MultiAutoTag/classifier.py", line 41, in &lt;module&gt;
      print("Accuracy Score: ", accuracy_score(Y_test, predicted))
    File "C:\ProgramData\Anaconda3\lib\site-packages\sklearn\metrics\classification.py", line 174, in accuracy_score
      differing_labels = count_nonzero(y_true - y_pred, axis=1)
    File "C:\ProgramData\Anaconda3\lib\site-packages\scipy\sparse\compressed.py", line 361, in __sub__
      raise ValueError("inconsistent shapes")
  ValueError: inconsistent shapes
  </code></pre>
  
  <p>Looking at the printed Y_test, the shape is different than the rest. What am i doing wrong and why does MultiLabelBinarizer return a different size for Y_test?
  Thanks for the help in advance!</p>
  
  <p><strong>Edit</strong> <strong>New error:</strong></p>
  
  <pre><code>Traceback (most recent call last):
    File "C:/Users/../PycharmProjects/MultiAutoTag/classifier.py", line 47, in &lt;module&gt;
      Y_test = mlb.transform(y_test)
    File "C:\ProgramData\Anaconda3\lib\site-packages\sklearn\preprocessing\label.py", line 763, in transform
      yt = self._transform(y, class_to_index)
    File "C:\ProgramData\Anaconda3\lib\site-packages\sklearn\preprocessing\label.py", line 787, in _transform
      indices.extend(set(class_mapping[label] for label in labels))
    File "C:\ProgramData\Anaconda3\lib\site-packages\sklearn\preprocessing\label.py", line 787, in &lt;genexpr&gt;
      indices.extend(set(class_mapping[label] for label in labels))
  KeyError: 'Sanction'
  </code></pre>
  
  <p>This is how y_test looks like:</p>
  
  <pre><code>print(y_test)
  
  [['App'] ['Contract'] ['Pay'] ['App'] 
   ['App'] ['App']
   ['Reports'] ['Reports'] ['Executive', 'Pay']
   ['Change'] ['Reports']
   ['Reports'] ['Issue']]
  </code></pre>