Difficulty: Medium Tags: ML Evaluation, Data Leakage, Time Series
A demand forecasting model is evaluated on trip records. A preprocessing change randomly shuffled rows before splitting, letting future observations leak into training. Given timestamps and a proposed cutoff, partition the records strictly by time and compute the resulting counts and mean target values.
Each record has timestamp t_i and target y_i. A record belongs to
training iff t_i < C; otherwise it belongs to test. Compute training
count, test count, and each partition's arithmetic mean target. If a
partition is empty, its mean is None. Never shuffle the records.
records (list of (timestamp, target) pairs), cutoff (number).
(train_count, test_count, train_mean_or_none, test_mean_or_none).
1 <= n <= 10^5, timestamps are integers, |y_i| <= 10^9.Input
records = [(8,100), (10,200), (12,300), (9,150)], cutoff = 10
Output
train_count = 2, test_count = 2
train_mean = 125.000000, test_mean = 250.000000
Explanation: Only timestamps strictly less than 10 enter training (8 and 9). Timestamp 10 and 12 belong to test.
No results yet
Run your code to check it against the examples, or submit to run every test.