Test train data leakage
Your task
A suspiciously high eval score often means test data leaked into training. Given train and test, two lists of example strings (chat messages used to train and evaluate a moderation model), return how many entries of test also appear anywhere in train, using exact string comparison. Count each test entry every time it occurs in the test list, but at most once per occurrence regardless of how many times it appears in train. Example: train = ["buy now", "hello team"], test = ["hello team", "lunch?", "hello team"] returns 2.
Examples
leakage_count(train: list[str], test: list[str]) -> intExample 1
Input
leakage_count(["buy now", "hello team"], ["hello team", "lunch?", "hello team"])Output
2