Skip to content
Python 2 & 3 wrapper around the Stanford Topic Modeling Toolbox. Intended to be used for hassle-free supervised topic classification with Labeled Latent Dirichlet Allocation (L-LDA, LLDA, sLDA).
Python Scala
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


A small Python 3 wrapper around the Stanford Topic Modeling Toolbox (STMT) that makes working with L-LDA a bit easier; no need to leave the Python environment. More information on its workings can be found on my blog.

Setting up

Just download STMT and put it in the box directory. After, import topbox from wherever you left it.

On Linux, this would look something like this:

$ cd ~
$ git clone
$ cd ~/topbox/box
$ wget
$ cd ~
$ vi

You can paste the code below in the script file to test if it's working.


import topbox

stmt = topbox.STMT('bit_of_testing', epochs=10, mem=15000)

space = ['text text more text', 'things to do with text']
labels = ['label1 label2', 'label1 label3']

stmt.train(space, labels)

infer = ['this is a text', 'things with more text']
gs = ['label1 label2', 'label1 label3']

stmt.test(infer, gs)

from sklearn.metrics import average_precision_score

# array requires numpy and scipy
y_true, y_score = stmt.results(gs, array=True)

print(average_precision_score(y_true, y_score))
You can’t perform that action at this time.