Compute the additive chi-squared kernel between observations in 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) = -Sum [(x - y)^2 / (x + y)]
It can be interpreted as a weighted difference per entry.
Read more in the User Guide.
A feature array.
An optional second feature array. If None, uses Y=X.
The kernel matrix.
See also
chi2_kernelThe exponentiated version of the kernel, which is usually preferable.
sklearn.kernel_approximation.AdditiveChi2SamplerA Fourier approximation to this kernel.
As the negative of a distance, this kernel is only conditionally positive definite.
>>> from sklearn.metrics.pairwise import additive_chi2_kernel
>>> X = [[0, 0, 0], [1, 1, 1]]
>>> Y = [[1, 0, 0], [1, 1, 0]]
>>> additive_chi2_kernel(X, Y)
array([[-1., -2.],
[-2., -1.]])
© 2007–2025 The scikit-learn developers
Licensed under the 3-clause BSD License.
https://scikit-learn.org/1.6/modules/generated/sklearn.metrics.pairwise.additive_chi2_kernel.html