Class LaplacianEigenmaps<T>
- Namespace
- AiDotNet.Preprocessing.DimensionalityReduction
- Assembly
- AiDotNet.dll
Laplacian Eigenmaps for nonlinear dimensionality reduction.
public class LaplacianEigenmaps<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
-
LaplacianEigenmaps<T>
- Implements
- Inherited Members
Remarks
Laplacian Eigenmaps constructs a weighted graph from the data and finds a low-dimensional embedding that preserves local neighborhood relationships by minimizing a cost function based on the graph Laplacian.
The algorithm: 1. Constructs a k-nearest neighbor or epsilon-neighborhood graph 2. Computes edge weights using a kernel (e.g., heat kernel) 3. Computes the graph Laplacian: L = D - W 4. Finds eigenvectors of the generalized eigenvalue problem: L*y = λ*D*y
For Beginners: Laplacian Eigenmaps finds a low-dimensional representation where: - Connected points in the graph stay close together - The embedding respects the local geometry of the data - It's similar to spectral clustering but for dimensionality reduction
Use cases:
- Manifold learning when data lies on a curved surface
- Image segmentation and clustering
- When you want to preserve local connectivity
Constructors
LaplacianEigenmaps(int, int, double?, LaplacianAffinityType, double, int?, int[]?)
Creates a new instance of LaplacianEigenmaps<T>.
public LaplacianEigenmaps(int nComponents = 2, int nNeighbors = 5, double? radius = null, LaplacianAffinityType affinity = LaplacianAffinityType.NearestNeighbors, double gamma = 1, int? randomState = null, int[]? columnIndices = null)
Parameters
nComponentsintTarget dimensionality. Defaults to 2.
nNeighborsintNumber of neighbors for graph construction. Defaults to 5.
radiusdouble?Radius for epsilon-neighborhood (if null, uses k-NN). Defaults to null.
affinityLaplacianAffinityTypeAffinity type for edge weights. Defaults to NearestNeighbors.
gammadoubleKernel coefficient for RBF affinity. Defaults to 1.0.
randomStateint?Random seed for reproducibility.
columnIndicesint[]The column indices to use, or null for all columns.
Properties
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
NNeighbors
Gets the number of neighbors.
public int NNeighbors { get; }
Property Value
SupportsInverseTransform
Gets whether this transformer supports inverse transformation.
public override bool SupportsInverseTransform { get; }
Property Value
Methods
FitCore(Matrix<T>)
Fits Laplacian Eigenmaps 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>