nirs4all.controllers.transforms.y_transformer module
- class nirs4all.controllers.transforms.y_transformer.YTransformerMixinController[source]
Bases:
OperatorControllerController for applying sklearn TransformerMixin operators to targets (y) instead of features (X).
Triggered by the “y_processing” keyword and applies transformations to target data, fitting on train targets and transforming all target data.
- Supports both single transformers and chained transformers (list syntax):
Single: {“y_processing”: StandardScaler()}
Chained: {“y_processing”: [StandardScaler, QuantileTransformer(n_quantiles=30)]}
When using chained transformers, each transformer is applied sequentially, with proper ancestry tracking and individual artifact persistence for prediction mode.
- execute(step_info: ParsedStep, dataset: SpectroDataset, context: ExecutionContext, runtime_context: RuntimeContext, source: int = -1, mode: str = 'train', loaded_binaries: Any = None, prediction_store: Any = None) Tuple[ExecutionContext, List[Any]][source]
Execute transformer(s) on dataset targets, fitting on train targets and transforming all targets.
Supports both single transformers and chained transformers (list). Each transformer is applied sequentially, with proper ancestry tracking.
- Parameters:
step_info – Parsed step containing operator and metadata
dataset – Dataset containing targets to transform
context – Pipeline context with partition information
runtime_context – Runtime context containing infrastructure components
source – Source index (not used for target processing)
mode – Execution mode (“train”, “predict”, or “explain”)
loaded_binaries – Pre-loaded fitted transformers for predict/explain mode
prediction_store – Not used for y_processing
- Returns:
Tuple of (updated_context, fitted_transformers_list)
- classmethod matches(step: Any, operator: Any, keyword: str) bool[source]
Match if keyword is ‘y_processing’ and operator is TransformerMixin or list thereof.
- Parameters:
step – Original step configuration
operator – Parsed operator (TransformerMixin instance, class, or list)
keyword – Step keyword
- Returns:
True if this controller should handle the step