NMF<T>

Models & Types · AiDotNet.Preprocessing.DimensionalityReduction

Non-negative Matrix Factorization for dimensionality reduction.

Inheritance: TransformerBase<T, Matrix<T>, Matrix<T>> → NMF<T>

For Beginners

NMF learns “building blocks” from your data:

  • For images: NMF might learn eyes, noses, mouths as separate components
  • For text: NMF might learn topics as combinations of words
  • Unlike PCA, components are always positive (additive, never subtractive)

Think of it as finding the parts that, when added together, recreate your data.

How It Works

NMF factorizes a non-negative matrix V into two non-negative matrices W and H such that V ≈ W × H. This is useful for data that is naturally non-negative (e.g., images, text term frequencies, audio spectrograms).

Unlike PCA, NMF produces parts-based representations where each component represents an additive combination of non-negative features.

Constructors

Constructor Summary
NMF(int nComponents, NMFInit init, NMFSolver solver, double beta, double alpha, double l1Ratio, int maxIterations, double tolerance, int randomState, int[] columnIndices) Creates a new instance of NMF.

Properties

Property Summary
Matrix<T> Components { get; } Gets the learned components (H matrix).
NMFSolver Solver { get; } Gets the solver type.
T ReconstructionError { get; } Gets the final reconstruction error.
bool SupportsInverseTransform { get; } Gets whether this transformer supports inverse transformation.
int NComponents { get; } Gets the number of components.
int NIterations { get; } Gets the number of iterations performed.

Methods

Method Summary
string[] GetFeatureNamesOut(string[] inputFeatureNames) Gets the output feature names after transformation.