8000 fix sign error in gp + unit test #3180 by filthysocks · Pull Request #3181 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

fix sign error in gp + unit test #3180 #3181

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions sklearn/gaussian_process/gaussian_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -730,9 +730,8 @@ def minus_reduced_likelihood_function(log10t):
raise ve

optimal_theta = 10. ** log10_optimal_theta
optimal_minus_rlf_value, optimal_par = \
optimal_rlf_value, optimal_par = \
self.reduced_likelihood_function(theta=optimal_theta)
optimal_rlf_value = - optimal_minus_rlf_value

# Compare the new optimizer to the best previous one
if k > 0:
Expand Down
24 changes: 24 additions & 0 deletions sklearn/gaussian_process/tests/test_gaussian_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,27 @@ def test_no_normalize():
gp = GaussianProcess(normalize=False).fit(X, y)
y_pred = gp.predict(X)
assert_true(np.allclose(y_pred, y))


def test_1d_tough_noisy(regr=regression.constant, corr=correlation.squared_exponential,
random_start=10, beta0=None):
"""
MLE estimation of a one-dimensional Gaussian Process model.
Check random start optimization with noisy / duplicate inputs.

Test the interpolating property.
"""

X = np.atleast_2d([1., 3., 5., 6., 7., 8., 9., 10., 12., 13., 14., 17.]).T
x = np.atleast_2d(np.linspace(0, 20, 100)).T

y = f(X).ravel() + np.random.normal(0, 0.1, len(X))

gp = GaussianProcess(regr=regr, corr=corr, beta0=beta0,
theta0=1e-2, thetaL=1e-4, thetaU=1.,
random_start=random_start, verbose=False, nugget=0.002).fit(X, y)

y_pred, MSE = gp.predict(x, eval_MSE=True)
y = f(x).ravel()

assert_true((np.abs(y_pred - y) <= (1.96 * MSE) ).all()) #check that true value is within 95% conf. int.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make sure your file is pep8 compliant

0