baybe.targets.transforms.linear_transform¶
- baybe.targets.transforms.linear_transform(arr: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], lower: float, upper: float, descending: bool)[source]¶
Linearly map values in a specified interval
[lower, upper]
to[0, 1]
.Outside the specified interval, the function remains constant. That is, 0 or 1, depending on the side and selected mode.
- Parameters:
arr (
Union
[_SupportsArray
[dtype
[Any
]],_NestedSequence
[_SupportsArray
[dtype
[Any
]]],bool
,int
,float
,complex
,str
,bytes
,_NestedSequence
[Union
[bool
,int
,float
,complex
,str
,bytes
]]]) – The values to be mapped.lower (
float
) – The lower boundary of the linear mapping interval.upper (
float
) – The upper boundary of the linear mapping interval.descending (
bool
) – IfTrue
, the function values decrease from 1 to 0 in the specified interval. IfFalse
, they increase from 0 to 1.
- Return type:
- Returns:
A new array containing the transformed values.