How it works...

There are several different kernels available besides the cosine kernel. You can even write your own kernel function. The available kernels are as follows:

  • Poly (polynomial)
  • RBF (radial basis function)
  • Sigmoid
  • Cosine
  • Pre-computed

There are also options that are contingent on the kernel choice. For example, the degree argument will specify the degree for the poly, RBF, and sigmoid kernels; also, gamma will affect the RBF or poly kernels.

The recipe on SVM will cover the RBF kernel function in more detail.

Kernel methods are great to create separability, but they can also cause overfitting if used without care. Make sure to train-test them properly.

Luckily, the available kernels are smooth, continuous, and differentiable ...

Get scikit-learn Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.