Norms and Distances

Your distance function defines what "similar" means. Choose wrong and everything downstream breaks.

Build 1.5 hr Python

Prerequisites: Phase 1, Lessons 01 (Linear Algebra Intuition), 02 (Vectors, Matrices & Operations)

#Learning Objectives

  • Implement L1, L2, cosine, Mahalanobis, Jaccard, and edit distance functions from scratch
  • Select the appropriate distance metric for a given ML task and explain why alternatives fail
  • Connect L1 and L2 norms to LASSO and Ridge regularization and their geometric constraint regions
  • Demonstrate how the same dataset produces different nearest neighbors under different metrics
Full Access lesson

Keep going. The rest of this lesson is one step away.

Unlock all 503 lessons, video, code, quizzes and every future update. Pay in your own currency with Paystack.

The text and code of this lesson are based on AI Engineering from Scratch by Rohit Ghumare, MIT licensed.