nirs4all.controllers.models.components.prediction_transformer module
Prediction Transformer - Handle scaling/unscaling of predictions
This component handles the transformation of predictions between different target spaces (scaled/unscaled, numeric/transformed).
Extracted from launch_training() lines 427-447 and _create_fold_averages() to eliminate duplicate logic.
- class nirs4all.controllers.models.components.prediction_transformer.PredictionTransformer[source]
Bases:
objectTransforms predictions between scaled and unscaled spaces.
- Handles:
Classification tasks: Keep predictions in transformed space
Regression tasks: Transform predictions back to numeric space
Respects current y_processing from context
Example
>>> transformer = PredictionTransformer() >>> y_pred_unscaled = transformer.transform_to_unscaled( ... y_pred_scaled, ... dataset, ... context ... )
- transform_batch_to_unscaled(predictions_dict: dict, dataset: SpectroDataset, context: ExecutionContext | None = None) dict[source]
Transform a dictionary of predictions to unscaled space.
- Parameters:
predictions_dict – Dictionary with keys like ‘train’, ‘val’, ‘test’ and values as prediction arrays
dataset – Dataset with transformation info
context – Execution context
- Returns:
Dictionary with same keys but unscaled predictions
- transform_to_unscaled(predictions_scaled: ndarray, dataset: SpectroDataset, context: ExecutionContext | None = None) ndarray[source]
Transform predictions from scaled/processed space to unscaled/numeric space.
- Parameters:
predictions_scaled – Predictions in scaled/processed space
dataset – Dataset with task type and target transformation info
context – Execution context with y processing info
- Returns:
Predictions in unscaled/numeric space