Trace the impact of a duplicate in evaluation
Return to the home row after each number or separator. · 209 words
Suppose a plant classifier has 160 training photos and 40 evaluation photos. Evaluation image T7 and training image T8 are different crops of source photo P31, so they are duplicates even though their pixels differ. The model can memorize T8 and then recognize T7 too easily. This is data leakage, meaning training information reaches the test through a copy. In a toy evaluation the model gets thirty-six of forty evaluation images right, including T7. After retraining without P31 in training, it misses T7 but keeps every other prediction. The score drops from 90 percent to 35 out of 40, or 87.5 percent. A search by source_photo_id reveals the leak.
Now consider a bookstore recommendation test. Book B7 appears twice in evaluation with the same year, genre, rating, and label, although one row has a new cover URL. The model answers both correctly, so the report says 80 of 100, or 80 percent. After one copy is removed, it gets 79 of 99 correct, about 79.8 percent. A filename check misses this pair. A work_id check catches it. The final split groups all editions of one work and all copies of one image in the same partition. Reports should show row counts, unique counts, and accuracy so inflation is visible.
Check your recall
In the plant example, how do T7 and T8 inflate evaluation, and which identifier reveals that they are duplicates?
Check your answer
T7 is an evaluation copy of source photo P31, and T8 is a training crop of that same source. The model can use the training copy to help answer T7. Grouping or searching with source_photo_id exposes the connection, while grouping by source photo prevents the leak.
Sources and credits
Original KeyTouch lesson. Background reading · Google · Machine Learning Crash Course.