Overview
Locally Linear Embedding (LLE) performs non-linear dimensionality reduction by preserving local linear relationships between neighbors. It assumes data lies on a locally linear manifold.
Constructor
new LocallyLinearEmbedding ( options ?: LocallyLinearEmbeddingOptions )
options
LocallyLinearEmbeddingOptions
Configuration options for LLE Number of neighbors to consider for each point.
Number of dimensions in the embedding space.
Regularization parameter for weight matrix computation.
Methods
fit
Compute the LLE embedding from training data.
Training data of shape [nSamples, nFeatures]
Returns: The fitted LocallyLinearEmbedding instance
fitTransform ( X : Matrix ): Matrix
Fit the model and return the embedding.
Training data of shape [nSamples, nFeatures]
Returns: Embedded data of shape [nSamples, nComponents]
transform ( X : Matrix ): Matrix
Transform new data using the fitted model.
New data to transform of shape [nSamples, nFeatures]
Returns: Embedded data of shape [nSamples, nComponents]
Properties
Embedded coordinates in low-dimensional space, shape [nSamples, nComponents]
Reconstruction error of the embedding
Number of features seen during fit
Example
import { LocallyLinearEmbedding } from '@elucidate/elucidate' ;
// Manifold data
const data = [
[ 1.0 , 2.0 , 1.0 ],
[ 1.2 , 2.1 , 1.1 ],
[ 1.1 , 2.3 , 1.2 ],
[ 2.0 , 3.0 , 2.0 ],
[ 2.1 , 3.2 , 2.1 ],
[ 2.2 , 3.1 , 2.2 ],
];
const lle = new LocallyLinearEmbedding ({
nNeighbors: 3 ,
nComponents: 2 ,
reg: 1e-3
});
const embedding = lle . fitTransform ( data );
console . log ( 'Embedded coordinates:' , embedding );
console . log ( 'Reconstruction error:' , lle . reconstructionError_ );
// Transform new data
const newData = [
[ 1.5 , 2.5 , 1.5 ],
[ 2.5 , 3.5 , 2.5 ],
];
const newEmbedding = lle . transform ( newData );
console . log ( 'New points embedded:' , newEmbedding );
Notes
LLE works best for data on smooth, locally linear manifolds
The reg parameter helps with numerical stability
The algorithm preserves local geometry but may distort global structure
Requires careful selection of nNeighbors based on data density