Learn how models predict a known function, estimate uncertainty, and choose new
experiments. All tutorials use f(x) = sin(3x) + 0.2x with Gaussian measurement
noise of standard deviation 0.15. The default initial dataset has eight observations.
| Stage | Entry point | What you learn |
|---|---|---|
| 1. GP fundamentals | src/gaussian.py | Fixed RBF kernel, posterior mean/covariance, draggable observations |
| 2. GP fitting and acquisition | src/gp_try.py | Fitted Matérn kernel, UCB and approximate EI |
| 3. Sequential GP optimization | src/bo_loop.py | Measure, append, refit, repeat, and independently confirm |
| 4. Tree models | model_zoo/ | Random forest, extra trees, gradient boosting, XGBoost |
| 5. Bootstrap uncertainty | bootstrap_ensemble/ | Complete model refits → predictive mean and covariance |
| 6. Comparison and combinations | oracle/ | Known-function benchmark, averaged predictor, family mixture |
| 7. Selected-model optimization | sequential_selection/ | Observed-data CV → selected-family bootstrap → UCB → new measurement |
Stages 4–6 fit static datasets; stage 7 runs a sequential simulated experiment.
bayesian-optimization-tutorials/
├── src/ GP tutorials and GP-loop diagnostics
├── tests/ GP-loop validation tests
├── model_zoo/
│ ├── common.py Shared data, model factories, bootstrap mathematics
│ ├── random_forest/ README + runnable tutorial.py
│ ├── extra_trees/ README + runnable tutorial.py
│ ├── gradient_boosting/ README + runnable tutorial.py
│ ├── xgboost/ README + runnable tutorial.py
│ ├── bootstrap_ensemble/ Bootstrap construction for any one family
│ ├── oracle/ Known-function evaluation and family combinations
│ ├── sequential_selection/ CV model selection and sequential UCB loop
│ ├── tests/ Numerical and end-to-end validation
│ └── requirements.txt GP dependencies plus tree-model dependencies
├── docs/BO_VALIDATION.md Sequential GP experiment and validation guide
├── results/
│ ├── examples/ Saved GP examples
│ ├── figures/ Initial GP illustration
│ └── runs/ Historical and new GP runs
└── requirements.txt GP-only dependencies
Clone this repository, then run:
cd bayesian-optimization-tutorials
python -m venv .venv
source .venv/bin/activate
# All tutorials (includes GP dependencies):
python -m pip install -r model_zoo/requirements.txt
# For GP tutorials alone, use: python -m pip install -r requirements.txt
python src/gaussian.py
python src/gp_try.py --n-obs 8
python src/bo_loop.py --steps 12 --gif
python model_zoo/random_forest/tutorial.py
python model_zoo/extra_trees/tutorial.py
python model_zoo/gradient_boosting/tutorial.py
python model_zoo/xgboost/tutorial.py
python model_zoo/bootstrap_ensemble/tutorial.py --model extra_trees
python model_zoo/oracle/tutorial.py
python model_zoo/sequential_selection/tutorial.py
python -m unittest discover -s tests
python -m unittest discover -s model_zoo/testsThe second test suite requires all four model libraries. Use the same Python interpreter for installation and execution. See the model-zoo guide for CPU-only XGBoost installation details and tutorial options.
GP runs default to results/runs/; each model tutorial defaults to its own
results/<timestamp>/. Defaults are independent of the current working directory.
Explicit --out, --data, and --save paths are relative to the working directory.
Existing experiment outputs are retained. Python caches, virtual environments, and
new timestamped runs are ignored by the local .gitignore.
These are separate jobs:
- Model selection: compare architectures using held-out measurements.
- Bootstrap ensemble: resample observations and refit complete models to estimate predictive means and covariance. Individual boosting trees are not bootstrap members.
- Acquisition: use predictions and uncertainty to choose the next experiment.
- Oracle: provide outcomes for a simulated experiment or evaluate predictions.
The current
oracle/tutorial uses the known function; it is not a model selector.
Lila reports cross-validation model selection, bootstrap uncertainty, and a portfolio of acquisition strategies. Its benchmark XGBoost oracle supplies simulated outcomes. The four-family mixture here is an educational comparison, not a claimed reproduction of Lila's live model combination. This tutorial places model selection before bootstrap fitting; its model zoo and numerical defaults are educational implementation choices.
- Initial GP figure
- GP progress GIF
- GP diagnostics
- GP validation report
- Four-model comparison
- Model comparison scores
GP bands condition on fitted kernel parameters. Bootstrap bands summarize variation across refits and are not automatically calibrated confidence intervals. Learning the whole function and finding its maximum are different objectives. See the GP validation guide and model-zoo guide.