Hyperplane
Last edited
Fact-checked
In review queue
Sources
14 citations
Revision
v5 · 3,791 words
Fact-checks are independent of edits: a reviewer re-verifies the article against its sources and stamps the date. How we verify
A hyperplane is a flat, affine subspace of dimension n-1 embedded in an n-dimensional space, defined by the linear equation , where w is a normal vector and b is a scalar offset [1][12]. It generalizes a line in two dimensions and a plane in three dimensions to spaces of arbitrary dimensionality, and every hyperplane divides the space into two half-spaces. In machine learning and statistics, hyperplanes serve as decision boundaries that separate data into distinct classes, which makes them foundational to linear classifiers such as support vector machines, logistic regression, and perceptrons [3][5].
ELI5: explain like I'm 5
Imagine you have a pile of red balls and a pile of blue balls on a table. You want to draw a line with a ruler so that all the red balls are on one side and all the blue balls are on the other. That line is a hyperplane in two dimensions.
Now imagine the balls are floating in the air instead of sitting on a flat table. You would need a flat sheet of paper (a plane) to separate the red ones from the blue ones. That sheet of paper is a hyperplane in three dimensions.
If you had even more dimensions (which is hard to picture, but computers handle it just fine), the separator would still be a flat surface one dimension thinner than the space it sits in. That flat separator is always called a hyperplane. The goal of many machine learning algorithms is to find the best position for this separator so that it divides the data as cleanly as possible.
What is a hyperplane in mathematics?
Formally, a hyperplane in the Euclidean space is the set of all points x satisfying a linear equation:
where is a nonzero normal vector perpendicular to the hyperplane and b is a scalar offset (also called the bias). Using vector notation, this can be written more compactly as:
where w is the weight (normal) vector and b is the bias term [1][12]. Every hyperplane divides the ambient space into two half-spaces: the set of points where and the set where .
Key properties
- A hyperplane in has dimension (equivalently, codimension 1) [12].
- Any hyperplane that passes through the origin is a linear subspace; otherwise it is an affine subspace.
- A hyperplane has exactly two unit normal vectors that point in opposite directions.
- The signed distance from a point to the hyperplane is , where is the Euclidean norm of [1][7]. The sign of this quantity tells you which half-space the point lies in, and its absolute value gives the perpendicular distance to the hyperplane.
Dimensional examples
The following table shows what a hyperplane looks like in spaces of increasing dimension.
| Ambient space dimension (n) | Hyperplane dimension (n-1) | Geometric object | Example |
|---|---|---|---|
| 1 | 0 | Point | A single point on a number line divides it into two rays |
| 2 | 1 | Line | A line divides the plane into two half-planes |
| 3 | 2 | Plane | A plane divides 3D space into two half-spaces |
| 4 | 3 | 3D hyperplane | A three-dimensional "slice" of 4D space |
| n | n-1 | (n-1)-flat | General case |
What are the types of hyperplanes?
Linear (vector) hyperplanes
A linear hyperplane passes through the origin and is defined by . It is a true linear subspace of .
Affine hyperplanes
An affine hyperplane does not necessarily pass through the origin. It is defined by where is not zero. An affine hyperplane can be seen as a translated copy of a linear hyperplane. Most hyperplanes encountered in machine learning are affine because the bias term b shifts the decision boundary away from the origin to better fit the data.
Projective hyperplanes
In projective geometry, a projective hyperplane is a subspace of codimension 1 in a projective space. Unlike Euclidean hyperplanes, it takes two projective hyperplanes to separate points in a projective space.
How is a hyperplane used in classification?
In supervised classification, a decision boundary is the surface that separates the regions of feature space assigned to different classes. When this surface is a hyperplane, the classifier is called a linear classifier. The model assigns a class label to an input based on which side of the hyperplane it falls on:
- If , predict class +1
- If , predict class -1
Classifying a new point therefore reduces to evaluating the sign of , a single dot product and comparison [3][7]. Several widely used algorithms produce hyperplane decision boundaries, as summarized below.
| Algorithm | How it finds the hyperplane | Key characteristic |
|---|---|---|
| Perceptron | Iteratively adjusts weights using misclassified points | Converges if data is linearly separable; no unique solution |
| Logistic regression | Maximizes the log-likelihood of class labels via a sigmoid function | Outputs class probabilities; decision boundary at |
| Support vector machine (SVM) | Maximizes the geometric margin between classes | Unique, optimal hyperplane determined by support vectors |
| Linear discriminant analysis (LDA) | Maximizes between-class variance relative to within-class variance | Also used for dimensionality reduction |
| Naive Bayes (Gaussian) | Derives boundary from posterior probability estimates | Linear boundary when class covariances are equal |
What is the maximum-margin hyperplane?
Support vector machines provide the most direct and well-studied application of hyperplanes in classification. The core idea is to find the hyperplane that maximizes the margin, the distance between the hyperplane and the nearest training points from each class. This maximum-margin hyperplane is the unique separating hyperplane that lies halfway between the two classes and is as far as possible from the closest point of either class [3][13].
The approach traces to Corinna Cortes and Vladimir Vapnik, whose 1995 paper "Support-Vector Networks" introduced the modern formulation. They described the method this way: "The support-vector network is a new learning machine for two-group classification problems" in which "input vectors are non-linearly mapped to a very high-dimension feature space" where "a linear decision surface is constructed" with "special properties" that "ensure high generalization ability of the learning machine" [3]. The earlier algorithm of Bernhard Boser, Isabelle Guyon, and Vapnik (1992) framed the same goal directly: "A training algorithm that maximizes the margin between the training patterns and the decision boundary is presented" [4].
Geometric margin
Given a separating hyperplane w . x + b = 0, the geometric margin is the perpendicular distance from the hyperplane to the closest data point of either class. For a correctly classified point with , the functional margin is . The geometric margin normalizes this by the magnitude of w:
The overall margin of the classifier is the minimum geometric margin across all training points [3][10].
Hard-margin SVM
When the training data is perfectly linearly separable, the hard-margin SVM solves the following optimization problem:
Minimize
Subject to for all
Minimizing is equivalent to maximizing the margin . The constraint ensures that every training point lies on the correct side of the margin boundary [3][8].
Soft-margin SVM
Real-world data is rarely perfectly separable. Corinna Cortes and Vladimir Vapnik introduced the soft-margin formulation in 1995, which allows some points to violate the margin by introducing slack variables [3]:
Minimize
Subject to and
The regularization parameter controls the trade-off between maximizing the margin and minimizing classification errors. A large C penalizes misclassifications heavily (narrower margin), while a small C allows more violations (wider margin).
Support vectors
The training points that lie exactly on the margin boundaries (where ) are called support vectors. These are the only data points that influence the position and orientation of the optimal hyperplane [3][10]. If a non-support-vector point were removed from the training set or moved (as long as it stays outside the margin), the resulting hyperplane would remain unchanged. In practice the number of support vectors is often a small fraction of the training set, which is why SVMs can be both compact and accurate.
Dual formulation
The SVM optimization problem can be reformulated using Lagrange multipliers into its dual form:
Maximize
Subject to and
The weight vector is recovered as . Points with are the support vectors. The dual form is significant because the data appears only through dot products , which enables the kernel trick [3][4].
How does the kernel trick relate to hyperplanes?
Many real-world datasets are not linearly separable in the original input space. The kernel method addresses this by implicitly mapping data into a higher-dimensional feature space where a linear hyperplane can separate the classes. Bernhard Boser, Isabelle Guyon, and Vladimir Vapnik proposed this approach in 1992 [4].
How it works
A mapping function transforms each input into a higher-dimensional space, . In this transformed space, a linear hyperplane can separate data that was nonlinearly distributed in the original space. The kernel function computes the dot product in the higher-dimensional space without explicitly performing the transformation. This avoids the computational cost of working in a potentially infinite-dimensional space [4][9].
In the dual SVM formulation, every occurrence of the dot product is simply replaced with .
Common kernel functions
| Kernel | Formula | Description |
|---|---|---|
| Linear | No transformation; equivalent to standard linear SVM | |
| Polynomial | Captures feature interactions up to degree ; | |
| Radial basis function (RBF) / Gaussian | Maps to infinite-dimensional space; controls width | |
| Sigmoid | Mimics neural network activation; valid only for certain , |
The RBF kernel is the most widely used nonlinear kernel in practice because it can model complex decision boundaries while having only one hyperparameter () to tune [9].
Interpretation in feature space
The resulting decision boundary in the original input space is nonlinear (it can be a curve, a closed region, or any complex shape), but in the high-dimensional feature space it remains a flat hyperplane. The kernel trick therefore lets SVMs find nonlinear decision boundaries while retaining the mathematical elegance and optimization guarantees of linear hyperplane separation [4][9].
How does the perceptron learn a hyperplane?
The perceptron, conceived by Frank Rosenblatt in 1957 and described in a 1958 paper, was one of the earliest algorithms to learn a hyperplane decision boundary [5]. A single-layer perceptron computes:
The perceptron learning algorithm updates the weights each time it encounters a misclassified training example:
where is the learning rate. The Perceptron Convergence Theorem guarantees that if the training data is linearly separable, the algorithm will find a separating hyperplane in a finite number of iterations [2][5]. However, the perceptron provides no guarantee about the quality of the hyperplane it finds; unlike SVMs, it does not maximize the margin.
Multi-layer perceptrons (the building blocks of deep learning) compose multiple layers of linear transformations and nonlinear activation functions. Each neuron in a hidden layer defines a hyperplane, and the network as a whole learns to combine many such hyperplanes to form complex, nonlinear decision boundaries.
How does logistic regression define its hyperplane?
Logistic regression is a linear classifier that models the probability that an input belongs to the positive class using the sigmoid function:
The decision boundary is the hyperplane where the predicted probability equals 0.5, which occurs when w . x + b = 0. Points on the positive side of the hyperplane receive predicted probabilities greater than 0.5 and are assigned to the positive class; points on the negative side are assigned to the negative class.
The decision threshold can be adjusted from 0.5 to change the trade-off between precision and recall. Changing the threshold effectively moves the decision boundary parallel to the original hyperplane.
What is linear discriminant analysis?
Linear discriminant analysis (LDA), developed by Ronald Fisher in 1936, finds a hyperplane that separates classes by maximizing the ratio of between-class variance to within-class variance [6]. The projection direction is chosen to maximize the Fisher criterion:
where is the between-class scatter matrix and is the within-class scatter matrix. The optimal solution is , where and are the class means. The resulting hyperplane is perpendicular to this direction.
LDA differs from SVM in that it models the class distributions (assuming Gaussian distributions with equal covariance), while SVM makes no distributional assumptions and focuses solely on the margin [6][7].
How are hyperplanes used for multiclass classification?
A single hyperplane can only separate two classes. To handle problems with classes, several strategies exist.
| Strategy | Number of classifiers | How it works |
|---|---|---|
| One-vs-rest (OvR) | K | Each classifier separates one class from all others; assign the class whose classifier gives the highest score |
| One-vs-one (OvO) | Each classifier separates one pair of classes; assign the class that wins the most pairwise comparisons | |
| Multiclass SVM (Crammer-Singer) | 1 (joint) | Optimizes a single objective over all K classes simultaneously |
For example, in a 5-class problem, OvR trains 5 binary classifiers (each learning one hyperplane), while OvO trains 10 binary classifiers.
What is the separating hyperplane theorem?
The theoretical foundation for using hyperplanes as class separators comes from the hyperplane separation theorem in convex optimization. The theorem states [1][14]:
If A and B are two disjoint, nonempty convex sets in R^n, then there exists a nonzero vector and a scalar such that for all and for all .
This is the weak separation form. A stronger version adds that if both sets are closed and at least one is compact, then strict separation is possible with a gap between two parallel hyperplanes [1][14].
The theorem guarantees that whenever two classes form disjoint convex sets in feature space, a separating hyperplane exists. The SVM optimization problem then finds the one with the maximum margin.
Where else do hyperplanes appear in machine learning?
Decision trees and piecewise-linear boundaries
Decision trees that split on a single feature at each node create axis-aligned hyperplanes. Each split is a hyperplane perpendicular to one feature axis. The overall decision boundary is a piecewise combination of these axis-aligned hyperplanes, forming rectangular regions in feature space. Oblique decision trees allow splits on linear combinations of features, producing arbitrarily oriented hyperplanes at each node.
Neural networks
Each neuron in a neural network computes w . x + b followed by a nonlinear activation function. Before the activation, the neuron defines a hyperplane in its input space. A single hidden layer with enough neurons can approximate any continuous decision boundary by composing many such hyperplanes. Deep neural networks create hierarchical compositions of hyperplanes across multiple layers, which enables them to learn highly complex, nonlinear boundaries.
Dimensionality reduction and random projections
Hyperplanes also play a role in dimensionality reduction. Principal component analysis (PCA) projects data onto a lower-dimensional subspace defined by hyperplanes. Random projection methods, supported by the Johnson-Lindenstrauss lemma, use random hyperplanes to project high-dimensional data into fewer dimensions while approximately preserving pairwise distances.
Clustering
Spectral clustering and some variants of k-means use hyperplanes to partition feature space. In particular, max-margin clustering extends the SVM framework to unsupervised settings by finding the hyperplane that separates unlabeled data with the largest margin.
Why does margin maximization improve generalization?
The margin is the perpendicular distance between the two parallel hyperplanes and . These are called the margin boundaries. The distance between them is [3][13].
To see why: pick any point on the positive margin boundary and compute its distance to the negative margin boundary . The distance is:
Maximizing is equivalent to minimizing , which is the SVM objective. A larger margin means the classifier is more robust to small perturbations in the test data, which generally leads to better generalization [3][10].
When were hyperplanes first used in machine learning?
The concept of hyperplanes has roots in 19th-century mathematics and has been applied in machine learning since the mid-20th century.
| Year | Milestone |
|---|---|
| 1936 | Ronald Fisher develops linear discriminant analysis, using hyperplanes to separate biological classes [6] |
| 1957 | Frank Rosenblatt introduces the perceptron, one of the first algorithms to learn a hyperplane from data (1958 paper) [5] |
| 1963 | Vladimir Vapnik and Alexey Chervonenkis propose the original SVM algorithm based on optimal separating hyperplanes [2] |
| 1992 | Boser, Guyon, and Vapnik introduce the kernel trick, allowing SVMs to find nonlinear boundaries via hyperplanes in transformed feature spaces [4] |
| 1995 | Cortes and Vapnik publish the soft-margin SVM formulation, handling non-separable data [3] |
| 1998 | SVMs gain widespread adoption in text classification, bioinformatics, and computer vision [10] |
What practical issues affect hyperplane classifiers?
Feature scaling
The position and orientation of the optimal hyperplane depend on the scale of each feature. Features with larger numeric ranges can dominate the dot product , causing the hyperplane to be biased toward those features. Normalization or standardization of features before training is therefore important for algorithms that rely on hyperplane decision boundaries.
High-dimensional spaces
In high-dimensional settings (where the number of features is large relative to the number of samples ), linear classifiers can often find a separating hyperplane even when no real pattern exists in the data. This is because, in high dimensions, random point sets become increasingly easy to separate with a hyperplane (Cover's theorem) [11]. Regularization and cross-validation are needed to avoid overfitting in such scenarios.
Computational complexity
Training a hard-margin SVM requires solving a quadratic programming problem. The time complexity is roughly to depending on the solver, where is the number of training samples and is the number of features [10]. The kernel trick does not change the asymptotic complexity but affects the constant factor, since kernel evaluations replace simple dot products.
Summary of key formulas
| Concept | Formula |
|---|---|
| Hyperplane equation | |
| Signed distance from point | |
| Margin width | |
| Hard-margin SVM objective | Minimize subject to |
| Soft-margin SVM objective | Minimize subject to |
| Weight vector from dual | |
| Kernel substitution | Replace with |
| Perceptron update rule | |
| Fisher criterion (LDA) |
See also
- Support vector machine
- Decision boundary
- Kernel support vector machines
- Perceptron
- Linear regression
- Logistic regression
- Activation function
- Convex optimization
- Regularization
- Dimensionality reduction
References
- Boyd, S. and Vandenberghe, L. (2004). *Convex Optimization*. Cambridge University Press. ↩
- Vapnik, V. and Chervonenkis, A. (1964). "A note on one class of perceptrons." *Automation and Remote Control*, 25(1). ↩
- Cortes, C. and Vapnik, V. (1995). "Support-vector networks." *Machine Learning*, 20(3), 273-297. ↩
- Boser, B., Guyon, I., and Vapnik, V. (1992). "A training algorithm for optimal margin classifiers." *Proceedings of the 5th Annual ACM Workshop on Computational Learning Theory*, 144-152. ↩
- Rosenblatt, F. (1958). "The perceptron: A probabilistic model for information storage and organization in the brain." *Psychological Review*, 65(6), 386-408. ↩
- Fisher, R.A. (1936). "The use of multiple measurements in taxonomic problems." *Annals of Eugenics*, 7(2), 179-188. ↩
- Hastie, T., Tibshirani, R., and Friedman, J. (2009). *The Elements of Statistical Learning*, 2nd edition. Springer. ↩
- Bishop, C.M. (2006). *Pattern Recognition and Machine Learning*. Springer. ↩
- Scholkopf, B. and Smola, A.J. (2002). *Learning with Kernels: Support Vector Machines, Regularization, Optimization, and Beyond*. MIT Press. ↩
- Burges, C.J.C. (1998). "A tutorial on support vector machines for pattern recognition." *Data Mining and Knowledge Discovery*, 2(2), 121-167. ↩
- Cover, T.M. (1965). "Geometrical and statistical properties of systems of linear inequalities with applications in pattern recognition." *IEEE Transactions on Electronic Computers*, EC-14(3), 326-334. ↩
- "Hyperplane." *Wikipedia*. https://en.wikipedia.org/wiki/Hyperplane ↩
- "Support vector machine." *Wikipedia*. https://en.wikipedia.org/wiki/Support_vector_machine ↩
- "Hyperplane separation theorem." *Wikipedia*. https://en.wikipedia.org/wiki/Hyperplane_separation_theorem ↩
Improve this article
Add missing citations, update stale details, or suggest a clearer explanation. Every suggestion is reviewed for sourcing before it goes live.
4 revisions by 1 contributors · full history