SpectralEmbedding
Laplacian eigenmaps: a spectral embedding from the eigenvectors of the graph Laplacian of a neighbourhood affinity graph.
Algorithm
Constructs an affinity graph (nearest-neighbours by default), forms the normalised Laplacian, and embeds using its smallest non-trivial eigenvectors.
Constructor
Skigen::SpectralEmbedding<Scalar> model(
int n_components = 2,
int n_neighbors = 5,
std::string eigen_solver = "auto",
std::optional<uint64_t> random_state = std::nullopt);
Parameters
| Parameter | Default | Description |
|---|---|---|
n_components | 2 | Embedding dimensionality. |
n_neighbors | 5 | Neighbours in the affinity graph. |
eigen_solver | "auto" | "auto", "arpack", or "dense" (sklearn spelling). |
Eigensolver backend
The Laplacian eigendecomposition runs through a shared helper that defaults to Eigen's dense SelfAdjointEigenSolver. When Skigen is built with -DSKIGEN_ENABLE_SPECTRA and the header-only Spectra library is reachable, eigen_solver="arpack" (and "auto" on large problems) uses a truncated ARPACK-style iterative solve that computes only the bottom eigenpairs — much cheaper when n_components << n_samples. Eigen remains the sole required dependency: with the flag off, only the dense path is compiled and "arpack" transparently falls back to dense. An unknown solver name raises std::invalid_argument.
Methods
| Method | Description |
|---|---|
fit_transform(X) | Return the embedding. |
Fitted Attributes
| Accessor | Description |
|---|---|
affinity_matrix() | The constructed affinity graph. |
Example
Skigen::SpectralEmbedding<double> se(2, 5);
auto Y = se.fit_transform(X);
This estimator is checked by the parity suite. See the generator tests/parity/generate_manifold_reference.py and the reference fixtures in tests/parity/data/spectral_embedding/, exercised by tests/parity/parity_manifold.cpp.
For full signatures see the SpectralEmbedding API Reference.