Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[MRG + 1] Fix GaussianProcess batch predict #7329 #7330

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

Merged
merged 7 commits into from
Oct 6, 2016

Conversation

zhengruifeng
Copy link
Contributor

@zhengruifeng zhengruifeng commented Sep 2, 2016

Reference Issue

Fix #7329
GaussianProcess batch predict fail on py3 due to range(float)

What does this implement/fix? Explain your changes.

1,add a int() to convert float to int for py3
2,add a test for 'batch_size'

@zhengruifeng zhengruifeng reopened this Sep 2, 2016
@TomDLT
Copy link
Member

TomDLT commented Sep 2, 2016

You should also modify this line. Otherwise LGTM

@zhengruifeng
Copy link
Contributor Author

@TomDLT Thanks, I have fix it.

@amueller amueller changed the title Fix GaussianProcess batch predict #7329 [MRG + 1] Fix GaussianProcess batch predict #7329 Sep 12, 2016
@amueller
Copy link
Member

amueller commented Sep 12, 2016

LGTM. The test failed on master? I guess because the dataset is small the test is not overly slow (batch_size=1 seems extreme)

@amueller amueller added this to the 0.18 milestone Sep 12, 2016
@zhengruifeng
Copy link
Contributor Author

@amueller I test on 0.17.1 and it will fail with batch_size=1. If batch_size=1 is extreme, what about setting batch_size=y.shape[0]?

@amueller
Copy link
Member

@zhengruifeng no that's ok, I think. Other reviews?

@amueller amueller added the Bug label Sep 22, 2016
@@ -129,7 +129,7 @@ def test_ordinary_kriging():

def test_no_normalize():
gp = GaussianProcess(normalize=False).fit(X, y)
Copy link
Member

Choose a reason for hiding this comment

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

we should test with eval_MSE=True too.

Copy link
Member

Choose a reason for hiding this comment

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

@zhengruifeng your fix looks fine. Can you follow @jnothman suggestion about the test?

If I were you I would leave test_no_normalize unmodified and just add a test function like this:

def test_batch_size():                                                                                                                
    # TypeError when using batch_size on Python 3, see                                                                                
    # https://github.com/scikit-learn/scikit-learn/issues/7329 for more            
    # details                                                                                                                         
    gp = GaussianProcess()                                                                                                            
    gp.fit(X, y)                                                                                                                      

    gp.predict(X, batch_size=1)                                                                                                       

    gp.predict(X, batch_size=1, eval_MSE=True) 

@jnothman jnothman modified the milestones: 0.19, 0.18, 0.18.1 Sep 29, 2016
@jnothman
Copy link
Member

jnothman commented Oct 5, 2016

@zhengruifeng Are you completing this fix, or should someone else?

@zhengruifeng
Copy link
Contributor Author

@jnothman I add the test with eval_MSE=True. Sorry for the delay.

@jnothman
Copy link
Member

jnothman commented Oct 5, 2016

Thanks. I'll look later. In the meantime, you've got test failures.

assert_true(np.allclose(y_pred, y))
y_pred = gp.predict(X, eval_MSE=True)
Copy link
Member

Choose a reason for hiding this comment

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

As suggested by @lesteve, this doesn't belong in test_no_normalize. Make a new test for batch_size only.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, I will update it ASAP

@@ -132,6 +132,14 @@ def test_no_normalize():
y_pred = gp.predict(X)
assert_true(np.allclose(y_pred, y))

def test_batch_size():
Copy link
Member

Choose a reason for hiding this comment

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

PEP8: insert another blank line

@jnothman jnothman merged commit e17d5c9 into scikit-learn:master Oct 6, 2016
@jnothman
Copy link
Member

jnothman commented Oct 6, 2016

Thanks!

@zhengruifeng zhengruifeng deleted the fix_gp_batch branch October 6, 2016 03:08
amueller pushed a commit to amueller/scikit-learn that referenced this pull request Oct 14, 2016
Sundrique pushed a commit to Sundrique/scikit-learn that referenced this pull request Jun 14, 2017
paulha pushed a commit to paulha/scikit-learn that referenced this pull request Aug 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GaussianProcess batch predict fail on py3
5 participants