8.26.2. sklearn.preprocessing.KernelCenterer¶
- class sklearn.preprocessing.KernelCenterer¶
Center a kernel matrix
Let K(x_i, x_j) be a kernel defined by K(x_i, x_j) = phi(x_i)^T phi(x_j), where phi(x) is a function mapping x to a hilbert space. KernelCenterer is a class to center (i.e., normalize to have zero-mean) the data without explicitly computing phi(x). It is equivalent equivalent to centering phi(x) with sklearn.preprocessing.StandardScaler(with_std=False).
Methods
fit fit_transform get_params set_params transform - __init__()¶
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
- fit(K, y=None)¶
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.
- get_params(deep=True)¶
Get parameters for the estimator
Parameters : deep: boolean, optional :
If True, will return the parameters for this estimator and contained subobjects that are estimators.
- 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, y=None, 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]