Home / Machine Learning

Support Vector Machines

A robust supervised learning model for classification. Add points to see the margin maximize.

Input Mode

Hyperplane Boundary

Status: Ready
Tip: Add points from both classes to calculate the decision boundary.

Model Metrics

Support Vectors 0
Bias Parameter (b) 0.000
"Support Vectors" are the points that 'support' the boundary. Only these points influence the final model position.

Legend

Decision Plane
Soft Margin
Active SV

Support Vector Machines: A Visual Guide

Explore the core concepts of SVMs by interacting with the model directly.

The Core Idea of SVM

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.

Maximizing the Margin

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.

What are Support Vectors?

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.

  • If you were to move a support vector, the optimal hyperplane would also move.
  • If you were to remove a non-support vector, the hyperplane would not change at all.

In the visualization, these points are highlighted with a green circle. Notice how few points are actually needed to define the entire boundary!

Interactive Exploration Guide

Use the canvas above to build your intuition:

  1. Start Fresh: Click "Reset Canvas". Add a few "Indigo" points on the left and a few "Amber" points on the right. Observe how the white decision boundary and the dashed margin lines appear, separating the two classes.
  2. Identify Support Vectors: Add a point very close to the boundary. Notice it gets a green circle, becoming a support vector. The "Support Vectors" count in the metrics panel will increase.
  3. Test Insensitivity: Now, add a new point far away from the boundary, deep within its class territory. Observe that the boundary does not move. This point is not a support vector and has no influence on the model.
  4. Create a Challenge: Place an "Indigo" point in the middle of the "Amber" cluster. This is a misclassified point. The SVM will try its best to find a boundary, but it demonstrates the concept of a "soft margin," where some misclassifications are tolerated to find a boundary that generalizes better than one that perfectly separates the training data (which could be overfit).
  5. Move a Support Vector: Reset the canvas and create a simple, clean separation. Now, add a new point that is closer to the boundary than the current support vectors. See how the margin shrinks and the hyperplane adjusts its position. This proves that only the support vectors dictate the outcome.

The Kernel Trick

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.

Why Use SVM?

  • Effective in High-Dimensional Spaces: Works well even when the number of dimensions exceeds the number of samples.
  • Memory Efficient: It only uses a subset of training points (the support vectors) in the decision function.
  • Versatile: Different kernel functions can be specified for the decision function, making it adaptable to various data types.
Cheat sheet

Support Vector Machines

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.

MACHINE LEARNING · vizlearn.in/machine_learning/svm.html