Compare stratified and unstratified sampling
Return to the home row after each number or separator. · 161 words
Stratified sampling splits data while preserving the share of important groups, called strata. An unstratified split uses randomness without requiring those shares. Suppose a shop has 100 recent shoppers: 20 bought an item and 80 did not. We want 20 records for training and 20 for testing. A proportional stratified split puts 4 buyers and 16 nonbuyers in each twenty-record set. Buyers fill one fifth of the sample, matching their share of the full population.
Now consider an unstratified random split of the same 100 records. By bad luck, training receives 7 buyers and 13 nonbuyers, while testing receives 13 buyers and 7 nonbuyers. The training set now has 35 percent buyers, and its measured accuracy may be affected by this imbalance. Stratification reduces that problem, but random selection is still used inside each stratum. Use it when a small group is rare or when classes must appear in both sets. Record the random seed so the split can be reproduced.
Check your recall
For 100 shoppers with 20 buyers, how many buyers belong in each set of a proportional stratified sample containing 20 records?
Check your answer
Buyers make up 20 percent of the full population. Twenty percent of a twenty-record set gives four buyers, leaving sixteen places for nonbuyers.
Sources and credits
Original KeyTouch lesson. Background reading · Google · Machine Learning Crash Course.