LIVE·WAITING…
connecting to the live quote stream…
--:--:--UTC
#28
Out-of-fold stacking features
hardMLacceptance —~40 min
Implement oof_predictions(y, k) — out-of-fold predictions from the simplest level-1 model there is: the mean. Cut the n observations into k contiguous folds (remainder to the last); for each fold, predict every one of its observations with the mean of y over all the OTHER folds. Return the n predictions in order.
A stacked meta-learner trains on level-1 predictions; if those predictions saw the answer, the stack is a leak wearing a lab coat. This is the ai quants stacking lever with the model reduced to its skeleton. Return values rounded to 4 decimal places.
example 1
input
y=[1.0, 2.0, 1.0, 2.0, 1.0, 2.0], k=3
output
[1.5, 1.5, 1.5, 1.5, 1.5, 1.5]
example 2
input
y=[1.0, 2.0, 3.0, 4.0, 5.0, 6.0], k=3
output
[4.5, 4.5, 3.5, 3.5, 2.5, 2.5]
note
Fold means differ from the full mean here, so the leak shows.
constraints
- 2 ≤ k ≤ n ≤ 5_000
teacher · 2 hints · the first is free
↗ read the theory
the chapter this problem is cut from
▶ open in the workbench
run the same math on a real tape
●solution.py· utf-8 · spaces:4
ln 1, col 1tab indent · esc leave editor
python 3.13 · pyodide
+ 6 hidden on submit
input · keyword arguments to oof_predictions()
y=[1.0, 2.0, 1.0, 2.0, 1.0, 2.0], k=3
expected
[1.5, 1.5, 1.5, 1.5, 1.5, 1.5]
the judge calls oof_predictions() with exactly these inputs · outputs are compared to 6 decimal places
● standing bypython 3.13 in your browser · pyodide 0.28.3 · judged on the server to 6 dp⌘↵ run · ⌘⇧↵ submit
paper only · educational · not advice