Let's say I have a very basic SVM model, implementin sk-learn:

clf = SVC(kernel='rbf', class_weight=weights, gamma=gamma)

X is the sample space with 2 features. I plot these sample using a scatter plot: enter image description here

And plot the hyperplane: enter image description here But now, I want to see how the new kernel (from radial basis function) transforms my sample into a 3D space, how would I do that?

I'm more interested in getting the new set of 3D coordinates After that, plotting in 3D is not that difficult.


  • $\begingroup$ You do know that SVMs don't actually transform the input into a higher dimension using the kernel trick? If I were you, I'd just implement the rbf as a function and pass my input to it and then plot the new transformation. $\endgroup$ – MichaelMMeskhi Oct 3 '19 at 11:16
  • $\begingroup$ @MichaelMMeskhi I did not know that! Can you elaborate further? I'm still learning here. $\endgroup$ – Anh Tran Oct 3 '19 at 11:35
  • $\begingroup$ Well what I tried to explain was, when you have data that cannot be separated by a linear boundary, an SVM, will use a kernel trick such as the rbf kernel to "project" the data into a higher dimensional space where it becomes linearly separable. So what you want is to plot the rbf kernel projection to see how the new data looks like. The problem you might encounter is that the rbf kernel might project it in 3rd, 4th, or nth dimension. You can only make use of 3rd. Play around with that idea. $\endgroup$ – MichaelMMeskhi Oct 4 '19 at 18:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.