Accessing predictions with multiple objectives #430
-
I've been figuring out how to optimize for multiple objectives using a DesirabilityObjective. If I do something like this. objective = DesirabilityObjective(
targets=targets,
weights=[50, 50],
scalarizer="MEAN",
)
searchspace = SearchSpace.from_product(parameters)
campaign = Campaign(searchspace, objective)
# df contains the experiments we've performed so far
campaign.add_measurements(df)
rec = campaign.recommend(3) Then I call p = campaign.posterior(rec)
p.mean I get tensor([[0.8652],
[0.8790],
[0.9023]]) I'm assuming p.mean is giving me the desirability scores. Is there a way to get the predictions for the individual components that comprise the targets in the DesirabilityObject? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 8 replies
-
Hi @PatWalters, at the moment, the answer is "yes and no" 🙃 but will be "yes" only soon. Let me explain: Current limitationGetting predictions for the individual target directly from an existing Upcoming solutionsWe plan to ship two features soon, both of which solve the problem in their own way:
Current workaroundThat said, there is also a workaround that you can do already today. That is, simply construct the corresponding surrogate models manually. Here is an example of how you could do it: import pandas as pd
from baybe.campaign import Campaign
from baybe.objectives.desirability import DesirabilityObjective
from baybe.parameters.numerical import NumericalDiscreteParameter
from baybe.searchspace.core import SearchSpace
from baybe.surrogates.gaussian_process.core import GaussianProcessSurrogate
from baybe.targets.numerical import NumericalTarget
searchspace = SearchSpace.from_parameter(NumericalDiscreteParameter("x", range(10)))
targets = [
NumericalTarget("t0", "MAX", bounds=(0, 1)),
NumericalTarget("t1", "MAX", bounds=(0, 1)),
]
objective = DesirabilityObjective(targets)
measurements = pd.DataFrame({"x": [2, 5, 8], "t0": [0.2, 1, 0.3], "t1": [0.9, 0.2, 0.4]})
campaign = Campaign(searchspace, objective)
campaign.add_measurements(measurements)
recommendations = campaign.recommend(3)
surrogate = GaussianProcessSurrogate()
surrogate.fit(searchspace, targets[0].to_objective(), measurements)
p0= surrogate.posterior(recommendations)
surrogate = GaussianProcessSurrogate()
surrogate.fit(searchspace, targets[1].to_objective(), measurements)
p1 = surrogate.posterior(recommendations)
print(p0.mean)
print(p1.mean) Note, however, that these models were not actually used in the recommendation process. So they simply show you what the same GP architecture would give you if applied to the targets individually. |
Beta Was this translation helpful? Give feedback.
Hi @PatWalters, at the moment, the answer is "yes and no" 🙃 but will be "yes" only soon. Let me explain:
Current limitation
Getting predictions for the individual target directly from an existing
DesirabilityObjective
is not possible because the surrogate model is currently being fitted directly on the desirability values, which means we'd have to invert the mapping from target values to desirability value – which is impossible since it's non-injective.Upcoming solutions
We plan to ship two features soon, both of which solve the problem in their own way:
MultiTargetObjective
for Pareto optimization, which inherently comes with separate surrogate models for each target, …