Skip to content

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

Merged
jnothman merged 7 commits intoscikit-learn:masterfrom
zhengruifeng:fix_gp_batch
Oct 6, 2016
Merged

[MRG + 1] Fix GaussianProcess batch predict #7329#7330
jnothman merged 7 commits intoscikit-learn:masterfrom
zhengruifeng:fix_gp_batch

Conversation

@zhengruifeng
Copy link
Copy Markdown
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
Copy Markdown
Member

TomDLT commented Sep 2, 2016

You should also modify this line. Otherwise LGTM

@zhengruifeng
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member

jnothman commented Oct 5, 2016

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

@zhengruifeng
Copy link
Copy Markdown
Contributor Author

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

@jnothman
Copy link
Copy Markdown
Member

jnothman commented Oct 5, 2016

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

y_pred = gp.predict(X)
y_pred = gp.predict(X, batch_size=1)
assert_true(np.allclose(y_pred, y))
y_pred = gp.predict(X, eval_MSE=True)
Copy link
Copy Markdown
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
Copy Markdown
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

y_pred = gp.predict(X)
assert_true(np.allclose(y_pred, y))

def test_batch_size():
Copy link
Copy Markdown
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
Copy Markdown
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