cellmil.datamodels.transforms.base_label_transform¶
Base classes for label transforms.
Classes
|
Base class for label transforms that need to be fitted on training data. |
|
Base class for all label transforms. |
- class cellmil.datamodels.transforms.base_label_transform.LabelTransform(name: str)[source]¶
Bases:
ABCBase class for all label transforms.
- __init__(name: str)[source]¶
Initialize the transform.
- Parameters:
name – Name of the transform for identification
- abstract transform_labels(labels: Dict[str, Union[int, Tuple[float, int]]]) Dict[str, Union[int, Tuple[float, int]]][source]¶
Apply the transform to labels.
- Parameters:
labels – Dictionary mapping slide IDs to labels For classification: int labels For survival: (duration, event) tuples
- Returns:
Transformed labels dictionary
- abstract get_config() Dict[str, Any][source]¶
Get the configuration dictionary for this transform.
- Returns:
Dictionary containing transform configuration
- abstract classmethod from_config(config: Dict[str, Any]) LabelTransform[source]¶
Create transform instance from configuration dictionary.
- Parameters:
config – Configuration dictionary
- Returns:
LabelTransform instance
- save(path: Path) None[source]¶
Save the transform to disk.
- Parameters:
path – Path to save the transform
- classmethod load(path: Path) LabelTransform[source]¶
Load transform from disk.
- Parameters:
path – Path to load the transform from
- Returns:
LabelTransform instance
- class cellmil.datamodels.transforms.base_label_transform.FittableLabelTransform(name: str)[source]¶
Bases:
LabelTransformBase class for label transforms that need to be fitted on training data.
- __init__(name: str)[source]¶
Initialize the fittable label transform.
- Parameters:
name – Name of the transform for identification
- abstract fit(labels: Dict[str, Union[int, Tuple[float, int]]], **kwargs: Any) FittableLabelTransform[source]¶
Fit the transform on training labels.
- Parameters:
labels – Training labels dictionary mapping slide IDs to labels
**kwargs – Additional keyword arguments for fitting
- Returns:
Self for method chaining
- fit_transform(labels: Dict[str, Union[int, Tuple[float, int]]], **kwargs: Any) Dict[str, Union[int, Tuple[float, int]]][source]¶
Fit the transform and apply it to the labels.
- Parameters:
labels – Labels to fit and transform
**kwargs – Additional keyword arguments for fitting
- Returns:
Transformed labels