~/blog

Distance of a Point from a Plane

Jun 25, 20266 min readBy Mohammed Vasim
Machine LearningAIData Science

A bank receives a loan application: income $45k, debt ratio 0.35. Should they approve it? The decision depends on where this applicant sits relative to the bank's decision boundary — a line separating "likely to repay" from "likely to default." The single number that captures both the decision and the confidence is the signed distance from the applicant's data point to that line.

The house price anchor from earlier posts can't demonstrate this — predicting a continuous price doesn't have a "sides of a line" concept. For signed distance, we need a classification scenario, so we'll introduce a minimal sub-dataset for this post only.

Anchor setup: Predict loan default from income (, in $k) and debt ratio (). A candidate decision line is , so , , . The denominator is .

This is not the same as regression error (vertical distance from point to fitted line). Here the distance is perpendicular, and its sign — not just magnitude — carries the prediction.

Computing distances for three anchor points:

Point — income $45k, debt ratio 0.35:

Point — income $31k, debt ratio 0.62:

Point — income $95k, debt ratio 0.12:

PointRaw: Distance
(45, 0.35)+1.451.453.040.477
(31, 0.62)−6.366.363.042.09
(95, 0.12)+27.1427.143.048.93
income ($k) debt ratio 0.5x₁ − 3x₂ − 20 = 0 (45, 0.35) default d=0.48 (31, 0.62) default d=2.09 (95, 0.12) no-default d=8.93

Signed Distance — Which Side of the Line?

The sign of directly identifies which side of the decision boundary a point is on:

  • Positive ( for point (45, 0.35)): on the side where . Classifier predicts class +1.
  • Negative ( for point (31, 0.62)): on the opposite side. Classifier predicts class −1.

This signed quantity is exactly what SVMs use. The sign is the prediction; the magnitude is the confidence. A point 8.93 units from the decision boundary is much more confidently classified than one 0.48 units away.

Normalizing the Line Equation

Dividing , , by creates a normalized form where the denominator equals 1, simplifying the distance formula to just the numerator:

Check for point :

The small difference from 0.477 is rounding. Normalizing is why SVM theory often assumes — it makes the distance formula clean.

Extension to 3D: Distance from a Point to a Plane

In 3D, the plane equation is . The distance formula extends naturally:

For the plane and point :

The geometry is identical to the 2D case: the denominator is the length of the normal vector to the plane, and dividing by it projects the point's displacement onto the unit normal.

Extension to p Dimensions: Distance from a Point to a Hyperplane

In dimensions the hyperplane is , and the distance from a point to it is:

This is the margin formula in SVMs. The margin between two classes is defined as — twice the minimum distance from the closest training point to the decision hyperplane. Maximizing the margin means minimizing , which is the SVM optimization objective.

Distance Formula Reference

SettingFormulaDenominator
Point to line (2D)Normal vector length
Point to plane (3D)Normal vector length
Point to hyperplane (D)Weight vector norm

The signed distance formula is the mathematical backbone of SVMs (margin maximization), the log-odds in logistic regression (which is before the sigmoid), and the geometric interpretation of regularization (constraining effectively widens the margin). In the house price anchor from earlier posts, the same distance formula appears as the residual — but without the sign, because regression cares about magnitude only.

A common mistake is treating the signed distance as a reliable probability. A point 8.93 units from the boundary is confidently classified, but that doesn't mean it's 8.93 times more likely to belong to the positive class — the distance is in raw feature space, not probability space. The sigmoid in logistic regression exists precisely to convert one into the other.

Test Your Understanding

  1. For the decision line , compute the distance for the point using the formula. Which class does the sign predict?

  2. If you multiply both sides of the line equation by (so ), does the distance change? Does the signed distance change?

  3. In SVM, the margin is . If as in our anchor, what is the margin? To double the margin, what would you need to do to ?

  4. The normalization step changes to . If you use the normalized coefficients in the distance formula, why does the denominator disappear?

  5. A data point lies exactly on the decision hyperplane. What is its signed distance? What prediction does an SVM make for it, and why is this a problem in practice?

Comments (0)

No comments yet. Be the first to comment!

Leave a comment