Created
July 17, 2019 10:06
-
-
Save khyatimahendru/1d58a8321bd2524d39efb04fcc2958c1 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
# create document term matrix for your data | |
# you can use TfidfVectorizer instead of CountVectorizer as well | |
from sklearn.feature_extraction.text import CountVectorizer | |
cvec = CountVectorizer() | |
docTermMat = cvec.fit_transform(data['text'].values) | |
# truncated SVD to preserve 20 topics | |
from sklearn.decomposition import TruncatedSVD | |
lsa = TruncatedSVD(n_components = 20, n_iter = 500) | |
lsa.fit(docTermMat) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment