package sklearn

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
type tag = [
  1. | `GaussianRandomProjection
]
type t = [ `BaseEstimator | `BaseRandomProjection | `GaussianRandomProjection | `Object | `TransformerMixin ] Obj.t
val of_pyobject : Py.Object.t -> t
val to_pyobject : [> tag ] Obj.t -> Py.Object.t
val as_transformer : t -> [ `TransformerMixin ] Obj.t
val as_estimator : t -> [ `BaseEstimator ] Obj.t
val as_random_projection : t -> [ `BaseRandomProjection ] Obj.t
val create : ?n_components:[ `Auto | `I of int ] -> ?eps:float -> ?random_state:int -> unit -> t

Reduce dimensionality through Gaussian random projection

The components of the random matrix are drawn from N(0, 1 / n_components).

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

.. versionadded:: 0.13

Parameters ---------- n_components : int or 'auto', optional (default = 'auto') Dimensionality of the target projection space.

n_components can be automatically adjusted according to the number of samples in the dataset and the bound given by the Johnson-Lindenstrauss lemma. In that case the quality of the embedding is controlled by the ``eps`` parameter.

It should be noted that Johnson-Lindenstrauss lemma can yield very conservative estimated of the required number of components as it makes no assumption on the structure of the dataset.

eps : strictly positive float, optional (default=0.1) Parameter to control the quality of the embedding according to the Johnson-Lindenstrauss lemma when n_components is set to 'auto'.

Smaller values lead to better embedding and higher number of dimensions (n_components) in the target projection space.

random_state : int, RandomState instance or None, optional (default=None) Control the pseudo random number generator used to generate the matrix at fit time. If int, random_state is the seed used by the random number generator; If RandomState instance, random_state is the random number generator; If None, the random number generator is the RandomState instance used by `np.random`.

Attributes ---------- n_components_ : int Concrete number of components computed when n_components='auto'.

components_ : numpy array of shape n_components, n_features Random matrix used for the projection.

Examples -------- >>> import numpy as np >>> from sklearn.random_projection import GaussianRandomProjection >>> rng = np.random.RandomState(42) >>> X = rng.rand(100, 10000) >>> transformer = GaussianRandomProjection(random_state=rng) >>> X_new = transformer.fit_transform(X) >>> X_new.shape (100, 3947)

See Also -------- SparseRandomProjection

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

Generate a sparse random projection matrix

Parameters ---------- X : numpy array or scipy.sparse of shape n_samples, n_features Training set: only the shape is used to find optimal random matrix dimensions based on the theory referenced in the afore mentioned papers.

y Ignored

Returns ------- self

val fit_transform : ?y:[> `ArrayLike ] Np.Obj.t -> ?fit_params:(string * Py.Object.t) list -> x:[> `ArrayLike ] Np.Obj.t -> [> tag ] Obj.t -> [> `ArrayLike ] Np.Obj.t

Fit to data, then transform it.

Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X.

Parameters ---------- X : numpy array of shape n_samples, n_features Training set.

y : numpy array of shape n_samples Target values.

**fit_params : dict Additional fit parameters.

Returns ------- X_new : numpy array of shape n_samples, n_features_new Transformed 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 transform : x:[> `ArrayLike ] Np.Obj.t -> [> tag ] Obj.t -> [> `ArrayLike ] Np.Obj.t

Project the data by using matrix product with the random matrix

Parameters ---------- X : numpy array or scipy.sparse of shape n_samples, n_features The input data to project into a smaller dimensional space.

Returns ------- X_new : numpy array or scipy sparse of shape n_samples, n_components Projected array.

val n_components_ : t -> int

Attribute n_components_: get value or raise Not_found if None.

val n_components_opt : t -> int option

Attribute n_components_: get value as an option.

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

Attribute components_: get value or raise Not_found if None.

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

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