Table of Contents

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

T

The numeric type for calculations (e.g., float, double).

Inheritance
TransformerBase<T, Matrix<T>, Matrix<T>>
DiffusionMaps<T>
Implements
IDataTransformer<T, Matrix<T>, Matrix<T>>
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

nComponents int

Target dimensionality. Defaults to 2.

alpha double

Normalization factor (0 to 1). Defaults to 0.5.

diffusionTime int

Number of diffusion steps. Defaults to 1.

epsilon double

Kernel bandwidth. If 0, computed automatically. Defaults to 0.

randomState int?

Random seed for reproducibility.

columnIndices int[]

The column indices to use, or null for all columns.

Properties

DiffusionTime

Gets the diffusion time parameter.

public int DiffusionTime { get; }

Property Value

int

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

int

SupportsInverseTransform

Gets whether this transformer supports inverse transformation.

public override bool SupportsInverseTransform { get; }

Property Value

bool

Methods

FitCore(Matrix<T>)

Fits Diffusion Maps and computes the embedding.

protected override void FitCore(Matrix<T> data)

Parameters

data Matrix<T>

GetFeatureNamesOut(string[]?)

Gets the output feature names after transformation.

public override string[] GetFeatureNamesOut(string[]? inputFeatureNames = null)

Parameters

inputFeatureNames string[]

Returns

string[]

InverseTransformCore(Matrix<T>)

Inverse transformation is not supported.

protected override Matrix<T> InverseTransformCore(Matrix<T> data)

Parameters

data Matrix<T>

Returns

Matrix<T>

TransformCore(Matrix<T>)

Returns the embedding computed during Fit.

protected override Matrix<T> TransformCore(Matrix<T> data)

Parameters

data Matrix<T>

Returns

Matrix<T>