Skip to content

Instantly share code, notes, and snippets.

@Abhayparashar31
Created October 27, 2022 03:35
Show Gist options
  • Save Abhayparashar31/b511083141a0d8015dada646d8156091 to your computer and use it in GitHub Desktop.
Save Abhayparashar31/b511083141a0d8015dada646d8156091 to your computer and use it in GitHub Desktop.
from sklearn.feature_extraction.text import CountVectorizer
import pandas as pd
vectorizer = CountVectorizer()
X = vectorizer.fit_transform(cleaned_corpus) ## passing cleaned corpus
doc_term_matrix = pd.DataFrame(X.toarray(),columns= vectorizer.get_feature_names())
print(doc_term_matrix)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment