SpectralEmbedding
#include <Skigen/Manifold>
template <typename Scalar = double>
class Skigen::SpectralEmbedding(n_components=2, n_neighbors=5, random_state=std::nullopt)
Spectral embedding for non-linear dimensionality reduction (Laplacian Eigenmaps).
Projects data into a lower-dimensional space by computing the bottom eigenvectors of the normalized graph Laplacian built from a K-nearest neighbor affinity graph with a heat kernel.
Mirrors sklearn.manifold.SpectralEmbedding.
Parameters:
-
n_components : int, default=2 Dimension of the projected subspace (default 2).
-
n_neighbors : int, default=5 Number of nearest neighbors for the affinity graph (default 5).
-
random_state : std::optional< uint64_t >, default=std::nullopt Optional RNG seed (default nullopt).
Attributes:
-
embedding : MatrixType Spectral embedding of the training data (n_samples x n_components).
-
affinity_matrix : MatrixType Affinity matrix from the training data (n_samples x n_samples).
Methods
SKIGEN_PARAMS()
Fit the spectral embedding on training data X.
Builds the KNN affinity graph, computes the normalized Laplacian, and extracts the bottom eigenvectors as the embedding.
Parameters:
- X Training data of shape (n_samples, n_features).
Returns:
- result
Reference to the fitted transformer (
*this).
transform()
Return the stored embedding (for the training data) or project new data using the Nystroem out-of-sample extension.
For new data, computes affinities to training points and uses the fitted Laplacian eigenvectors to produce an approximate embedding. When called on the training data itself, returns the stored embedding.
Parameters:
- X Data matrix of shape (n_samples, n_features).
Returns:
- result : MatrixType Transformed data of shape (n_samples, n_components).