Created
December 12, 2018 18:25
-
-
Save FelixChop/0afaf8ba440eae8aff82f0fffee76e39 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| from gensim import corpora, models | |
| # list_of_list_of_tokens = [["a","b","c"], ["d","e","f"]] | |
| # ["a","b","c"] are the tokens of document 1, ["d","e","f"] are the tokens of document 2... | |
| dictionary_LDA = corpora.Dictionary(list_of_list_of_tokens) | |
| dictionary_LDA.filter_extremes(no_below=3) | |
| corpus = [dictionary_LDA.doc2bow(list_of_tokens) for list_of_tokens in list_of_list_of_tokens] | |
| num_topics = 20 | |
| %time lda_model = models.LdaModel(corpus, num_topics=num_topics, \ | |
| id2word=dictionary_LDA, \ | |
| passes=4, alpha=[0.01]*num_topics, \ | |
| eta=[0.01]*len(dictionary_LDA.keys())) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment