# Can someone explain the RBF Kernel to me?

I have read every explanation out there on this but nobody seems capable of explaining this in a way that I am able to understand. For an SVM RBF Kernel we often say that: But what does x and x' represent here? Let's say my input data x is of shape 5x100 (5 features aka dimensions aka columns) and 100 rows, and output y is 1x100 rows, then what is x and x' in relation to this?

• This looks very similar to this question. $x$ and $x'$ are individual measurements (so 5x1 in your example), and $K(x,x')$ gives the covariance between the observations for the corresponding measurements. – combo Aug 29 '17 at 22:50
• The link you gave is to an Gaussian Process RBF not an SVM RBF Kernel. None of the explanations for SVM RBF ever mention the word co-variance hence my confusion (en.wikipedia.org/wiki/Radial_basis_function_kernel). If K(x,x') is the covariance , does that mean x' is the transpose of x? – user1761806 Aug 29 '17 at 23:15
• As a further example of why I'm genuinally confused, see this. Here co-variance is not mentioned, instead it is 'test' data. Then look at this here nothing is mentioned either about covariance or about test data. – user1761806 Aug 29 '17 at 23:28
• Prime notation in this case just means "different". The kernel is a measure of similarity (e.g. an inner product) - in a Gaussian process setting it is covariance between samples, in the SVM setting it is similarity between samples (the basic math/kernel trick is the same in either case). The first link you give uses the kernel to quantify the similarity between the train and test features; The second certainly mentions test data, and also discusses the kernel as a similarity metric. I think thoroughly reading this tutorial would help you. – combo Aug 30 '17 at 0:43
• Awesome - thanks. Yes I finally got to the same conclusion after I read this, and this. I did read Andrew Ngs notes (pg. 14-16 are the key bits for anyone reading it) but did not find it clearly addressing the above point (couldn't tell if i,j were samples or dimensions). Anyway thanks for your help -- if you post it as an answer I can award the points. Much appreciated! – user1761806 Aug 30 '17 at 1:19

The kernel function is a measure of similarity between two sets of features. So in this case, $x'$ and $x$ will both be $5\times 1$ feature vectors (not necessarily the same). $K(x,x')$ is a scalar that represents the similarity between $x$ and $x'$, and the kernel matrix $[K(x,x')]_{x\in X, x'\in X}$ is a $100\times 100$ matrix which represents the pairwise similarities.
Here's my attempt at giving a non-mathy explanation for the RBF kernel. The kernel function gives you the distance between $x$ and $x'$. It's not like the regular Euclidean distance though. I imagine living in an RBF kernel world like walking around in a little bubble where anything what is within arms reach of me is just like normal Euclidean distances but anything farther than that (outside the bubble) is warped to be extremely far The way this works with the math is $\sigma$ is like the size of the bubble and the $\exp$ function is what pushes everything to be really far away if it is not already close.
• I don't think it's correct to say that the kernel function gives a distance. It returns values that are higher for nearby points, with a maximum when $x=x'$. This is opposite to how distance behaves. – user20160 Aug 30 '17 at 14:22