NMF breaks a big "who bought what" table into two smaller ones — people-to-tastes and tastes-to-products. Multiply the two back together and the empty cells fill in with what each person would probably buy.
Where you meet it
- Recommender systems — the "people who bought this also bought…" behind shops and streaming.
- Topic modelling: a documents-by-words table split into documents-by-topics and topics-by-words.
- Parts in images and audio: faces into facial features, a music mix into separate instruments.
- scikit-learn's
decomposition.NMF— and the exam question "why NMF and not just SVD?"
What it does
It discovers a handful of hidden tastes that nobody wrote down, describes every person as a blend of them and every product as belonging to them, then rebuilds the table from those blends — so the blank cells come out with a predicted score.
Nobody labels the tastes — the factorisation invents them, then recommends what your taste-twins already bought.
How it works
Non-negativity is the whole trick. Because the pieces may only add up, never subtract, each taste ends up a lump of things that go together. That is exactly what Lee & Seung found in 1999: NMF on face photos learns a nose, eyebrows, lips — nameable parts. PCA and SVD, which allow minus signs, give ghostly whole-face blends you can't put a word to.
V ≈ W · H
6×5 6×k k×5 # k hidden "tastes" — you pick k
# start W, H random and non-negative, then repeat:
# nudge W and H so W·H matches the cells you actually observed
# keep every entry ≥ 0 the whole time
V̂ = W · H # a high value in a once-empty cell = a recommendation
"Collaborative" means the crowd fills your blanks: your gaps get scored from the pattern of people whose tastes look like yours.
Watch out
- A 0 is not a "no". In a buys or ratings table most blanks mean "hasn't seen it", not "dislikes it". Fit only on the cells you actually observed (this tool greys the unknowns out) — pour raw zeros in and NMF learns to predict rejection everywhere.
- One run isn't the answer. The objective isn't convex; the updates only promise the error won't rise, so different random starts land on different
WandH. Run it a few times and keep the best. - Factors aren't unique numbers. You can stretch one taste and shrink its matching row of
Hand rebuild the exact sameV— so read a taste by which products light up together, never by the raw values.
Non-negativity is the trick: parts may only add up — so the pieces stay things you can name.
Go deeper
NMF zerlegt eine große Tabelle „wer kaufte was" in zwei kleinere — Personen-zu-Vorlieben und Vorlieben-zu-Produkten. Multipliziert man beide zurück, füllen sich die leeren Zellen mit dem, was jede Person wohl kaufen würde.
Wo es vorkommt
- Empfehlungssysteme — das „wer das kaufte, kaufte auch…" hinter Shops und Streaming.
- Topic Modeling: eine Dokumente-mal-Wörter-Tabelle, geteilt in Dokumente-mal-Themen und Themen-mal-Wörter.
- Teile in Bildern und Audio: Gesichter in Gesichtszüge, ein Musik-Mix in einzelne Instrumente.
- scikit-learns
decomposition.NMF— und die Klausurfrage „warum NMF und nicht einfach SVD?"
Was es tut
Es entdeckt eine Handvoll verborgener Vorlieben, die niemand aufgeschrieben hat, beschreibt jede Person als Mischung daraus und jedes Produkt als Zugehörigkeit dazu — und baut die Tabelle aus diesen Mischungen neu auf, sodass die leeren Zellen einen vorhergesagten Wert bekommen.
Niemand benennt die Vorlieben — die Faktorisierung erfindet sie selbst und empfiehlt dann, was deine Geschmacks-Zwillinge längst gekauft haben.
Wie es funktioniert
Nicht-Negativität ist der ganze Trick. Weil sich die Teile nur addieren, nie abziehen dürfen, wird jede Vorliebe ein Klumpen zusammengehöriger Dinge. Genau das fanden Lee & Seung 1999: NMF auf Gesichtsfotos lernt Nase, Augenbrauen, Lippen — benennbare Teile. PCA und SVD, die Minuszeichen erlauben, liefern geisterhafte Ganz-Gesicht-Mischungen, für die man kein Wort hat.
V ≈ W · H
6×5 6×k k×5 # k verborgene „Vorlieben" — k wählst du
# starte W, H zufällig und nicht-negativ, dann wiederhole:
# schiebe W und H so, dass W·H die tatsächlich beobachteten Zellen trifft
# jeder Eintrag bleibt die ganze Zeit ≥ 0
V̂ = W · H # ein hoher Wert in einer einst leeren Zelle = eine Empfehlung
„Collaborative" heißt, die Menge füllt deine Lücken: deine Leerstellen werden aus dem Muster jener geschätzt, deren Vorlieben deinen ähneln.
Worauf achten
- Eine 0 ist kein „Nein". In einer Kauf- oder Rating-Tabelle heißen die meisten Leerstellen „noch nicht gesehen", nicht „mag ich nicht". Trainiere nur auf den tatsächlich beobachteten Zellen (dieses Tool blendet die Unbekannten grau aus) — kippst du rohe Nullen hinein, lernt NMF, überall Ablehnung vorherzusagen.
- Ein Lauf ist nicht die Antwort. Die Zielfunktion ist nicht konvex; die Updates versprechen nur, dass der Fehler nicht steigt — verschiedene Zufalls-Starts landen auf verschiedenen
WundH. Ein paar Läufe, den besten behalten. - Faktoren sind keine eindeutigen Zahlen. Du kannst eine Vorliebe strecken und die zugehörige
H-Zeile stauchen und bekommst exakt dasselbeV— lies eine Vorliebe also daran, welche Produkte gemeinsam aufleuchten, nie an den rohen Werten.
Nicht-Negativität ist der Trick: Teile dürfen sich nur addieren — so bleiben die Stücke Dinge, die man benennen kann.