blackboxopt.utils
get_loss_vector(known_objectives, reported_objectives)
Convert reported objectives into a vector of known objectives.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
known_objectives |
Sequence[blackboxopt.base.Objective] |
[description] |
required |
reported_objectives |
Dict[str, Optional[float]] |
[description] |
required |
Returns:
Type | Description |
---|---|
list |
[description] |
Source code in blackboxopt/utils.py
def get_loss_vector(
known_objectives: Sequence[Objective],
reported_objectives: Dict[str, Optional[float]],
) -> list:
"""Convert reported objectives into a vector of known objectives.
Args:
known_objectives: [description]
reported_objectives: [description]
Returns:
[description]
"""
losses = []
for objective in known_objectives:
objective_value = reported_objectives[objective.name]
if objective_value is None:
losses.append(float("NaN"))
elif objective.greater_is_better:
losses.append(-1.0 * objective_value)
else:
losses.append(objective_value)
return losses