Euclidean Distance
noun
say it: “yoo-KLID-ee-un DIS-tunss” /juˈklɪdiən ˈdɪstəns/
The length of the straight line between two points, found by adding the squared differences of their coordinates and taking the square root.
What is Euclidean distance?
Euclidean distance is the straight-line distance between two examples, treating each feature as a direction: subtract feature by feature, square the differences, add them and take the square root. k-nearest neighbors and k-means use it to decide which examples are close.
import math
apple = [150, 7] # grams, sweetness out of 10
mystery = [154, 4]
print(math.dist(apple, mystery)) # 5.0: the square root of 4² + 3²
In a sentence
- “The Euclidean distance between the two fruits was 5.”
- “k-nearest neighbors uses Euclidean distance to find the examples closest to a new one.”
Level: Journeyman · More AI Basics terms at this level
Updated