Verifying a Stratified Split
Halewood Analytics refuses to accept a proposed test split until someone has checked its class balance. The full dataset holds a known number of rows in each class. The proposed split holds far fewer rows, but it should carry the same mix: a class making up 30% of everything ought to be roughly 30% of the split too. A split built that way is called stratified, and one that is not can flatter or wreck a model's score for reasons that have nothing to do with the model. How much drift counts as roughly is set by a tolerance the desk supplies.
Task: Print whether the proposed split keeps every class's share of the whole.
Input
Four lines. The first holds k, the number of classes. The second holds the full dataset's row count for each class, separated by single spaces. The third holds the proposed split's row count for each class, in the same class order. The fourth holds the tolerance.
Output
One line: stratified or not stratified. A class fails when the distance between its two shares is strictly greater than the tolerance, drifting in either direction; a distance of exactly the tolerance still passes. One failing class condemns the whole split, however well every other class matches.
Example:
Input:
2
700 300
140 60
0.02
Output:
stratified
Sign in to solve this problem
Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.
Sign in