Kernel Trick
Sometimes, the points in a dataset are not always linearly separable. Consider the points shown in Figure 8.11.
You can see that it is not possible to draw a straight line to separate the two sets of points. With some manipulation, however, you can make this set of points linearly separable. This technique is known as the kernel trick. The kernel trick is a technique in machine learning that transforms data into a higher dimension space so that, after the transformation, it has a clear dividing margin between classes of data.
Adding a Third Dimension
To do so, we can add a third dimension, say the z‐axis, and define z to be:
Once we plot the points using a 3D chart, the points are now linearly separable. It is difficult to visualize this unless you plot the points out. The following code snippet does just that:
%matplotlib inline
from mpl_toolkits.mplot3d...