# How can I map the sample from the original feature space to the new kernel feature space? (Sk-learn)

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

clf = SVC(kernel='rbf', class_weight=weights, gamma=gamma)
clf.fit(X,y)


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

And plot the hyperplane: 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.

Thanks!

• 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. – MichaelMMeskhi Oct 3 '19 at 11:16
• @MichaelMMeskhi I did not know that! Can you elaborate further? I'm still learning here. – Anh Tran Oct 3 '19 at 11:35
• 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. – MichaelMMeskhi Oct 4 '19 at 18:13