AI Fundamentals

What are Support Vector Machines?

mm
Add Unite.AI to your preferred sources on Google

A support vector machine (SVM) is a supervised-learning method that finds a decision boundary with the widest possible margin between classes. The training examples that determine that boundary are the support vectors.

SVMs can perform linear or nonlinear classification, regression, and novelty detection. They are especially useful for small-to-medium datasets with informative features, including high-dimensional sparse data, but their training cost can become impractical on very large datasets.

Key takeaways

  • An SVM maximizes the minimum margin between the boundary and the closest training points.
  • Support vectors are data points, not additional hyperplanes.
  • The parameter C balances margin width against penalties for violations.
  • Kernels calculate similarity in an implicit feature space without explicitly materializing every transformed feature.
Support vector machine comparison showing a maximum-margin linear boundary, soft-margin violations controlled by C, and a nonlinear kernel boundary
SVMs use support vectors to define a maximum-margin boundary and kernels to represent nonlinear separation.

The maximum-margin idea

For a linear binary classifier, the decision boundary is a hyperplane:

w · x + b = 0

The vector w determines the orientation and b the offset. Many hyperplanes may separate the training classes. The SVM chooses the one that maximizes the distance to the closest examples on either side. Those closest examples are the support vectors and have the greatest influence on the fitted boundary.

The objective is not to maximize the distance from the boundary to every point independently. It maximizes the minimum margin while satisfying or penalizing class constraints.

Hard and soft margins

A hard-margin SVM requires perfect linear separation and is sensitive to outliers. Real datasets usually need a soft margin, which introduces slack variables for observations inside the margin or on the wrong side of the boundary.

The hyperparameter C controls the penalty for these violations:

  • A larger C penalizes violations more strongly and often produces a narrower margin that follows training examples more closely.
  • A smaller C allows more violations in exchange for a wider, more regularized margin.

The number of support vectors is a result of the data and solution; increasing C does not guarantee a particular support-vector count.

The kernel trick

Some classes cannot be separated with a straight hyperplane in the original feature space. A kernel evaluates an inner product corresponding to another feature space. This lets the SVM fit a nonlinear boundary without explicitly calculating every transformed coordinate.

Common kernels include:

  • Linear: efficient for high-dimensional sparse features such as text.
  • Polynomial: models interactions up to a chosen degree.
  • Radial basis function (RBF): creates flexible local boundaries based on distance.
  • Sigmoid: resembles a neural activation but is less commonly the default choice.

For an RBF SVM, gamma controls how locally each training example influences the boundary. Large gamma can create highly detailed regions and overfit; small gamma produces smoother influence.

Multiclass classification

The classic SVM objective is binary. Libraries extend it using strategies such as one-vs-rest, which trains one classifier per class, or one-vs-one, which trains classifiers for class pairs and combines their decisions. Multiclass SVMs do not simply draw one fewer line than the number of classes.

Support vector regression and one-class SVM

Support vector regression (SVR) fits a function while ignoring errors inside an epsilon-wide tube and penalizing larger deviations. A one-class SVM estimates a boundary around typical data and can support novelty detection. An unusual point is not automatically fraud or failure; it is unusual under the fitted representation.

Practical requirements

SVMs depend on distances and inner products, so numerical features generally need scaling. C, kernel, gamma, and class weights should be selected through validation. Probability estimates are not inherent to the margin and often require calibration, which adds cost and should be evaluated separately.

Kernel SVM training can scale between quadratic and cubic time in the number of samples, depending on data and implementation. Linear SVM variants or stochastic linear models are better suited to very large datasets. For raw images, audio, or language, learned representations from deep learning may be more effective, while an SVM can still classify a fixed embedding.

SVM strengths and limitations

SVMs can work well with many features, offer a clear regularized objective, and depend primarily on support vectors at prediction time. Limitations include sensitivity to scaling and hyperparameters, potentially expensive training, reduced interpretability under nonlinear kernels, and probability calibration requirements.

Margins, kernels, and the optimization objective

A support vector machine seeks a separating hyperplane with a large margin between classes. Only support vectors on or inside the margin determine the boundary. Soft-margin SVMs introduce slack for overlap and mislabeled points; the parameter C trades a wider margin against training violations. Inputs should usually be scaled because distance and dot products drive the solution. Class weights or resampling help when error costs and prevalence are unequal, but thresholds and probabilities still need independent validation.

The kernel trick evaluates similarity as if inputs were mapped to a higher-dimensional feature space. Linear, polynomial, radial-basis, and specialized kernels encode different assumptions. For an RBF kernel, gamma controls how locally each point influences the boundary: high gamma can create intricate regions and overfit, while low gamma can underfit. Kernel matrices grow quadratically with sample count, making nonlinear SVMs expensive on large datasets. Linear solvers or approximate feature maps are often preferable at scale.

Multiclass use, calibration, and operational limits

Binary SVMs extend to multiclass through one-vs-rest, one-vs-one, or structured formulations. Hyperparameters must be tuned inside cross-validation, with grouped or temporal splits where needed. Evaluate class-specific precision and recall, margin distributions, calibration, and performance under shift. Raw decision scores are not probabilities; Platt scaling or isotonic calibration uses separate data and can degrade if prevalence changes. Compare against logistic regression, trees, and modern representation-based methods at matched preprocessing and tuning effort.

Serving requires the exact scaler, feature ordering, kernel parameters, support vectors, and class mapping. Prediction cost for a kernel SVM grows with support vectors, so measure latency and memory on realistic batches. Inputs far from training support can still receive confident labels; add out-of-distribution checks or an abstention policy where appropriate. Inspect errors for sensitive proxies and dataset artifacts. SVMs remain strong for medium-sized, high-dimensional problems, but a maximal geometric margin is not proof of causal structure or safety.

Worked example: an SVM for rare document routing

A legal operations team classifies short filings into routing categories using TF–IDF features and a linear SVM. It splits by matter and time to prevent templates from leaking, scales class weights based on reviewed error cost, and tunes C inside nested validation. The linear model is compared with logistic regression and a transformer. Per-class precision, recall, calibration, and reviewer workload matter more than overall accuracy.

Decision scores are calibrated on separate data, and low-margin or unsupported-language documents go to manual intake. The serving artifact includes tokenizer, vocabulary, weighting, model, calibration, and label map. Monitoring tracks new terms, category prevalence, margins, and corrected routes. Documents and support vectors are protected because text features can expose confidential information. A nonlinear kernel is rejected when its small quality gain cannot justify latency, memory, and interpretability cost.

Implementation evidence and operational readiness

A production decision needs more than a successful demonstration. Define the intended users, operating environment, inputs, outputs, dependencies, owner, and the consequence of each important failure. Establish a reproducible baseline and a versioned evaluation set before tuning. Test ordinary cases, boundary conditions, malformed or missing input, distribution shift, dependency outage, misuse, and the groups or environments most likely to be underserved. Measure task quality together with calibration or uncertainty, latency, throughput, resource cost, accessibility, privacy, and security. Record every transformation and threshold so an independent reviewer can reproduce the result and distinguish evidence from an attractive prototype.

Before launch, assign authority for release, exceptions, changes, rollback, and retirement. Use a staged rollout, preserve a safe fallback, and verify monitoring with deliberately injected failures. Operational telemetry should reveal input quality, output behavior, model or rule version, dependency health, human overrides, and confirmed outcomes without collecting unnecessary sensitive data. Define alert thresholds and a response owner, then review real-world evidence after deployment rather than assuming offline performance will persist. Reevaluate whenever data sources, users, models, vendors, policies, hardware, or objectives change. A maintained system also needs documented recovery, incident learning, deletion and retention procedures, and a clear point at which it should be disabled or replaced.

Frequently asked questions

Do SVMs only perform classification?

No. Support vector regression predicts continuous targets, while a one-class SVM can estimate a novelty boundary. Each variant has a different objective and set of hyperparameters.

When is a linear SVM a strong choice?

Linear SVMs are often effective for high-dimensional sparse features, including traditional text representations, where a flexible kernel would add cost without clear benefit.

Primary references

Blogger and programmer with specialties in Machine Learning and Deep Learning topics. Daniel hopes to help others use the power of AI for social good.