Skip to content

Global seterr statements in some tests [was: Gaussian process raises many underflow warnings] #5664

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
amueller opened this issue Nov 2, 2015 · 7 comments
Milestone

Comments

@amueller
Copy link
Member

amueller commented Nov 2, 2015

running the tests the new GP raises a whole lot of underflow warnings.
Not sure what to think about that.
ping @jmetzen

@amueller amueller added this to the 0.18 milestone Aug 26, 2016
@amueller
Copy link
Member Author

@jmetzen or maybe @MechCoder or @btabibian? If they are expected, we should catch them, if they are not, we should fix them.

@MechCoder
Copy link
Member

I'll have a look.

@amueller
Copy link
Member Author

hm I can't reproduce this issue when just running the gp tests... maybe it's cause by some seterr somewhere in the test?

@amueller
Copy link
Member Author

amueller commented Sep 12, 2016

I get something like

sklearn.gaussian_process.tests.test_gpc.test_custom_optimizer ... /home/andy/checkout/scikit-learn/sklearn/gaussian_process/kernels.py:1171: RuntimeWarning: underflow encountered in exp
  K = np.exp(-.5 * dists)
/home/andy/checkout/scikit-learn/sklearn/gaussian_process/gpc.py:392: RuntimeWarning: underflow encountered in multiply
  W_sr_K = W_sr[:, np.newaxis] * K
/home/andy/checkout/scikit-learn/sklearn/gaussian_process/gpc.py:393: RuntimeWarning: underflow encountered in multiply
  B = np.eye(W.shape[0]) + W_sr_K * W_sr
/home/andy/checkout/scikit-learn/sklearn/gaussian_process/kernels.py:1171: RuntimeWarning: underflow encountered in exp
  K = np.exp(-.5 * dists)
/home/andy/checkout/scikit-learn/sklearn/gaussian_process/gpc.py:392: RuntimeWarning: underflow encountered in multiply
  W_sr_K = W_sr[:, np.newaxis] * K
/home/andy/checkout/scikit-learn/sklearn/gaussian_process/gpc.py:393: RuntimeWarning: underflow encountered in multiply
  B = np.eye(W.shape[0]) + W_sr_K * W_sr
/home/andy/checkout/scikit-learn/sklearn/gaussian_process/kernels.py:1171: RuntimeWarning: underflow encountered in exp
  K = np.exp(-.5 * dists)
/home/andy/checkout/scikit-learn/sklearn/gaussian_process/gpc.py:392: RuntimeWarning: underflow encountered in multiply
  W_sr_K = W_sr[:, np.newaxis] * K
/home/andy/checkout/scikit-learn/sklearn/gaussian_process/gpc.py:393: RuntimeWarning: underflow encountered in multiply
  B = np.eye(W.shape[0]) + W_sr_K * W_sr
/home/andy/checkout/scikit-learn/sklearn/gaussian_process/kernels.py:1171: RuntimeWarning: underflow encountered in exp
  K = np.exp(-.5 * dists)
/home/andy/checkout/scikit-learn/sklearn/gaussian_process/gpc.py:393: RuntimeWarning: underflow encountered in multiply
  B = np.eye(W.shape[0]) + W_sr_K * W_sr
/home/andy/checkout/scikit-learn/sklearn/gaussian_process/gpc.py:392: RuntimeWarning: underflow encountered in multiply
  W_sr_K = W_sr[:, np.newaxis] * K
/home/andy/checkout/scikit-learn/sklearn/gaussian_process/kernels.py:1171: RuntimeWarning: underflow encountered in exp
  K = np.exp(-.5 * dists)
/home/andy/checkout/scikit-learn/sklearn/gaussian_process/gpc.py:393: RuntimeWarning: underflow encountered in multiply
  B = np.eye(W.shape[0]) + W_sr_K * W_sr
/home/andy/checkout/scikit-learn/sklearn/gaussian_process/gpc.py:392: RuntimeWarning: underflow encountered in multiply
  W_sr_K = W_sr[:, np.newaxis] * K
/home/andy/checkout/scikit-learn/sklearn/gaussian_process/kernels.py:1171: RuntimeWarning: underflow encountered in exp
  K = np.exp(-.5 * dists)
/home/andy/checkout/scikit-learn/sklearn/gaussian_process/gpc.py:393: RuntimeWarning: underflow encountered in multiply
  B = np.eye(W.shape[0]) + W_sr_K * W_sr
/home/andy/checkout/scikit-learn/sklearn/gaussian_process/gpc.py:392: RuntimeWarning: underflow encountered in multiply
  W_sr_K = W_sr[:, np.newaxis] * K
/home/andy/checkout/scikit-learn/sklearn/gaussian_process/kernels.py:1171: RuntimeWarning: underflow encountered in exp
  K = np.exp(-.5 * dists)
/home/andy/checkout/scikit-learn/sklearn/gaussian_process/kernels.py:734: RuntimeWarning: underflow encountered in multiply
  return self.k1(X, Y) * self.k2(X, Y)
/home/andy/checkout/scikit-learn/sklearn/gaussian_process/gpc.py:392: RuntimeWarning: underflow encountered in multiply
  W_sr_K = W_sr[:, np.newaxis] * K

but when I run the tests by themselves, I don't get that.

@amueller
Copy link
Member Author

amueller commented Sep 12, 2016

Hm there are three global seterr:

sklearn/mixture/tests/test_dpgmm.py:np.seterr(all='warn')
sklearn/neural_network/tests/test_mlp.py:np.seterr(all='warn')
sklearn/neural_network/tests/test_rbm.py:np.seterr(all='warn')

these are outside of the tests. I guess there should be fixtures for them so that we undo them?
Alternatively, we can make sure that they are always run and put this in our test setup.

What was the motivation for this? Catching numerical precision errors?

We could go one step further and set it even to 'raise' in the tests. But the current behavior that depends on the import order of the tests seems pretty confusing.

@amueller amueller changed the title Gaussian process raises many underflow warnings Global seterr statements in some tests [was: Gaussian process raises many underflow warnings] Sep 12, 2016
@amueller amueller modified the milestones: 0.18, 0.19 Sep 22, 2016
@jnothman jnothman modified the milestones: 0.20, 0.19 Jun 14, 2017
@jnothman jnothman added Easy Well-defined and straightforward way to resolve Need Contributor labels Jun 14, 2017
@jnothman
Copy link
Member

Why aren't we just using np.errstate? should be as good as a fixture

@glemaitre glemaitre modified the milestones: 0.20, 0.21 Jun 13, 2018
@jnothman jnothman added good first issue Easy with clear instructions to resolve and removed Easy Well-defined and straightforward way to resolve good first issue Easy with clear instructions to resolve labels Apr 16, 2019
@jnothman
Copy link
Member

I'm not sure if the problems with GPs stand, but I'm going to rewrite this issue as it's confusing for newbies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants