# Support Vector Machines and Kernels

> Maximum-margin classifiers and the kernel trick for nonlinear boundaries on small and medium datasets. Free notes, key concepts, resources and a mini project.

Canonical: https://www.internhack.in/roadmaps/tracks/machine-learning/support-vector-machines
Last updated: 2026-11-28

Maximum-margin classifiers and the kernel trick for nonlinear boundaries on small and medium datasets.

Intermediate · about 5 hours · difficulty 3/5

Learn first: [Logistic Regression and Linear Classifiers](https://www.internhack.in/roadmaps/tracks/machine-learning/logistic-regression)

SVMs find the boundary that separates classes with the widest margin. The **kernel trick** lets them draw nonlinear boundaries by implicitly mapping data into higher dimensions.

### Concepts

- **Margin and support vectors**: only the points closest to the boundary define it.
- **Soft margin and C**: trades margin width against training errors; high C overfits.
- **Kernels**: linear, polynomial and RBF. For RBF, `gamma` controls how local each point's influence is.
- **Hinge loss**: the loss behind linear SVMs, comparable to log loss for logistic regression.
- **SVR** applies the same ideas to regression.

### When to use today

SVMs shine on small to medium datasets with many features (for example text or bioinformatics). Kernel SVMs scale poorly past roughly 100k samples, and gradient boosting usually wins on typical tabular data. They do not output probabilities natively.

### Must-do

Scale features and tune `C` and `gamma` together on a log grid.

**Good enough to move on** when you can visualize decision boundaries for linear and RBF SVMs on a 2D toy dataset and explain the effect of C and gamma.

## Key concepts

- **Maximum margin**
- **Soft margin and C**
- **Kernel trick and RBF**
- **Hinge loss**
- **Support vector regression**

## Mini project

Plot decision boundaries of linear, polynomial and RBF SVMs on scikit-learn's make_moons data for a grid of C and gamma values, then apply the best setup to the digits dataset.

## Check yourself

What does a very large gamma do to an RBF SVM's decision boundary?

## Free resources

- [scikit-learn: Support vector machines](https://scikit-learn.org/stable/modules/svm.html) (scikit-learn)
- [An Introduction to Statistical Learning (chapter 9)](https://www.statlearning.com/) (ISL)

Previous: [Gradient Boosting with XGBoost and LightGBM](https://www.internhack.in/roadmaps/tracks/machine-learning/gradient-boosting) · Next: [Evaluation Metrics](https://www.internhack.in/roadmaps/tracks/machine-learning/evaluation-metrics)

## More in Classical Supervised Learning

- [Framing ML Problems and the scikit-learn API](https://www.internhack.in/roadmaps/tracks/machine-learning/ml-problem-framing)
- [Linear Regression and Regularization](https://www.internhack.in/roadmaps/tracks/machine-learning/linear-regression)
- [Logistic Regression and Linear Classifiers](https://www.internhack.in/roadmaps/tracks/machine-learning/logistic-regression)
- [k-Nearest Neighbours and Naive Bayes](https://www.internhack.in/roadmaps/tracks/machine-learning/knn-and-naive-bayes)
- [Decision Trees](https://www.internhack.in/roadmaps/tracks/machine-learning/decision-trees)
- [Bagging and Random Forests](https://www.internhack.in/roadmaps/tracks/machine-learning/random-forests)
- [Gradient Boosting with XGBoost and LightGBM](https://www.internhack.in/roadmaps/tracks/machine-learning/gradient-boosting)
- [Support Vector Machines and Kernels](https://www.internhack.in/roadmaps/tracks/machine-learning/support-vector-machines)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [Machine Learning Engineer Roadmap](https://www.internhack.in/roadmaps/tracks/machine-learning)
