Qu

nmf

Builtin index · Statistics & ML

result = nmf(X, [n_components=], [max_iter=200], [tol=1e-4], [seed=])

Input: X, n_components, max_iter, tol, seed · Output: result

What it is

Non-negative matrix factorization X ≈ W H of an N-row, D-column non-negative matrix X, by Lee & Seung's multiplicative updates on the Frobenius objective (a negative or non-finite entry is a named error, not silently clipped). Because nothing may be negative, components can only add to a reconstruction and never cancel, so the factors read as parts that make up the whole rather than the signed directions pca_model returns — which is what makes it usable on spectra, concentrations and counts. n_components (integer) defaults to min(N, D); max_iter (integer, default 200) caps the iterations and tol (number, default 1e-4) stops early once the relative improvement falls below it; an optional integer seed= fixes the random initialization.

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
result = nmf(X, [n_components=], [max_iter=200], [tol=1e-4], [seed=])
X matrixNon-negative matrix factorization X ≈ W H of an N-row, D-column non-negative matrix X, by Lee & Seung's multiplicative updates on the Frobenius objective (a negative or non-finite entry is a named error, not silently clipped).
n_components optionaln_components (integer) defaults to min(N, D).
max_iter number, optional (default 200)max_iter (integer, default 200) caps the iterations and tol (number, default 1e-4) stops early once the relative improvement falls below it.
tol number, optional (default 1e-4)max_iter (integer, default 200) caps the iterations and tol (number, default 1e-4) stops early once the relative improvement falls below it.
seed optionalan optional integer seed= fixes the random initialization.
w —(N, k)
h —(k, D)
reconstruction_error —the final ‖X − WH‖_F
errors —its value at every iteration, non-increasing by construction
Returns a fitted model Record with fields w ((N, k)), h ((k, D)), n_components, n_iter, reconstruction_error (the final ‖X − WH‖_F), errors (its value at every iteration, non-increasing by construction) and n_features. .predict(Xnew) returns the (M, k) non-negative encoding of new rows against the fitted H — a transform, not a reconstruction; multiply by .h to approximate Xnew itself. Added in v0.3.0.

Examples

No documentation example calls this form yet. The Statistics & ML chapter is where one belongs.