MCPcopy Index your code
hub / github.com/scikit-learn/scikit-learn / KernelCenterer

Class KernelCenterer

sklearn/preprocessing/_data.py:2437–2602  ·  view source on GitHub ↗

r"""Center an arbitrary kernel matrix :math:`K`. Let define a kernel :math:`K` such that: .. math:: K(X, Y) = \phi(X) . \phi(Y)^{T} :math:`\phi(X)` is a function mapping of rows of :math:`X` to a Hilbert space and :math:`K` is of shape `(n_samples, n_samples)`. This c

Source from the content-addressed store, hash-verified

2435
2436
2437class KernelCenterer(ClassNamePrefixFeaturesOutMixin, TransformerMixin, BaseEstimator):
2438 r"""Center an arbitrary kernel matrix :math:`K`.
2439
2440 Let define a kernel :math:`K` such that:
2441
2442 .. math::
2443 K(X, Y) = \phi(X) . \phi(Y)^{T}
2444
2445 :math:`\phi(X)` is a function mapping of rows of :math:`X` to a
2446 Hilbert space and :math:`K` is of shape `(n_samples, n_samples)`.
2447
2448 This class allows to compute :math:`\tilde{K}(X, Y)` such that:
2449
2450 .. math::
2451 \tilde{K(X, Y)} = \tilde{\phi}(X) . \tilde{\phi}(Y)^{T}
2452
2453 :math:`\tilde{\phi}(X)` is the centered mapped data in the Hilbert
2454 space.
2455
2456 `KernelCenterer` centers the features without explicitly computing the
2457 mapping :math:`\phi(\cdot)`. Working with centered kernels is sometime
2458 expected when dealing with algebra computation such as eigendecomposition
2459 for :class:`~sklearn.decomposition.KernelPCA` for instance.
2460
2461 Read more in the :ref:`User Guide <kernel_centering>`.
2462
2463 Attributes
2464 ----------
2465 K_fit_rows_ : ndarray of shape (n_samples,)
2466 Average of each column of kernel matrix.
2467
2468 K_fit_all_ : float
2469 Average of kernel matrix.
2470
2471 n_features_in_ : int
2472 Number of features seen during :term:`fit`.
2473
2474 .. versionadded:: 0.24
2475
2476 feature_names_in_ : ndarray of shape (`n_features_in_`,)
2477 Names of features seen during :term:`fit`. Defined only when `X`
2478 has feature names that are all strings.
2479
2480 .. versionadded:: 1.0
2481
2482 See Also
2483 --------
2484 sklearn.kernel_approximation.Nystroem : Approximate a kernel map
2485 using a subset of the training data.
2486
2487 References
2488 ----------
2489 .. [1] `Schölkopf, Bernhard, Alexander Smola, and Klaus-Robert Müller.
2490 "Nonlinear component analysis as a kernel eigenvalue problem."
2491 Neural computation 10.5 (1998): 1299-1319.
2492 <https://www.mlpack.org/papers/kpca.pdf>`_
2493
2494 Examples

Callers 6

test_center_kernelFunction · 0.90
fitMethod · 0.90
reconstruction_errorMethod · 0.90

Calls

no outgoing calls

Used in the wild real call sites across dependent graphs

searching dependent graphs…