WRITE · TRACE · UNDERSTAND
Project: train a stacking model from out-of-fold base predictions
Training rows have disjoint unique id, fold, finite scalar x,y; test rows need id,x only.
Read lesson: Project: train a stacking model from out-of-fold base predictions →
Your experiment
Training rows have disjoint unique id, fold, finite scalar x,y; test rows need id,x only. Require >=4 training rows, >=2 folds and >=2 fitting rows per held fold. Base learners are centered raw polynomial ridge models of degree 1 and 2, penalty .1 and unpenalized intercept. Form two OOF features per training row using only other folds. Fit a centered two-feature ridge meta-model with penalty .001 on OOF features. Refit bases on all training rows for test prediction. Return oof, folds with fit_ids/held_ids, meta weights,bias and predictions.
Python runs in your browser. Your draft stays on this device.
What to look for
Audit that every OOF feature excludes its target row's fold. Use an outer evaluation loop for the complete stack and defend fold construction before trusting an ensemble score. Replay follows the main orchestration function; helper computations execute and are checked separately.
Watch your code work
Ready to experimentWrite a solution or load the worked answer, then choose Trace & check.
Step through arrays, variables and training curves produced by your own Python.
