tem1-bo: derivative-free optimizers on a protein fitness landscape
The problem
We want a TEM-1 beta-lactamase variant with high fitness (antibiotic resistance, Gray et al. 2018 / PEER benchmark; the train/valid/test splits are merged into 5198 single mutants).
Each variant is represented by the mean-pooled final-layer embedding of ESM2-8M (320 dims). Those embeddings are pre-computed and shipped in src/tem1_bo/data/tem1.npz (6 MB), so nothing is downloaded and no GPU / torch is needed.
To get a continuous black box, the first d principal components of the embeddings (default d = 8) span a box, each axis rescaled to [0, 1]:
xin[0, 1]^d: a point in embedding spacef(x): minus the measured fitness of the variant whose embedding is nearest tox(everything is minimized)
f is piecewise constant (one plateau per variant), so it has no useful gradient. It is deterministic (not noisy) and one evaluation takes about 0.1 ms here. The real-world analogue is a lab measurement of a variant, which is why sample efficiency is the interesting question.
Optimizers
All get the same number of evaluations T per seed.
| name | family | implementation |
|---|---|---|
random |
baseline | uniform samples |
sobol |
space-filling | scrambled Sobol (scipy.stats.qmc) |
nelder-mead |
direct search | scipy.optimize, restarted from a random point when it converges |
cma-es |
direct search / ES | cma, sigma0 = 0.3, restarted when it stops |
bo |
model-based | own numpy GP (RBF, hypers by marginal likelihood) + lower confidence bound (beta = 2), 10 Sobol initial points |
Run
uv sync
uv run q2 --help
uv run q2 compare --budget 100 --seeds 10 --out results/
uv run pytest
Without uv (plain venv + pip)
Python >= 3.11. From this folder:
python3 -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install . # builds and installs the package and q2
q2 --help
q2 compare --budget 100 --seeds 10 --out results/
For development use pip install -e . pytest and run pytest. To build a wheel instead: pip install build && python -m build (writes dist/), then pip install dist/*.whl in any other venv. pip install resolves the dependencies from pyproject.toml (uv.lock is only used by uv), so versions may differ slightly from the locked ones.
The defaults (--budget 100 --seeds 10) take about 2 min on a laptop CPU. Other options: --dim (box dimension), --optimizers (subset). Seeds 0 .. S-1 are used for everything, running twice gives identical results.json.
Output
results/results.json: problem description, budget and one entry per (optimizer, seed) with the valuefof every evaluation in order (xhas the evaluated points).results/ranking.json: for every (optimizer, seed) the Spearman rho between the truefof all 5198 variants and the prediction of a GP fitted on the firsttevaluations (t= 10, 20, ..., budget). The same surrogate is used for all optimizers, so it measures how informative each optimizer's evaluations are about the whole landscape. If all evaluatedfare equal the prediction is constant and rho is set to 0.results/comparison.png, three panels:- best
ffound so far against the number of evaluations (mean over seeds, band = +-1 std; lower is better,f = -fitness) - histogram of
fover all 5198 variants in the dataset (same y axis as panel 1, log counts) - the Spearman rho curves from
ranking.json(mean +- std over seeds)
- best
Metadata
Release files for tem1-bo 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| tem1_bo-0.1.1.tar.gz | 6.3 MB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| tem1_bo-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.5 MB
Release files / tem1_bo-0.1.1.tar.gz
| Download URL | tem1_bo-0.1.1.tar.gz |
|---|---|
| Size | 6.3 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
95f5c06ca46676b8d375e9b53af38d913312a04e071f08d9b3dc9e46713578f7
|
|
BLAKE2b-256 checksum How to use checksums |
1d12e6997e01acda7eb428b80871f02ce52c03708d28dbaf170761adcea6d7a9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.11 {"installer":{"name":"uv","version":"0.11.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"42","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / tem1_bo-0.1.1-py3-none-any.whl
| Download URL | tem1_bo-0.1.1-py3-none-any.whl |
|---|---|
| Size | 6.2 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
849a06703875a886153686f9a304960050be968b23fba9373534b1f0fa5104ff
|
|
BLAKE2b-256 checksum How to use checksums |
14abc66f96b28f42196e889f7d5400d417d7232f571ce9c71af83fd4002f8632
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.11 {"installer":{"name":"uv","version":"0.11.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"42","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for tem1-bo 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.