From 9f24f0e76cccbf894d92182325be36b4f1eda479 Mon Sep 17 00:00:00 2001 From: "Alexander V. Hopp" Date: Fri, 23 Feb 2024 16:57:33 +0100 Subject: [PATCH 1/6] First draf of Transfer Learning User Guide --- docs/userguide/transfer_learning.md | 50 +++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/docs/userguide/transfer_learning.md b/docs/userguide/transfer_learning.md index c6870dfc3..28f9b2fcf 100644 --- a/docs/userguide/transfer_learning.md +++ b/docs/userguide/transfer_learning.md @@ -1,4 +1,50 @@ # Transfer Learning -This page will soon contain information about transfer learning. -In the meantime, please see the [examples](../../examples/examples) instead. \ No newline at end of file +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. +The act of combining the data of several contexts can be done via multiple models, +shared architectures, special kernels in a single model and whatnot. +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`. +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. \ No newline at end of file From 8cad44459ea3f1074fe0feed59fec672d7986874 Mon Sep 17 00:00:00 2001 From: "Alexander V. Hopp" Date: Fri, 1 Mar 2024 11:28:50 +0100 Subject: [PATCH 2/6] Improve admonition on terminology --- docs/userguide/transfer_learning.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/userguide/transfer_learning.md b/docs/userguide/transfer_learning.md index 28f9b2fcf..8f489a1f8 100644 --- a/docs/userguide/transfer_learning.md +++ b/docs/userguide/transfer_learning.md @@ -8,8 +8,10 @@ Surrogate model and is implemented by the [`TaskParameter`](baybe.parameters.cat ```{admonition} Terminology :class: note The term "Transfer Learning" is used in a lot of different ways. -The act of combining the data of several contexts can be done via multiple models, -shared architectures, special kernels in a single model and whatnot. +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. ``` From 962acff74bc973d47062af41f46dc4314b053210 Mon Sep 17 00:00:00 2001 From: "Alexander V. Hopp" Date: Fri, 1 Mar 2024 11:30:11 +0100 Subject: [PATCH 3/6] Add examples for cell lines --- docs/userguide/transfer_learning.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/userguide/transfer_learning.md b/docs/userguide/transfer_learning.md index 8f489a1f8..8719e2628 100644 --- a/docs/userguide/transfer_learning.md +++ b/docs/userguide/transfer_learning.md @@ -49,4 +49,9 @@ TaskParameter( ``` This can be abstracted easily to other scenarios such as changing substrates (while -screening same reaction conditions) or formulating mixtures for different cell lines. \ No newline at end of file +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"]) +~~~ \ No newline at end of file From 82d130e03e24b66269f9838d2410cdef31b53026 Mon Sep 17 00:00:00 2001 From: "Alexander V. Hopp" Date: Fri, 1 Mar 2024 11:30:40 +0100 Subject: [PATCH 4/6] Add link to and explanation of example --- docs/userguide/transfer_learning.md | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/docs/userguide/transfer_learning.md b/docs/userguide/transfer_learning.md index 8719e2628..452c0aecc 100644 --- a/docs/userguide/transfer_learning.md +++ b/docs/userguide/transfer_learning.md @@ -54,4 +54,26 @@ screening same reaction conditions) or formulating mixtures for different cell l ~~~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"]) -~~~ \ No newline at end of file +~~~ + +## 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 +``` \ No newline at end of file From 2836729d4ef43e6ccc8da92a787c473afe0bad69 Mon Sep 17 00:00:00 2001 From: "Alexander V. Hopp" Date: Fri, 1 Mar 2024 16:10:39 +0100 Subject: [PATCH 5/6] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 66008dd06..e5fc3e407 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 From 98eae5d4476efba6afa56daf3f290779497abe04 Mon Sep 17 00:00:00 2001 From: "Alexander V. Hopp" Date: Tue, 5 Mar 2024 13:29:57 +0100 Subject: [PATCH 6/6] Format code blocks --- docs/userguide/transfer_learning.md | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/docs/userguide/transfer_learning.md b/docs/userguide/transfer_learning.md index 452c0aecc..c27451e28 100644 --- a/docs/userguide/transfer_learning.md +++ b/docs/userguide/transfer_learning.md @@ -45,15 +45,24 @@ from baybe.parameters import TaskParameter TaskParameter( name="Reactor", values=["ReactorA", "ReactorB", "ReactorC"], - active_values=["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"]) +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