Skip to content

Fix Inconsistency in GaussianProcessRegressor between return_std and return_cov #19936 #19980

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 4 commits into from

Conversation

Caratheodory301
Copy link

Reference Issues/PRs

Fixes Issue #19936 Inconsistency in GaussianProcessRegressor between return_std and return_cov

What does this implement/fix? Explain your changes.

This pull request tries to fix the inconsistency in GaussianProcessRegressor between return_std and return_cov. As discussed in Issue #19936, GaussianProcessRegressor.predict(x, return_std=True) and GaussianProcessRegressor.predict(x, return_cov=True) return inconsistent results on the predicted variances on the evaluated points x. This is due to numerical instability during solve_triangle in gpr.GaussianProcessRegressor.predict. I used cho_solve((self.L, True), K_trans.T) instead of solve_triangle to calculate kernel(X_train,X_train)^(-1)*kernel(X_train,X_test) to fix the bug. I also changed subscripts of np.eisum later to calculate the predicted covariance. I created 10 random test cases to check if results from return_std and return_cov are consistent and all of them passed in less than 1s.

Any other comments?

I also tried other methods to fix this bug. For example, I tried np.linalg.solve instead of solve_triangle to get the inverse of the kernel matrix evaluated at X_train. However, in this case, since K_inv is a positive definite, solve method based on Cholesky decomposition would be the most efficient way to do so. Local testing verified the performace difference.

@glemaitre
Copy link
Member

We are happy with the current PR and already have reviewed it and will merge it during the day most probably: #19939

Closing this PR in favor of #19939

@glemaitre glemaitre closed this Apr 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants