package sklearn

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
type tag = [
  1. | `SpectralEmbedding
]
type t = [ `BaseEstimator | `Object | `SpectralEmbedding ] 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 -> ?affinity:[ `S of string | `Callable of Py.Object.t ] -> ?gamma:float -> ?random_state:int -> ?eigen_solver:[ `Arpack | `PyObject of Py.Object.t | `Lobpcg ] -> ?n_neighbors:int -> ?n_jobs:int -> unit -> t

Spectral embedding for non-linear dimensionality reduction.

Forms an affinity matrix given by the specified function and applies spectral decomposition to the corresponding graph laplacian. The resulting transformation is given by the value of the eigenvectors for each data point.

Note : Laplacian Eigenmaps is the actual algorithm implemented here.

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

Parameters ---------- n_components : integer, default: 2 The dimension of the projected subspace.

affinity : string or callable, default : 'nearest_neighbors' How to construct the affinity matrix.

  • 'nearest_neighbors' : construct the affinity matrix by computing a graph of nearest neighbors.
  • 'rbf' : construct the affinity matrix by computing a radial basis function (RBF) kernel.
  • 'precomputed' : interpret ``X`` as a precomputed affinity matrix.
  • 'precomputed_nearest_neighbors' : interpret ``X`` as a sparse graph of precomputed nearest neighbors, and constructs the affinity matrix by selecting the ``n_neighbors`` nearest neighbors.
  • callable : use passed in function as affinity the function takes in data matrix (n_samples, n_features) and return affinity matrix (n_samples, n_samples).

gamma : float, optional, default : 1/n_features Kernel coefficient for rbf kernel.

random_state : int, RandomState instance, default=None Determines the random number generator used for the initialization of the lobpcg eigenvectors when ``solver`` == 'amg'. Pass an int for reproducible results across multiple function calls. See :term: `Glossary <random_state>`.

eigen_solver : None, 'arpack', 'lobpcg', or 'amg' The eigenvalue decomposition strategy to use. AMG requires pyamg to be installed. It can be faster on very large, sparse problems.

n_neighbors : int, default : max(n_samples/10 , 1) Number of nearest neighbors for nearest_neighbors graph building.

n_jobs : int or None, optional (default=None) The number of parallel jobs to run. ``None`` means 1 unless in a :obj:`joblib.parallel_backend` context. ``-1`` means using all processors. See :term:`Glossary <n_jobs>` for more details.

Attributes ----------

embedding_ : array, shape = (n_samples, n_components) Spectral embedding of the training matrix.

affinity_matrix_ : array, shape = (n_samples, n_samples) Affinity_matrix constructed from samples or precomputed.

n_neighbors_ : int Number of nearest neighbors effectively used.

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

References ----------

  • A Tutorial on Spectral Clustering, 2007 Ulrike von Luxburg http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.165.9323
  • On Spectral Clustering: Analysis and an algorithm, 2001 Andrew Y. Ng, Michael I. Jordan, Yair Weiss http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.19.8100
  • Normalized cuts and image segmentation, 2000 Jianbo Shi, Jitendra Malik http://citeseer.ist.psu.edu/viewdoc/summary?doi=10.1.1.160.2324
val fit : ?y:Py.Object.t -> x:[> `ArrayLike ] Np.Obj.t -> [> tag ] Obj.t -> t

Fit the model from data in X.

Parameters ---------- X : array-like, sparse matrix, shape (n_samples, n_features) Training vector, where n_samples is the number of samples and n_features is the number of features.

If affinity is 'precomputed' X : array-like, sparse matrix, shape (n_samples, n_samples), Interpret X as precomputed adjacency graph computed from samples.

Returns ------- self : object Returns the instance itself.

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

Fit the model from data in X and transform X.

Parameters ---------- X : array-like, sparse matrix, shape (n_samples, n_features) Training vector, where n_samples is the number of samples and n_features is the number of features.

If affinity is 'precomputed' X : array-like, sparse matrix, shape (n_samples, n_samples), Interpret X as precomputed adjacency graph computed from samples.

Returns ------- X_new : array-like, shape (n_samples, n_components)

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 affinity_matrix_ : t -> [> `ArrayLike ] Np.Obj.t

Attribute affinity_matrix_: get value or raise Not_found if None.

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

Attribute affinity_matrix_: get value as an option.

val n_neighbors_ : t -> int

Attribute n_neighbors_: get value or raise Not_found if None.

val n_neighbors_opt : t -> int option

Attribute n_neighbors_: 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.