mojolearn.ClassicalMDS#
- class mojolearn.ClassicalMDS(n_components=2, *, metric='euclidean', metric_params=None, numeric_mode=None)[source]#
Bases:
_BaseClassical (Torgerson) multidimensional scaling.
Follows scikit-learn’s
ClassicalMDS: double-centers-0.5 * D**2for the pairwise distances D and embeds by its top eigenvectors scaled by the square roots of the eigenvalues.- Parameters:
n_components (int, default 2) – Embedding dimension.
metric (str, default “euclidean”) –
"precomputed"(X is a distance matrix) or a distance metric:"euclidean","l2","minkowski"(pfrommetric_params),"manhattan"("cityblock","l1"),"chebyshev"("infinity") or"cosine"; a callable or any other name raises NotImplementedError.metric_params (dict or None, default None) – Only
{"p": ...}is supported.numeric_mode ({“identical”, “fast”} or None, default None) – Numeric mode for this estimator. None uses the package default (
"identical"unless changed)."identical"gives the same bits on NVIDIA and AMD GPUs;"fast"applies on Apple GPUs.
- Variables:
embedding_ (ndarray of shape (n_samples, n_components))
eigenvalues_ (ndarray of shape (n_components,))
dissimilarity_matrix_ (ndarray of shape (n_samples, n_samples))
n_features_in_ (int)
Examples
>>> import numpy as np, mojolearn >>> X = np.random.default_rng(0).random((500, 8), dtype=np.float32) >>> Y = mojolearn.ClassicalMDS(n_components=2).fit_transform(X)
Methods
fit(X[, y])Compute the embedding.
fit_transform(X[, y])Compute the embedding and return
embedding_.get_params([deep])Return this estimator's constructor parameters.
set_params(**params)Set constructor parameters by keyword.