Table of Contents

Class LocallyLinearEmbedding<T>

Namespace
AiDotNet.Preprocessing.DimensionalityReduction
Assembly
AiDotNet.dll

Locally Linear Embedding for nonlinear dimensionality reduction.

public class LocallyLinearEmbedding<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>>
LocallyLinearEmbedding<T>
Implements
IDataTransformer<T, Matrix<T>, Matrix<T>>
Inherited Members

Remarks

LLE preserves local neighborhood structure by representing each point as a weighted linear combination of its neighbors. The embedding is found by preserving these reconstruction weights in lower dimensions.

The algorithm: 1. Find k nearest neighbors for each point 2. Compute reconstruction weights that best reconstruct each point from neighbors 3. Find low-dimensional embedding that preserves these weights

For Beginners: LLE preserves local relationships: - Each point is described by its neighbors - The weights describe "how much" each neighbor contributes - The embedding keeps these relationships intact - Good for unfolding curved manifolds (like the Swiss roll)

Constructors

LocallyLinearEmbedding(int, int, double, LLEMethod, int[]?)

Creates a new instance of LocallyLinearEmbedding<T>.

public LocallyLinearEmbedding(int nComponents = 2, int nNeighbors = 5, double reg = 0.001, LLEMethod method = LLEMethod.Standard, int[]? columnIndices = null)

Parameters

nComponents int

Target dimensionality. Defaults to 2.

nNeighbors int

Number of neighbors. Defaults to 5.

reg double

Regularization constant. Defaults to 0.001.

method LLEMethod

LLE algorithm variant. Defaults to Standard.

columnIndices int[]

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

Properties

Embedding

Gets the embedding result.

public double[,]? Embedding { get; }

Property Value

double[,]

Method

Gets the LLE method.

public LLEMethod Method { get; }

Property Value

LLEMethod

NComponents

Gets the number of components.

public int NComponents { get; }

Property Value

int

NNeighbors

Gets the number of neighbors.

public int NNeighbors { get; }

Property Value

int

Regularization

Gets the regularization parameter.

public double Regularization { get; }

Property Value

double

SupportsInverseTransform

Gets whether this transformer supports inverse transformation.

public override bool SupportsInverseTransform { get; }

Property Value

bool

Methods

FitCore(Matrix<T>)

Fits LLE by computing reconstruction weights and 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>