targets#
Output features to be optimized
Functions
|
Resolve a name filter against a list of ``Target``s. |
|
Validate and convert f to a torch.Tensor. |
Classes
|
Base class for optimization response targets. |
- class obsidian.parameters.targets.Target(name: str, f_transform: str | None = 'Standard', aim: str = 'max', tracking_only: bool = False, threshold: float | None = None)[source]#
Bases:
objectBase class for optimization response targets.
- Parameters:
name – Name of the target/response variable
f_transform – Transform function to apply (default: “Standard”)
aim – Optimization direction - “max” or “min” (default: “max”)
tracking_only – If True, target is tracked but not optimized (default: False)
threshold – Optional threshold value for characterization tasks. - If aim=”max”: characterize regions where response >= threshold - If aim=”min”: characterize regions where response <= threshold
- get_threshold(transformed: bool = True) float | None[source]#
Get the threshold value, optionally transformed.
- Parameters:
transformed – If True, apply the target’s transform to the threshold (default: True)
- Returns:
The threshold value (transformed or raw), or None if no threshold is set
- Raises:
UnfitError – If transformed=True but the transform function hasn’t been fit yet
- classmethod load_state(obj_dict: dict)[source]#
Loads the state of the target object from a dictionary.
- Parameters:
cls (class) – The class of the target object.
obj_dict (dict) – A dictionary containing the state of the target object.
- Returns:
The loaded target object.
- save_state() dict[source]#
Saves the state of the object as a dictionary.
- Returns:
A dictionary containing the state of the object.
- Return type:
dict
- transform_f(f: float | int | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], inverse=False, fit=False)[source]#
Converts a raw response to an objective function value (“score”). Cost-penalization and response transformation should be handled here.
- Parameters:
f (array-like) – The column(s) containing the response values (y)
inverse (bool, optional) – An indicator to perform the inverse transform. Defaults to
False.fit (bool, optional) – An indicator to fit the properties of the transform function. Defaults to
False.
- Returns:
An array of transformed f values matching the responses in Z
- Return type:
pd.Series
- Raises:
TypeError – If f is not numeric or array-like
UnfitError – If the transform function is called without being fit first
- obsidian.parameters.targets.resolve_target_names(targets: list, target_names: list[str] | None, *, require_thresholds: bool = False, drop_tracking_only: bool = True) list[source]#
Resolve a name filter against a list of ``Target``s.
Centralizes the existence / tracking-only / threshold checks shared by plotting and characterization.
Nonemeans “all targets that pass the filters”; an explicit list raises on unknown names so typos surface.- Parameters:
targets – All targets defined on the campaign.
target_names – Optional subset to restrict to.
require_thresholds – If True, every selected target must have a threshold set (used by characterization / passfail / confidence).
drop_tracking_only – If True,
tracking_onlytargets are dropped whentarget_namesis None and rejected when listed explicitly.
- Returns:
Selected targets in the order they appear in
targets.
- obsidian.parameters.targets.to_tensor(f: Any, dtype: dtype = torch.float64, device: device | str | int | None = None) Tensor[source]#
Validate and convert f to a torch.Tensor. Accepts: torch.Tensor, numpy.ndarray, pandas Series/DataFrame, Python scalar (int/float), or list/tuple of numerics.
- Parameters:
f – input to convert
dtype – optional torch dtype for the resulting tensor
device – optional torch device for the resulting tensor
- Returns:
torch.Tensor