AI Glossary / Graphs and symbolic AI / Advanced
Polynomial kernel
Definition
A polynomial kernel compares two feature vectors by raising a scaled, shifted dot product to an integer power. A common form is K(x, z) = (1 + x dot z)^d. It lets a compatible learning algorithm work with polynomial combinations of the original features without explicitly constructing every combination for every observation.
What it means
A straight decision boundary in the original features may miss a relationship involving their products. For example, the effect of temperature could depend on pressure. A polynomial feature representation can include temperature squared, pressure squared and their product. A model that is linear in those expanded features can describe a curved boundary in the original coordinates. The kernel supplies the inner products that such a model needs. It supplies neither the final prediction nor evidence that the additional complexity is useful.
How it works
The general expression is K(x, z) = (gamma times x dot z + c)^d. Here gamma scales the dot product, c is an offset, and d is the degree. Nonnegative gamma and c with a nonnegative integer degree give a positive-semidefinite kernel; these conditions are sufficient, not a claim that every other parameter choice is invalid.
With positive gamma and offset, the associated polynomial features include terms through degree d. With zero offset, the homogeneous kernel contains degree-d terms. For p original features, the full expansion through degree d has binomial(p + d, d) coordinates, including the constant. Growth can be substantial, but it is not universally exponential in d: the behavior depends on which quantities vary. The kernel avoids enumerating those coordinates while still computing their correctly weighted inner product.
Three practical examples
- A production analyst compares a linear classifier with a quadratic-kernel classifier for inspection outcomes. Interactions between normalized temperature and pressure may help explain which combinations accompany defects.
- A delivery team tests kernel regression for journey duration. Distance and congestion can interact, so a purely additive relationship may be insufficient. Performance on later journeys determines whether the extra flexibility helps.
- A document-classification experiment applies a polynomial kernel to numeric text features. The experiment checks whether feature combinations improve classification, while accounting for the number of training documents and the resulting computational cost.
Think of it this way
Imagine comparing recipes using both their ingredients and ingredient combinations. Rather than writing out every possible combination on a separate card, a special comparison rule produces the same weighted comparison directly. The shortcut saves that expansion; it does not tell you which recipe a customer will prefer.
Worked example
Take two vectors x = (1, 2) and z = (3, -1), with gamma = 1, c = 1 and d = 2. Their dot product is 1 times 3 plus 2 times -1, which equals 1. The kernel value is therefore (1 + 1)^2 = 4.
An explicit feature map for this two-dimensional quadratic kernel is phi(u) = (1, square-root(2)u1, square-root(2)u2, u1^2, square-root(2)u1u2, u2^2).
The dot product phi(x) dot phi(z) has six contributions: 1, 6, -4, 9, -12 and 4. Their sum is 4, matching the shortcut. The square-root weights matter: simply listing the six unweighted monomials would define a different inner product.
The self-comparisons are K(x, x) = (1 + 5)^2 = 36 and K(z, z) = (1 + 10)^2 = 121. The two-observation kernel matrix consequently has rows (36, 4) and (4, 121). Its entries are not probabilities.
If the offset becomes zero, the cross-comparison is instead 1^2 = 1. If x is doubled while the original parameters and z stay fixed, the dot product becomes 2 and the comparison becomes 9. These changes illustrate why preprocessing and parameter choices are part of the model specification.
Illustrative case study
In a fictional packaging company, analysts test whether two sensor readings jointly predict rejected packages. They first fit a linear baseline, then compare degree-two and degree-three kernels using the same training and validation periods. Scaling parameters are learned from the training observations and then applied consistently to validation data.
The team records predictive errors, processing time and sensitivity to unusual readings. A polynomial model advances only if its measured benefit justifies the extra complexity. The numerical example above explains one pairwise computation; it does not establish that a packaging classifier has been trained successfully or that a particular degree will improve factory outcomes.
Common misconceptions and mistakes
A larger kernel value is not automatically a higher predicted probability. The learner combines kernel values using fitted coefficients and possibly an intercept. Increasing the degree does not guarantee better predictions, and explicit polynomial features are not automatically identical to this kernel unless their weights match.
Feature-space dimension and training cost are also different questions. Avoiding explicit expansion does not eliminate the cost of processing many observations. Finally, a function being accepted by a numerical routine does not itself prove that arbitrary parameter settings satisfy the mathematical kernel requirements.
Business use
Polynomial kernels provide a way to test nonlinear interactions without designing each interaction separately. Compare them against simpler models using a validation design that reflects the intended deployment. Record feature order, units, scaling, degree, offset, gamma and the learning algorithm's regularization. This makes results reproducible and helps diagnose changes after deployment. For illustration, a fully materialized matrix for 50,000 observations contains 2.5 billion entries: at eight bytes each, the entries alone require 20 billion bytes. Actual implementations can use different storage and computation strategies.
People also ask
Is a polynomial kernel a complete model?
No. A learning method must fit a predictor using it.
Does degree two mean only pairwise products?
With a positive offset, the expansion also includes constant and linear terms.
Is the kernel trick an approximation?
The stated polynomial identity is exact; numerical arithmetic and optional approximation methods introduce separate considerations.
Check your understanding
What is the cross-kernel value in the example?
Answer: Four.
Why are there six expanded coordinates?
Answer: Two original features expanded through degree two give binomial(4, 2) = 6.
Must a kernel value stay below one?
Answer: No; the example's self-comparisons are 36 and 121.
Related terms
- Kernel trick
- Feature map
- Support vector machine
- Kernel ridge regression
- Gram matrix
- Regularization
- polynomial features
- radial basis function kernel
Learn next
Expand (1 + x1z1 + x2z2)^2 by hand and match each term to the feature map. Then compare its six coordinates with the three coordinates of the homogeneous quadratic expansion.
More in Graphs and symbolic AI
- Ply - A ply is one move by a single player in a game, corresponding to one action step down a game tree under the usual convention.
- Pointwise product - A pointwise product multiplies corresponding values of functions or arrays.
- Policy search - Policy search is a reinforcement-learning approach that improves a decision rule by searching over candidate policies or their parameters.
- POMCP - POMCP stands for Partially Observable Monte Carlo Planning.
- Pose - Pose is an object's position and orientation relative to a specified reference frame. It describes both where the object is and how it is turned.
- Possibility theory - Possibility theory is a mathematical framework for representing uncertainty through degrees of possibility and necessity.
Sources
Cornell University, Kernels continued: https://www.cs.cornell.edu/courses/cs4780/2018fa/lectures/lecturenote14.html Scikit-learn, polynomial_kernel: https://scikit-learn.org/stable/modules/generated/sklearn.metrics.pairwise.polynomial_kernel.html AIMA glossary, polynomial kernel: https://github.com/aimacode/aima-glossary/blob/master/glossary.md
Previous: Polynomial fitting Next: Polynomial matrix spectral factorization