Non-negative Matrix Factorization for Topics
You have fifty thousand support tickets, no labels, and one question: what is in here? Arrange them as a big table of word counts, split that table into two smaller non-negative tables, and the pieces come back reading like themes.
The factorisation
Non-negative Matrix Factorization approximates a document-term matrix V — typically TF-IDF weighted — as the product of two matrices: W, giving each document a weight for each of k topics, and H, giving each topic a weight for each word. The solver minimises reconstruction error (Frobenius norm or a KL-style divergence) by alternating updates. Because no entry may go negative, nothing can cancel out, so a document must be built up as an additive mixture of parts. That constraint is the whole reason the output is readable, and it is what separates NMF from an SVD-based Latent Semantic Analysis, whose negative loadings resist interpretation.
In practice
- Run TfidfVectorizer then NMF in scikit-learn, and print the top-weighted words of each row of H — those word lists are your topics, and you name them by hand.
- It is faster and more stable run-to-run than LDA, and frequently crisper on short texts like tickets, reviews and survey answers.
- There is no generative probability model behind it, so there is no held-out likelihood to quote; evaluate with topic coherence and by reading the topics.
- k is yours to choose, and the topics genuinely change with it — there is no setting that reveals the true number.
Why it matters
This is how an unlabelled corpus gets its first map, before anyone writes a classifier. The common failure is upstream rather than in the solver: leave boilerplate signatures and stop words in, and you get a topic about “regards” and “unsubscribe” — document-frequency pruning does more for topic quality than any tuning of the factorisation.
Non-negative Matrix Factorization for topics approximates a document-term matrix, usually TF-IDF weighted, as the product of a document-topic matrix and a topic-word matrix whose entries cannot go negative. Because nothing cancels, each document reads as an additive mixture of word groups, making the components directly interpretable as topics. It is faster and more reproducible than LDA and often crisper on short texts, but it offers no probability model, so topics are judged by coherence.
Picture a librarian faced with a thousand unsorted articles. Without reading any of them properly, they flick through, notice which words keep turning up together, and end up with piles: one about weather, one about sport, one about money. Articles can belong to more than one pile.
Non-negative Matrix Factorization does that sorting by arithmetic. It breaks a big table of word counts into two smaller tables — which words make up each theme, and how much of each theme is in each document. The rule that no number may be negative is what keeps the result readable: themes only ever add up, never cancel out. Companies use it to find out what customers are complaining about.