我正在使用三个类别的新闻分类器,但是使用随机梯度下降代码有问题
我从Kaggle导入了有关“印度新闻”的数据框,并获取了三类新闻。然后,我创建了一个具有三个类的新Dataframe
,当我尝试执行sgd时遇到错误。
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3,
random_state=42)
sgd = Pipeline([('vect', vectorizer),
('tfidf', tfidfconverter),
('clf', SGDClassifier(loss='hinge', penalty='elasticnet',
alpha=1e-05, random_state=42,
max_iter=10, tol=None))
])
sgd.fit(X_train, y_train)
错误:
File "/Users/Matias/anaconda3/lib/python3.6/site-packages/pandas/core/generic.py", line 1121, in __nonzero__
.format(self.__class__.__name__))
ValueError: The truth value of a DataFrame is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().