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
TThe numeric type for calculations (e.g., float, double).
- Inheritance
-
LocallyLinearEmbedding<T>
- Implements
- 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
nComponentsintTarget dimensionality. Defaults to 2.
nNeighborsintNumber of neighbors. Defaults to 5.
regdoubleRegularization constant. Defaults to 0.001.
methodLLEMethodLLE algorithm variant. Defaults to Standard.
columnIndicesint[]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
NComponents
Gets the number of components.
public int NComponents { get; }
Property Value
NNeighbors
Gets the number of neighbors.
public int NNeighbors { get; }
Property Value
Regularization
Gets the regularization parameter.
public double Regularization { get; }
Property Value
SupportsInverseTransform
Gets whether this transformer supports inverse transformation.
public override bool SupportsInverseTransform { get; }
Property Value
Methods
FitCore(Matrix<T>)
Fits LLE by computing reconstruction weights and 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>