VIEW THIS AS

Auto mode follows the Route Engine until you choose a viewpoint.

YOU ARE HERE

ROUTE CHECK

CONNECTED TO

WHAT NEXT

Use the canonical route for this room, or HELP if you are unsure.

How Artificial Intelligence AI Works | How Support Vector Machines Separate Categories

Did you know? Imagine two groups of dots on a sheet of paper: blue on the left, orange on the right. Many straight lines might separate them. Some lines pass uncomfortably close to both groups, while another leaves a broad, empty strip between the nearest dots. A support vector machine (SVM) is built around the idea of finding a useful separating boundary with a large margin.

Quick answer: encode examples as feature vectors → choose a classifier and kernel → learn a separating boundary that balances a wide margin against classification errors → identify support vectors → test on new examples. An SVM is a supervised learning algorithm: its training examples need labels for the classes it is learning to distinguish.

In ordinary teaching examples, the model can be understood geometrically. It does not ‘see’ categories as a person does; it computes positions and decisions in a feature space.

Support vector machines in 30 seconds

  • Feature vector: numerical representation of an example.
  • Class label: the category the example is known to belong to.
  • Decision boundary: the line or higher-dimensional surface dividing predicted classes.
  • Margin: the separation between the boundary and selected nearby training points, under the SVM formulation.
  • Support vectors: training points that determine the fitted boundary in the relevant formulation.
  • Soft margin: a way to trade wider separation against violations and misclassification.
  • Kernel: a similarity-based mathematical method enabling nonlinear boundaries.

A one-dimensional example you can solve without software

Picture a number line. Our fictional blue training points lie at x = 1 and x = 2. Our orange points lie at x = 6 and x = 7. The groups are perfectly separable in this tiny example.

A separating boundary can sit anywhere between 2 and 6. But the midpoint at x = 4 is equally far from the closest blue point at 2 and orange point at 6: the distance is 2 units on each side.

In this idealised one-dimensional hard-margin case, the closest points at 2 and 6 are the support vectors. The outer points at 1 and 7 do not move the boundary in this setup.

The example demonstrates geometric intuition. Real SVM software uses a precise optimisation objective, multiple features and choices about regularisation and kernels.

Step 1: Decide what categories mean

Suppose a fictional machine-inspection dataset marks manufactured components as ‘pass’ or ‘review’. Its feature vector might contain a measured length and a vibration statistic. Labels must come from a documented inspection rule, not an arbitrary guess by the training algorithm.

A classifier does not know why a feature relates to the label. If an inspection process is inconsistent, the training set may contain contradictory examples that no neat boundary can repair.

Step 2: Turn observations into coordinates

With two features, an example becomes a point on a plane. With twenty features, it is a point in twenty-dimensional space. The geometry remains mathematical even when we cannot draw it.

Distance and margin depend on units. A feature measured in thousands can dominate one measured as a small decimal. Consistent scaling is especially important for many SVM configurations.

Step 3: Find a boundary, not merely a memorable example

Unlike k-nearest neighbours, which compares a new example with stored nearby examples, an SVM learns a decision function from training data. The trained model then uses this function to classify new feature vectors.

In a linear SVM, the boundary is a straight line in two dimensions, a plane in three dimensions or a hyperplane in more dimensions. The objective seeks a broad margin while respecting an allowed level of classification error.

Step 4: Understand why the nearest training points matter

If we add another blue point at x = 0 in the number-line example, the closest blue point remains x = 2. The maximum-margin midpoint between x = 2 and x = 6 therefore stays at x = 4.

If we instead add a correctly labelled blue point at x = 3, the closest points are now at 3 and 6. The idealised midpoint moves to x = 4.5. The points pressing closest to the gap influence the boundary.

This is the intuition behind support vectors. It does not mean an SVM blindly ignores all other training observations: the full optimisation problem and soft-margin violations matter.

Step 5: Use a soft margin when real data overlap

Real-world classes often overlap. There may be an orange point inside a mostly blue region because measurement noise, human error or underlying uncertainty is present. A perfect hard-margin separator may no longer exist.

A soft-margin SVM balances the desire for a broad boundary against penalties for margin violations. A regularisation parameter commonly called C controls that trade-off in standard C-SVM formulations.

Larger C places greater weight on penalising violations, potentially fitting training examples more tightly; smaller C usually permits more violations in exchange for stronger regularisation. Neither extreme is universally optimal.

Step 6: Know what kernels really do

Imagine blue points arranged in the centre of a circle and orange points arranged in a surrounding ring. No single straight line on the original drawing can separate the middle from the outside.

An SVM with a suitable nonlinear kernel can express a curved decision boundary. A common choice is the radial basis function (RBF) kernel, which compares how similar observations are at a chosen scale.

A kernel does not magically discover objective truth. It changes the class of decision functions the algorithm can learn. Kernel choice, scaling and regularisation need validation.

The scikit-learn SVM guide documents linear and nonlinear classifiers, support vectors and the strengths and limits of kernel methods.

Step 7: Beware of an overly flexible boundary

A model that bends around every questionable label may score extremely well on training examples and fail on new observations. The problem is called overfitting.

A reasonable evaluation compares a simple linear boundary with more flexible alternatives using validation data. Try multiple regularisation and kernel settings without using the final test set as a hidden practice sheet.

Step 8: Scale features inside the training process

Suppose one feature is temperature in the low tens and another is a sensor count in the tens of thousands. Without sensible preprocessing, distances can largely follow the count rather than the combined signal.

Fit scalers on training data only. Apply the learned transformation to validation, test and live examples. Fitting on the entire dataset before splitting can leak information from evaluation cases into training.

Step 9: Separate class decisions from probabilities

The default output of many SVM classifiers is a decision score or predicted label, not a directly calibrated probability. The magnitude of the distance-to-boundary-like score should not be casually interpreted as ‘90% confident’.

Some implementations offer probability estimates after extra fitting steps. Their quality must be evaluated. If meaningful probabilities are essential, a well-tested logistic regression or a separately calibrated SVM may be more appropriate.

Step 10: Evaluate the error that matters

A classifier can achieve high overall accuracy while overlooking a small important category. Inspect precision, recall, false positives, false negatives and results across relevant subgroups. If labels are noisy, audit the label process.

For a model expected to handle future observations, preserve a fair hold-out set and check whether production measurements have drifted away from training conditions.

When an SVM may help

  • Document classification: classifying suitably encoded text using linear SVMs.
  • Image or sensor features: classifying numerical feature representations where the dataset and modelling assumptions fit.
  • Smaller-to-medium structured datasets: testing a strong baseline when data size and kernel computation remain manageable.
  • Educational geometry: learning how feature scaling, distances and boundaries affect classification.

Kernel SVM training can become expensive as a dataset grows. High-dimensional data and strongly overlapping classes can also make model and hyperparameter choices difficult. The right method depends on data and constraints.

Five mistakes worth avoiding

  • ‘SVM always draws a straight line.’ Linear SVMs do; kernel methods can learn nonlinear boundaries.
  • ‘Only the closest two points matter in every case.’ That is a teaching picture, not a description of all support vectors and slack constraints.
  • ‘A larger margin guarantees better predictions.’ Margin is a design principle, not a replacement for out-of-sample evidence.
  • ‘Every SVM number is a probability.’ Ordinary decision scores are not probabilities.
  • ‘Feature scaling is optional because maths will adjust.’ Units change the geometry and can seriously affect a fitted model.

Try it: move one dot

  1. Draw a number line and label blue dots at 1 and 2, orange dots at 6 and 7.
  2. Find the gap between the closest opposing dots: from 2 to 6.
  3. Mark the midpoint at 4 and show that each closest dot is two units away.
  4. Add a new blue dot at 3. Find the new midpoint between 3 and 6: 4.5.
  5. Now add an orange dot at 2.5. Can one hard-margin boundary still separate all labels? No. Discuss why a soft margin or a different model may be needed.

Frequently asked questions

What does SVM stand for?

Support vector machine, a family of supervised methods for classification, regression and related tasks.

What is a support vector?

A training observation that influences the learned decision boundary under the fitted SVM model.

Are SVMs better than neural networks?

Not categorically. They make different assumptions and have different computational costs. Compare them with an appropriate benchmark.

Does the kernel replace training?

No. The kernel specifies a mathematical similarity and shapes the possible boundary; the classifier must still be fitted using training examples.

Why should students learn SVMs?

They make an abstract AI idea visible: classification can be treated as geometry, with margins, distances, constraints and trade-offs.

The one-minute takeaway

A support vector machine turns labelled observations into a decision boundary designed to balance separation and classification errors. Support vectors define critical parts of the boundary. Kernels can make the boundary nonlinear, but scaling, regularisation, trustworthy labels and independent testing determine whether the result is useful.

Trusted reading and connected articles

Discover more from eduKate Singapore

Subscribe now to keep reading and get access to the full archive.

Continue reading