coco_pipe.decoding.stack_oof_predictions#
- coco_pipe.decoding.stack_oof_predictions(inputs, y, folds, *, inner_cv=None, combiner=None, n_jobs=1, random_state=0)#
Nested out-of-fold stacking over inputs that cover different units.
For each outer fold, every input scores the training units it covers by an inner cross-validation and the test units it covers by a model fit on all of its training units (each through
Experiment). The combiner learns from the inner scores and scores the test units. A unit an input does not cover staysNaN(no imputation), so the combiner must accept missing values.- Parameters:
inputs (mapping of str to (DataContainer, ExperimentConfig)) – Named inputs with
ids(unit IDs) and the config of their single model.coords["feature_block"]gives per-block preprocessing.y (pandas.Series) – Binary target indexed by unit ID.
folds (pandas.Series) – Outer fold of each unit of y, indexed by unit ID (any order).
inner_cv (CVConfig, optional) – Inner splits of each outer training set. Defaults to stratified 5-fold.
combiner (sklearn estimator, optional) – Classifier with
predict_probathat acceptsNaN. Defaults to a shallowHistGradientBoostingClassifier.n_jobs (int, default=1) – Number of (outer fold, input) fits run in parallel.
random_state (int, default=0) – Seed of the default inner splits and combiner.
- Returns:
scores – Out-of-fold positive-class probabilities indexed like y.
- Return type:
- Raises:
ValueError – If inputs is empty, a unit of y has no fold, an input has no
ids, itsidsshare no unit with y, or its config holds more than one model.RuntimeError – If an input fails to fit.