Log inStart free
LESSON 4.17 · 6 STAGES · 3 CONTROLS · 3 CHECKSPRO · PREVIEW

Distance and similarity measures

Watch six measures rank eight points around a query, and see the winner change.


Pro lesson. Stage 1 is free to watch. Pro opens all 6 stages, 3 controls and 3 checks, in this lesson and every other.

Go Pro · $8.25/mo
EXPLAINER · 4.17 · DISTANCE BAYL2 NEAREST: POINT 3 · 1.57
01
Stage 1 of 6 · Euclidean
Euclidean distance is the straight line from q. Point 3 is nearest: √(0.7² + (−1.4)²) = 1.57.
Explain it simply

Each point is two numbers, its features. Euclidean distance is the straight line from q, the query, to a point. Square the two gaps, add them, and take the square root, like Pythagoras. The dashed circle passes through point 3, and no point sits inside it.

Lines join q to all eight points. Point 3 is nearest, at 1.57. A dashed circle passes through it.

pointsp and covariance Σwinner, contour, valuesdetour that breaks a distancegrid, other paths
feature spaceranking · Euclideannearest first2462460feature 1feature 21.5712345678q814.3623.22131.57342.44552.92261.65472.51783.54d₂(q, x₃) = √(0.7² + (−1.4)²) = 1.57x₃ − q = (0.7, −1.4)feature spaceranking · Euclideannearest first2462460feature 1feature 21.5712345678q814.3623.22131.57342.44552.92261.65472.51783.54d₂(q, x₃) = √(0.7² + (−1.4)²) = 1.57x₃ − q = (0.7, −1.4)
Toy: 8 points · 2 features · 1 query q · 3 cloud shapes from one seed
STAGE 1 / 6
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
d2(q,x)=∑i(xi−qi)2\sy{d}{out}{d_2}(\sy{q}{ink}{\mathbf q}, \sy{x}{data}{\mathbf x}) = \sqrt{\textstyle\sum_i (\sy{x}{data}{x_i} - \sy{q}{ink}{q_i})^2}
d2(q,x3)=0.72+(−1.4)2=1.57d_2(\mathbf q, \mathbf x_{3}) = \sqrt{0.7^2 + (-1.4)^2} = 1.57

Square each gap, add them, then take the square root.

Common mix-ups

MYTHThe biggest dot product marks the most similar direction.

The fix, and 1 more mix-up with the diagram to show them, come with Pro.

Predict, then reveal
3 CHECKS · PRO
Q01As p grows from 1 to ∞, does point 3's distance from q grow or shrink?

Make your guess, then test it in the diagram. All 3 checks come with Pro.

PRO LESSON · YOU WATCHED STAGE 1 OF 6
Unlock the full explainer
  • 5 more stages and 3 live controls
  • 2 mix-up cards and 3 predict-then-reveal checks
  • Watch it as a narrated video, in three voices
  • Every Pro lesson and capstone · 656 in total

$99 a year, or $15 a month. Cancel any time.