Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

286 add surrogate models that can extrapolate #300

Merged
merged 26 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions bofire/data_models/surrogates/botorch_surrogates.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
MixedSingleTaskGPSurrogate,
)
from bofire.data_models.surrogates.mlp import MLPEnsemble
from bofire.data_models.surrogates.polynomial import PolynomialSurrogate
from bofire.data_models.surrogates.random_forest import RandomForestSurrogate
from bofire.data_models.surrogates.single_task_gp import SingleTaskGPSurrogate
from bofire.data_models.surrogates.tanimoto_gp import TanimotoGPSurrogate
Expand All @@ -26,6 +27,7 @@
SaasSingleTaskGPSurrogate,
TanimotoGPSurrogate,
LinearSurrogate,
PolynomialSurrogate,
]


Expand Down
21 changes: 20 additions & 1 deletion tests/bofire/surrogates/test_linear.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from bofire.data_models.domain.api import Inputs, Outputs
from bofire.data_models.features.api import ContinuousInput, ContinuousOutput
from bofire.data_models.kernels.api import LinearKernel
from bofire.data_models.surrogates.api import LinearSurrogate
from bofire.data_models.surrogates.api import BotorchSurrogates, LinearSurrogate


def test_LinearSurrogate():
Expand Down Expand Up @@ -41,3 +41,22 @@ def test_LinearSurrogate():
surrogate.loads(dump)
preds2 = surrogate.predict(experiments)
assert_frame_equal(preds, preds2)


def test_can_define_botorch_surrogate():
inputs = Inputs(
features=[
ContinuousInput(key="a", bounds=(0, 40)),
ContinuousInput(key="b", bounds=(20, 80)),
]
)
outputs = [ContinuousOutput(key="c"), ContinuousOutput(key="d")]
_ = (
BotorchSurrogates(
surrogates=[
LinearSurrogate(inputs=inputs, outputs=Outputs(features=[outputs[0]])),
LinearSurrogate(inputs=inputs, outputs=Outputs(features=[outputs[1]])),
]
),
)
assert True
25 changes: 24 additions & 1 deletion tests/bofire/surrogates/test_polynomial.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from bofire.data_models.domain.api import Inputs, Outputs
from bofire.data_models.features.api import ContinuousInput, ContinuousOutput
from bofire.data_models.kernels.api import PolynomialKernel
from bofire.data_models.surrogates.api import PolynomialSurrogate
from bofire.data_models.surrogates.api import BotorchSurrogates, PolynomialSurrogate


def test_polynomial_surrogate():
Expand Down Expand Up @@ -43,3 +43,26 @@ def test_polynomial_surrogate():
surrogate.loads(dump)
preds2 = surrogate.predict(experiments)
assert_frame_equal(preds, preds2)


def test_can_define_botorch_surrogate():
inputs = Inputs(
features=[
ContinuousInput(key="a", bounds=(0, 40)),
ContinuousInput(key="b", bounds=(20, 80)),
]
)
outputs = [ContinuousOutput(key="c"), ContinuousOutput(key="d")]
_ = (
BotorchSurrogates(
surrogates=[
PolynomialSurrogate(
inputs=inputs, outputs=Outputs(features=[outputs[0]])
),
PolynomialSurrogate(
inputs=inputs, outputs=Outputs(features=[outputs[1]])
),
]
),
)
assert True