nirs4all.controllers.models.residual_model module
Controller for the residual model-combination operator (ResidualModel / {"residual": {...}}).
Fits a base model (leakage-safe OOF), trains a learner on the OOF residuals, and stores the combined
prediction base + lambda*gate*learner. Both sub-models are routed through their own framework
controllers, so the learner may be any nirs4all model (sklearn, PyTorch nicon, TabPFN, …).
The two sub-models are fit by delegating to the standard model controllers via the router; the residual
target is delivered to the learner through a numeric-rooted processed-target series (add_processed_targets
+ context.with_y), so no learner-side change is needed.
- class nirs4all.controllers.models.residual_model.ResidualModelController[source]
Bases:
OperatorControllerFit base + residual-learner combination. Priority 5 (above framework model controllers).
- execute(step_info, dataset, context, runtime_context, source: int = -1, mode: str = 'train', loaded_binaries=None, prediction_store=None)[source]
Run the operator with the given parameters and context.
- Parameters:
step_info – Parsed step containing operator, keyword, and metadata
dataset – Dataset to operate on
context – Pipeline execution context
runtime_context – Runtime infrastructure context
source – Data source index
mode – Execution mode (“train” or “predict”)
loaded_binaries – Pre-loaded binary objects for prediction mode
prediction_store – External prediction store for model predictions
- Returns:
Tuple of (updated_context, StepOutput)
- classmethod matches(step: Any, operator: Any, keyword: str) bool[source]
Check if the operator matches the step and keyword.