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

First draft of Transfer Learning User Guide #140

Merged
merged 6 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Better human readable `__str__` representation of campaign
- README now contains an example on substance encoding results
- Transfer Learning User Guide

### Changed
- [WIP] `torch` is loaded lazily
Expand Down
88 changes: 86 additions & 2 deletions docs/userguide/transfer_learning.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,88 @@
# Transfer Learning

This page will soon contain information about transfer learning.
In the meantime, please see the [examples](../../examples/examples) instead.
BayBE offers the possibility to mix data from multiple campaigns in order to accelerate
optimization.
Using data from multiple campaigns is currently supported when using a Gaussian Process
Surrogate model and is implemented by the [`TaskParameter`](baybe.parameters.categorical.TaskParameter).

```{admonition} Terminology
:class: note
The term "Transfer Learning" is used in a lot of different ways.
Scienfitz marked this conversation as resolved.
Show resolved Hide resolved
Within BayBE, "Transfer Learning" refers to combining data from multiple campaigns.
Depending on the field, this might also be known as "contextual learning".
Further, note that the act of combining the data of several contexts can be done via
multiple models, shared architectures, special kernels in a single model, etc.
We do not necessarily want to limit to any of these methods, even though BayBE currently
offers only a single one.
```

## The role of `TaskParameter`

The `TaskParameter` is used to "mark" the context of an individual experiment. The
set of all possible contexts is provided upon the initialization of a `TaskParameter`
by providing them as `values`.
Scienfitz marked this conversation as resolved.
Show resolved Hide resolved
In the following example, the context might be one of several reactors in which
a chemical experiments can be conducted.

```python
from baybe.parameters import TaskParameter

TaskParameter(name="Reactor", values=["ReactorA", "ReactorB", "ReactorC"])
```

If not specified further, a campaign using the `TaskParameter` as specified above
would now make recommendations for all possible values of the parameter. Using the
`active_values` argument upon initialization, this behavior can be changed such that
the `campaign` only makes recommendations for the corresponding values.

The following example models a situation in which data from experiments in three
different reactors are available, but new experiments should only be conducted in
`ReactorC`.

```python
from baybe.parameters import TaskParameter

TaskParameter(
name="Reactor",
values=["ReactorA", "ReactorB", "ReactorC"],
active_values=["ReactorC"],
)
```

This can be abstracted easily to other scenarios such as changing substrates (while
screening same reaction conditions) or formulating mixtures for different cell lines:

~~~python
TaskParameter(
name="Substrate",
values=["3,5-dimethylisoxazole", "benzo[d]isoxazole", "5-methylisoxazole"],
active_values=["3,5-dimethylisoxazole"],
)
TaskParameter(
name="Month",
values=["Liver cell", "Heart cell", "Hamster brain cell"],
active_values=["Liver cell"],
)
~~~

## Seeing Transfer Learning in Action

We provide full example demonstrating BayBE's transfer learning capabilities.
We want to briefly discuss and highlight the results of this example in this user guide.
The full example can be found [here](../../examples/Transfer_Learning/basic_transfer_learning).

The example optimizes an analytical function, the so-called "Hartmann Function".
We use transfer learning by providing additional data that was obtained by evaluating a
negated noisy variant of the same function.

The following plot demonstrates the effect that providing this additional data has:

```{image} ../../examples/Transfer_Learning/basic_transfer_learning_light.svg
:align: center
:class: only-light
```

```{image} ../../examples/Transfer_Learning/basic_transfer_learning_dark.svg
:align: center
:class: only-dark
```