Polynomial Kernel Function

Instance-Based, Kernel & Probabilistic Methods DS practice problem on Onlearn.

Difficulty: medium.

Topics: Understanding Kernel Methods in Support Vector Machines, Vector Inner Product, Polynomial Degree Hyperparameter, Bias/Intercept Term (coef0), Broadcasting in NumPy, Kernel Trick Implementation, Linear Algebra, Kernel Methods, Optimization Theory, Computational Geometry, Statistical Learning Theory, Dot Product Operations, Feature Mapping, Support Vector Machines, Non-linear Decision Boundaries, Mercer's Theorem.

Implement a function polynomial kernel(x1, x2, degree=3, coef0=1) that computes the polynomial kernel between two vectors. The polynomial kernel is defined as K(x1, x2) = (gamma <x1, x2 + coef0)^degree. For this implementation, assume gamma=1.