ennbo 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- enn/__init__.py +24 -0
- enn/enn/__init__.py +4 -0
- enn/enn/enn.py +229 -0
- enn/enn/enn_fit.py +143 -0
- enn/enn/enn_normal.py +27 -0
- enn/enn/enn_params.py +10 -0
- enn/enn/enn_util.py +96 -0
- enn/turbo/__init__.py +11 -0
- enn/turbo/base_turbo_impl.py +98 -0
- enn/turbo/lhd_only_impl.py +42 -0
- enn/turbo/proposal.py +133 -0
- enn/turbo/turbo_config.py +28 -0
- enn/turbo/turbo_enn_impl.py +176 -0
- enn/turbo/turbo_gp.py +29 -0
- enn/turbo/turbo_gp_base.py +27 -0
- enn/turbo/turbo_gp_noisy.py +36 -0
- enn/turbo/turbo_mode.py +10 -0
- enn/turbo/turbo_mode_impl.py +67 -0
- enn/turbo/turbo_one_impl.py +163 -0
- enn/turbo/turbo_optimizer.py +337 -0
- enn/turbo/turbo_trust_region.py +123 -0
- enn/turbo/turbo_utils.py +248 -0
- enn/turbo/turbo_zero_impl.py +24 -0
- ennbo-0.1.0.dist-info/METADATA +109 -0
- ennbo-0.1.0.dist-info/RECORD +27 -0
- ennbo-0.1.0.dist-info/WHEEL +4 -0
- ennbo-0.1.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import TYPE_CHECKING, Callable
|
|
4
|
+
|
|
5
|
+
if TYPE_CHECKING:
|
|
6
|
+
import numpy as np
|
|
7
|
+
from numpy.random import Generator
|
|
8
|
+
|
|
9
|
+
from .base_turbo_impl import BaseTurboImpl
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class TurboZeroImpl(BaseTurboImpl):
|
|
13
|
+
def select_candidates(
|
|
14
|
+
self,
|
|
15
|
+
x_cand: np.ndarray,
|
|
16
|
+
num_arms: int,
|
|
17
|
+
num_dim: int,
|
|
18
|
+
rng: Generator,
|
|
19
|
+
fallback_fn: Callable[[np.ndarray, int], np.ndarray],
|
|
20
|
+
from_unit_fn: Callable[[np.ndarray], np.ndarray],
|
|
21
|
+
) -> np.ndarray:
|
|
22
|
+
from .proposal import select_uniform
|
|
23
|
+
|
|
24
|
+
return select_uniform(x_cand, num_arms, num_dim, rng, from_unit_fn)
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ennbo
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Epistemic Nearest Neighbors
|
|
5
|
+
Project-URL: Homepage, https://github.com/yubo-research/enn
|
|
6
|
+
Project-URL: Source, https://github.com/yubo-research/enn
|
|
7
|
+
Author-email: YUBO Lab <david.sweet@yu.edu>
|
|
8
|
+
License: MIT License
|
|
9
|
+
|
|
10
|
+
Copyright (c) 2025 yubo research
|
|
11
|
+
|
|
12
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
14
|
+
in the Software without restriction, including without limitation the rights
|
|
15
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
17
|
+
furnished to do so, subject to the following conditions:
|
|
18
|
+
|
|
19
|
+
The above copyright notice and this permission notice shall be included in all
|
|
20
|
+
copies or substantial portions of the Software.
|
|
21
|
+
|
|
22
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
|
+
SOFTWARE.
|
|
29
|
+
License-File: LICENSE
|
|
30
|
+
Classifier: Intended Audience :: Science/Research
|
|
31
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
32
|
+
Classifier: Programming Language :: Python :: 3
|
|
33
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
34
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
35
|
+
Classifier: Topic :: Scientific/Engineering
|
|
36
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
37
|
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
38
|
+
Requires-Python: >=3.11
|
|
39
|
+
Requires-Dist: faiss-cpu==1.9.0
|
|
40
|
+
Requires-Dist: gpytorch==1.13
|
|
41
|
+
Requires-Dist: nds==0.4.3
|
|
42
|
+
Requires-Dist: numpy==1.26.4
|
|
43
|
+
Requires-Dist: scipy==1.15.3
|
|
44
|
+
Requires-Dist: torch==2.5.1
|
|
45
|
+
Description-Content-Type: text/markdown
|
|
46
|
+
|
|
47
|
+
# Epistemic Nearest Neighbors
|
|
48
|
+
A fast, alternative surrogate for Bayesian optimization
|
|
49
|
+
|
|
50
|
+
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]
|
|
51
|
+
|
|
52
|
+
## Contents
|
|
53
|
+
- ENN model, [`EpistemicNearestNeighbors`](https://github.com/yubo-research/enn/blob/main/src/enn/enn/enn.py) [1]
|
|
54
|
+
- TuRBO-ENN optimizer, class [`TurboOptimizer`](https://github.com/yubo-research/enn/blob/main/src/enn/turbo/turbo_optimizer.py) has four modes
|
|
55
|
+
- `TURBO_ONE` - A clone of the TuRBO [2] reference [code](https://github.com/uber-research/TuRBO), reworked to have an `ask()`/`tell()` interface.
|
|
56
|
+
- `TURBO_ENN` - Same as TURBO_ONE, except uses ENN instead of GP and Pareto(mu, se) instead of Thompson sampling.
|
|
57
|
+
- `TURBO_ZERO` - Same as TURBO_ONE, except randomly-chosen RAASP [3] candidates are picked to be proposals. There is no surrogate.
|
|
58
|
+
- `LHD_ONLY` - Just creates an LHD design for every `ask()`. Good for a baseline and for testing.
|
|
59
|
+
|
|
60
|
+
[1] **Sweet, D., & Jadhav, S. A. (2025).** Taking the GP Out of the Loop. *arXiv preprint arXiv:2506.12818*.
|
|
61
|
+
https://arxiv.org/abs/2506.12818
|
|
62
|
+
[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*.
|
|
63
|
+
https://arxiv.org/abs/1910.01739
|
|
64
|
+
[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.
|
|
65
|
+
https://proceedings.mlr.press/v238/rashidi24a.html
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
## Installation
|
|
69
|
+
`pip install ennbo`
|
|
70
|
+
|
|
71
|
+
## Demonstration
|
|
72
|
+
[`demo_enn.ipynb`](https://github.com/yubo-research/enn/tree/main/examples/demo_enn.ipynb) - Shows how to use [`EpistemicNearestNeighbors`](https://github.com/yubo-research/enn/blob/main/src/enn/enn/enn.py) to build and query an ENN model.
|
|
73
|
+
[`demo_turbo_enn.ipynb`](https://github.com/yubo-research/enn/tree/main/examples/demo_turbo_enn.ipynb) - Shows how to use [`TurboOptimizer`](https://github.com/yubo-research/enn/blob/main/src/enn/turbo/turbo_optimizer.py) to optimize the Ackley function.
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
## Installation, MacOS
|
|
78
|
+
|
|
79
|
+
On my MacBook I can run into problems with dependencies and compatibilities.
|
|
80
|
+
|
|
81
|
+
On MacOS try:
|
|
82
|
+
```
|
|
83
|
+
micromamba env create -n ennbo -f conda-macos.yml
|
|
84
|
+
micromamba activate ennbo
|
|
85
|
+
pip install --no-deps ennbo
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
You may replace `micromamba` with `conda` and this will probably still work.
|
|
89
|
+
|
|
90
|
+
The commands above make sure
|
|
91
|
+
- You use the MacOS-specific PyTorch (with `mps`).
|
|
92
|
+
- You avoid having multiple, competing OpenMPs installed [PyTorch issue](https://github.com/pytorch/pytorch/issues/44282) [faiss issue](https://github.com/faiss-wheels/faiss-wheels/issues/40).
|
|
93
|
+
- You use old enough versions of NumPy and PyTorch to be compatible with faiss [faiss issue](https://github.com/faiss-wheels/faiss-wheels/issues/104).
|
|
94
|
+
- Prevent matplotlib's installation from upgrading your NumPy to an incompatible version.
|
|
95
|
+
- `ennbo`'s listed dependencies do not undo any of the above (which is fine b/c the above commands set the up correctly).
|
|
96
|
+
|
|
97
|
+
Run tests with
|
|
98
|
+
```
|
|
99
|
+
pytest -x -sv tests
|
|
100
|
+
```
|
|
101
|
+
and they should all pass fairly quickly (~10s-30s).
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
If your code still crashes or hangs your, try this [hack](https://discuss.pytorch.org/t/ran-into-this-issue-while-executing/101460):
|
|
105
|
+
```
|
|
106
|
+
export KMP_DUPLICATE_LIB_OK=TRUE
|
|
107
|
+
export OMP_NUM_THREADS=1
|
|
108
|
+
```
|
|
109
|
+
I don't recommend this, however, as it will slow things down.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
enn/__init__.py,sha256=VYIuOTCjhUFIJm78IoJv0WXtvA_IuZhY1sSMJJM3dx8,507
|
|
2
|
+
enn/enn/__init__.py,sha256=K3rntg_ZkITStmXMTBcEhxeS1kel1bb7wB_C7-2WE5Y,135
|
|
3
|
+
enn/enn/enn.py,sha256=ZdDPivZj4SL9e87FolU1oscdPdcwUeIByIrvBLsoCfE,8060
|
|
4
|
+
enn/enn/enn_fit.py,sha256=uv1BHO-nbxVXkR_tM1Ggoh6YNuR-VrjVECFxLquC7u8,4328
|
|
5
|
+
enn/enn/enn_normal.py,sha256=3kOymSx2kzcBMavScXLflPm_gDDLGF9fYLBJ816I3xg,596
|
|
6
|
+
enn/enn/enn_params.py,sha256=fwLZTA8ciRp4XUF5L_VAVsC3EvFuOzR85OYLVtv6TSw,184
|
|
7
|
+
enn/enn/enn_util.py,sha256=ZELPVeyUl0wiHOxjHYKjxeDz88ExmKMeX3P-bQ6tCoE,3075
|
|
8
|
+
enn/turbo/__init__.py,sha256=utnD3CLZgjCvw-46AAu5Tv2M2Vbg5YXK-_TycGk5BU4,197
|
|
9
|
+
enn/turbo/base_turbo_impl.py,sha256=wThjwXGboRrVTamsnvzmM0WNIOZ91GNJ-BmGzjgqdhg,2699
|
|
10
|
+
enn/turbo/lhd_only_impl.py,sha256=yWsOw7Oq0xfEnyXg5AXJSzZFjM7162pqNY37fHQtJQ4,1023
|
|
11
|
+
enn/turbo/proposal.py,sha256=w1izo3ooiiravNRoFWK5ZK7BH-f_HWgqYP8heVtLmYs,3977
|
|
12
|
+
enn/turbo/turbo_config.py,sha256=J0ww_qKDDMpbFVXdntuSbJtUTbdnXrFJyGD1svzG3RM,980
|
|
13
|
+
enn/turbo/turbo_enn_impl.py,sha256=YMAS4krpPXPNtlh46RRG3VLMuGyYLFw5UkPRBU29mzA,5837
|
|
14
|
+
enn/turbo/turbo_gp.py,sha256=i1bxVHima0Nv4MCLlADtlRzt1cENcnVLYk3S9vCoF4c,797
|
|
15
|
+
enn/turbo/turbo_gp_base.py,sha256=tnE5uX_eAt1Db-gemyy83ZvKpdNbMg_tsWkh6sG7zaM,638
|
|
16
|
+
enn/turbo/turbo_gp_noisy.py,sha256=itTL9jUCjE566jwDODT0P36fozsfU_bXACyuKqxYMXs,1080
|
|
17
|
+
enn/turbo/turbo_mode.py,sha256=JMP1jkFCRwPtOzU95MWWd04Sgze7eKF0xNkiPqtQ8SI,181
|
|
18
|
+
enn/turbo/turbo_mode_impl.py,sha256=3HKBjOS96Wn-R_znctQm9Ivrm3FhgZFTuBp7McNDQ88,1749
|
|
19
|
+
enn/turbo/turbo_one_impl.py,sha256=nS02RdRMcEsi3II07jzcrQbsFsfWYTeahUcqoyhig4Q,5207
|
|
20
|
+
enn/turbo/turbo_optimizer.py,sha256=IlofW9_ogCeQMVXa7n8xWEg5fbJBUkvAkeLKe3MoXlA,11902
|
|
21
|
+
enn/turbo/turbo_trust_region.py,sha256=VHNYKWtKLt3iKHI0enL9qMMu1Bwi1nupo20L0Sv-vYY,3759
|
|
22
|
+
enn/turbo/turbo_utils.py,sha256=XU9-YtW1u5-HKk3bA_M-hVNFPAuNcIYozAmej7ulVsY,7532
|
|
23
|
+
enn/turbo/turbo_zero_impl.py,sha256=S4TEHYkVDowtyWSVxWO0ncd1OUIFpeV3IR-eanGr1vg,643
|
|
24
|
+
ennbo-0.1.0.dist-info/METADATA,sha256=slkhtsGXaO31u8w35LNKXN2noxUJYTqHQF7bv1DZMmA,5930
|
|
25
|
+
ennbo-0.1.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
26
|
+
ennbo-0.1.0.dist-info/licenses/LICENSE,sha256=KTA0NjGalsl_JGrjT_x6SSq9ZYVO3gQ-hLVMEaekc5w,1070
|
|
27
|
+
ennbo-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 yubo research
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|