Skip to main content

Epistemic Nearest Neighbors

A fast, alternative surrogate for Bayesian optimization

ENN estimates a function's value and associated epistemic uncertainty using a K-Nearest Neighbors model. Queries take $O(N lnK)$ time, where $N$ is the number of observations available for KNN lookups. Compare to an exact GP, which takes $O(N^2)$ time. Additionally, measured running times are very small compared to GPs and other alternative surrogates. [1]

Contents

  • ENN surrogate, EpistemicNearestNeighbors [1]

  • TuRBO optimizer via create_optimizer with config factories

    • turbo_enn_config() - TuRBO-ENN (Rust-backed by default)
    • turbo_zero_config() - TuRBO-zero (Rust-backed)
    • lhd_only_config() - LHD design on every ask() (Rust-backed)
    • turbo_one_config() - TuRBO with GP surrogate (Python fallback until GP is ported) The optimizer has an ask()/tell() interface. All turbo_*() methods follow TuRBO:
    • Generate candidates with RAASP [3] sampling.
    • Select a candidate with Thompson sampling (TuRBO-one), UCB (TuRBO-ENN), or randomly (TURBO-zero).
  • Overview of algorithms: algos.pdf

[1] M. Bafna, Jadhav, S. a., & Sweet, D., (2025). Taking the GP Out of the Loop. arXiv preprint arXiv:2506.12818. https://arxiv.org/abs/2506.12818 [2] Eriksson, D., Pearce, M., Gardner, J. R., Turner, R., & Poloczek, M. (2020). Scalable Global Optimization via Local Bayesian Optimization. Advances in Neural Information Processing Systems, 32. https://arxiv.org/abs/1910.01739 [3] Rashidi, B., Johnstonbaugh, K., & Gao, C. (2024). Cylindrical Thompson Sampling for High-Dimensional Bayesian Optimization. Proceedings of The 27th International Conference on Artificial Intelligence and Statistics (pp. 3502–3510). PMLR. https://proceedings.mlr.press/v238/rashidi24a.html

Installation

pip install ennbo[with-deps] or cargo add ennbo

PyPI wheels are platform-specific (they include the enn.enn_rust native extension). If pip install ennbo gives an import error about enn.enn_rust, install a matching wheel (same OS/arch/Python) or build from source (Rust + linkable Faiss C API; see below).

Demonstration

demo_enn.ipynb - Shows how to use EpistemicNearestNeighbors to build and query an ENN model. demo_turbo_enn.ipynb - Shows how to use TurboOptimizer to optimize the Ackley function.

Installation, MacOS

On my MacBook I can run into problems with dependencies and compatibilities.

On MacOS try:

micromamba env create -n ennbo -f admin/conda-macos.yml
micromamba activate ennbo
pip install --no-deps ennbo
pytest -sv tests

You may replace micromamba with conda and this will probably still work.

The commands above make sure

  • You use the MacOS-specific PyTorch (with mps).
  • You avoid having multiple, competing OpenMPs installed PyTorch issue faiss issue.
  • You use old enough versions of NumPy and PyTorch to be compatible with faiss faiss issue.
  • Prevent matplotlib's installation from upgrading your NumPy to an incompatible version.
  • ennbo's listed dependencies do not undo any of the above (which is fine b/c the above commands set the up correctly).

Run tests with

pytest -x -sv tests

and they should all pass fairly quickly (~10s-30s).

If your code still crashes or hangs, try this hack:

export KMP_DUPLICATE_LIB_OK=TRUE
export OMP_NUM_THREADS=1

I don't recommend this, however, as it will slow things down.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

ennbo-0.3.14-cp312-cp312-manylinux_2_31_x86_64.whl (6.9 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.31+ x86-64

ennbo-0.3.14-cp312-cp312-manylinux_2_25_x86_64.whl (6.8 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.25+ x86-64

ennbo-0.3.14-cp311-cp311-macosx_26_0_arm64.whl (12.4 MB view details)

Uploaded CPython 3.11macOS 26.0+ ARM64

File details

Details for the file ennbo-0.3.14-cp312-cp312-manylinux_2_31_x86_64.whl.

File metadata

  • Download URL: ennbo-0.3.14-cp312-cp312-manylinux_2_31_x86_64.whl
  • Upload date:
  • Size: 6.9 MB
  • Tags: CPython 3.12, manylinux: glibc 2.31+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for ennbo-0.3.14-cp312-cp312-manylinux_2_31_x86_64.whl
Algorithm Hash digest
SHA256 0a593bfa2c4a1d0439747aa9fe0cc081da2a7e926cf7dc96af94fc824629d2b8
MD5 0a5209ac14c44a630960c535643f91b4
BLAKE2b-256 7c19ba18f7dafd1f0d01e409f21913ec4c2d547a0e57a1aaf3095bb9a18fcc82

See more details on using hashes here.

File details

Details for the file ennbo-0.3.14-cp312-cp312-manylinux_2_25_x86_64.whl.

File metadata

  • Download URL: ennbo-0.3.14-cp312-cp312-manylinux_2_25_x86_64.whl
  • Upload date:
  • Size: 6.8 MB
  • Tags: CPython 3.12, manylinux: glibc 2.25+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for ennbo-0.3.14-cp312-cp312-manylinux_2_25_x86_64.whl
Algorithm Hash digest
SHA256 ebe856535ab4f2bb985b83e121e5eab1696d985203121bb96fbb3f40c106307b
MD5 6888becac0e81d9166099b7f2fc05ff3
BLAKE2b-256 4fa68c018adea1f0d636c3b9cef76c559b12c94f1c4c2451557b1a3cedbf4697

See more details on using hashes here.

File details

Details for the file ennbo-0.3.14-cp311-cp311-macosx_26_0_arm64.whl.

File metadata

  • Download URL: ennbo-0.3.14-cp311-cp311-macosx_26_0_arm64.whl
  • Upload date:
  • Size: 12.4 MB
  • Tags: CPython 3.11, macOS 26.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for ennbo-0.3.14-cp311-cp311-macosx_26_0_arm64.whl
Algorithm Hash digest
SHA256 311ee5992d10e4bbce954f019b1fd50320ace23b601837abeb6f4f1f36e6cd96
MD5 367609d314caa089597461f10a513288
BLAKE2b-256 a0d1cd5e18e3e519c3c9f75261269e71316b0ceebefcd38c156f44adce645cc4

See more details on using hashes here.

Release history Release notifications | RSS feed

0.3.16

3 files

0.3.15

3 files

This release

0.3.14 This release

3 files

0.3.13

3 files

0.3.12

3 files

0.3.11

3 files

0.3.10

3 files

0.3.9

3 files

0.3.8

3 files

0.3.7

3 files

0.3.6

3 files

0.3.5

2 files

0.3.4

3 files

0.3.3

4 files

0.3.2

2 files

0.2.1

2 files

0.2.0

2 files

0.1.9

2 files

0.1.8

2 files

0.1.7

2 files

0.1.6

2 files

0.1.4

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

0.0.9

2 files

0.0.8

2 files

0.0.7

2 files

0.0.6

2 files

0.0.5

2 files

0.0.4

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page