Lecture 2: k-Nearest Neighbors
From Similarity to Learned Compatibility
Overview
This lecture begins with practical decisions: predicting whether you will like a track and finding classmates who may work well with you. We use k-nearest neighbors to see how representation, distance, and evaluation turn proximity into a prediction.
Learning Objectives
By the end of this lecture, you will:
- Formulate a practical decision in terms of examples, features, a target, eligibility rules, and evidence of success
- Apply k-NN classification using a neighborhood, a voting rule, and a justified choice of \(k\)
- Explain how representation and distance encode the model’s proximity assumption
- Translate a human preference into a logical constraint and a loss for distance learning
Materials
TipQuick Access
Key Topics
- Problem formulation: connect examples, features, targets, and evidence to the decision
- k-NN classification: retrieve a neighborhood and aggregate its labels
- Geometry: understand what each representation and distance assumes
- Compatibility: use human preferences to learn a better distance
- Whole-pipeline evaluation: locate failures in data, features, eligibility, distance, aggregation, or evidence
Additional Resources
Previous: ← Lecture 1: Welcome to ML | Next: Lecture 3: Linear Regression →