Bag of words in Python

0

I have a news dataset and want to separate them between two classes. For this I thought of using Bag of words, but I'm not getting with Sklearn. I've tried the following:

#Bag of words
from sklearn.feature_extraction.text import CountVectorizer

vectorizer = CountVectorizer()
print(vectorizer.fit_transform(traindata).todense())
print(vectorizer.vocabulary_)

Any indication of how to use Bag of words using Pandas, Sklearn etc?

    
asked by anonymous 31.10.2018 / 02:01

0 answers