Chapter 5 introduces Support Vector Machines (SVMs), one of the most powerful and versatile ML algorithms. You will learn the large-margin classification intuition, how to handle non-linearly separable data with soft margins and kernel functions, and how to apply SVMs to regression tasks withDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/ageron/handson-ml3/llms.txt
Use this file to discover all available pages before exploring further.
SVR.
What you’ll learn
- The large-margin classification intuition and support vectors
- Hard-margin versus soft-margin classification and the
Chyperparameter - Training linear SVMs with
LinearSVCusing a preprocessing pipeline - Non-linear SVMs: the polynomial kernel and the Gaussian RBF kernel
- The kernel trick: fitting non-linear boundaries without explicitly computing feature maps
- Similarity features and the intuition behind the RBF kernel
- SVM regression with
SVRand theepsilonparameter - Computational complexity: when to use
LinearSVCvs.SVC
Key concepts
Large-margin classification. An SVM classifier fits the widest possible street between two classes. The decision boundary is determined solely by the instances closest to the boundary—the support vectors. This makes SVMs robust to outliers far from the boundary. Soft-margin classification. Real data is rarely linearly separable. Soft-margin SVMs allow some instances to violate the margin; theC hyperparameter controls the trade-off. A large C enforces a stricter margin (low bias, higher variance); a small C allows more violations (higher bias, lower variance).
The kernel trick. Adding polynomial or radial basis function (RBF) features can make a non-linearly separable dataset linearly separable. The kernel trick lets SVMs implicitly compute the dot products in a very high-dimensional feature space without ever constructing that space, keeping computation tractable.
SVR (Support Vector Regression). SVR fits a “tube” of width 2ε around the training data; instances inside the tube do not contribute to the loss. This makes SVR insensitive to small errors and robust to outliers.
Code examples
Training a linear SVM with a preprocessing pipeline on the iris dataset:Running this notebook
Open in Colab
Run the setup cells
The first cells set matplotlib defaults and create the
images/svm directory for saving figures.Exercises
The chapter exercises ask you to train aLinearSVC on the iris dataset, use SVC with an RBF kernel on the same data and compare results, and train an SVM regressor on the California housing dataset. Solutions are in the notebook.