Sampling Training Data
ML Engineer path · lesson 67 of 80Self-driving data is mostly from sunny Phoenix and the sunny Bay Area, and sentiment models learn from people willing to write reviews. Step the four nonprobability methods, then compute the odds that simple random sampling loses a 0.01% class entirely.
Key insight
Notice that none of the four is wrong in a way you can see from inside the sample. A convenience sample of a million points looks exactly like a representative sample of a million points, right up until the model meets someone the supermarket queue did not contain.
Probability or not?
Sort each sampling method by whether every example has a known chance of selection.
Tap a piece, then tap where it goes — or drag it. Tap the tray to take one back.
Nonprobability
Drop items hereProbability
Drop items hereTest your knowledge
The book prefers "training data" to "training dataset" because "dataset" denotes a set that is:
The short version
Polling a city by standing outside one supermarket. You will get a thousand responses by lunchtime, and every one of them is from someone who shops there, at that hour, on a weekday. The sample size was never the problem.
In more depth
Sampling Training Data
The book says training data, not training dataset, because "dataset" denotes a set that is finite and stationary, and data in production is neither.
Nonprobability sampling — four criteria
These samples are not representative and are riddled with selection biases. Three real cases: language models trained on Wikipedia, Common Crawl, Reddit; sentiment analysis on IMDB and Amazon reviews, biased toward people willing to review; self-driving data from Phoenix (lax regulations) and the Bay Area — both sunny. Waymo expanded to Kirkland, Washington in 2016 for the rain, and sunny data still dominates.
Random sampling
Reservoir sampling
For streaming data of unknown length that won't fit in memory.
Two guarantees: every item has an equal probability of selection (k/n), and you can stop at any time with correct probabilities.
Interview Questions
References & Further Reading
Love this visualization?
Sign up to track your progress, earn achievements, use the AI assistant, and access your personal learning dashboard.
100% free • No credit card required