sklearn.metrics.pairwise.chi2_kernel
-
sklearn.metrics.pairwise.chi2_kernel(X, Y=None, gamma=1.0)
[source] -
Computes the exponential chi-squared kernel X and Y.
The chi-squared kernel is computed between each pair of rows in X and Y. X and Y have to be non-negative. This kernel is most commonly applied to histograms.
The chi-squared kernel is given by:
k(x, y) = exp(-gamma Sum [(x - y)^2 / (x + y)])
It can be interpreted as a weighted difference per entry.
Read more in the User Guide.
- Parameters
-
-
Xarray-like of shape (n_samples_X, n_features)
-
Yndarray of shape (n_samples_Y, n_features), default=None
-
gammafloat, default=1.
-
Scaling parameter of the chi2 kernel.
-
- Returns
-
-
kernel_matrixndarray of shape (n_samples_X, n_samples_Y)
-
See also
-
additive_chi2_kernel
-
The additive version of this kernel.
-
sklearn.kernel_approximation.AdditiveChi2Sampler
-
A Fourier approximation to the additive version of this kernel.
References
- Zhang, J. and Marszalek, M. and Lazebnik, S. and Schmid, C. Local features and kernels for classification of texture and object categories: A comprehensive study International Journal of Computer Vision 2007 https://research.microsoft.com/en-us/um/people/manik/projects/trade-off/papers/ZhangIJCV06.pdf
© 2007–2020 The scikit-learn developers
Licensed under the 3-clause BSD License.
https://scikit-learn.org/0.24/modules/generated/sklearn.metrics.pairwise.chi2_kernel.html