Created
July 1, 2019 07:17
-
-
Save andy51002000/59d7337d526da4dcfecab43307be399a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
from sklearn.feature_extraction.text import CountVectorizer | |
corpus = ['The cat sat on the mat', 'The dog sat on the mat', 'The goat sat on the mat'] | |
vectorizer = CountVectorizer(lowercase=True, analyzer='word', binary=False) | |
representation = vectorizer.fit_transform(corpus) | |
representation_df = pd.DataFrame(data = representation.toarray(), columns=sorted(vectorizer.vocabulary_.keys())) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment