Classification in Machine Learning
1. Introduction
Many problems in data analysis require assigning discrete labels to observations. An email is classified as spam or not spam. An image patch is classified as background or object. A medical measurement is classified as healthy or pathological. In each case, the output is a category drawn from a finite set.
Problems of this type are instances of supervised classification: labeled examples are provided during training, and the goal is to infer a rule that assigns labels to new inputs in a way that generalizes beyond the training set.
The technical difficulty is not in defining a mapping from inputs to labels—infinitely many mappings can fit any finite dataset—but in choosing a mapping that reflects stable structure in the data-generating process. Doing so requires a modeling language (geometry or probability), an objective (a loss), and an algorithm (an optimizer).
2. Problem Formulation
We are given a dataset of input–output pairs
where and , a finite label set. For binary classification, .
A classifier is a function
The objective is not merely to match labels on the training set but to achieve low error on unseen data drawn from the same distribution.
3. Classification as Space Partitioning
Any classifier partitions input space into decision regions. For binary classification, the boundary separating the regions is the decision boundary.
A linear classifier takes the form
with decision boundary . This geometric view clarifies what can and cannot be represented by a model class: linear boundaries cannot represent disjoint regions without an explicit feature map.
Geometry alone, however, does not account for overlap, noise, and uncertainty. For that, probability is the more appropriate language.
4. A Necessary Contrast: Clustering Is Not Classification
It is common to confuse class structure with cluster structure. Clustering methods can produce visually plausible partitions, but they do not use labels and do not optimize predictive risk.
The next example demonstrates the difference. The same type of point cloud can be partitioned by an unsupervised algorithm without any notion of “correctness” relative to labels.
K-means clustering (unsupervised contrast)
This output is not “wrong,” but it is not a supervised classifier. The algorithm has no access to labels and therefore cannot minimize classification error. Any mapping from clusters to classes (if classes exist at all) is imposed after training.
5. Probabilistic Formulation
In supervised classification one typically models conditional probabilities
and predicts by the decision rule
This framework separates estimation (learning a probability model) from decision-making (choosing a label). It also provides a direct route to objective functions derived from likelihood principles.
6. Support Vector Machines
Logistic regression and related probabilistic models define classification through a conditional probability and derive an objective from likelihood. Support Vector Machines (SVMs) take a different route: they define classification through separation with margin and derive an objective from geometric robustness.
Consider binary labels . A linear decision function has the form
and predictions are made by
If the data are linearly separable, there are infinitely many separating hyperplanes. SVMs select the separator that maximizes the geometric margin. In the canonical normalization, the margin constraints are written as
and the (hard-margin) optimization problem is
The quantity controls the margin width; minimizing maximizes the margin.
Real data are rarely separable. The soft-margin SVM introduces hinge penalties through the objective
where controls the trade-off between large margin (small ) and training violations of the margin constraints. The term
is the hinge loss. It is zero once a point is correctly classified with margin at least 1, and grows linearly for margin violations.
In contrast to logistic loss, hinge loss does not attempt to model probabilities. It enforces a margin-based notion of correctness that is particularly aligned with generalization arguments based on margins.
Linear SVM (soft margin) trained with subgradient descent
The key distinction from logistic regression is conceptual, not cosmetic. Logistic regression optimizes a probabilistic loss that depends on log-likelihood; the SVM optimizes a margin objective in which only points on or inside the margin directly influence the solution through hinge penalties.
Support Vector Machines and logistic regression both learn linear decision functions of the form , but they differ in what they optimize and what their outputs mean. Logistic regression is a conditional probabilistic model: it fits by maximizing likelihood (equivalently minimizing log loss), so its scores are interpretable as calibrated probabilities under the model and training continues to be influenced by essentially all points, with increasingly large penalties for confident mistakes. A (soft-margin) SVM instead minimizes , which is a margin-based objective that does not define probabilities; once a point is correctly classified with margin at least 1, it exerts no further influence on the hinge term, so the solution is determined primarily by points near the boundary (the “support vectors”). Consequently, logistic regression is typically preferred when probabilistic interpretation or downstream decision-making under uncertainty matters, whereas SVMs are often preferred when margin maximization and robustness to small perturbations near the boundary are the primary goals.