Skip to content

Instantly share code, notes, and snippets.

@rchurch4
Last active April 10, 2022 17:09
Show Gist options
  • Save rchurch4/1ba9d948cf945d2b629b130f7db3d9d5 to your computer and use it in GitHub Desktop.
Save rchurch4/1ba9d948cf945d2b629b130f7db3d9d5 to your computer and use it in GitHub Desktop.
from gdtm.models import NLDA
# Set these paths to the path where you saved the Mallet implementation of each model, plus bin/mallet
tnd_path = 'path/to/mallet-tnd/bin/mallet'
lda_path = 'path/to/mallet-lda/bin/mallet'
# We pass in the paths to the java code along with the data set and whatever parameters we want to set
model = NLDA(dataset=dataset, mallet_tnd_path=tnd_path, mallet_lda_path=lda_path,
tnd_k=30, lda_k=30, nlda_phi=10, top_words=20)
topics = model.get_topics()
noise = model.get_noise_distribution()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment