|
16 | 16 | "This notebook contains an example on how to use BayBE for the optimization of reaction conditions. It is inspired by the corresponding notebook developed by Pat Walters as part of his [Practical Cheminformatics Tutorial](https://github.com/PatWalters/practical_cheminformatics_tutorials). This notebook assumes basic familiarity with the core concepts of Bayesian Optimization. The intention of this notebook is *not* to introduce and explain all aspects of Bayesian Optimization, but to focus on the usage of `BayBE`.\n", |
17 | 17 | "\n", |
18 | 18 | "In drug discovery, we frequently encounter situations where we need to modify a set of reaction conditions to optimize the yield. This notebook shows how to use `BayBE` to model and optimize such a campaign.\n", |
19 | | - "In particular, it demonstrates the power and usefulness of `BayBE`'s chemical encodings. If parameters in a process to be optimized are chemicals, this feature enables `BayBE` to automatically use meaningful chemical descriptors, automatically leveraging chamical knowledge for the optimization process.\n", |
| 19 | + "In particular, it demonstrates the power and usefulness of `BayBE`'s chemical encodings. If parameters in a process to be optimized are chemicals, this feature enables `BayBE` to automatically use meaningful chemical descriptors, automatically leveraging chemical knowledge for the optimization process.\n", |
20 | 20 | "\n", |
21 | 21 | "**Caution**\n", |
22 | 22 | "This notebook was developed for `BayBE` version 0.14.2. Although we do our best in keeping our breaking changes minimal and support outdated versions for a long time, this notebook might not be immediately applicable for other `BayBE` versions. If you install `BayBE` via the instructions in this repository, version 0.14.2 will thus be installed." |
|
29 | 29 | "source": [ |
30 | 30 | "## Installation\n", |
31 | 31 | "\n", |
32 | | - "To install `BayBE` in AWS SageMaker, make sure that you have the `conda_python3` kernel activated. Then, run the following cell to install all required packagages.\n", |
| 32 | + "To install `BayBE` in AWS SageMaker, make sure that you have the `conda_python3` kernel activated. Then, run the following cell to install all required packages.\n", |
33 | 33 | "Note that this might take some minutes." |
34 | 34 | ] |
35 | 35 | }, |
|
115 | 115 | "import pandas as pd\n", |
116 | 116 | "from utils import create_dict_from_columns\n", |
117 | 117 | "\n", |
118 | | - "df = pd.read_csv(\"../data/shields.csv\")\n", |
| 118 | + "df = pd.read_csv(\"data/shields.csv\")\n", |
119 | 119 | "\n", |
120 | 120 | "# Extract SMILES data for all chemical substances\n", |
121 | 121 | "solvents_dict = create_dict_from_columns(df, \"Solvent_Name\", \"Solvent_SMILES\")\n", |
|
157 | 157 | "Setting up an experimentation campaign with `BayBE` requires us to set up the main components individually. In this notebook, we will set up the following components one after another.\n", |
158 | 158 | "\n", |
159 | 159 | "1. [**Parameters**](https://emdgroup.github.io/baybe/0.14.2/userguide/parameters.html): In our setting, a _parameter_ is something that we can control directly. An example of this is which ligand to choose, or at which of the available temperatures to run the experiment. Each of the 5 parameters described earlier will correspond to exactly one of `BayBE`'s `Parameter`s.\n", |
160 | | - "2. [**Search space**](https://emdgroup.github.io/baybe/0.14.2/userguide/searchspace.html): The search space defines the combination of parameters to be searched. It thus contains all possible experiments that we could conduct. The search space is typically defined using the function `Searchspace.from_product`, which creates a search space as the Cartesian product of the parameters.\n", |
| 160 | + "2. [**Search space**](https://emdgroup.github.io/baybe/0.14.2/userguide/searchspace.html): The search space defines the combination of parameters to be searched. It thus contains all possible experiments that we could conduct. The search space is typically defined using the function `SearchSpace.from_product`, which creates a search space as the Cartesian product of the parameters.\n", |
161 | 161 | "3. [**Target**](https://emdgroup.github.io/baybe/0.14.2/userguide/targets.html): The target is the quantity we are optimizing. In the case of reaction optimization, this is typically the yield. `BayBE` can optimize a single parameter or multiple parameters at once. In this notebook, we'll focus on single parameter optimization, where we are only optimizing the yield, and we hence stick to single target optimization.\n", |
162 | 162 | "4. [**Recommender**](https://emdgroup.github.io/baybe/0.14.2/userguide/recommenders.html): The recommender selects the next set of experiments to be performed. In this case, we use the default [`TwoPhaseMetaRecommender`](https://emdgroup.github.io/baybe/0.14.2/_autosummary/baybe.recommenders.meta.sequential.TwoPhaseMetaRecommender.html). This recommender behaves differently depending on whether it has experimental data. At the beginning of an optimization process, we typically don't have experimental data and want to find a diverse set of conditions to gather some initial data. If the `TwoPhaseMetaRecommender` has no data available, it uses random sampling to select a set of initial experiments. If the recommender has data, it uses the [`BotorchRecommender`](https://emdgroup.github.io/baybe/0.14.2/_autosummary/baybe.recommenders.pure.bayesian.botorch.BotorchRecommender.html), a Bayesian optimizer that balances exploration and exploitation when selecting sets of reaction conditions.\n", |
163 | | - "5. [**Campaign**](https://emdgroup.github.io/baybe/0.14.2/userguide/campaigns.html): In `BayBE`, the search space, objective, and recommender are combined into an `campaign` object. The Campaign has two important methods: `recommend`, which recommends the next set of experiments, and `add_measurements`, which adds a set of experiments and updates the underlying Bayesian model." |
| 163 | + "5. [**Campaign**](https://emdgroup.github.io/baybe/0.14.2/userguide/campaigns.html): In `BayBE`, the search space, objective, and recommender are combined into a `Campaign` object. The `Campaign` has two important methods: `recommend`, which recommends the next set of experiments, and `add_measurements`, which adds a set of experiments and updates the underlying Bayesian model." |
164 | 164 | ] |
165 | 165 | }, |
166 | 166 | { |
|
638 | 638 | " CategoricalParameter(\n", |
639 | 639 | " name=\"Ligand_Name\", values=df[\"Ligand_Name\"].unique(), encoding=\"OHE\"\n", |
640 | 640 | " ),\n", |
641 | | - " NumericalDiscreteParameter(name=\"Temp_C\", values=[90, 105, 120]),\n", |
642 | | - " NumericalDiscreteParameter(name=\"Concentration\", values=[0.057, 0.1, 0.153]),\n", |
| 641 | + " NumericalDiscreteParameter(\n", |
| 642 | + " name=\"Temp_C\", values=df[\"Temp_C\"].unique()\n", |
| 643 | + " ),\n", |
| 644 | + " NumericalDiscreteParameter(\n", |
| 645 | + " name=\"Concentration\", values=df[\"Concentration\"].unique()\n", |
| 646 | + " ),\n", |
643 | 647 | "]\n", |
644 | 648 | "campaign_ohe = Campaign(\n", |
645 | 649 | " searchspace=SearchSpace.from_product(parameters=ohe_parameters),\n", |
|
0 commit comments