- Numpy-based PLSA (Probabilistic Latent Semantic Analysis), plsa.py.
- LDA (Latent Dirichlet Allocation) vs hLDA (Hierarchical Latent Dirichlet Allocation) and vizualization LDA_vs.hLDA.ipynb
All numpy-based implementation in PLSA
This was when I took Text Mining lecture by UIUC MSCS Dept. Prof.ChengXiang Zhai, where we are asked to build the PLSA model in numpy.
PLSA learns both document-topic distribution and topic-word distribution by Bayes inference and optimize the log-likelihood by EM algorithm. The code comments in plsa.py includes
- How to initialized the parameters
- How to do E-step
- How to do M-step
- How to calculate the log-likelihood of the inference
Summary and visual comparison between LDA and hLDA
This was when I took one of the topic mining campus analytic challenges in the U.S, where we're asked to provide sth more than LDA.
The corpus used here is from NASA dataset with some masked token to make the task harder.
This one starts from using gensim API to lemmatize and add bi-gram token, and then train LDA model and visualize by pyLDAvis and IPython widget for interactive result.
For currently there is no popular Python packages with implementation on hLDA. The file hlda_sampler.py is referred to joewand's github. hlda_sampler.py is the Gibbs sampler for hLDA inference, based on the implementation from Mallet having a fixed depth on the nCRP tree. The most distinguished attribute in hLDA is we could have a hierarchial topic tree, with higher branches having more general topics and lower branches having more specialized topics.