Tutorial 11

Bayesian Optimization for Reaction Conditions

Treat catalyst/ligand/base/solvent/temperature choice as a black box and use a Gaussian-Process-guided Bayesian optimization (BO) loop to find high-yield conditions in as few "experiments" as possible — closed-loop simulation against real (and one synthetic-representative) published reaction-condition datasets.

Jules Schleinitz
105 min
Python · Google Colab
Back to schedule

Open in Google Colab

The notebook has most of the code pre-filled. Complete the exercises marked ### YOUR CODE HERE ###.

Open Notebook

Getting started

Open the Colab notebook using the button above. Run each cell in order; cells marked Exercise require you to fill in code. The eight numbered sections below match the notebook's section headers exactly.

  1. Present the dataset(s) and variables. Set DATASET to one of four options (Perera Suzuki grid, Reizman Suzuki, Shields direct arylation, Baumgartner C–N coupling). Each loader returns a dataframe, a factor dictionary (type, levels/range), and a yield column normalized to [0,1] by that dataset's own max observed yield. Print the summary table and yield histogram.

  2. Featurize the reaction. Set FEATURIZATION to "onehot", "descriptors" (RDKit physicochemical descriptors on SMILES where available, COSMO-RS-style placeholders otherwise), or "random_projection" (a deliberately weak baseline). Features are computed once into a cached CSV so the BO loop only ever does a fast lookup.

  3. Choose an initialization technique. INIT_METHOD: "random" or "kmeans" (cluster the featurized space into N_INIT = 10 clusters, take the point nearest each centroid).

  4. Choose an acquisition function. ACQUISITION: "EI", "UCB" (editable beta), or "qEI" for the batch case.

  5. Batch size. Fixed at BATCH_SIZE = 4 for everyone (not user-editable) — see the notebook for why — using optimize_acqf with q=4.

  6. Preview the trajectory on a 2D plot. Run one quick preview BO loop (single seed, 4 rounds) with your Section 1–5 config, project the featurized candidate pool to 2D with PCA, and check whether later rounds cluster near the best-yield region before committing to the full run.

  7. Submit the design choices. Assemble dataset/featurization/init_method/acquisition/acquisition_hparams/batch_size/n_rounds into a design dict, print it, and write it to a local JSON checkpoint.

  8. Launch the full run and submit to the leaderboard. Run the closed-loop BO simulation for 5 seeds x N_ROUNDS = 8 rounds against the fixed lookup-table dataset, compute AUC (mean and std over seeds) and max score achieved, plot all 5 trajectories, and POST your results to the live leaderboard below.


Answer these questions as you work through the notebook. Discuss with your neighbour — some have no single right answer.

    Warm-up

    For your chosen dataset, what is the best normalized yield among the 10 initial (random or k-means) points? How much of the way to the dataset's maximum (1.0, by construction) does that represent?

    Easy
    Core

    Look at your Section 6 2D preview plot. Do later rounds visibly cluster near the best-yield region, or stay scattered? If scattered, which single change (featurization or acquisition) would you try first, and why?

    Medium
    Core

    Compare your 5-seed auc_mean and auc_std between EI and UCB (try at least two values of beta) on the same dataset/featurization/init. Which is more consistent across seeds, and does that match Shields et al.'s finding that BO's advantage over expert chemists was more about consistency than best-case performance?

    Medium
    Challenge

    Run the same design (featurization, init, acquisition) on two different datasets, e.g. reizman_suzuki (small, noisy, ~96 reactions) vs. baumgartner_cn_coupling (96 reactions but COSMO-style descriptors available). Do the same design choices transfer well across datasets, or is the best acquisition/featurization pair dataset-dependent — consistent with Summit's finding that no single BO strategy dominates everywhere?

    Challenge

Class challenge results

Run the notebook's Section 8 and submit cell — it self-computes auc_mean/auc_std/max_score_achieved for your 5-seed run and POSTs them directly from Colab. There is no independent instructor grading for this tutorial (unlike the docking-oracle leaderboard in Tutorial 8): scores are self-reported, and ranking is per dataset — a run on perera_suzuki is not comparable to one on baumgartner_cn_coupling. Pick a dataset below to see its ranking. Resubmit as many times as you like; each team's best auc_mean per dataset is shown.

Loading leaderboard…
Loading…

Notebook (Colab) GitHub repo (notebook + leaderboard setup) Paired lecture notes Perera et al., Science 2018 Reizman & Jensen, React. Chem. Eng. 2016 Shields et al., Nature 2021 EDBO (Shields et al. code) Felton, Rittig & Lapkin, Chem. Methods 2021 (Summit) Summit (Felton/Rittig/Lapkin code) Honegumi (BO script generator)