Information design · Poster · Politecnico di Milano · 2022 — 23

K-Nearest Neighbors.

How a machine classifies the unknown, explained as a video game.

The top of the poster: K-Nearest Neighbor Classifier, and the welcome message to recruit IX 209 in the Main Control Tower.

01Overview

Explain an algorithm to anyone.

In the first month of the Final Synthesis Design Studio, each team took one popular data analysis algorithm and made a poster explaining how it works, with its strengths and weaknesses. Ours was K-Nearest Neighbors: it predicts the category of something new from the K known items closest to it.

Role
Information design and illustration, in a team of seven
Course
Final Synthesis Design Studio, Sect. C3 · MSc Communication Design · Politecnico di Milano · 2022/23
Series
Visual explanations of statistical methods, DensityDesign Lab
Team
Andrea Benedetto, Simone Cerea, Camilla Guerci, Surabhi Gupta, Haleh Nobar, Alessandro Pedriali, Yousef Taffal

02The idea

You are in the control tower.

Instead of starting with formulas, the poster starts with a job. “Hi recruit IX 209, welcome to the Main Control Tower!” Unidentified ships appear on the radar, and you have to decide whether each one is an enemy or an ally, by looking at the known ships around it. Every concept of the algorithm becomes a step of that mission.

The full K-Nearest Neighbor Classifier poster: the mission, the dataset, three steps, the test-train method, overfitting and underfitting, and final tips.
The full poster. Click to see it large.

03Three steps

Set, measure, vote.

The training set of known enemies and allies sits on a map. Step 1 sets the parameters: K and the distance formula. Step 2 measures the distance from the unknown ship to every known one. Step 3 sorts them, takes the K closest, and lets the most frequent class decide.

The three steps on the poster: setting the parameters, computing distances, sorting and assigning.
Steps 1 to 3, on the same radar map.

04Finding the best K

Not too tight, not too loose.

There is no shortcut to the right K. The poster walks through the test-train method, then shows what happens when K is wrong: too small and the boundary hugs every ship (overfitting); too large and it ignores them (underfitting). The ideal balance sits in between.

The test-train method as a flow: split the dataset, load the training set, predict, compare, calculate accuracy, select the best K.
Three maps: overfitting with K = 1, ideal balance with K = 4, underfitting with K = 18, each with its accuracy.
Same ships, three values of K.
41.6%accuracy with K = 1: overfitting
83.3%accuracy with K = 4: ideal balance
75%accuracy with K = 18: underfitting

05Before you go

Features, distances, and a warning.

The poster ends with what a recruit needs next: adding features to handle complex cases, choosing between distance formulas like Manhattan, Minkowski and Hamming, and a reminder that more features also mean more risk of errors.

The last part of the poster: features, distances, and a warning about adding too many features.

Open the poster (PDF) ↗  ·  All posters on DensityDesign ↗