Your First Machine Learning Model: k-Nearest Neighbors
The Saturday Afternoon Problem Before we dive into algorithms, let's think about how you already do machine learning without knowing it. You want to find someone to spend Saturday afternoon with. You're looking for your "nearest neighbor" based on: Gender (0 or 1) Age (in years) Outdoor sports interest (0-10 scale) Three candidates appear. Who's most similar to you (male, 50 years old, sports score 7)? Candidate 1: Male, 21 years old, score 5 → Average difference: 10.33 Candidate 2: Female, 51 years old, score 9 → Average difference: 1.33 Wait - the 21-year-old guy seems visually closer, but the math says the 51-year-old woman is more similar? This is the scaling problem we'll solve today. What Is k-Nearest Neighbors? It's the most intuitive machine learning algorithm: to classify something new, find what it's closest to and copy that label. If k=1: Find the single closest penguin and use its species If k=4: Find the 4 closest penguin...