Machine Learning · Insper · E3.4

Comparing the Models

Fundamental approach

Which model should I trust, and when?

The path of this part

  1. Measure the threesame posts, 24 topics, two seeds
  2. Compare overallwhat a topic is, short texts, outliers, cost
  3. Choosewhich model, for which corpus
Each stage answers one question: how do the three score on equal terms? → how do they differ beyond the scores? → which one for my corpus?
Stage 1 · how do the three score on equal terms?

LDA vs NMF vs BERTopic, measured

Same 2,155 posts, 24 topics for LDA (latent Dirichlet allocation), NMF (non-negative matrix factorization) and BERTopic, two seeds each. Homogeneity: 1 when every topic holds a single forum. Coherence: mean NPMI (normalized pointwise mutual information) of top words. Diversity: share of distinct top words. Predict: whose topics are purest?

modelseedtopicsoutlierscoherencediversityhomogeneity
LDA42240%0.2650.720.526
NMF42240%0.3910.920.646
BERTopic422420%0.2510.880.927
LDA43240%0.2760.700.574
NMF43240%0.4070.910.644
BERTopic431610%0.2950.820.662

Reading the table

  • Homogeneity: BERTopic 0.927, but on the 80% of posts it kept; with seed 43 it finds 16 broader topics and falls to 0.662.
  • Coherence and diversity favor NMF: NPMI rewards co-occurring words, which NMF reconstructs; BERTopic picks distinctive words.
  • Stability between seeds, ARI (adjusted Rand index): LDA 0.164, NMF 0.736, BERTopic 0.324, with even the number of topics changing.
A coherence score measures one aspect of quality, not the truth.
Stage 2 · how do they differ beyond the scores?

The overall comparison

LDANMFBERTopic
a topic isa distribution over wordsa non-negative row of \(H\)a cluster, named by c-TF-IDF
number of topicsfixed in advancefixed in advancefound by HDBSCAN
short documentsweakweakstrong
outliersnonenoneexplicit (−1)
seed-dependencestrongweaker (SVD start)yes, even the number of topics
costcheap, CPUcheapest, CPUembedding model; a GPU (graphics processor) helps

c-TF-IDF: TF-IDF per cluster · SVD: singular value decomposition · CPU: central processor.

Stage 3 · which one for my corpus?

Which model, when

short documents?

tweets, titles, ticket subjects: too few shared words for counts

BERTopic

mixtures?

a document should mix several topics, with readable weights

LDA or NMF

cheap and stable?

no model download, an SVD-based start

NMF

No model wins everywhere: NMF beat LDA on the lesson's posts, LDA beat NMF in the lab. Measure against something the model never saw, and always read the topics.
Practice

To close the fundamental part

  • Why is BERTopic's homogeneity of 0.927 not directly comparable with NMF's 0.646?
  • Which model's topics changed the most with the seed, and which one changed even their number?
  • For 50,000 product-review titles of eight words each, which model would you start with?

Next: the summary and the fundamental lab on the overview page (steps 1 to 7).