All problems
Train/Validation/Test Sizes
Problem
Compute train/validation/test sizes for a deterministic split: n_test = int(n * test_fraction), n_val = int(n * val_fraction), and n_train is the remainder.
Return [n_train, n_val, n_test].
Hint
Floor each split size independently and give the remainder to training.
Test cases
case 1
in: [100,0.1,0.2]
expected: [70,10,20]
case 2
in: [10,0.2,0.3]
expected: [5,2,3]
case 3
in: [5,0,0.4]
expected: [3,0,2]
case 4
in: [7,0.5,0.5]
expected: [1,3,3]
Starter codePython
def split_sizes(n, val_fraction, test_fraction):
# Returns [n_train, n_val, n_test]
# Your code here
pass4 test cases · run your code against them in the editor