MDS
#include <Skigen/Manifold>
template <typename Scalar = double>
class Skigen::MDS(n_components=2, max_iter=300, tol=1e-3, metric=true, random_state=std::nullopt)
Multidimensional Scaling (MDS).
Non-linear dimensionality reduction through the SMACOF (Scaling by MAjorizing a COmplicated Function) algorithm. Given an input data matrix X the algorithm minimises the criterion, which measures how well pairwise Euclidean distances in the low-dimensional embedding approximate the original pairwise distances.
Mirrors sklearn.manifold.MDS.
Parameters:
-
n_components : int, default=2 Embedding dimensionality (default 2).
-
max_iter : int, default=300 Maximum SMACOF iterations (default 300).
-
tol : Scalar, default=1e-3 Convergence tolerance on relative stress change (default 1e-3).
-
metric : bool, default=true If true, metric
MDSis used (default true, the only mode supported). -
random_state : std::optional< uint64_t >, default=std::nullopt Optional seed for reproducible initialisation.
Attributes:
-
embedding : MatrixType Embedding coordinates (n_samples x n_components).
-
stress : Scalar Final stress value after fitting.
-
n_iter : int Number of SMACOF iterations performed.
Methods
SKIGEN_PARAMS()
Fit the MDS model using the SMACOF algorithm.
Computes pairwise Euclidean distances of X then iteratively optimises an n_components-dimensional embedding that preserves those distances as faithfully as possible.
Parameters:
- X Data matrix of shape (n_samples, n_features).
Returns:
- result
Reference to the fitted transformer (
*this).
transform()
Return the stored embedding.
For MDS the transform simply returns the embedding computed during fit. The input X is expected to match the training data.
Parameters:
- X Data matrix (ignored; the stored embedding is returned).
Returns:
- result : MatrixType The embedding matrix (n_samples x n_components).