class sklearn.preprocessing.KernelCenterer[source]

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).



x.__init__(...) initializes x; see help(type(x)) for signature

fit(K, y=None)[source]

Fit KernelCenterer


K : numpy array of shape [n_samples, n_samples]

Kernel matrix.


self : returns an instance of self.

fit_transform(X, y=None, **fit_params)[source]

Fit to data, then transform it.

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


X : numpy array of shape [n_samples, n_features]

Training set.

y : numpy array of shape [n_samples]

Target values.


X_new : numpy array of shape [n_samples, n_features_new]

Transformed array.


Get parameters for this estimator.


deep: boolean, optional :

If True, will return the parameters for this estimator and contained subobjects that are estimators.


params : mapping of string to any

Parameter names mapped to their values.


Set the parameters of this estimator.

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

Returns:self :
transform(K, y=None, copy=True)[source]

Center kernel matrix.


K : numpy array of shape [n_samples1, n_samples2]

Kernel matrix.

copy : boolean, optional, default True

Set to False to perform inplace computation.


K_new : numpy array of shape [n_samples1, n_samples2]