TruncatedSVD<T>

Models & Types · AiDotNet.Preprocessing.DimensionalityReduction

Truncated Singular Value Decomposition for dimensionality reduction.

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

For Beginners

SVD is similar to PCA but:

  • Doesn’t center the data (preserves sparsity in sparse matrices)
  • Can be more memory-efficient for large sparse datasets
  • Often used for text analysis (finding hidden topics in documents)

Example: In text analysis, TruncatedSVD can find that “car” and “automobile” are related even if they never appear together in the same document.

How It Works

TruncatedSVD performs dimensionality reduction by computing the truncated singular value decomposition. Unlike PCA, it does not center the data, making it suitable for sparse matrices (e.g., TF-IDF from text).

Also known as Latent Semantic Analysis (LSA) when applied to document-term matrices.

Constructors

Constructor Summary
TruncatedSVD(int nComponents, int nIterations, int randomState, int[] columnIndices) Creates a new instance of TruncatedSVD.

Properties

Property Summary
Matrix<T> Components { get; } Gets the components (right singular vectors).
Vector<T> ExplainedVariance { get; } Gets the explained variance for each component.
Vector<T> ExplainedVarianceRatio { get; } Gets the explained variance ratio for each component.
Vector<T> SingularValues { get; } Gets the singular values.
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 for randomized SVD.

Methods

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