ValueError: matrices encontradas con números inconsistentes de muestras [6 1786]

Aquí está mi código:

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) 

Recibo un error y no entiendo por qué. El rastreo:

Rastreo (última llamada más reciente): archivo
"C: /Users/Roman/PycharmProjects/week_3/assignment_2.py", línea 23, en

gs.fit (X, y_scaled) #TODO: marque esta línea Archivo "C: \ Users \ Roman \ AppData \ Roaming \ Python \ Python35 \ site-packages \ sklearn \ grid_search.py",
línea 804, en forma
return self._fit (X, y, ParameterGrid (self.param_grid)) Archivo "C: \ Users \ Roman \ AppData \ Roaming \ Python \ Python35 \ site-packages \ sklearn \ grid_search.py",
línea 525, en _fit
X, y = Archivo indexable (X, y) "C: \ Users \ Roman \ AppData \ Roaming \ Python \ Python35 \ site-packages \ sklearn \ utils \ validation.py",
línea 201, en indexable
check_consistent_length (* result) Archivo "C: \ Users \ Roman \ AppData \ Roaming \ Python \ Python35 \ site-packages \ sklearn \ utils \ validation.py",
línea 176, en check_consistent_length
"% s"% str (exclusivos))

ValueError: matrices encontradas con números inconsistentes de muestras: [6 1786]

¿Alguien podría explicar por qué ocurre este error?

Respuestas a la pregunta(1)

Su respuesta a la pregunta