Skip to content

Instantly share code, notes, and snippets.

@amankharwal
Created Jun 7, 2021
Embed
What would you like to do?
from sklearn.feature_extraction.text import CountVectorizer
vect = CountVectorizer()
text = ["Hi, how are you", "I hope you are doing good", "My name is Aman Kharwal"]
vect.fit(text)
train = vect.transform(text)
train.toarray()
import pandas as pd
data = pd.DataFrame(train.toarray(), columns=vect.get_feature_names())
print(data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment