NumericalTarget¶
- class baybe.targets.numerical.NumericalTarget[source]¶
Bases:
Target
,SerialMixin
Class for numerical targets.
Public methods
__init__
(name, *args[, ...])Translate legacy target specifications.
abs
()Apply an absolute transformation to the target.
clamp
([min, max])Clamp the target to a given range.
exp
()Apply an exponential transformation to the target.
from_dict
(dictionary)Create an object from its dictionary representation.
from_json
(string)Create an object from its JSON representation.
from_legacy_interface
(name, mode[, bounds, ...])A deprecation helper for creating targets using the legacy interface.
from_modern_interface
(name[, ...])A deprecation helper for creating targets using the modern interface.
get_codomain
([interval])Get the codomain of an interval (assuming transformation continuity).
get_image
([interval])Get the image of an interval (assuming transformation continuity).
log
()Apply a logarithmic transformation to the target.
match_absolute
(name, match_value, *[, metadata])Create a target to match a given value using an absolute transformation.
match_bell
(name, match_value, sigma, *[, ...])Create a target to match a given value using a bell transformation.
match_power
(name, match_value, exponent, *)Create a target to match a given value using a power transformation.
match_quadratic
(name, match_value, *[, metadata])Create a target to match a given value using a quadratic transformation.
match_triangular
(name[, match_value, ...])Create a target to match a given value using a triangular transformation.
negate
()Apply a negation transformation to the target.
Normalize the target to the unit interval using an affine transformation.
normalized_ramp
(name, cutoffs, *[, ...])Create a target that is affine in a given range and clamped to 0/1 outside.
normalized_sigmoid
(name, anchors, *[, metadata])Create a sigmoid-transformed target.
power
(exponent)Apply a power transformation to the target.
summary
()Return a custom summarization of the target.
to_dict
()Create an object's dictionary representation.
to_json
()Create an object's JSON representation.
Create a single-task objective from the target.
transform
([series, data])Transform target measurements to computational representation.
Public attributes and properties
An optional target transformation.
Boolean flag indicating if the target is to be minimized.
The description of the target.
Boolean flag indicating if the target is normalized to the unit interval.
Optional metadata containing description, unit, and other information.
The name of the target.
The unit of measurement for the target.
- __init__(name: str, *args, _enforce_modern_interface: bool = False, **kwargs)[source]¶
Translate legacy target specifications.
For details on the parameters, see Public attributes and properties.
- abs()[source]¶
Apply an absolute transformation to the target.
- Return type:
- Returns:
The target with applied absolute transformation.
- clamp(min: float | None = None, max: float | None = None)[source]¶
Clamp the target to a given range.
- Parameters:
- Return type:
- Returns:
The clamped target.
- exp()[source]¶
Apply an exponential transformation to the target.
- Return type:
- Returns:
The target with applied exponential transformation.
- classmethod from_legacy_interface(name: str, mode: TargetMode, bounds: Interval | Iterable[float] | None = None, transformation: TargetTransformation | None = None, *, metadata: MeasurableMetadata | dict[str, Any] | None = None)[source]¶
A deprecation helper for creating targets using the legacy interface.
- Parameters:
name (
str
) – The name of the target.mode (
TargetMode
) – The target mode (MAX, MIN, MATCH).bounds (
Union
[Interval
,Iterable
[float
],None
]) – Optional target bounds.transformation (
Optional
[TargetTransformation
]) – An optional target transformation.metadata (
Union
[MeasurableMetadata
,dict
[str
,Any
],None
]) – Optional metadata containing description, unit, and other information.
- Return type:
- Returns:
The created target object.
- classmethod from_modern_interface(name: str, transformation: Transformation | None = None, *, minimize: bool = False, metadata: MeasurableMetadata | dict[str, Any] | None = None)[source]¶
A deprecation helper for creating targets using the modern interface.
- Parameters:
name (
str
) – The name of the target.transformation (
Optional
[Transformation
]) – An optional transformation.minimize (
bool
) – Boolean flag indicating if the target should be minimized.metadata (
Union
[MeasurableMetadata
,dict
[str
,Any
],None
]) – Optional metadata containing description, unit, and other information.
- Return type:
- Returns:
The created target object.
- get_codomain(interval: Interval | None = None, /)[source]¶
Get the codomain of an interval (assuming transformation continuity).
- Return type:
- get_image(interval: Interval | None = None, /)[source]¶
Get the image of an interval (assuming transformation continuity).
- Return type:
- log()[source]¶
Apply a logarithmic transformation to the target.
- Return type:
- Returns:
The target with applied logarithmic transformation.
- classmethod match_absolute(name: str, match_value: float, *, metadata: MeasurableMetadata | dict[str, Any] | None = None)[source]¶
Create a target to match a given value using an absolute transformation.
- Parameters:
name (
str
) – The name of the target.match_value (
float
) – The value to be matched.metadata (
Union
[MeasurableMetadata
,dict
[str
,Any
],None
]) – Seebaybe.targets.numerical.NumericalTarget
.
- Return type:
- Returns:
The target with applied absolute matching transformation.
- classmethod match_bell(name: str, match_value: float, sigma: float, *, metadata: MeasurableMetadata | dict[str, Any] | None = None)[source]¶
Create a target to match a given value using a bell transformation.
- Parameters:
name (
str
) – The name of the target.match_value (
float
) – The value to be matched.sigma (
float
) – The scale parameter controlling the width of the bell curve. For more details, seebaybe.transformations.basic.BellTransformation
.metadata (
Union
[MeasurableMetadata
,dict
[str
,Any
],None
]) – Seebaybe.targets.numerical.NumericalTarget
.
- Return type:
- Returns:
The target with applied bell matching transformation.
- classmethod match_power(name: str, match_value: float, exponent: int, *, metadata: MeasurableMetadata | dict[str, Any] | None = None)[source]¶
Create a target to match a given value using a power transformation.
- Parameters:
name (
str
) – The name of the target.match_value (
float
) – The value to be matched.exponent (
int
) – The exponent of applied the power transformation.metadata (
Union
[MeasurableMetadata
,dict
[str
,Any
],None
]) – Seebaybe.targets.numerical.NumericalTarget
.
- Return type:
- Returns:
The target with applied power matching transformation.
- classmethod match_quadratic(name: str, match_value: float, *, metadata: MeasurableMetadata | dict[str, Any] | None = None)[source]¶
Create a target to match a given value using a quadratic transformation.
- Parameters:
name (
str
) – The name of the target.match_value (
float
) – The value to be matched.metadata (
Union
[MeasurableMetadata
,dict
[str
,Any
],None
]) – Seebaybe.targets.numerical.NumericalTarget
.
- Return type:
- Returns:
The target with applied quadratic matching transformation.
- classmethod match_triangular(name: str, match_value: float | None = None, *, cutoffs: Interval | Iterable[float] | None = None, width: float | None = None, margins: Sequence[float] | None = None, metadata: MeasurableMetadata | dict[str, Any] | None = None)[source]¶
Create a target to match a given value using a triangular transformation.
- Parameters:
name (
str
) – The name of the target.match_value (
Optional
[float
]) – The value to be matched. Can be omitted whencutoffs
are provided, in which case it defaults to the midpoint.cutoffs (
Union
[Interval
,Iterable
[float
],None
]) – The cutoff values where the output of the transformation reaches zero.width (
Optional
[float
]) – The width of the (symmetric) triangular transformation.margins (
Optional
[Sequence
[float
]]) – The margins defining how far the triangle extends in both directions.metadata (
Union
[MeasurableMetadata
,dict
[str
,Any
],None
]) – Seebaybe.targets.numerical.NumericalTarget
.
- Raises:
ValueError – If more than one of
cutoffs
,width
, ormargins
is provided.- Return type:
- Returns:
The target with applied triangular matching transformation.
- negate()[source]¶
Apply a negation transformation to the target.
- Return type:
- Returns:
The target with applied negation transformation.
- normalize()[source]¶
Normalize the target to the unit interval using an affine transformation.
- Raises:
IncompatibilityError – If the target image is not bounded.
- Return type:
- Returns:
The normalized target.
- classmethod normalized_ramp(name: str, cutoffs: Interval | Iterable[float] | None, *, descending: bool = False, metadata: MeasurableMetadata | dict[str, Any] | None = None)[source]¶
Create a target that is affine in a given range and clamped to 0/1 outside.
- Parameters:
name (
str
) – The name of the target.cutoffs (
Union
[Interval
,Iterable
[float
],None
]) – The cutoff values defining the affine region.descending (
bool
) – Boolean flag indicating if the transformation is ascending or descending in the affine region.metadata (
Union
[MeasurableMetadata
,dict
[str
,Any
],None
]) – Seebaybe.targets.numerical.NumericalTarget
.
- Return type:
- Returns:
The target with applied clamped affine transformation.
- classmethod normalized_sigmoid(name: str, anchors: Sequence[Sequence[float]], *, metadata: MeasurableMetadata | dict[str, Any] | None = None)[source]¶
Create a sigmoid-transformed target.
- Parameters:
name (
str
) – The name of the target.anchors (
Sequence
[Sequence
[float
]]) – Seebaybe.transformations.basic.SigmoidTransformation
.metadata (
Union
[MeasurableMetadata
,dict
[str
,Any
],None
]) – Seebaybe.targets.numerical.NumericalTarget
.
- Return type:
- Returns:
The target with applied sigmoid transformation.
- power(exponent: int)[source]¶
Apply a power transformation to the target.
- Parameters:
exponent (
int
) – The exponent of the power transformation.- Return type:
- Returns:
The target with applied power transformation.
- to_dict()¶
Create an object’s dictionary representation.
- Return type:
- Returns:
The dictionary representation of the object.
- to_json()¶
Create an object’s JSON representation.
- Return type:
- Returns:
The JSON representation as a string.
- to_objective()¶
Create a single-task objective from the target.
- Return type:
SingleTargetObjective
- transform(series: Series | None = None, /, *, data: DataFrame | None = None)[source]¶
Transform target measurements to computational representation.
- property is_normalized: UncertainBool¶
Boolean flag indicating if the target is normalized to the unit interval.
-
metadata:
MeasurableMetadata
¶ Optional metadata containing description, unit, and other information.
-
transformation:
Transformation
¶ An optional target transformation.