Decomposition Laplacian Eigenmap#
laplacian_eigenmap
#
| CLASS | DESCRIPTION |
|---|---|
LaplacianEigenmap |
Laplacian eigenmaps for nonlinear dimensionality reduction. |
| FUNCTION | DESCRIPTION |
|---|---|
laplacian_eigenmap |
Compute Laplacian eigenmap embedding. |
Classes#
LaplacianEigenmap(*, kernel_fn: Kernel | str = 'gaussian', kernel_kwargs: dict | None = None, distance_fn: PairwiseDistance | str = 'euclidean', distance_kwargs: dict | None = None, score_fn: Callable | None = None, out_features: int = 0, symmetric_eigendecomposition: bool = True)
#
Bases: Decomposition
Laplacian eigenmaps for nonlinear dimensionality reduction.
Laplacian eigenmaps use graph Laplacian eigendecomposition to find a low-dimensional embedding that preserves local neighborhood structure [@belkin2001laplacian,belkin2003laplacian].
The method constructs a graph Laplacian from pairwise similarities and uses the smallest non-trivial eigenvectors as embedding coordinates.
This implementation uses a modular architecture that separates pairwise distance computation from kernel computation. The kernel must have a normalization configured to construct the appropriate Laplacian type.
| PARAMETER | DESCRIPTION |
|---|---|
kernel_fn
|
Kernel function for similarity computation. Can be a Kernel instance,
string name of a kernel, or None. Use kernel's
TYPE:
|
kernel_kwargs
|
Additional keyword arguments to pass to the kernel function if
TYPE:
|
distance_fn
|
Pairwise distance function. Can be a PairwiseDistance instance, string name of a distance function, or None.
TYPE:
|
distance_kwargs
|
Additional keyword arguments to pass to the distance function if
TYPE:
|
score_fn
|
Scoring function to evaluate the model. Must be callable if provided. If None,
TYPE:
|
out_features
|
Number of eigenvectors to compute. If 0, computes all eigenvectors. Must be non-negative.
TYPE:
|
symmetric_eigendecomposition
|
Whether to perform symmetric eigendecomposition.
TYPE:
|
| ATTRIBUTE | DESCRIPTION |
|---|---|
eigenvalues |
Eigenvalues from kernel matrix decomposition of shape (out_features, ).
TYPE:
|
eigenvectors |
Eigenvectors from kernel matrix decomposition of shape (n_samples, out_features).
TYPE:
|
diffusion_coordinates |
Diffusion coordinates extracted from the eigenvectors (n_samples, out_features) or (n_samples, out_features - 1).
TYPE:
|
kernel |
Computed kernel matrix of shape (n_samples, n_samples).
TYPE:
|
explained_variance |
Explained variance for each component.
TYPE:
|
cumulative_explained_variance |
Cumulative explained variance for components.
TYPE:
|
| METHOD | DESCRIPTION |
|---|---|
score |
Compute score using the provided scoring function. |
fit |
Fit the Laplacian eigenmap to the provided data. |
predict |
Return extrapolation of the fitted Laplacian embedding coordinates |
Source code in spectre/decomposition/laplacian_eigenmap.py
Attributes#
explained_variance: torch.Tensor
property
#
Explained variance for each diffusion component.
cumulative_explained_variance: torch.Tensor
property
#
Cumulative explained variance for embedding dimensions.
eigenvalues: torch.Tensor
property
#
Eigenvalues of the Laplacian matrix.
eigenvectors: torch.Tensor
property
#
Eigenvectors of the Laplacian matrix.
kernel: torch.Tensor
property
#
Computed Laplacian matrix.
Functions#
score(X: torch.Tensor, weights: torch.Tensor | None = None, target: torch.Tensor | None = None, **kwargs) -> float | torch.Tensor
#
Compute score using the provided scoring function.
| PARAMETER | DESCRIPTION |
|---|---|
X
|
Input data of shape (n_samples, n_features).
TYPE:
|
weights
|
Sample weights of shape (n_samples,).
TYPE:
|
target
|
Target values for scoring.
TYPE:
|
**kwargs
|
Additional keyword arguments passed to the scoring function.
DEFAULT:
|
| RETURNS | DESCRIPTION |
|---|---|
float | Tensor
|
Score computed by the scoring function. |
Source code in spectre/decomposition/laplacian_eigenmap.py
fit(X: torch.Tensor, weights: torch.Tensor | None = None, target: torch.Tensor | None = None) -> LaplacianEigenmap
#
Fit the Laplacian eigenmap to the provided data.
| PARAMETER | DESCRIPTION |
|---|---|
X
|
Training data of shape (n_samples, n_features).
TYPE:
|
weights
|
Sample weights of shape (n_samples,).
TYPE:
|
target
|
Not used in Laplacian eigenmaps (unsupervised method).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
LaplacianEigenmap
|
Returns self for method chaining. |
Source code in spectre/decomposition/laplacian_eigenmap.py
predict(X: torch.Tensor) -> torch.Tensor
#
Return extrapolation of the fitted Laplacian embedding coordinates using Nystrom extension.
| PARAMETER | DESCRIPTION |
|---|---|
X
|
Input data of shape (n_samples, n_features).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Tensor
|
Embedding coordinates of shape (n_samples, out_features). |
Source code in spectre/decomposition/laplacian_eigenmap.py
Functions#
laplacian_eigenmap(X: torch.Tensor, weights: torch.Tensor | None = None, *, kernel_fn: Kernel, distance_fn: PairwiseDistance, out_features: int = 0, symmetric_eigendecomposition: bool = True) -> DecompositionResult
#
Compute Laplacian eigenmap embedding.
See [@belkin2001laplacian,belkin2003laplacian].
This function provides a modular approach to Laplacian eigenmaps by separating pairwise distance computation from kernel computation. The kernel must have a normalization configured to construct the appropriate Laplacian type.
| PARAMETER | DESCRIPTION |
|---|---|
Parameters
|
|
X
|
Input data of shape (n_samples, out_features).
TYPE:
|
weights
|
Sample weights of shape (n_samples,). If None, weights are assigned ones.
TYPE:
|
kernel_fn
|
Kernel function for similarity computation. Must be a Kernel instance.
Use kernel's
TYPE:
|
distance_fn
|
Pairwise distance function. Must be a PairwiseDistance instance.
TYPE:
|
out_features
|
Number of eigenvectors to compute. If 0, computes all eigenvectors. Must be non-negative.
TYPE:
|
symmetric_eigendecomposition
|
Whether to compute symmetric eigendecomposition.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
DecompositionResult
|
A tuple containing:
|
Source code in spectre/decomposition/laplacian_eigenmap.py
272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 | |