This documentation is for scikit-learn version 0.10Other versions

Citing

If you use the software, please consider citing scikit-learn.

This page

8.23.5. sklearn.preprocessing.KernelCenterer

class sklearn.preprocessing.KernelCenterer

Center a kernel matrix

This is equivalent to centering phi(X) with sklearn.preprocessing.Scaler(with_std=False).

Methods

fit(K) Fit KernelCenterer
fit_transform(X[, y]) Fit to data, then transform it
set_params(**params) Set the parameters of the estimator.
transform(K[, copy]) Center kernel
__init__()

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

fit(K)

Fit KernelCenterer

Parameters :

K : numpy array of shape [n_samples, n_samples]

Kernel matrix.

Returns :

self : returns an instance of self.

fit_transform(X, y=None, **fit_params)

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.

Returns :

X_new : numpy array of shape [n_samples, n_features_new]

Transformed array.

Notes

This method just calls fit and transform consecutively, i.e., it is not an optimized implementation of fit_transform, unlike other transformers such as PCA.

set_params(**params)

Set the parameters of the 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, copy=True)

Center kernel

Parameters :

K : numpy array of shape [n_samples1, n_samples2]

Kernel matrix.

Returns :

K_new : numpy array of shape [n_samples1, n_samples2]