Split by customer to avoid repeated records
Return to the home row after each number or separator. · 170 words
An online bookstore predicts whether a customer will buy again within 30 days. Its raw table has one row per purchase, so customer 17 may appear six times. The customer ID is a grouping key: it identifies rows belonging to the same person. A random row split could put some purchases from customer 17 in training and others in test. The model could reuse that customer's habits instead of learning patterns for new customers. Group rows by customer ID first, then divide customers among training, validation, and test.
A sports club records one row per monthly attendance. Member 23 appears in January, February, and March, showing a preference for weekday classes. Randomly splitting rows would leak these repeated patterns across sets. Instead, assign whole member IDs, perhaps 70% of members to training, 15% to validation, and 15% to test. Training teaches the model, validation selects settings, and test gives the final estimate. Test may include several records for one held-out member, but that member cannot appear in training or validation.
Check your recall
In the sports club example, what should be assigned to each split?
Check your answer
Assign whole member IDs to training, validation, or test. Do not split one member's attendance records across different sets.
Sources and credits
Original KeyTouch lesson. Background reading · Google · Machine Learning Crash Course.