Skip to content
Handbook navigation

Full-access lesson

Vectors

Take scikit-learn's 1,797 handwritten digits, each an 8 × 8 image flattened into a vector of 64 numbers, and for every image find the most similar other image. Measured by Euclidean distance, the nearest image shows the same digit 98.8% of the time. Measured by cosine similarity, 98.9%. Measured by the raw dot product, 72.1%, and one heavily inked "1" turns out to be the nearest neighbour of 166 different images. Software libraries offer all three formulas as measures of similarity, and on this job one of them is worse than the others by 27 percentage points.

The complete curriculum

All 12 volumes, companion resources, interviews, and architecture reviews.

Executable engineering practice

Subscriber-only Python, Java, TypeScript, and SQL labs in the isolated runner.

Vectors | KnowledgeOS