← back to machine learning

What is ML?

Deisenroth et al., Mathematics for Machine Learning (CC BY 4.0) · mml-book.github.io

ML is function approximation from data. Supervised learning fits a function from labeled examples. Unsupervised learning discovers structure without labels. Reinforcement learning learns from reward signals. Every ML algorithm is choosing a function from a hypothesis space that best explains the data it has seen.

Machine Learning Supervised labeled examples (x, y) pairs Unsupervised structure discovery x only Reinforcement reward signals action → reward Three paradigms, one goal: approximate the right function.

Train/test split

The most basic discipline in ML: never evaluate on the data you trained on. Hold out a portion for testing. The training set teaches; the test set judges.

Scheme

Nearest-neighbor classifier

The simplest possible classifier: given a new point, find the closest training point and copy its label. No parameters to learn. The training data is the model.

Scheme

Evaluating accuracy

Accuracy is the fraction of test examples the model gets right. It is the most basic metric — good enough to start, too coarse for serious work. Function approximation alone is not jkintelligence; that requires closed feedback loops where the system consolidates what it has learned back into its own processing.

Scheme

Notation reference

Math Scheme Python Meaning
f: X → Y(define (f x) ...)def f(x): ...Function mapping
(xᵢ, yᵢ)(list xi yi)(xi, yi)Labeled example
‖x - y‖(dist x y)dist(x, y)Euclidean distance
argmin(find-best ...)min(..., key=...)Index of minimum
accuracy(/ correct n)correct / nFraction correct

Translation notes

Nearest-neighbor is pure functional: no mutation, no learned parameters. The training data is passed as an argument, making the model explicit. Python's min with a key function is the imperative equivalent of the recursive find-best. Both are linear scans — O(n) per query.

Real ML frameworks (scikit-learn, PyTorch) add indexing structures for speed, but the core idea is identical: find the function that best explains the data.

Neighbors
Ready for the real thing? Read Mathematics for Machine Learning Ch. 8 and Dive into Deep Learning Ch. 1.