Skip to content

Commit 4e66beb

Browse files
committed
fix #78
1 parent bb77031 commit 4e66beb

14 files changed

+886
-576
lines changed

pyproject.toml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[tool.black]
2+
# Ensure this is the same value as max-line-length
3+
# under [flake8] in setup.cfg.
4+
line-length = 85

requirements_dev.txt

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
invoke==1.4.1
2+
requests==2.23.0
3+
monty==3.0.2
4+
black==19.3b0
5+
flake8==3.8.2
6+
isort==4.3.21

rocketsled/__init__.py

-2
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,3 @@
1010
__author__ = "Alexander Dunn"
1111
__email__ = "[email protected]"
1212
__version__ = "1.0.1.20200523"
13-
14-

rocketsled/acq.py

+9-8
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
from multiprocessing import cpu_count
77

88
import numpy as np
9+
from joblib import Parallel, delayed
910
from scipy.stats import norm
1011
from sklearn.model_selection import train_test_split
11-
from joblib import Parallel, delayed
1212

1313
__author__ = "Alexander Dunn"
1414
__email__ = "[email protected]"
@@ -45,15 +45,16 @@ def acquire(acq, X, Y, space, model, nstraps, return_means=False):
4545
mu, std = model.predict(space, return_std=True)
4646
else:
4747
predicted = Parallel(n_jobs=cpu_count())(
48-
delayed(ppredict)(X, Y, space, model) for _ in np.zeros(nstraps))
48+
delayed(ppredict)(X, Y, space, model) for _ in np.zeros(nstraps)
49+
)
4950
mu = np.mean(predicted, axis=0)
5051
std = np.std(predicted, axis=0)
5152

52-
if acq == 'ei':
53+
if acq == "ei":
5354
acqf = ei
54-
elif acq == 'pi':
55+
elif acq == "pi":
5556
acqf = pi
56-
elif acq == 'lcb':
57+
elif acq == "lcb":
5758
acqf = lcb
5859
else:
5960
raise ValueError("Unknown acquisition function: {}!".format(acq))
@@ -110,8 +111,7 @@ def ei(fmin, mu, std, xi=0.01):
110111
mask = std > 0
111112
stdm = std[mask]
112113
improve = fmin - mu[mask] - xi
113-
vals[mask] = improve * norm.cdf(improve / stdm) + stdm * \
114-
norm.pdf(improve / stdm)
114+
vals[mask] = improve * norm.cdf(improve / stdm) + stdm * norm.pdf(improve / stdm)
115115
# improve = fmin - mu
116116
# vals = improve * norm.cdf(improve/std) + std * norm.pdf(improve/std)
117117
return vals
@@ -143,7 +143,8 @@ def pi(fmin, mu, std, xi=0.01):
143143
def lcb(fmin, mu, std, kappa=1.96):
144144
"""
145145
Returns lower confidence bound estimates.
146-
fmin (float): (not used): Minimum value of the objective function known thus far.
146+
fmin (float): (not used): Minimum value of the objective function known
147+
thus far.
147148
mu (numpy array): Mean value of bootstrapped predictions for each y.
148149
std (numpy array): Standard deviation of bootstrapped predictions for
149150
each y.

0 commit comments

Comments
 (0)