scale_to_range
ScaleToRange(*, features=None, lower_range=-1.0, upper_range=1.0)
dataclass
Scale features to a fixed range using a linear mapping.
A sample \(x\) is scaled as:
\[
z = x \cdot m + b
\]
where
- \(m\) is the scaling factor
- \(b\) is the offset.
When instantiating this transform directly, the scaling factor \(m\) and
offset \(b\) for each feature are calculated during training from the data.
To specify the scaling factor \(m\) and offset \(b\) directly, use the
from_limits
method.
Attributes:
Name | Type | Description |
---|---|---|
m |
dict[str, float] | None
|
The scaling factor \(m\) of each feature. |
b |
dict[str, float] | None
|
The offset \(b\) of each feature. |
Source code in src/flowcean/polars/transforms/scale_to_range.py
43 44 45 46 47 48 49 50 51 52 |
|
from_limits(feature_limits, *, lower_range=-1.0, upper_range=1.0)
classmethod
Creates a new ScaleToRange transform based on the given limits.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
feature_limits
|
dict[str, tuple[float, float]]
|
A dictionary mapping each features name to its (min_value, max_value) tuple. |
required |
lower_range
|
float
|
The lower bound of the range to scale to. |
-1.0
|
upper_range
|
float
|
The upper bound of the range to scale to. |
1.0
|
Source code in src/flowcean/polars/transforms/scale_to_range.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
|