Class DiffusionMaps<T>
- Namespace
- AiDotNet.Preprocessing.DimensionalityReduction
- Assembly
- AiDotNet.dll
Diffusion Maps for nonlinear dimensionality reduction.
public class DiffusionMaps<T> : TransformerBase<T, Matrix<T>, Matrix<T>>, IDataTransformer<T, Matrix<T>, Matrix<T>>
Type Parameters
TThe numeric type for calculations (e.g., float, double).
- Inheritance
-
DiffusionMaps<T>
- Implements
- Inherited Members
Remarks
Diffusion Maps embeds data into a low-dimensional space where Euclidean distances approximate diffusion distances on the data manifold. It simulates a random walk on the data graph and uses the eigenvectors of the diffusion operator.
The algorithm: 1. Constructs a kernel matrix (typically Gaussian) 2. Normalizes to create a Markov transition matrix 3. Computes eigenvectors of the diffusion operator 4. Scales eigenvectors by eigenvalue powers for embedding
For Beginners: Diffusion Maps captures the underlying geometry by: - Simulating how information "diffuses" through the data - Points connected by many short paths are close in diffusion distance - Robust to noise compared to geodesic distances
Use cases:
- Discovering underlying manifold structure
- Robust to noise in the data
- When you want distances to reflect connectivity, not just proximity
Constructors
DiffusionMaps(int, double, int, double, int?, int[]?)
Creates a new instance of DiffusionMaps<T>.
public DiffusionMaps(int nComponents = 2, double alpha = 0.5, int diffusionTime = 1, double epsilon = 0, int? randomState = null, int[]? columnIndices = null)
Parameters
nComponentsintTarget dimensionality. Defaults to 2.
alphadoubleNormalization factor (0 to 1). Defaults to 0.5.
diffusionTimeintNumber of diffusion steps. Defaults to 1.
epsilondoubleKernel bandwidth. If 0, computed automatically. Defaults to 0.
randomStateint?Random seed for reproducibility.
columnIndicesint[]The column indices to use, or null for all columns.
Properties
DiffusionTime
Gets the diffusion time parameter.
public int DiffusionTime { get; }
Property Value
Eigenvalues
Gets the eigenvalues.
public double[]? Eigenvalues { get; }
Property Value
- double[]
Embedding
Gets the embedding result.
public double[,]? Embedding { get; }
Property Value
- double[,]
NComponents
Gets the number of components (dimensions).
public int NComponents { get; }
Property Value
SupportsInverseTransform
Gets whether this transformer supports inverse transformation.
public override bool SupportsInverseTransform { get; }
Property Value
Methods
FitCore(Matrix<T>)
Fits Diffusion Maps and computes the embedding.
protected override void FitCore(Matrix<T> data)
Parameters
dataMatrix<T>
GetFeatureNamesOut(string[]?)
Gets the output feature names after transformation.
public override string[] GetFeatureNamesOut(string[]? inputFeatureNames = null)
Parameters
inputFeatureNamesstring[]
Returns
- string[]
InverseTransformCore(Matrix<T>)
Inverse transformation is not supported.
protected override Matrix<T> InverseTransformCore(Matrix<T> data)
Parameters
dataMatrix<T>
Returns
- Matrix<T>
TransformCore(Matrix<T>)
Returns the embedding computed during Fit.
protected override Matrix<T> TransformCore(Matrix<T> data)
Parameters
dataMatrix<T>
Returns
- Matrix<T>