Skip to content

Commit f848a04

Browse files
committed
FIX heisenfailure on 32 bit python + speedup
1 parent 0fcace7 commit f848a04

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

sklearn/gaussian_process/tests/test_gaussian_process.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from sklearn.gaussian_process import GaussianProcess
1414
from sklearn.gaussian_process import regression_models as regression
1515
from sklearn.gaussian_process import correlation_models as correlation
16+
from sklearn.utils.testing import assert_greater
1617

1718

1819
f = lambda x: x * np.sin(x)
@@ -148,20 +149,19 @@ def test_random_starts():
148149
Test that an increasing number of random-starts of GP fitting only
149150
increases the reduced likelihood function of the optimal theta.
150151
"""
151-
n_input_dims = 3
152-
n_samples = 100
152+
n_samples, n_features = 50, 3
153153
np.random.seed(0)
154-
X = np.random.random(n_input_dims*n_samples).reshape(n_samples,
155-
n_input_dims) * 2 - 1
156-
y = np.sin(X).sum(axis=1) + np.sin(3*X).sum(axis=1)
154+
rng = np.random.RandomState(0)
155+
X = rng.randn(n_samples, n_features) * 2 - 1
156+
y = np.sin(X).sum(axis=1) + np.sin(3 * X).sum(axis=1)
157157
best_likelihood = -np.inf
158-
for random_start in range(1, 10):
158+
for random_start in range(1, 5):
159159
gp = GaussianProcess(regr="constant", corr="squared_exponential",
160-
theta0=[1e-0]*n_input_dims,
161-
thetaL=[1e-4]*n_input_dims,
162-
thetaU=[1e+1]*n_input_dims,
160+
theta0=[1e-0] * n_features,
161+
thetaL=[1e-4] * n_features,
162+
thetaU=[1e+1] * n_features,
163163
random_start=random_start, random_state=0,
164164
verbose=False).fit(X, y)
165165
rlf = gp.reduced_likelihood_function()[0]
166-
assert_true(rlf >= best_likelihood)
166+
assert_greater(rlf, best_likelihood - np.finfo(np.float32).eps)
167167
best_likelihood = rlf

0 commit comments

Comments
 (0)