What parameter represents sigma in scikitleans Support Vector Machine?
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
In scikit-learn’s SVM implementation, the parameter that corresponds to sigma from the Gaussian or RBF kernel formula is gamma. They are not equal, but they are directly related: gamma = 1 / (2 * sigma^2). So if a textbook or paper gives you sigma, you convert it to gamma before passing it to SVC or SVR with an RBF kernel.
Where sigma Comes From
Many explanations of the Gaussian kernel write it like this:
- '
K(x, y) = exp(-||x - y||^2 / (2 * sigma^2))'
In scikit-learn, the same kernel is parameterized as:
- '
K(x, y) = exp(-gamma * ||x - y||^2)'
Matching the two expressions gives the conversion:
- '
gamma = 1 / (2 * sigma^2)'
That is why there is no separate sigma argument in scikit-learn’s SVM API.
Convert sigma to gamma
If you already know the sigma value you want, compute gamma explicitly.
Then use that value in the classifier.
This is the cleanest way to translate formulas from notes, papers, or older code examples into scikit-learn.
What gamma Controls Intuitively
The gamma value controls how far the influence of each training example reaches.
- large
gammameans very local influence and more complex decision boundaries - small
gammameans broader influence and smoother decision boundaries
Because of the inverse-square relationship, larger sigma means smaller gamma.
That relationship often confuses people at first: increasing sigma makes the kernel wider, while increasing gamma makes it narrower.
Example with a Model
A small example:
If you tune the model with grid search, you normally search over gamma directly because that is what the library exposes.
This Only Applies to the RBF-Style Kernel
The sigma relationship matters for the Gaussian-style RBF kernel. It does not apply the same way to the linear kernel, and it is not the same tuning story for polynomial or sigmoid kernels.
So if you are using kernel="linear", there is no hidden sigma parameter to look for.
Scale Features Before Tuning
The gamma value interacts strongly with feature scale. If one feature spans thousands while another spans fractions, the kernel distance calculation becomes hard to interpret and the sigma to gamma conversion is less useful in practice. Standardizing features before tuning usually makes the parameter search much more meaningful.
Common Pitfalls
- Looking for a literal
sigmaparameter in scikit-learn’sSVCAPI. - Treating
gammaas if it were numerically equal tosigma. - Forgetting the square in the conversion formula.
- Applying the
sigmatogammaconversion to non-RBF kernels. - Tuning
gammawithout scaling features first, which often makes the search misleading.
Summary
- In scikit-learn SVMs,
gammais the parameter that corresponds to Gaussian-kernelsigma. - The conversion is
gamma = 1 / (2 * sigma^2). - Use that conversion when translating formulas from books or papers.
- The relationship matters for RBF-style kernels, not for every kernel choice.
- Larger
sigmameans smallergamma, and largergammameans tighter local influence.

