Intel® oneAPI Data Analytics Library
Learn from community members on how to build compute-intensive applications that run efficiently on Intel® architecture.

How can SVM support rbf kernel?

Bin
Beginner
666 Views

I try to use rbf kernel in SVM classification in C++.

I just modify the DAALExamples code, svm_two_class_dense_batch.cpp,

Line 49: services::SharedPtr<kernel_function::KernelIface> kernel(new kernel_function::linear::Batch<>());

I change it to services::SharedPtr<kernel_function::KernelIface> kernel(new kernel_function::rbf::Batch<>());

However, the prediction result is much lower than linear kernel. Do I miss something?  Also how can I set sigma in rbf kernel used in SVM algorithm?  Thanks!

 

 

 

 

0 Kudos
1 Reply
VictoriyaS_F_Intel
666 Views

Hello Bin,

It is expected that with the default values of RBF parameter sigma and SVM parameter C you get different or even worse predictions than with linear kernel.

To set sigma parameter change the line with the kernel declaration to:

services::SharedPtr<kernel_function::rbf::Batch<> > kernel(new kernel_function::rbf::Batch<>());

And add this code to set sigma parameter to 100.0:

kernel->parameter.sigma = 100.0;

To get a good accuracy with RBF kernel you have to properly choose sigma and C parameters. There are many techniques that allow to find a good combination of those parameters. An example of a practical approach is a grid search among exponentially varying sequences. For example, try all combinations of sigma = (0.0001, 0.01, 1, 100, 10000) and C = (0.0001, 0.01, 1, 100, 10000).

Best regards,

Victoriya

0 Kudos
Reply