Skip to content
Merged
2 changes: 1 addition & 1 deletion CHANGELOG.md
Comment thread
AdrianSosic marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Support for GPyTorch objects (kernels, means, likelihood) as Gaussian process
components, enabling full low-level customization
- Factories for all Gaussian process components
- `EDBO` and `EDBO_SMOOTHED` presets for `GaussianProcessSurrogate`
- `CHEN`, `EDBO` and `EDBO_SMOOTHED` presets for `GaussianProcessSurrogate`
- `TypeSelector` and `NameSelector` classes for parameter selection in kernel factories
- `parameter_names` attribute to basic kernels for controlling the considered parameters
- `ParameterKind` flag enum for classifying parameters by their role and automatic
Expand Down
8 changes: 7 additions & 1 deletion CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,10 @@
- Kathrin Skubch (Merck KGaA, Darmstadt, Germany):\
Transfer learning regression benchmarks infrastructure
- Myra Zmarsly (Merck Life Science KGaA, Darmstadt, Germany):\
Identification of non-dominated parameter configurations
Identification of non-dominated parameter configurations
- Thijs Stuyver (PSL University, Paris, France):\
Adaptive hyper-prior tailored for reaction yield optimization tasks
- Maximilian Fleck (PSL University, Paris, France):\
Adaptive hyper-prior tailored for reaction yield optimization tasks
- Guanming Chen (PSL University, Paris, France):\
Adaptive hyper-prior tailored for reaction yield optimization tasks
5 changes: 5 additions & 0 deletions baybe/surrogates/gaussian_process/presets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
BayBEMeanFactory,
)

# Chen preset
from baybe.surrogates.gaussian_process.presets.chen import CHENKernelFactory

# Core
from baybe.surrogates.gaussian_process.presets.core import GaussianProcessPreset

Expand All @@ -31,6 +34,8 @@
"BayBEKernelFactory",
"BayBELikelihoodFactory",
"BayBEMeanFactory",
# Chen preset
"CHENKernelFactory",
# EDBO preset
"EDBOKernelFactory",
"EDBOLikelihoodFactory",
Expand Down
77 changes: 77 additions & 0 deletions baybe/surrogates/gaussian_process/presets/chen.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
"""Preset for adaptive kernel hyperpriors proposed by :cite:p:`Chen2026`."""

from __future__ import annotations

import gc
import math
from typing import TYPE_CHECKING, ClassVar

from attrs import define, field
from typing_extensions import override

from baybe.kernels.basic import MaternKernel
from baybe.kernels.composite import ScaleKernel
from baybe.parameters.categorical import TaskParameter
from baybe.parameters.selectors import (
ParameterSelectorProtocol,
TypeSelector,
to_parameter_selector,
)
from baybe.priors.basic import GammaPrior
from baybe.surrogates.gaussian_process.components.kernel import (
_PureKernelFactory,
)
from baybe.surrogates.gaussian_process.presets.baybe import (
BayBELikelihoodFactory,
BayBEMeanFactory,
)

if TYPE_CHECKING:
from torch import Tensor

from baybe.kernels.base import Kernel
from baybe.searchspace.core import SearchSpace


@define
class CHENKernelFactory(_PureKernelFactory):
"""A factory providing adaptive hyperprior kernels as proposed by :cite:p:`Chen2026`.""" # noqa: E501

_uses_parameter_names: ClassVar[bool] = True
# See base class.

parameter_selector: ParameterSelectorProtocol | None = field(
factory=lambda: TypeSelector([TaskParameter], exclude=True),
converter=to_parameter_selector,
)
# TODO: Reuse base attribute (https://github.com/python-attrs/attrs/pull/1429)

@override
def _make(
self, searchspace: SearchSpace, train_x: Tensor, train_y: Tensor
) -> Kernel:
lengthscale = 0.4 * math.sqrt(train_x.shape[-1]) + 4.0
lengthscale_prior = GammaPrior(2.0 * lengthscale, 2.0)
lengthscale_initial_value = lengthscale
outputscale_prior = GammaPrior(1.0 * lengthscale, 1.0)
outputscale_initial_value = lengthscale
Comment thread
AdrianSosic marked this conversation as resolved.

return ScaleKernel(
MaternKernel(
nu=2.5,
lengthscale_prior=lengthscale_prior,
lengthscale_initial_value=lengthscale_initial_value,
parameter_names=self.get_parameter_names(searchspace),
),
outputscale_prior=outputscale_prior,
outputscale_initial_value=outputscale_initial_value,
)


# Collect leftover original slotted classes processed by `attrs.define`
gc.collect()

# Aliases for generic preset imports
PresetKernelFactory = CHENKernelFactory
PresetMeanFactory = BayBEMeanFactory
PresetLikelihoodFactory = BayBELikelihoodFactory
Comment thread
AdrianSosic marked this conversation as resolved.
Outdated
7 changes: 5 additions & 2 deletions baybe/surrogates/gaussian_process/presets/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ class GaussianProcessPreset(Enum):
BAYBE = "BAYBE"
"""The default BayBE settings of the Gaussian process surrogate class."""

CHEN = "CHEN"
"""The adaptive kernel hyperprior settings proposed by :cite:p:`Chen2026`."""

