How does varying the regularization parameter in an SVM change the decision boundary for a non-separable dataset? A visual answer and/or some commentary on the limiting behaviors (for large and small regularization) would be very helpful.


1 Answer 1


The regularization parameter (lambda) serves as a degree of importance that is given to misclassifications. SVM pose a quadratic optimization problem that looks for maximizing the margin between both classes and minimizing the amount of misclassifications. However, for non-separable problems, in order to find a solution, the miclassification constraint must be relaxed, and this is done by setting the mentioned "regularization".

So, intuitively, as lambda grows larger the less the wrongly classified examples are allowed (or the highest the price the pay in the loss function). Then when lambda tends to infinite the solution tends to the hard-margin (allow no miss-classification). When lambda tends to 0 (without being 0) the more the miss-classifications are allowed.

There is definitely a tradeoff between these two and normally smaller lambdas, but not too small, generalize well. Below are three examples for linear SVM classification (binary).

Linear SVM Lambda = 0.1 Linear SVM Lambda = 1 enter image description here

For non-linear-kernel SVM the idea is the similar. Given this, for higher values of lambda there is a higher possibility of overfitting, while for lower values of lambda there is higher possibilities of underfitting.

The images below show the behavior for RBF Kernel, letting the sigma parameter fixed on 1 and trying lambda = 0.01 and lambda = 10

RBF Kernel SVM lambda = 0.01 RBF Kernel SVM lambda = 10

You can say the first figure where lambda is lower is more "relaxed" than the second figure where data is intended to be fitted more precisely.

(Slides from Prof. Oriol Pujol. Universitat de Barcelona)

  • 1
    $\begingroup$ Nice pictures! Did you create them yourself? If yes, maybe you can share the code for drawing them? $\endgroup$ Commented Jan 27, 2015 at 8:34
  • 1
    $\begingroup$ nice graphics. regarding the last two => from the text one would implicitly think the first picture is the one with lambda = 0.01, but from my understanding (and to be consistent with the graph in the beginning) this is the one with lambda = 10. because this is clearly the one with the least regularization (most overfitting, most relaxed). $\endgroup$ Commented May 6, 2018 at 8:13
  • 1
    $\begingroup$ ^this is my understanding as well. The top of the two color graphs clearly shows more contours for the shape of the data, so that must be the graph where the margin of the SVM equation was favored with higher lambda. The bottom of the two color graphs shows a more relaxed classification of the data (small cluster of blue in the orange area) meaning margin maximization was not favored over minimizing the amount of error in classification. $\endgroup$ Commented Jan 12, 2019 at 22:40
  • $\begingroup$ @Javierfdr can you please share the code for drawing those visualizations? $\endgroup$ Commented Jul 12, 2022 at 5:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.