Target#
- 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
- __init__(name: str, f_transform: str | None = 'Standard', aim: str = 'max', tracking_only: bool = False, threshold: float | None = None)[source]#
Methods
__init__(name[, f_transform, aim, ...])get_threshold([transformed])Get the threshold value, optionally transformed.
load_state(obj_dict)Loads the state of the target object from a dictionary.
Saves the state of the object as a dictionary.
transform_f(f[, inverse, fit])Converts a raw response to an objective function value ("score").
- 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