Compute the polynomial kernel between X and Y.
K(X, Y) = (gamma <X, Y> + coef0) ^ degree
Read more in the User Guide.
A feature array.
An optional second feature array. If None, uses Y=X.
Kernel degree.
Coefficient of the vector inner product. If None, defaults to 1.0 / n_features.
Constant offset added to scaled inner product.
The polynomial kernel.
>>> from sklearn.metrics.pairwise import polynomial_kernel
>>> X = [[0, 0, 0], [1, 1, 1]]
>>> Y = [[1, 0, 0], [1, 1, 0]]
>>> polynomial_kernel(X, Y, degree=2)
array([[1. , 1. ],
[1.77..., 2.77...]])
© 2007–2025 The scikit-learn developers
Licensed under the 3-clause BSD License.
https://scikit-learn.org/1.6/modules/generated/sklearn.metrics.pairwise.polynomial_kernel.html