Foundations to Frontier
Tests
D. Classical Machine Learning › D5 Support Vector Machines and Kernel Methods

Support Vector Regression (SVR, ε-insensitive loss)

Support vector regression carries the SVM idea over to real-valued targets. It fits the flattest function whose errors stay within a tube of half-width ε: errors inside the tube cost nothing, and errors outside cost linearly. The result is a sparse model whose support vectors are the points on or outside the tube, and which is robust to outliers because each point's pull is capped at C. This page covers the ε-insensitive loss, the primal with two slack variables, the dual and its kernelisation, how ε, C and γ interact, and the comparison with kernel ridge regression. In the exercises you implement kernel SVR through its dual and verify the tube conditions; then you test SVR against kernel ridge under gross outliers and sweep ε.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

A tube of “close enough”

Suppose you calibrate a thermometer whose readings wobble by about ±0.1°. Chasing every wobble is pointless, and one wild reading from a loose wire should not bend the calibration curve. Support vector regression fits a curve with a tube of half-width ε around it. Points inside the tube are “close enough” and cost nothing. Points outside pay in proportion to how far out they are, so one wild point can pull only so hard. Only the points on or outside the tube (the support vectors) determine the curve.

SVR: a tube of tolerance around the fit
support vectors 19 of 40 · RMSE to the true curve: SVR 0.070, kernel ridge (λ = 0.1) 0.086
Solid: SVR; shaded: its ε-tube; dashed: kernel ridge; dotted: the true curve. Widen ε and fewer points become support vectors, until the tube is so wide it no longer follows the curve. With outliers, each outlier's pull on SVR is capped at C, while squared loss lets it drag the ridge fit upward.
Why engineers care

SVR gives smooth non-linear regression with a built-in tolerance in the units of the target (“errors under 0.1 K don’t matter”) and robustness to occasional bad readings. It is widely used for sensor calibration, battery state-of-health and remaining-useful-life estimation, and surrogate models of expensive simulations.

📝 Quick check (Level 0)
0/3 answered
  1. 1. Errors smaller than ε cost…
  2. 2. SVR support vectors are the points…
  3. 3. In the demo, outliers drag which fit more?

Level 1: Beginner

★★☆☆☆ Basic⏱ 25 minSecondary-school mathematics: arithmetic and elementary algebra.

The ε-insensitive loss by hand

The loss is L_ε(r) = max(0, |r| − ε) for residual r = y − f(x).

Example: ε = 0.1, the line f(x) = x, C = 1.

x y r L_ε
0 0.0 0.0 0
1 1.2 0.2 0.1
2 1.8 −0.2 0.1
3 3.4 0.4 0.3

Total loss = 0.5. The objective is ½‖w‖² + C·Σ L_ε = 0.5 + 0.5 = 1.0.

  • The first point is inside the tube and does not affect the solution at all.
  • The other three are outside, so at the optimum each pulls with full strength C, in the direction of its residual.
  • With ε = 0.5 every point would be inside the tube, and the flattest line wins: w shrinks toward 0 until some point touches the tube.

The steps in plain English:

  1. Choose ε about equal to the noise level you are willing to ignore, in the target’s units.
  2. Choose a kernel (RBF by default) and standardise the inputs.
  3. Solve the dual. Each point gets βᵢ = αᵢ − αᵢ*, with |βᵢ| ≤ C.
  4. Predict with f(x) = Σβᵢk(xᵢ, x) + b, summing over support vectors only.
  5. Tune C and γ by cross-validation. ε can be tuned too, or set from the noise level.
📝 Quick check (Level 1)
0/3 answered
  1. 1. L_ε(0.25) with ε = 0.1?
  2. 2. A point strictly inside the tube has β…
  3. 3. Max magnitude of any βᵢ?

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 35 minUndergraduate students and practising engineers.

Primal, dual and kernels

Primal. Minimise ½‖w‖² + C·Σ(ξᵢ + ξᵢ*) subject to:

  • yᵢ − w·xᵢ − b ≤ ε + ξᵢ;
  • w·xᵢ + b − yᵢ ≤ ε + ξᵢ*;
  • ξᵢ, ξᵢ* ≥ 0.

Two slack variables handle errors above and below the tube.

Dual. With α, α* in [0, C] and β = α − α*: minimise ½βᵀKβ + ε·Σ(αᵢ + αᵢ*) − yᵀβ subject to Σβᵢ = 0.

  • At the optimum αᵢαᵢ* = 0, so Σ(αᵢ + αᵢ*) = Σ|βᵢ|.
  • ε acts like an L1 penalty on β, which is the source of sparsity.

KKT conditions in words.

  • |rᵢ| below ε gives βᵢ = 0.
  • |rᵢ| = ε gives 0 ≤ |βᵢ| ≤ C (on the tube).
  • |rᵢ| above ε gives |βᵢ| = C, with sign(βᵢ) = sign(rᵢ).

Prediction: f(x) = Σβᵢk(xᵢ, x) + b.

Method Loss Sparse? Outlier pull
Kernel ridge squared no (all points) unbounded
SVR ε-insensitive (linear) yes capped at C
Gaussian process squared (likelihood) no unbounded

Exercise 1 absorbs b by adding 1 to the kernel, as on the kernel-SVM page, and solves the box-constrained dual with L-BFGS-B.

from sklearn.svm import SVR
model = make_pipeline(StandardScaler(), SVR(kernel="rbf", C=3, epsilon=0.1, gamma="scale")).fit(X, y)
model[-1].support_            # indices of support vectors
🐍 Exercise 1: kernel SVR through the dual
Implement the ε-insensitive loss, kernel SVR via the box-constrained dual (split variables α, α*), prediction and the primal objective; verify a zero duality gap, the tube conditions (β = 0 inside, |β| = C outside with the residual's sign), that wider ε gives fewer support vectors, and that a linear SVR recovers y = 2x + 1.
📝 Quick check (Level 2)
0/3 answered
  1. 1. In the dual, ε acts like…
  2. 2. A point with |r| above ε has…
  3. 3. Why two slack variables per point?

Level 3: Advanced

★★★★☆ Advanced⏱ 30 minGraduate level, with full derivations and proofs.

Theory

Robustness. The ε-insensitive loss grows linearly, so each point’s influence on the solution is bounded: |βᵢ| ≤ C. That gives SVR the robustness of absolute-error (L1) regression. Squared loss lets a single gross outlier exert unbounded pull. Exercise 2: with 8% outliers, kernel ridge’s error rose almost six-fold while SVR’s barely moved.

Sparsity and ε. ε sets how many points become support vectors. Too small (ε = 0) makes every point a support vector, and the loss becomes plain absolute error. Too large makes the tube swallow the signal. For Gaussian noise with standard deviation σ, theory and practice suggest ε of about σ, scaled down with √(log n / n) for large n (Cherkassky and Ma, 2004). Exercise 2 found the best ε at 0.1, against a noise σ of 0.15.

Statistical view. SVR is regularised risk minimisation with loss L_ε in an RKHS. The ε-insensitive loss is the negative log-likelihood of a noise density that is flat on [−ε, ε] with exponential tails (Pontil, Mukherjee and Girosi, 1998). SVR is consistent when C grows and ε shrinks suitably.

Interview questions.

  • How do you choose ε? Set it near the noise level you want to ignore, in target units, or tune it by CV. ν-SVR picks it automatically from a target fraction of support vectors.
  • When prefer SVR over gradient boosting? Small data, smooth targets, and when you want a tolerance band and outlier robustness with few hyperparameters.
📝 Quick check (Level 3)
0/3 answered
  1. 1. With ε = 0, the SVR loss becomes…
  2. 2. SVR's outlier robustness comes from…
  3. 3. The ε-insensitive loss corresponds to a noise density that is…

Level 4: Expert

★★★★★ Expert⏱ 25 minResearchers: original papers and open problems.

SVR versus kernel ridge under outliers

History.

  • Vapnik (1995) introduced the ε-insensitive loss.
  • Drucker, Burges, Kaufman, Smola and Vapnik (1997) demonstrated SVR on benchmarks.
  • Smola and Schölkopf (2004) wrote the standard tutorial.
  • Cherkassky and Ma (2004) gave practical rules for C and ε.
  • Schölkopf et al. (2000) introduced ν-SVR to choose ε automatically (next page).

Exercise 1.

  • The duality gap is zero.
  • Points inside the tube have β = 0; points outside have |β| = C with their residual’s sign.
  • Support vectors fall from 60 of 60 (ε = 0) to 22 (ε = 0.1) and 5 (ε = 0.3).
  • A linear SVR recovers y = 2x + 1.

Exercise 2. Setup: y = sin(2x) + noise with σ = 0.15, n = 120, RBF γ = 1, and in the contaminated version 8% of targets shifted by +3. C (for SVR) and λ (for ridge) are tuned on a clean validation set. Scores are RMSE against the true curve, averaged over 3 seeds.

Training data SVR (ε = 0.1) Kernel ridge
clean 0.050 0.054
8% outliers 0.055 0.316

The ε sweep (C = 3, clean data):

ε 0 0.05 0.1 0.2 0.4
RMSE 0.063 0.050 0.048 0.063 0.156
support vectors 100% 78% 55% 22% 6%
  • On clean data the two methods tie. SVR’s sparsity costs nothing.
  • With outliers, ridge’s error grew about 6×; SVR’s grew about 10%. The linear loss caps each outlier’s pull.
  • ε near the noise level is best. ε = 0.1 used about half the points. ε = 0 was slightly worse and used every point. ε = 0.4 kept 6% of the points as support vectors but tripled the error.
  • Caveat: the validation set was clean. With contaminated validation data, ridge’s tuning would also be misled, and a robust validation metric would be needed.
🐍 Exercise 2 (research): SVR versus kernel ridge, and the ε trade-off
Fit RBF SVR and kernel ridge to sin(2x) data with and without 8% gross outliers, tuning C or λ on clean validation data; report RMSE to the true curve. Then sweep ε and report RMSE and support-vector share.

SVR in AI, robotics and aerospace

  • Battery health: state-of-health and remaining-useful-life regression from charge-curve features.
  • Sensor calibration with a stated tolerance band.
  • Surrogate models of CFD or structural simulations for design optimisation.
  • Robot dynamics: learning inverse-dynamics residuals with robustness to glitches.

References

  1. V. Vapnik (1995). The Nature of Statistical Learning Theory. Springer.
  2. H. Drucker, C. J. C. Burges, L. Kaufman, A. Smola, V. Vapnik (1997). “Support vector regression machines.” NeurIPS.
  3. A. J. Smola, B. Schölkopf (2004). “A tutorial on support vector regression.” Statistics and Computing 14.
  4. V. Cherkassky, Y. Ma (2004). “Practical selection of SVM parameters and noise estimation for SVM regression.” Neural Networks 17.
  5. M. Pontil, S. Mukherjee, F. Girosi (1998). “On the noise model of support vector machine regression.” MIT AI Memo 1651.