title: ValueError: Found arrays with inconsistent numbers of samples [ 6 1786]
body: <p>Here is my code:</p>
  
  <pre><code>from sklearn.svm import SVC
  from sklearn.grid_search import GridSearchCV
  from sklearn.cross_validation import KFold
  from sklearn.feature_extraction.text import TfidfVectorizer
  from sklearn import datasets
  import numpy as np
  
  newsgroups = datasets.fetch_20newsgroups(
                  subset='all',
                  categories=['alt.atheism', 'sci.space']
           )
  X = newsgroups.data
  y = newsgroups.target
  
  TD_IF = TfidfVectorizer()
  y_scaled = TD_IF.fit_transform(newsgroups, y)
  grid = {'C': np.power(10.0, np.arange(-5, 6))}
  cv = KFold(y_scaled.size, n_folds=5, shuffle=True, random_state=241) 
  clf = SVC(kernel='linear', random_state=241)
  
  gs = GridSearchCV(estimator=clf, param_grid=grid, scoring='accuracy', cv=cv)
  gs.fit(X, y_scaled) 
  </code></pre>
  
  <p>I am getting error and I don't understand why. The traceback:</p>
  
  <blockquote>
    <p>Traceback (most recent call last):   File<br>
    "C:/Users/Roman/PycharmProjects/week_3/assignment_2.py", line 23, in<br>
    <br>
        gs.fit(X, y_scaled) #TODO: check this line   File "C:\Users\Roman\AppData\Roaming\Python\Python35\site-packages\sklearn\grid_search.py",<br>
    line 804, in fit<br>
        return self._fit(X, y, ParameterGrid(self.param_grid))   File "C:\Users\Roman\AppData\Roaming\Python\Python35\site-packages\sklearn\grid_search.py",<br>
    line 525, in _fit<br>
        X, y = indexable(X, y)   File "C:\Users\Roman\AppData\Roaming\Python\Python35\site-packages\sklearn\utils\validation.py",<br>
    line 201, in indexable<br>
        check_consistent_length(*result)   File "C:\Users\Roman\AppData\Roaming\Python\Python35\site-packages\sklearn\utils\validation.py",<br>
    line 176, in check_consistent_length<br>
        "%s" % str(uniques))  </p>
    
    <p><strong>ValueError: Found arrays with inconsistent numbers of samples: [   6 1786]</strong>  </p>
  </blockquote>
  
  <p>Could someone explain why this error occur?</p>