How Many Topics? Stability Analysis for Topic Models

Derek Greene, Derek O'Callaghan, Padraig Cunningham

TL;DR

Choosing the "right" number of topics ($k$) is the hardest part of topic modeling. This paper proposes a term-centric stability analysis that identifies the optimal $k$ by measuring how consistently an algorithm produces the same top-ranked words across different subsets of data.

What Problem Does This Paper Address?

Topic modeling (using techniques like LDA or Non-negative Matrix Factorization) is a powerful way to summarize massive text collections. However, these models require the user to specify the number of topics ($k$) upfront.

If $k$ is too low, the topics are "under-clustered" and overly broad (e.g., merging "Politics" and "Business"). If $k$ is too high, the model "over-clusters," splitting coherent themes into many tiny, redundant fragments. While heuristics like "Residual Sum of Squares" exist, they often fail to capture the semantic nuances that human readers care about. The authors aim to provide a robust, automated way to find the "Goldilocks" value for $k$.

Methods

The authors introduce a stability-based framework that focuses on term rankings rather than document assignments.

  1. Average Jaccard (AJ) Similarity: The authors argue that in topic modeling, the top-ranked words are the most important. They use a "top-weighted" version of the Jaccard index to compare two lists of words. This metric gives more weight to agreements at the very top of the list (rank 1, 2, 3) than at the bottom (rank 19, 20).
  2. Topic Model Agreement: To compare two different models (each with $k$ topics), they use the Hungarian method to find the best one-to-one matching between the two sets of topics based on their AJ scores.
  3. The Stability Pipeline:
    • Generate a "reference" model using the full dataset.
  4. Generate multiple "perturbed" models by running the algorithm on random subsamples of the data.
  5. Calculate the mean agreement between the reference model and the subsampled models.
  6. The "Aha!" Moment: High stability scores (peaks in a plot) indicate a $k$ value where the data naturally clusters into distinct, reproducible themes.

Datasets

The researchers evaluated their method on eight diverse text corpora, most of which include "ground truth" labels (pre-defined categories) for validation:

  • News Media: bbc, bbc-sport, guardian-2013, irishtimes-2013, nytimes-1999, and nytimes-2003.
  • Wikipedia: wikipedia-high (broad categories) and wikipedia-low (fine-grained sub-groups).
  • Synthetic Data: A control set of 500 randomly generated documents to ensure the model doesn't find "stability" where none exists.

Key Insights and Ideas

  • Stability = Reliability: A "good" model should be robust to small changes in the data. If removing 20% of your documents completely changes your top topics, your $k$ is likely poorly chosen.
  • Term-Centric vs. Document-Centric: Previous stability methods (like Brunet’s consensus matrix) looked at how documents were clustered. This paper argues that since humans interpret topics via words, we should measure stability based on word rankings.
  • Multi-Resolution Structure: The stability plots often show multiple peaks. For example, the Guardian dataset showed peaks at $k=3$ (coarse themes like "Culture" and "Politics/Business") and $k=6$ (the actual sections of the newspaper). This suggests that data often has multiple "correct" levels of granularity.
  • Efficiency: By comparing models to a single reference point rather than doing all-pairs comparisons, the method is significantly faster and more parallelizable than previous consensus-based approaches.

Key Results

  • Matching Ground Truth: On the bbc dataset, the method showed a sharp peak at $k=5$, perfectly matching the five annotated news categories (Business, Entertainment, etc.).
  • Identifying "Clustering Tendency": On the synthetic random data, the stability scores remained flat and low, correctly indicating that there were no coherent topics to be found.
  • Performance: The proposed method outperformed the standard "consensus matrix" approach in identifying the ground truth $k$ for several datasets, particularly where categories were less distinct (like the NY Times sports data).

Limitations and Future Work

  • Algorithm Specificity: While the paper focuses on Non-negative Matrix Factorization (NMF), the authors note that the framework is generic. However, they haven't yet extensively tested it on probabilistic models like LDA or traditional clustering like k-means.
  • Ground Truth Mismatch: The authors found that sometimes the "ground truth" labels provided by humans (like newspaper sections) don't actually match the thematic structure of the text. In these cases, the stability analysis might suggest a $k$ that is "better" than the human labels, but this is difficult to quantify objectively.
  • Future Directions: The authors suggest applying this term-centric approach to other types of data where "top-ranked features" are the primary output, such as bioinformatics.

Summary updated

BibTeX
@inproceedings{greene2014how,
  author = {Derek Greene and Derek O'Callaghan and Padraig Cunningham},
  title = {{How Many Topics? Stability Analysis for Topic Models}},
  booktitle = {Ecml/pkdd},
  year = {2014},
  doi = {10.1007/978-3-662-44848-9\_32},
}
Figure