EDBO = "EDBO"
"""The EDBO settings."""
"""The EDBO settings proposed by :cite:p:`Shields2021`."""

EDBO_SMOOTHED = "EDBO_SMOOTHED"
"""A smoothed version of the EDBO settings."""
"""A smoothed version of the EDBO settings (adapted from :cite:p:`Shields2021`)."""
14 changes: 5 additions & 9 deletions baybe/surrogates/gaussian_process/presets/edbo.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""EDBO preset for Gaussian process surrogates."""
"""EDBO preset :cite:p:`Shields2021`."""

from __future__ import annotations

Expand Down Expand Up @@ -58,11 +58,9 @@ def _contains_encoding(

@define
class EDBOKernelFactory(_PureKernelFactory):
"""A factory providing EDBO kernels.
"""A factory providing EDBO kernels, as proposed by :cite:p:`Shields2021`.

References:
* https://github.com/b-shields/edbo/blob/master/edbo/bro.py#L664
* https://doi.org/10.1038/s41586-021-03213-y
GitHub repository: https://github.com/b-shields/edbo
"""
Comment thread
AdrianSosic marked this conversation as resolved.

_uses_parameter_names: ClassVar[bool] = True
Expand Down Expand Up @@ -130,11 +128,9 @@ def _make(

@define
class EDBOLikelihoodFactory(LikelihoodFactoryProtocol):
"""A factory providing EDBO likelihoods.
"""A factory providing EDBO likelihoods, as proposed by :cite:p:`Shields2021`.

References:
* https://github.com/b-shields/edbo/blob/master/edbo/bro.py#L664
* https://doi.org/10.1038/s41586-021-03213-y
GitHub repository: https://github.com/b-shields/edbo
Comment thread
AdrianSosic marked this conversation as resolved.
"""
Comment thread
AdrianSosic marked this conversation as resolved.

@override
Expand Down
10 changes: 5 additions & 5 deletions baybe/surrogates/gaussian_process/presets/edbo_smoothed.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Smoothed EDBO preset for Gaussian process surrogates."""
"""Smoothed EDBO preset (adapted from :cite:p:`Shields2021`)."""

from __future__ import annotations

Expand Down Expand Up @@ -40,12 +40,12 @@

@define
class SmoothedEDBOKernelFactory(_PureKernelFactory):
"""A factory providing smoothed versions of EDBO kernels.
"""A factory providing smoothed versions of EDBO kernels (adapted from :cite:p:`Shields2021`).

Takes the low and high dimensional limits of
:class:`baybe.surrogates.gaussian_process.presets.edbo.EDBOKernelFactory`
and interpolates the prior moments linearly in between.
"""
""" # noqa: E501
Comment thread
AdrianSosic marked this conversation as resolved.

_uses_parameter_names: ClassVar[bool] = True
# See base class.
Expand Down Expand Up @@ -94,12 +94,12 @@ def _make(

@define
class SmoothedEDBOLikelihoodFactory(LikelihoodFactoryProtocol):
"""A factory providing smoothed versions of EDBO likelihoods.
"""A factory providing smoothed versions of EDBO likelihoods (adapted from :cite:p:`Shields2021`).

Takes the low and high dimensional limits of
:class:`baybe.surrogates.gaussian_process.presets.edbo.EDBOLikelihoodFactory`
and interpolates the prior moments linearly in between.
"""
""" # noqa: E501

Comment thread
AdrianSosic marked this conversation as resolved.
@override
def __call__(
Expand Down
1 change: 1 addition & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Contribute <misc/contributing_link>
Contributors <misc/contributors_link>
Known Issues <known_issues>
Changelog <misc/changelog_link>
References <misc/references>
Github <https://github.com/emdgroup/baybe/>
License <misc/license_link>
```
Expand Down
4 changes: 4 additions & 0 deletions docs/misc/references.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# References

```{bibliography}
```
19 changes: 19 additions & 0 deletions docs/references.bib
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,22 @@ @inproceedings{NIPS2007_66368270
volume = {20},
year = {2007}
}

@article{Chen2026,
author = {Chen, Guanming and Fleck, Maximilian and Stuyver, Thijs},
title = {Leveraging Hidden-Space Representations Effectively in Bayesian Optimization for Experiment Design through Dimension-Aware Hyperpriors},
journal = {ChemRxiv},
year = {2026},
doi = {10.26434/chemrxiv.10001986/v2}
Comment thread
AdrianSosic marked this conversation as resolved.
}

@article{Shields2021,
author = {Shields, Benjamin J. and Stevens, Jason and Li, Jun and Parasram, Marvin and Damani, Farhan and Alvarado, Jesus I. Martinez and Janey, Jacob M. and Adams, Ryan P. and Doyle, Abigail G.},
title = {Bayesian reaction optimization as a tool for chemical synthesis},
journal = {Nature},
volume = {590},
number = {7844},
pages = {89--96},
year = {2021},
doi = {10.1038/s41586-021-03213-y}
}
3 changes: 0 additions & 3 deletions docs/userguide/transfer_learning.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,4 @@ on the optimization:
:class: only-dark
```

```{bibliography}
```

[`TaskParameter`]: baybe.parameters.categorical.TaskParameter
Loading