Skip to content

Instantly share code, notes, and snippets.

@jasmarc
Created April 19, 2011 03:37
Show Gist options
  • Save jasmarc/926775 to your computer and use it in GitHub Desktop.
Save jasmarc/926775 to your computer and use it in GitHub Desktop.
running LDA on some stuff
entries = Entry.all :limit => 20, :abstractText.not => nil
corpus = Lda::Corpus.new
entries.each do |entry|
doc = Lda::TextDocument.new(corpus, entry.abstractText)
corpus.add_document(doc)
end
lda = Lda::Lda.new(corpus) # create an Lda object for training
lda.em("random") # run EM algorithm using random starting points
lda.print_topics(20) # print the topic 20 words per topic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment