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

One-Class SVM

The one-class SVM learns what normal data looks like from normal examples alone, then flags anything outside that region as novel. Schölkopf's version separates the data from the origin in kernel feature space with maximum margin. Tax and Duin's support vector data description (SVDD) encloses the data in the smallest ball, and the two coincide for the RBF kernel. This page covers both formulations, the ν-property (ν bounds the fraction of training outliers), the role of γ, the score plateau inside the data, and how the method compares with simpler novelty detectors. In the exercises you implement the one-class SVM with an accelerated projected-gradient solver and verify the ν-property; then you test it against Mahalanobis and nearest-neighbour detectors on two-mode telemetry.

Level 0: Foundation

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

Learning “normal” without examples of failure

Spacecraft rarely fail, so you may have months of nominal telemetry and no examples of the faults you care about. A one-class SVM draws a boundary around the nominal data and calls everything outside it novel. One knob, ν, says what fraction of the training data you are willing to treat as unusual. The RBF width γ decides how tightly the boundary hugs the data: one loose blob, or a separate island for each operating mode.

One-class SVM: learning what "normal" looks like
training outliers 0% ≤ ν = 10% ≤ support vectors 23%
Small γ: one smooth blob that covers the gap between the two modes, so a reading in the gap looks normal. Larger γ: the region splits into one island per mode. Very large γ: islands around individual points, and nearly every point becomes a support vector. ν is the fraction of training data you are willing to call unusual.
Why engineers care

One-class methods power fault and anomaly detection when faults are rare, unlabeled or unforeseen. Examples include spacecraft housekeeping telemetry, rotating machinery vibration, network intrusion and manufacturing inspection. They need only nominal data, which is plentiful.

📝 Quick check (Level 0)
0/3 answered
  1. 1. A one-class SVM is trained on…
  2. 2. ν roughly controls…
  3. 3. In the demo, too small a γ makes the region…

Level 1: Beginner

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

A two-point example

Setup. Take two training points with RBF kernel values k(x₁, x₁) = k(x₂, x₂) = 1 and k(x₁, x₂) = 0.6, and ν = 1, so each αᵢ ≤ 1/(νn) = 0.5.

  • The constraint Σα = 1 forces α = (0.5, 0.5).
  • Offset: ρ = (Kα)₁ = 0.5·1 + 0.5·0.6 = 0.8.
  • Training point x₁: f(x₁) = 0.8 − 0.8 = 0, exactly on the boundary.
  • New point with kernel value 0.3 to both: f = 0.5·0.3 + 0.5·0.3 − 0.8 = −0.5, so it is flagged as novel.
  • New point halfway between, with kernel value 0.9 to both: f = 0.9 − 0.8 = 0.1, so it is normal.

Ball picture (SVDD). For the RBF kernel every point has φ(x)·φ(x) = 1, so all points lie on a sphere in feature space. Separating them from the origin with a hyperplane is then the same as enclosing them in the smallest ball. Novel points are those outside the ball.

The steps in plain English:

  1. Collect nominal data only, and standardise the features.
  2. Choose ν (an upper bound on the fraction of training points that may fall outside) and γ.
  3. Solve the dual: minimise ½αᵀKα subject to 0 ≤ αᵢ ≤ 1/(νn) and Σα = 1.
  4. Compute ρ from free support vectors and score new points with f(x) = Σαᵢk(xᵢ, x) − ρ.
  5. Flag f(x) below 0, or rank by −f(x) and set a threshold on a validation set.
📝 Quick check (Level 1)
0/3 answered
  1. 1. Upper bound on αᵢ for ν = 0.1 and n = 50?
  2. 2. A point with f(x) = −0.5 is…
  3. 3. For the RBF kernel the one-class SVM is equivalent to…

Level 2: Intermediate

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

The formulations

Schölkopf et al. (2001), primal. Minimise ½‖w‖² + (1/(νn))·Σξᵢ − ρ subject to w·φ(xᵢ) ≥ ρ − ξᵢ and ξᵢ ≥ 0. The decision function is f(x) = w·φ(x) − ρ.

Dual. Minimise ½αᵀKα subject to 0 ≤ αᵢ ≤ 1/(νn) and Σαᵢ = 1. Then f(x) = Σαᵢk(xᵢ, x) − ρ.

SVDD (Tax and Duin, 2004). Find the smallest ball, with centre c and radius R, containing most points: minimise R² + C·Σξᵢ subject to ‖φ(xᵢ) − c‖² ≤ R² + ξᵢ.

  • Its dual is maximise Σαᵢkᵢᵢ − αᵀKα with the same constraints when C = 1/(νn).
  • When kᵢᵢ is constant (the RBF kernel), Σαᵢkᵢᵢ is constant, so the two problems coincide.

ν-property. Fraction of training outliers ≤ ν ≤ fraction of support vectors, by the same counting as on the ν-SVM page.

Solvers. SMO-style pair updates (LIBSVM) or projected gradient. Exercise 1 uses accelerated projected gradient (FISTA). It projects onto the “capped simplex” with a bisection on a scalar shift.

Detector Assumes Strength Weakness
Mahalanobis (one Gaussian) one elliptical mode fast, interpretable fails on multi-modal data
k-NN distance local density flexible, almost no tuning slow at test time; sensitive to scaling
Isolation forest anomalies are easy to isolate scales well axis-aligned splits
One-class SVM smooth support region kernel flexibility, ν control γ is sensitive; O(n²) memory
from sklearn.svm import OneClassSVM
det = make_pipeline(StandardScaler(), OneClassSVM(kernel="rbf", nu=0.05, gamma=1.0)).fit(X_nominal)
det.decision_function(X_new)      # < 0: novel
🐍 Exercise 1: one-class SVM by projected gradient
Implement projection onto the capped simplex, the one-class SVM dual solved by accelerated projected gradient, ρ from free SVs and the decision function; verify the ν-property for ν in {0.05, 0.2, 0.5} and that scores fall along a ray leaving the data.
📝 Quick check (Level 2)
0/3 answered
  1. 1. The one-class SVM dual's equality constraint is…
  2. 2. SVDD and the one-class SVM coincide when…
  3. 3. A single-Gaussian Mahalanobis detector fails when the normal data are…

Level 3: Advanced

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

Theory

What it estimates. Schölkopf et al. (2001) showed that the one-class SVM estimates a region containing a fraction about 1 − ν of the probability mass with small “volume” in the RKHS sense. That is a minimum-volume set or density level set. It is not a density estimate, so its scores are reliable near the boundary but not as a ranking deep inside the data.

The plateau. Points with αᵢ = 0 have f(xᵢ) ≥ 0 and free SVs have f = 0 exactly. With a wide kernel the score is therefore almost flat (close to 0) throughout the interior. Exercise 1 found f(0, 0) = −0.0004 at the centre of a Gaussian cloud. As a result, ranking normal points by f is noisy, and AUC suffers when anomalies sit near or inside the support, such as the gap between two modes.

Choosing γ and ν.

  • γ is the critical parameter. Too small merges modes (exercise 2: AUC 0.73 on gap anomalies at γ = 0.1). Too large overfits individual points.
  • Without anomalies to validate on, heuristics include: choose γ so that a small fraction of held-out nominal points are rejected (close to ν), or maximise a proxy such as the stability of the boundary.
  • ν should match the expected contamination of the “nominal” training set.

Interview questions.

  • How do you validate a novelty detector with no fault examples? Use held-out nominal data to check the false-alarm rate (it should be close to ν), inject synthetic faults, and review flagged events with experts.
  • Why might k-NN beat a one-class SVM? The data are low-dimensional with complex local structure, k-NN needs no γ, and the OCSVM’s plateau weakens ranking.
📝 Quick check (Level 3)
0/3 answered
  1. 1. The one-class SVM estimates…
  2. 2. Inside the data the OCSVM score is often…
  3. 3. Which parameter is most critical?

Level 4: Expert

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

Novelty detection on two-mode telemetry

History.

  • Schölkopf, Platt, Shawe-Taylor, Smola and Williamson (2001) introduced the one-class SVM and its ν-property.
  • Tax and Duin (1999, 2004) introduced SVDD.
  • Applications spread to machinery fault detection, intrusion detection and spacecraft telemetry.
  • Isolation forest (Liu, Ting and Zhou, 2008) and deep one-class methods (Deep SVDD, Ruff et al., 2018) followed, keeping the one-class idea.

Exercise 1.

  • The ν-property held: 0.000 ≤ 0.05 ≤ 0.188, 0.138 ≤ 0.2 ≤ 0.275 and 0.475 ≤ 0.5 ≤ 0.525.
  • Scores never rose along a ray leaving the data, and a point at (4, 4) scored −0.198.
  • At the cloud’s centre the score was −0.0004. With γ = 0.5 the score is almost flat inside the data, so the centre sits on the plateau, technically just below 0.

Exercise 2. Setup: nominal data from two operating modes (n = 200), test data with 200 nominal points, 60 “gap” anomalies between the modes and 60 “far” anomalies. ν = 0.05. The table shows ROC AUC averaged over 3 seeds.

Detector gap anomalies far anomalies
OCSVM, γ = 0.1 0.725 1.000
OCSVM, γ = 1 0.936 1.000
OCSVM, γ = 10 0.962 0.999
Mahalanobis (one Gaussian) 0.056 0.984
5-NN distance 0.988 1.000
  • Far anomalies are easy. Every detector scored at least 0.98.
  • Gap anomalies separate the methods. A single Gaussian puts its centre in the gap, so it ranks gap anomalies as the most normal points of all (AUC 0.056, far below chance).
  • The OCSVM needs a large enough γ to split the two modes. It improved from 0.73 to 0.96 as γ grew.
  • The simple 5-NN distance was best (0.988) in this low-dimensional setting. The OCSVM’s score plateau weakens its ranking. In higher dimensions, or with very large n, the comparison can change.
🐍 Exercise 2 (research): one-class SVM versus simpler detectors
Train on two-mode nominal telemetry; score held-out nominal points, gap anomalies and far anomalies with OCSVM (γ in {0.1, 1, 10}, ν = 0.05), Mahalanobis distance and 5-NN distance; report ROC AUC per anomaly type, averaged over 3 seeds.

One-class SVMs in AI, robotics and aerospace

  • Spacecraft telemetry monitoring: learn nominal housekeeping behaviour per operating mode and flag departures.
  • Machinery health: bearing and gearbox vibration features from healthy runs.
  • Robot safety: detect out-of-distribution sensor inputs before a learned controller acts on them.
  • Deep SVDD: the same objective applied to neural-network features for images.

References

  1. B. Schölkopf, J. C. Platt, J. Shawe-Taylor, A. J. Smola, R. C. Williamson (2001). “Estimating the support of a high-dimensional distribution.” Neural Computation 13(7).
  2. D. M. J. Tax, R. P. W. Duin (2004). “Support vector data description.” Machine Learning 54.
  3. F. T. Liu, K. M. Ting, Z.-H. Zhou (2008). “Isolation forest.” ICDM.
  4. L. Ruff et al. (2018). “Deep one-class classification.” ICML.
  5. M. A. F. Pimentel, D. A. Clifton, L. Clifton, L. Tarassenko (2014). “A review of novelty detection.” Signal Processing 99.