← Назад в Академию
Wearing headphones, a music student places translucent coloured strips on a printed spectrogram as her tutor follows the alignment.
Знания об ИИЯдро22 нояб. 2026 г.· 3 мин

Nonnegative Matrix Factorization

Nonnegative matrix factorization splits a table of nonnegative numbers into parts and weights that sum additively. A toy spectrogram shows how components combine, why solutions vary, and how to judge reconstruction error.

matrix factorizationspectrogram analysisadditive models

Источники

Полное резюме урока

Nonnegative matrix factorization (NMF) takes a table of numbers in which every entry is zero or positive, such as a spectrogram, and approximates it as the product of two smaller nonnegative tables. One table, often called the components, holds patterns. The other, often called the weights, says how strongly each pattern appears in each column. Because nothing is negative, the patterns add together. NMF never subtracts one sound to reveal another, so every column is rebuilt by stacking scaled copies of the patterns.

Picture a hypothetical spectrogram of a two-second recording with three frequency rows and four time columns, measured in arbitrary energy units. Let the rows be 2, 4, 2, 0 then 4, 8, 4, 0 then 0, 0, 3, 6. One exact factorization uses two components. The first component is a column vector with values 1, 2, 0 and the second is 0, 0, 1. The matching weight rows are 2, 4, 2, 0 and 0, 0, 3, 6. Check one cell by hand. the second row of the third column is 2 times 2 plus 0 times 3, giving 4. At the same instant, the third frequency row receives 0 times 2 plus 1 times 3, giving 3. One component describes a low tone that fades after the second column, and the other describes a high tone that begins in the third.

A useful caution is that a component need not correspond to a single instrument. If a piano and a violin share the same frequency band, NMF may merge them into one component or split each into pieces. The parts are statistical patterns, not physical sources. Inspection of the reconstruction, usually by comparing the original table with the product and computing a squared error across all cells, shows how much structure the approximation misses.

Solutions are also nonunique. Multiply one component by 2 and divide its weight row by 2 and the product is unchanged. Different starting values or solvers can settle on different patterns with similar error, as practitioners of the scikit-learn library note. A low error supports the fit, not a unique story about the data. Two analysts can report different components from the same table.

Give pairs a small nonnegative table and ask them to propose two components by hand. Students write their component and weight tables on a card, compute the product, and post the squared error beside it. The teacher collects the cards and displays several valid answers for the same table. Invite a pair whose factor tables differ from the others to explain the comparison. Which component did you name, and what in the table supported that name? Does your reconstruction match every cell? Would a different pair of patterns fit equally well?

Finally, ask which answer would help a task such as finding when a tone starts, and which would not. A component that begins sharply in the third column serves that timing task, while a blended pattern may not. This connects the mathematics to the purpose of the analysis and keeps interpretation honest. Students see that a good fit and a useful reading are separate judgments, each supported by evidence they can show.