cellmil.datamodels.transforms.label_pipeline¶
Pipeline for composing multiple label transforms.
Classes
|
Pipeline for applying multiple label transforms in sequence. |
- class cellmil.datamodels.transforms.label_pipeline.LabelTransformPipeline(transforms: List[LabelTransform])[source]¶
Bases:
objectPipeline for applying multiple label transforms in sequence.
This class manages a sequence of label transforms, ensuring that fittable transforms are properly fitted on training data before being applied.
- __init__(transforms: List[LabelTransform])[source]¶
Initialize the pipeline with a list of transforms.
- Parameters:
transforms – List of LabelTransform instances to apply in sequence
- fit(labels: Dict[str, Union[int, Tuple[float, int]]], **kwargs: Any) LabelTransformPipeline[source]¶
Fit all fittable transforms in the pipeline on training labels.
- Parameters:
labels – Training labels dictionary
**kwargs – Additional keyword arguments passed to each transform’s fit method
- Returns:
Self for method chaining
- transform_labels(labels: Dict[str, Union[int, Tuple[float, int]]]) Dict[str, Union[int, Tuple[float, int]]][source]¶
Apply all transforms in the pipeline sequentially.
- Parameters:
labels – Labels dictionary to transform
- Returns:
Transformed labels dictionary after applying all transforms
- fit_transform(labels: Dict[str, Union[int, Tuple[float, int]]], **kwargs: Any) Dict[str, Union[int, Tuple[float, int]]][source]¶
Fit the pipeline and apply it to labels.
- Parameters:
labels – Labels to fit and transform
**kwargs – Additional keyword arguments for fitting
- Returns:
Transformed labels
- get_config() Dict[str, Any][source]¶
Get configuration for all transforms in the pipeline.
- Returns:
Dictionary containing pipeline configuration
- save(directory: Path) None[source]¶
Save the pipeline and all its transforms to disk.
- Parameters:
directory – Directory to save the pipeline configuration and transforms
- classmethod load(directory: Path) LabelTransformPipeline[source]¶
Load a pipeline from disk.
- Parameters:
directory – Directory containing the saved pipeline
- Returns:
LabelTransformPipeline instance
- __getitem__(idx: int) LabelTransform[source]¶
Get a transform by index.