package sklearn

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
type tag = [
  1. | `MDS
]
type t = [ `BaseEstimator | `MDS | `Object ] Obj.t
val of_pyobject : Py.Object.t -> t
val to_pyobject : [> tag ] Obj.t -> Py.Object.t
val as_estimator : t -> [ `BaseEstimator ] Obj.t
val create : ?n_components:int -> ?metric:bool -> ?n_init:int -> ?max_iter:int -> ?verbose:int -> ?eps:float -> ?n_jobs:int -> ?random_state:int -> ?dissimilarity:[ `Euclidean | `Precomputed ] -> unit -> t

Multidimensional scaling

Read more in the :ref:`User Guide <multidimensional_scaling>`.

Parameters ---------- n_components : int, optional, default: 2 Number of dimensions in which to immerse the dissimilarities.

metric : boolean, optional, default: True If ``True``, perform metric MDS; otherwise, perform nonmetric MDS.

n_init : int, optional, default: 4 Number of times the SMACOF algorithm will be run with different initializations. The final results will be the best output of the runs, determined by the run with the smallest final stress.

max_iter : int, optional, default: 300 Maximum number of iterations of the SMACOF algorithm for a single run.

verbose : int, optional, default: 0 Level of verbosity.

eps : float, optional, default: 1e-3 Relative tolerance with respect to stress at which to declare convergence.

n_jobs : int or None, optional (default=None) The number of jobs to use for the computation. If multiple initializations are used (``n_init``), each run of the algorithm is computed in parallel.

``None`` means 1 unless in a :obj:`joblib.parallel_backend` context. ``-1`` means using all processors. See :term:`Glossary <n_jobs>` for more details.

random_state : int, RandomState instance, default=None Determines the random number generator used to initialize the centers. Pass an int for reproducible results across multiple function calls. See :term: `Glossary <random_state>`.

dissimilarity : 'euclidean' | 'precomputed', optional, default: 'euclidean' Dissimilarity measure to use:

  • 'euclidean': Pairwise Euclidean distances between points in the dataset.
  • 'precomputed': Pre-computed dissimilarities are passed directly to ``fit`` and ``fit_transform``.

Attributes ---------- embedding_ : array-like, shape (n_samples, n_components) Stores the position of the dataset in the embedding space.

stress_ : float The final value of the stress (sum of squared distance of the disparities and the distances for all constrained points).

Examples -------- >>> from sklearn.datasets import load_digits >>> from sklearn.manifold import MDS >>> X, _ = load_digits(return_X_y=True) >>> X.shape (1797, 64) >>> embedding = MDS(n_components=2) >>> X_transformed = embedding.fit_transform(X:100) >>> X_transformed.shape (100, 2)

References ---------- 'Modern Multidimensional Scaling - Theory and Applications' Borg, I.; Groenen P. Springer Series in Statistics (1997)

'Nonmetric multidimensional scaling: a numerical method' Kruskal, J. Psychometrika, 29 (1964)

'Multidimensional scaling by optimizing goodness of fit to a nonmetric hypothesis' Kruskal, J. Psychometrika, 29, (1964)

val fit : ?y:Py.Object.t -> ?init:[> `ArrayLike ] Np.Obj.t -> x:[> `ArrayLike ] Np.Obj.t -> [> tag ] Obj.t -> t

Computes the position of the points in the embedding space

Parameters ---------- X : array, shape (n_samples, n_features) or (n_samples, n_samples) Input data. If ``dissimilarity=='precomputed'``, the input should be the dissimilarity matrix.

y : Ignored

init : ndarray, shape (n_samples,), optional, default: None Starting configuration of the embedding to initialize the SMACOF algorithm. By default, the algorithm is initialized with a randomly chosen array.

val fit_transform : ?y:Py.Object.t -> ?init:[> `ArrayLike ] Np.Obj.t -> x:[> `ArrayLike ] Np.Obj.t -> [> tag ] Obj.t -> [> `ArrayLike ] Np.Obj.t

Fit the data from X, and returns the embedded coordinates

Parameters ---------- X : array, shape (n_samples, n_features) or (n_samples, n_samples) Input data. If ``dissimilarity=='precomputed'``, the input should be the dissimilarity matrix.

y : Ignored

init : ndarray, shape (n_samples,), optional, default: None Starting configuration of the embedding to initialize the SMACOF algorithm. By default, the algorithm is initialized with a randomly chosen array.

val get_params : ?deep:bool -> [> tag ] Obj.t -> Dict.t

Get parameters for this estimator.

Parameters ---------- deep : bool, default=True If True, will return the parameters for this estimator and contained subobjects that are estimators.

Returns ------- params : mapping of string to any Parameter names mapped to their values.

val set_params : ?params:(string * Py.Object.t) list -> [> tag ] Obj.t -> t

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as pipelines). The latter have parameters of the form ``<component>__<parameter>`` so that it's possible to update each component of a nested object.

Parameters ---------- **params : dict Estimator parameters.

Returns ------- self : object Estimator instance.

val embedding_ : t -> [> `ArrayLike ] Np.Obj.t

Attribute embedding_: get value or raise Not_found if None.

val embedding_opt : t -> [> `ArrayLike ] Np.Obj.t option

Attribute embedding_: get value as an option.

val stress_ : t -> float

Attribute stress_: get value or raise Not_found if None.

val stress_opt : t -> float option

Attribute stress_: get value as an option.

val to_string : t -> string

Print the object to a human-readable representation.

val show : t -> string

Print the object to a human-readable representation.

val pp : Format.formatter -> t -> unit

Pretty-print the object to a formatter.

OCaml

Innovation. Community. Security.