ML 4.1Lesson outlineLesson 1 of 9 in Module 4
Distance and Similarity
Measure how alike two rows are, and see how the choice of measure and the feature scales change who counts as a neighbour.
Video in production.
Lesson outline: Distance and Similarity
In this lesson9 parts
- 01Which tumor is most like this one?
- 02Two measurements
- 03Euclidean distance on the raw values
- 04Standardise, then measure
- 05Four distances, Hamming and cosine
- 06Which measure finds the right neighbors?
- 07Where distances mislead
- 08Code
- 09Recap, your challenge, and what comes next
Builds on
This lesson stands on its own. These go deeper into what it uses.
Key terms: Distance and Similarity
The words this lesson introduces, each in one line. The module’s glossary collects them all, and the AI glossary has every term across the courses.
- norm (reminder, Maths 2.2)
- The length of a vector; a distance is the norm of a difference.
- standardising (reminder, Maths 2.2)
- Subtracting a feature's training mean and dividing by its training standard deviation.
- nearest neighbor
- The row with the smallest distance to a given row.
- Euclidean distance
- The square root of the sum of squared differences.
- Manhattan distance
- The sum of the absolute differences.
- Chebyshev distance
- The largest absolute difference.
- Minkowski distance
(Σ | dᵢ | ᵖ)^(1/p); Manhattan at p = 1, Euclidean at p = 2; a distance only for p ≥ 1.- Hamming distance
- The number of positions at which two rows differ.
- cosine similarity (reminder, Maths 2.3)
- The cosine of the angle between two vectors.
- cosine distance
- One minus cosine similarity.
Quiz: Distance and Similarity
Your first pick on each question is the one that counts. Getting one wrong here is how the lesson sticks.