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) – If True, the function values decrease from 1 to 0 in the specified interval. If False, they increase from 0 to 1.

Return type:

ndarray

Returns:

A new array containing the transformed values.