Decomposition Lodestar.Decomposition - CyrilB1531/lodestar GitHub Wiki

Development build. This page describes main, not a released package. The latest published Lodestar.Decomposition is 0.3.0 — read its documentation.

Home › Decomposition

Lodestar.Decomposition

Truncated SVD and non-negative matrix factorization over a sparse matrix, without centring it: latent semantic analysis on a term-document matrix, with the explained variance, and NMF for a parts-based decomposition. Randomized SVD with all three power-iteration normalizers, the Householder QR, and the variance principal components explain. The dense kernels are written here, so the only dependency is Lodestar.Abstractions.

Install

dotnet add package Lodestar.Decomposition

Example

using Lodestar.Abstractions;
using Lodestar.Decomposition;

// Row-major CSR: values, the column each sits in, and where each row starts.
CsrMatrix matrix = new(
    4, 3,
    [3.0, 1.0, 2.0, 1.0, 1.0, 4.0, 2.0, 3.0],
    [0, 1, 0, 2, 1, 2, 0, 2],
    [0, 2, 4, 6, 8]);

TruncatedSvd fitted = TruncatedSvd.Fit(matrix, 2);
double first = fitted.SingularValues[0];   // 5.614…

Parity

Replayed against sklearn.decomposition.TruncatedSVD and NMF. docs/equivalence.md maps each Python call to its C# counterpart, with every deliberate divergence.

Dependencies

A core package (decision 0003), built for net10.0 and netstandard2.0:

  • Lodestar.Abstractions 0.2.0 or later

Documentation