Skip to main content

Module lda

Module lda 

Source
Expand description

Latent Dirichlet allocation by variational Bayes, for sparse count and binary matrices.

The topic model behind cisTopic: given a binarised cells x regions scATAC matrix or TF binary activity, recover a cell-topic distribution for clustering and a topic-region/TF distribution for region/TF set discovery. Nothing here is ATAC-specific or TF-specific, so any documents x terms count matrix works.

§Layout

The solver holds the corpus in both orientations, CSR for the document-major E-step and CSC for the term-major M-step, the same trick the sparse NMF backend uses. Every dense buffer is column-major faer::Mat, laid out so that the k-vector each hot loop touches is contiguous.

Note that CompressedSparseData2 indexes with u32, which caps a corpus at roughly 4.3e9 non-zeros.

§References

Hoffman, Blei and Bach, Online Learning for Latent Dirichlet Allocation, NIPS, 2010

Bravo Gonzalez-Blas et al., cisTopic, Nature Methods, 2019

Re-exports§

pub use vb::lda_bound;

Modules§

metrics
Model selection metrics for LDA, and the combination that picks a topic count.
vb
The variational Bayes solver: E-step, M-step, bound and the outer loop.

Structs§

LdaCorpus
A corpus held in both orientations, with counts cast to the solver’s float.
LdaParams
Options for the variational Bayes LDA solver.
LdaResult
A fitted LDA model.
LdaSweepEntry
One fitted model plus its evaluation, as produced by a topic-count sweep.
LdaSweepResult
The outcome of a topic-count sweep.

Enums§

LdaLearning
How the variational parameters are updated across the corpus.

Constants§

DEFAULT_MIN_TOPICS_COH
Smallest topic count admitted into a coherence-based model selection.
DEFAULT_TOP_TOPICS_COH
Default number of top-scoring topics averaged into the reported coherence.

Functions§

lda_fit
Fit an LDA model to a documents x terms count matrix.
lda_k_sweep
Fit LDA across a range of topic counts and score each fit.
parse_lda_learning
Parse the LDA learning strategy.