Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- doc1 = "My favoruite TV series are Spartacus and Breaking Bad"
- doc2 = "My name is John Constantine and I am 27 years old."
- doc3 = "I am working as a Machine Learning Engineer."
- doc4 = "I love pokemons. Tyranitar is my favorite pokemon"
- doc5 = "Health experts say that Sugar is not good for your lifestyle."
- # compile documents
- doc_complete = [doc1, doc2, doc3, doc4, doc5]
- # I have done preprocessing in this step(haven't inclueded the full code.
- doc_clean = [clean(doc).split() for doc in doc_complete]
- I then use gensim to make predicition.
- import gensim
- from gensim import corpora
- dictionary = corpora.Dictionary(doc_clean )
- doc_term_matrix = [dictionary.doc2bow(doc) for doc in doc_clean]
- Lda = gensim.models.ldamodel.LdaModel
- # Running and Trainign LDA model on the document term matrix.
- ldamodel = Lda(doc_term_matrix, num_topics=3, id2word = dictionary, passes=50)
- print ldamodel.show_topics(num_topics=3)
- doc1 a b c
- doc2 b c d
- doc3 x y z
- doc4 l m o
- doc5 a c o
Add Comment
Please, Sign In to add comment