Note
Click here to download the full example code
Train an LDA model and use it¶
This example trains a latent Dirichlet allocation with MALLET using abstracts from Neurosynth.
Start with the necessary imports¶
import os
import nimare
from nimare import annotate
from nimare.tests.utils import get_test_data_path
Load dataset with abstracts¶
dset = nimare.dataset.Dataset.load(
os.path.join(get_test_data_path(), 'neurosynth_laird_studies.pkl.gz'))
Run model¶
Five iterations will take ~10 minutes
model = annotate.topic.LDAModel(dset.texts, text_column='abstract', n_iters=5)
model.fit()
model.save('lda_model.pkl.gz')
Total running time of the script: ( 0 minutes 0.000 seconds)