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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.