nos.transforms package¶
Submodules¶
nos.transforms.min_max_scale module¶
- class nos.transforms.min_max_scale.MinMaxScale(min_value: Tensor, max_value: Tensor)¶
Bases:
Transform
- forward(tensor: Tensor) Tensor ¶
Applies the transformation.
- Parameters:
tensor – Tensor that should be transformed.
- Returns:
Transformed tensor.
- undo(tensor: Tensor) Tensor ¶
Applies the inverse of the transformation (if it exists).
- Parameters:
tensor – Transformed tensor.
- Returns:
Tensor with the transformation undone.
- Raises:
NotImplementedError – If the inverse of the transformation is not implemented.
nos.transforms.quantile_scaler module¶
- class nos.transforms.quantile_scaler.QuantileScaler(src: Tensor, n_quantile_intervals: int = 1000, target_mean: float | Tensor = 0.0, target_std: float | Tensor = 1.0, eps: float = 0.001)¶
Bases:
Transform
Quantile Scaler Class.
A transform for scaling input data to a specified target distribution using quantiles. This is particularly useful for normalizing data in a way that is more robust to outliers than standard z-score normalization.
The transformation maps the quantiles of the input data to the quantiles of the target distribution, effectively performing a non-linear scaling that preserves the relative distribution of the data.
- Parameters:
src – tensor from which the source distribution is drawn.
n_quantile_intervals – Number of individual bins into which the data is categorized.
target_mean – Mean of the target Gaussian distribution. Can be float (all dimensions use the same mean), or tensor (allows for different means along different dimensions).
target_std – Std of the target Gaussian distribution. Can be float (all dimensions use the same std), or tensor (allows for different stds along different dimensions).
eps – Small value to bound the target distribution to a finite interval.
- forward(tensor: Tensor) Tensor ¶
Transforms the input tensor to match the target distribution using quantile scaling .
- Parameters:
tensor – The input tensor to transform.
- Returns:
The transformed tensor, scaled to the target distribution.
- undo(tensor: Tensor) Tensor ¶
Reverses the transformation applied by the forward method, mapping the tensor back to its original distribution.
- Parameters:
tensor – The tensor to reverse the transformation on.
- Returns:
The tensor with the quantile scaling transformation reversed according to the src distribution.
Module contents¶
- class nos.transforms.MinMaxScale(min_value: Tensor, max_value: Tensor)¶
Bases:
Transform
- forward(tensor: Tensor) Tensor ¶
Applies the transformation.
- Parameters:
tensor – Tensor that should be transformed.
- Returns:
Transformed tensor.
- undo(tensor: Tensor) Tensor ¶
Applies the inverse of the transformation (if it exists).
- Parameters:
tensor – Transformed tensor.
- Returns:
Tensor with the transformation undone.
- Raises:
NotImplementedError – If the inverse of the transformation is not implemented.
- class nos.transforms.QuantileScaler(src: Tensor, n_quantile_intervals: int = 1000, target_mean: float | Tensor = 0.0, target_std: float | Tensor = 1.0, eps: float = 0.001)¶
Bases:
Transform
Quantile Scaler Class.
A transform for scaling input data to a specified target distribution using quantiles. This is particularly useful for normalizing data in a way that is more robust to outliers than standard z-score normalization.
The transformation maps the quantiles of the input data to the quantiles of the target distribution, effectively performing a non-linear scaling that preserves the relative distribution of the data.
- Parameters:
src – tensor from which the source distribution is drawn.
n_quantile_intervals – Number of individual bins into which the data is categorized.
target_mean – Mean of the target Gaussian distribution. Can be float (all dimensions use the same mean), or tensor (allows for different means along different dimensions).
target_std – Std of the target Gaussian distribution. Can be float (all dimensions use the same std), or tensor (allows for different stds along different dimensions).
eps – Small value to bound the target distribution to a finite interval.
- forward(tensor: Tensor) Tensor ¶
Transforms the input tensor to match the target distribution using quantile scaling .
- Parameters:
tensor – The input tensor to transform.
- Returns:
The transformed tensor, scaled to the target distribution.
- undo(tensor: Tensor) Tensor ¶
Reverses the transformation applied by the forward method, mapping the tensor back to its original distribution.
- Parameters:
tensor – The tensor to reverse the transformation on.
- Returns:
The tensor with the quantile scaling transformation reversed according to the src distribution.