Leanpub Header

Skip to main content

Bayesian Optimization for Experiments

A Practical Guide to Self-Driving Laboratories

The instructor has published 100% of this course.Last updated on 2026-11-21

Learn to choose each next experiment intelligently with Gaussian processes and acquisition functions, from your first optimization loop to batch, multi-objective, and self-driving labs, with Python and BoTorch code, a quiz in every lesson, and a certificate.

Minimum price

$39.00

$59.00

You pay

Author earns

$

Also available for 1 course credit with a Learner Membership

PDF
EPUB
WEB
About

About

About the Course

Bayesian Optimization for Experiments is a practical online course for scientists and engineers who run expensive, noisy experiments and want to reach good conditions in far fewer runs.

In 15 lessons you move from foundations to a working self-driving lab:

  • Foundations: why Bayesian optimization, essential probability, Gaussian process surrogates, and your first optimization loop.
  • Methods: noise, constraints and categorical choices, batch experiments, multi-objective optimization, debugging a failing loop, prior knowledge, and multi-fidelity optimization.
  • Practice: three case studies (a reaction campaign, a transparent conducting film, a crystallization process) and building a self-driving laboratory.

Every method is built from scratch in Python before moving to BoTorch, and every lesson includes equations, figures, real code output, and key takeaways. Each lesson ends with a marked quiz (120 questions in total). Score 70% or more to earn your certificate of completion.

Share this course

Instructor

About the Instructor

Kompri

Kompri is an academic, author, investor, and educator based in Jambi, Indonesia. He holds a doctorate in Education Management and a bachelor’s degree in Physics, and has written and published dozens of books along with numerous other scholarly works. An avid reader, he is one of today’s most productive researchers. Alongside his academic career, he publishes both theoretical and practical books for readers around the world. His work rests on one conviction: knowledge is most valuable when it is clear, usable, and shared, so that anyone, in any country, can put it to work.

Material

