Skip to content

Instantly share code, notes, and snippets.

@GeorgeSeif
Created December 28, 2019 17:13
Show Gist options
  • Save GeorgeSeif/97f58ab815a3480c908fe8854d788c6c to your computer and use it in GitHub Desktop.
Save GeorgeSeif/97f58ab815a3480c908fe8854d788c6c to your computer and use it in GitHub Desktop.
from sklearn.decomposition import LatentDirichletAllocation as LDA
NUM_TOPICS = 3
# Here we create and fit the LDA model
# The "document_word_matrix" is a 2D array where each row is a document
# and each column is a word. The cells contain the count of the word within
# each document
lda = LDA(n_components=NUM_TOPICS, n_jobs=-1)
lda.fit(document_word_matrix)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment