question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Improving the error message on the Gaussian Process Regression

See original GitHub issue

I’m trying to do my first Gaussian Process Regression using scikit-learn.

Here’s my MWE:

from sklearn.gaussian_process import GaussianProcessRegressor
from sklearn.gaussian_process.kernels import Matern

kernel=Matern(nu=0.5)
model=lambda x: x*np.sin(x)
xdata=np.array([1,3,5,6,8])
ydata=model(xdata)
xfit=xdata[:,np.newaxis]
gp=GaussianProcessRegressor(kernel=kernel,alpha=0.5)
gp.fit(xfit,ydata)

When I run the above, I get

(...)\sklearn\gaussian_process\kernels.py:1623: RuntimeWarning: invalid value encountered in true_divide
  K_gradient = K[..., np.newaxis] * D \

Why is that? If I change the nu in the kernel to 1.5, the error disappears… I though it could be due to an inversion in the covariance matrix when compution the gaussian process, but I’ve used an alpha=0.5.

Also, if I try to plot the graph, with the code as is, I get a really strange plot… I somehow need to use length_scale_bounds=(1e-1, 10.0) to create a more truthful graph.

This tells me that probably the length-scale parameter is trying to go to problematic regions of the parameter space…

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
anoldmanintheseacommented, Mar 2, 2021

@cmarmo that warning is consistent with the hypothesis I put forward of the inversion of the covariance matrix being done for values that are problematic.

0reactions
cmarmocommented, Mar 4, 2021

Thanks @AidarShakerimoff for the follow-up! And thanks @anoldmaninthesea for the report. Closing then as fixed in #19396.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Gaussian Process Regression with Location Errors - arXiv
Abstract. In this paper, we investigate Gaussian process regression mod- els where inputs are subject to measurement error. In spatial statistics,.
Read more >
Validation of error bars with Gaussian process regression
I think that the covariance that you're using is improper. When you set alpha = 0.2 * np.abs(y) , what you're doing is...
Read more >
Evaluation of Gaussian process regression kernel functions ...
Gaussian process regression (GPR) is a popular data-driven method used to build a statistical complementary model to correct systematic prediction error and ...
Read more >
Uniform Error Bounds for Gaussian Process Regression with ...
Based on this work an improved bound is derived in [9] in order to analyze the regret of an upper confidence bound algorithm...
Read more >
Quick Start to Gaussian Process Regression | by Hilarie Sit
Gaussian process regression (GPR) is a nonparametric, Bayesian approach to regression that is making waves in the area of machine learning.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found