Course Material

  • Welcome to the Course

  • How the Course Works

  • Earning the Certificate

  • Chapter 1: Why Bayesian Optimization for Experiments?

  • 1.1 The Cost of an Experiment: Why One-Factor-at-a-Time and Grids Fall Short

  • One factor at a time

  • Grids and classical designed experiments

  • Learning as you go

  • What a sample-efficient method buys you

  • 1.2 A Short History: From Kriging to Self-Driving Laboratories

  • Mining engineers and spatial interpolation

  • Sequential search under noise

  • Computer experiments and EGO

  • Machine learning rediscovers the idea

  • Back to the laboratory

  • 1.3 Bayesian Optimization versus the Alternatives

  • When the classical tools are better

  • When Bayesian optimization is the right tool

  • Random search as the honest baseline

  • 1.4 Roadmap and Prerequisites

  • What you need to know

  • 1.5 Limits, Stated at the Outset

  • Key Takeaways

  • Further Reading

  • Exercises

  • Lesson 1 Quiz

    10 attempts allowed

  • Chapter 2: Essential Probability — Bayes, Gaussians, and Uncertainty

  • 2.1 Uncertainty as a Quantity

  • Random variables, means, and variances

  • What probability means here

  • 2.2 Bayes’ Rule: Updating Belief with Data

  • A worked example: estimating a rate constant

  • Why “Bayesian” optimization

  • 2.3 The Gaussian and Its Many Dimensions

  • One dimension

  • Many dimensions

  • 2.4 Conditioning a Gaussian: The One Formula Everything Rests On

  • A two-variable example

  • From two variables to a whole curve

  • The computational cost

  • 2.5 Noise, Measurement Error, and Two Kinds of Uncertainty

  • Two kinds of uncertainty

  • Replicates are not wasted

  • 2.6 Drawing Random Functions: The Cholesky Trick

  • Key Takeaways

  • Further Reading

  • Exercises

  • Lesson 2 Quiz

    10 attempts allowed

  • Chapter 3: Setting Up Your Environment

  • 3.1 Installing Your Environment

  • Python and a virtual environment

  • Checking what you have

  • 3.2 Choosing a Library: From Scratch, scikit-optimize, or BoTorch?

  • Writing it yourself

  • scikit-optimize: the five-line optimizer

  • BoTorch and Ax: the research-grade toolkit

  • The approach of this book

  • 3.3 A Simulated Laboratory

  • The kinetic model

  • The landscape

  • Adding noise

  • Working on the unit cube

  • A third knob for later

  • 3.4 Project Structure and Logging Every Experiment

  • The book’s project layout

  • An append-only experiment log

  • Reproducibility and random seeds

  • Key Takeaways

  • Further Reading

  • Exercises

  • Lesson 3 Quiz

    10 attempts allowed

  • Chapter 4: The Anatomy of a Gaussian Process Surrogate

  • 4.1 From Functions to Distributions over Functions

  • The definition

  • The mean function: usually zero

  • Where the information really lives

  • 4.2 Kernels: Encoding What You Believe About Smoothness

  • The squared-exponential kernel

  • The Matérn 5/2 kernel

  • Seeing the prior

  • Several inputs: one length scale per dimension

  • 4.3 The Posterior: Predicting a Value and Its Uncertainty

  • Computing it stably

  • The five-experiment example

  • 4.4 Learning the Hyperparameters from Data

  • The marginal likelihood

  • Computing and maximizing it

  • The landscape of the marginal likelihood

  • When the optimizer gets stuck

  • Learning the noise, and why replicates help

  • 4.5 Building It and Checking It

  • Checking against scikit-learn

  • What the surrogate gives the optimizer

  • Key Takeaways

  • Further Reading

  • Exercises

  • Lesson 4 Quiz

    10 attempts allowed

  • Chapter 5: Your First Optimization Loop — Optimizing a Reaction Yield

  • 5.1 The Problem and What Counts as Success

  • 5.2 Acquisition Functions: Turning Belief into a Decision

  • Probability of improvement

  • Expected improvement

  • Upper confidence bound

  • Thompson sampling

  • Comparing them on the five-experiment example

  • A numerical warning about EI

  • 5.3 The Complete Loop

  • Maximizing the acquisition function

  • The loop

  • Watching it think: a one-dimensional campaign

  • The two-dimensional campaign

  • Reading the fitted model

  • 5.4 Did It Work? Comparing Against Random Search and a Grid

  • The two-variable problem: an honest disappointment

  • The three-variable problem: where the method earns its place

  • The grid: lucky, and why that should worry you

  • What the comparison teaches

  • 5.5 Experiments and What to Take Away

  • Turning the exploration knob

  • Changing the initial design

  • Making the noise worse

  • Recommending with the model, not the best measurement

  • Knowing when to stop

  • What Stage 1 has built

  • Key Takeaways

  • Further Reading

  • Exercises

  • Lesson 5 Quiz

    10 attempts allowed

  • Chapter 6: Noise, Constraints, and Categorical Choices

  • 6.1 Noise That Is Not Polite

  • Problem one: the incumbent is a lie

  • Problem two: the recommendation is a lie

  • What each fix buys

  • Noise that varies across the space

  • 6.2 Constraints: Optimizing What You Are Allowed to Make

  • Two outputs, two models

  • What the constraint model buys

  • Known and unknown constraints

  • 6.3 Experiments That Fail

  • 6.4 Categorical Choices: Solvents, Catalysts, Ligands

  • Encoding a choice

  • Does the loop find the right solvent?

  • 6.5 Better Starting Points: Space-Filling Designs

  • Key Takeaways

  • Further Reading

  • Exercises

  • Lesson 6 Quiz

    10 attempts allowed

  • Chapter 7: Batch and Parallel Experiments

  • 7.1 Why Not Just Take the Top Five?

  • 7.2 Kriging Believer: Pretend, Then Proceed

  • 7.3 Monte Carlo Batch Acquisition

  • 7.4 Thompson Sampling for Batches

  • 7.5 Experiments or Rounds? A Head-to-Head Comparison

  • Per experiment, sequential wins

  • Per round, batches win by a mile

  • Among batch methods

  • 7.6 Practical Matters

  • Choosing the batch size

  • Experiments that finish at different times

  • Mixing replicates and exploration

  • Recording the batch

  • Key Takeaways

  • Further Reading

  • Exercises

  • Lesson 7 Quiz

    10 attempts allowed

  • Chapter 8: Multi-Objective Optimization — Trading Yield Against Purity

  • 8.1 Yield, Purity, and the Pareto Front

  • Dominance

  • Measuring a front: the hypervolume

  • 8.2 Scalarization and ParEGO

  • 8.3 Expected Hypervolume Improvement

  • 8.4 Head-to-Head on the Yield–Purity Trade-off

  • 8.5 Choosing a Point on the Front

  • Constraints are often better than objectives

  • Key Takeaways

  • Further Reading

  • Exercises

  • Lesson 8 Quiz

    10 attempts allowed

  • Chapter 9: Debugging Bayesian Optimization — When the Loop Fails

  • 9.1 Symptoms Worth Noticing

  • 9.2 A Model That Believes the Data Are Exact

  • 9.3 The Optimum Is Outside the Box

  • 9.4 One Bad Number

  • What one error does

  • Why the outlier hides itself

  • What works

  • 9.5 Drift

  • 9.6 Diagnosing the Surrogate

  • Leave-one-out cross-validation

  • Calibration on the simulator

  • 9.7 A Checklist

  • Key Takeaways

  • Further Reading

  • Exercises

  • Lesson 9 Quiz

    10 attempts allowed

  • Chapter 10: Bringing Knowledge In — Mechanistic Priors, the Literature, and More Dimensions

  • 10.1 The Model Knows Nothing Unless You Tell It

  • 10.2 A Mechanistic Model as the Prior Mean

  • Modelling the discrepancy

  • What a good model buys, and what a bad one costs

  • When to use a mechanistic mean

  • 10.3 Starting From the Literature

  • 10.4 More Knobs: Dimensions and Relevance

  • Making dimensions cheaper

  • 10.5 What Not to Tell the Model

  • Key Takeaways

  • Further Reading

  • Exercises

  • Lesson 10 Quiz

    10 attempts allowed

  • Chapter 11: Multi-Fidelity Optimization — Cheap Simulations and Expensive Experiments

  • 11.1 Two Kinds of Evidence

  • 11.2 Strategy One: Simulate, Then Start There

  • 11.3 Strategy Two: Co-Kriging

  • 11.4 Head-to-Head: A Good Simulator and a Flawed One

  • With a good simulator

  • With a flawed simulator

  • What the comparison teaches

  • 11.5 Choosing the Fidelity Adaptively

  • 11.6 Transfer from Past Campaigns

  • Key Takeaways

  • Further Reading

  • Exercises

  • Lesson 11 Quiz

    10 attempts allowed

  • Chapter 12: Case Study I — A Reaction Campaign from Start to Finish

  • 12.1 The Brief

  • 12.2 The Plan

  • 12.3 The Campaign, Round by Round

  • 12.4 Ten Campaigns, and the Traditional Alternative

  • 12.5 Writing It Up

  • Key Takeaways

  • Further Reading

  • Exercises

  • Lesson 12 Quiz

    10 attempts allowed

  • Chapter 13: Case Study II — A Transparent Conducting Film

  • 13.1 The Material and the Simulator

  • 13.2 First Attempt: Optimizing the Figure of Merit Directly

  • 13.3 Transforming the Objective

  • 13.4 Starting From a Larger Design

  • The lesson about objectives

  • 13.5 The Full Trade-Off: Resistance Against Transmittance

  • 13.6 What Carries Over

  • Key Takeaways

  • Further Reading

  • Exercises

  • Lesson 13 Quiz

    10 attempts allowed

  • Chapter 14: Case Study III — A Crystallization Process

  • 14.1 The Process and Its Objective

  • 14.2 The Campaign

  • 14.3 A Recipe and What the Model Learned

  • 14.4 From Recipe to Operating Window

  • Key Takeaways

  • Further Reading

  • Exercises

  • Lesson 14 Quiz

    10 attempts allowed

  • Chapter 15: Closing the Loop — Building a Self-Driving Laboratory

  • 15.1 The Architecture

  • 15.2 A Simulated Laboratory to Develop Against

  • 15.3 Keeping the Instruments Busy

  • 15.4 Faults, Retries, and Approvals

  • 15.5 A Ledger You Can Trust

  • 15.6 Starting Small

  • 15.7 The Frontier, and the Limits

  • Key Takeaways

  • Further Reading

  • Exercises

  • Lesson 15 Quiz

    10 attempts allowed

  • Appendix A: Derivations

  • A.1 Conditioning a Multivariate Gaussian

  • A.2 The Closed Form of Expected Improvement

  • A.3 Leave-One-Out Predictions Without Refitting

  • Appendix C: Choosing a Method — A Quick Reference

  • Appendix D: Glossary

  • Appendix E: A Campaign Template

  • Appendix F: Hints for the Exercises

  • Chapter 1

  • Chapter 2

  • Chapter 3

  • Chapter 4

  • Chapter 5

  • Chapter 6

  • Chapter 7

  • Chapter 8

  • Chapter 9

  • Chapter 10

  • Chapter 11

  • Chapter 12

  • Chapter 13

  • Chapter 14

  • Chapter 15

  • Appendix G: A NumPy Primer for Experimental Scientists

  • G.1 Arrays and Shapes

  • G.2 Broadcasting

  • G.3 Random Numbers, Reproducibly

  • G.4 Boolean Masks

  • G.5 Solve, Never Invert

  • G.6 Where to Go Next

  • Appendix H: From Scratch to BoTorch

  • H.1 A Translation Table

  • H.2 The Chapter 5 Campaign in BoTorch

  • H.3 Which to Use

  • Appendix I: Troubleshooting — Questions Readers Ask

  • Appendix J: A Campaign Planning Worksheet

  • J.1 The Goal

  • J.2 The Search Space

  • J.3 The Measurements

  • J.4 The Budget and the Equipment

  • J.5 Prior Knowledge

  • J.6 The Method

  • J.7 Records and Review

  • Appendix K: Notation

  • References

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub