package sklearn

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
type t
val of_pyobject : Py.Object.t -> t
val to_pyobject : t -> Py.Object.t
val create : unit -> t

Center a kernel matrix

Let K(x, z) be a kernel defined by phi(x)^T phi(z), where phi is a function mapping x to a Hilbert space. KernelCenterer centers (i.e., normalize to have zero mean) the data without explicitly computing phi(x). It is equivalent to centering phi(x) with sklearn.preprocessing.StandardScaler(with_std=False).

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

Attributes ---------- K_fit_rows_ : array, shape (n_samples,) Average of each column of kernel matrix

K_fit_all_ : float Average of kernel matrix

Examples -------- >>> from sklearn.preprocessing import KernelCenterer >>> from sklearn.metrics.pairwise import pairwise_kernels >>> X = [ 1., -2., 2.], ... [ -2., 1., 3.], ... [ 4., 1., -2.] >>> K = pairwise_kernels(X, metric='linear') >>> K array([ 9., 2., -2.], [ 2., 14., -13.], [ -2., -13., 21.]) >>> transformer = KernelCenterer().fit(K) >>> transformer KernelCenterer() >>> transformer.transform(K) array([ 5., 0., -5.], [ 0., 14., -14.], [ -5., -14., 19.])

val fit : ?y:Py.Object.t -> k:Arr.t -> t -> t

Fit KernelCenterer

Parameters ---------- K : numpy array of shape n_samples, n_samples Kernel matrix.

Returns ------- self : returns an instance of self.

val fit_transform : ?y:Arr.t -> ?fit_params:(string * Py.Object.t) list -> x:Arr.t -> t -> Arr.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 -> 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 -> 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 : ?copy:bool -> k:Arr.t -> t -> Arr.t

Center kernel matrix.

Parameters ---------- K : numpy array of shape n_samples1, n_samples2 Kernel matrix.

copy : boolean, optional, default True Set to False to perform inplace computation.

Returns ------- K_new : numpy array of shape n_samples1, n_samples2

val k_fit_rows_ : t -> Arr.t

Attribute K_fit_rows_: get value or raise Not_found if None.

val k_fit_rows_opt : t -> Arr.t option

Attribute K_fit_rows_: get value as an option.

val k_fit_all_ : t -> float

Attribute K_fit_all_: get value or raise Not_found if None.

val k_fit_all_opt : t -> float option

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