Support Vector Machines
A robust supervised learning model for classification. Add points to see the margin maximize.
A robust supervised learning model for classification. Add points to see the margin maximize.
Explore the core concepts of SVMs by interacting with the model directly.
A Support Vector Machine (SVM) is a powerful supervised learning algorithm used for classification and regression. For classification, its primary goal is to find the optimal hyperplane that best separates data points of different classes in a high-dimensional space. The "best" hyperplane is the one that has the largest possible margin—the distance between the hyperplane and the nearest data point from either class.
Why is a large margin so important? A larger margin implies a more confident and robust classification model. It means the decision boundary is as far as possible from the data points of both classes, making it less sensitive to small variations in the data and more likely to generalize well to new, unseen data.
The hyperplane is defined by the equation w·x - b = 0, where `w` is a weight vector and `b` is the bias. The two parallel hyperplanes that define the margin are w·x - b = 1 and w·x - b = -1.
The data points that lie exactly on the margin boundaries are called Support Vectors. These are the most critical data points in the dataset because they alone "support" or define the position and orientation of the optimal hyperplane.
In the visualization, these points are highlighted with a green circle. Notice how few points are actually needed to define the entire boundary!
Use the canvas above to build your intuition:
What if the data isn't linearly separable? This is where SVMs truly shine. The kernel trick is a powerful technique that allows SVMs to create non-linear decision boundaries. It works by mapping the data into a higher-dimensional space where it becomes linearly separable.
Imagine data points arranged in a circle, with one class inside and another outside. A straight line can't separate them. But if we add a third dimension (e.g., `z = x² + y²`), we can lift the points into a 3D space where a simple plane can separate them. The kernel trick achieves this without the computational cost of actually transforming the data, by modifying the dot product calculation.
A Support Vector Machine (SVM) is a powerful supervised learning algorithm used for classification and regression. For classification, its primary goal is to find the optimal hyperplane that best separates data points of different classes in a high-dimensional space. The "best" hyperplane is the one that has the largest possible margin—the distance between the hyperplane and the nearest data point from either class.