liveBook · Manning

Topic model

As explained in Machine Learning Algorithms in Depth

A topic model is a probabilistic latent-variable model that represents discrete observations such as documents through unobserved thematic components.

A topic model is a probabilistic latent-variable model for discrete observations such as text documents. Latent Dirichlet allocation (LDA) represents each document as a finite mixture of topics, with each topic defined as a distribution over words. section 9.1 section 9.8

Under the bag-of-words assumption, word order and sentence structure are discarded. Each document becomes a vocabulary-count vector, and the corpus becomes a term-document matrix A. LDA can also be viewed as nonnegative matrix factorization, A = WH, where W contains shared topics and H contains document topic proportions. section 9.1

The LDA representation assigns:

  • Each word occurrence xi,d a topic label zi,d drawn from K possible topics. section 9.1
  • Each document d topic proportions θd, which can measure document similarity. section 9.1
  • Each topic βk a distribution over the vocabulary shared across documents. section 9.1
  • Hyperparameters α and η prior roles for document topic proportions and topic distributions. section 9.1

Document preprocessing

Represent a corpus of D documents with vocabulary counts, then optionally apply tf-idf weighting, A log(D/nt), to reduce the influence of terms appearing in many documents. The same matrix construction can use n-grams instead of unigrams. section 9.1 section 9.8

Figure 9.1 Latent Dirichlet allocation graphical model
figure

Use the graphical model to inspect how document proportions, topic-word distributions, topic labels, words, and hyperparameters relate. section 9.1

How Machine Learning Algorithms in Depth covers it

How deep it goes
Defines LDA assumptions, notation, matrix structure, latent assignments, and priors, while stopping short of the full derivation.
Examples
Uses text documents, unigram and n-gram count matrices, tf-idf weighting, and topic proportions as a document-similarity measure.
What you can do after
Evaluate and understand document representations built from shared topic distributions and document-specific topic proportions.
How it connects
Connects latent-variable models, bag-of-words, term-document matrices, nonnegative matrix factorization, tf-idf, and document similarity.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Machine Learning Algorithms in Depth. The section links point to the parts of the book it draws on.