I am implementing different classifiers using different machine learning algorithms.
I'm sorting text files, and do as follows:
classifier = Pipeline([
('vectorizer', CountVectorizer ()),
('TFIDF', TfidfTransformer ()),
('clf', OneVsRestClassifier (GaussianNB()))])
classifier.fit(X_train,Y)
predicted = classifier.predict(X_test)
When I use the algorithm GaussianNB the following error occurs:
TypeError: A sparse matrix was passed, but dense data is required. Use X.toarray () to convert to a dense numpy array.
I saw the following post here
In this post a class is created to perform the transformation of the data. It is possible to adapt my code with TfidfTransformer. How I can fix this?