MATLAB Answers

SVM KernelFunction and KernelScale. What is the difference?

50 views (last 30 days)
Dylan den Hartog
Dylan den Hartog on 27 Jan 2021
Answered: Pratyush Roy on 5 Feb 2021
When using Support Vector Machines in the Classification Learner, what is the diffence between the KernelFunction (gaussian, linear, quadratic or cubic) and the KernelScale (which could be any number)?
Is a SVM with a linear KernelFunction and Kernelscale of 2 the same as a SVM wth a quadratic KernelFunction and a KernelScale of 1?
Thanks in advance.

Answers (1)

Pratyush Roy
Pratyush Roy on 5 Feb 2021
Hi Dylan,
The KernelScale is a scaling parameter which is used to scale the data before evaluation of the appropriate Gram matrix.
  • In case one specifies the parameter to be 'auto', the software selects an appropriate scale factor using a heuristic procedure. This heuristic procedure uses subsampling, so estimates can vary from one call to another. Therefore, to reproduce results, set a random number seed using rng before training.
  • If one specifies KernelScale and a custom kernel function, for example, 'KernelFunction', 'kernel', then the software throws an error. Then scaling must be applied within kernel.
The KernelFunction is the function used to compute the elements of Gram Matrix G after scaling has been applied using the KernelScale parameter.
The linear kernel function can be defined as:
Scaling the predictor variables by a factor of, say, s gives us the Gram matrix
This is not same as a quadratic kernel function with scaling factor 1 with the following form:
You can refer to this link for further information.
Hope this helps!

Products


Release

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!