Skip to content

Instantly share code, notes, and snippets.

@FelixChop
Created December 12, 2018 18:19
Show Gist options
  • Select an option

  • Save FelixChop/42a263e444864d5da18e462e60716603 to your computer and use it in GitHub Desktop.

Select an option

Save FelixChop/42a263e444864d5da18e462e60716603 to your computer and use it in GitHub Desktop.
from gensim import corpora, models
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