The code implements the collapsed variational inference for LDA as a Python C extension module.

from numpy import * from cvbLDA import cvbLDA # Model params (T,W) = (3,5) alpha = .1 * ones((1,T)) beta = .1 * ones((T,W)) # Dataset docs_w = [[1,2],[1,2],[3,4], [3,4],[0],[0]] docs_c = [[2,1],[4,1],[3,1], [4,2],[5],[4]] # Stopping conditions for inference (maxiter,convtol) = (10,.01) # Do CVB inference for LDA (phi,theta,gamma) = cvbLDA(docs_w,docs_c,alpha,beta, maxiter=maxiter,verbose=1,convtol=convtol)

'@'.join(['andrzeje','.'.join(['cs','wisc','edu'])])

Teh Y.W., Newman D., and Welling, M.

Advances in Neural Information Processing Systems (NIPS) 19, 2007.

[2] Latent Dirichlet Allocation

Blei, D. M., Ng, A. Y., and Jordan, M. I.

Journal of Machine Learning Research (JMLR), 3, Mar. 2003, 993-1022.