Skip to content

GaussianProcess with batch_size gives "'float' object cannot be interpreted as an integer" #6483

Closed

Description

@stmax82
Windows-10-10.0.10586
Python 3.4.4 |Continuum Analytics, Inc.| (default, Jan 29 2016, 15:20:20) [MSC v.1600 64 bit (AMD64)]
NumPy 1.10.4
SciPy 0.17.0
Scikit-Learn 0.17.1

The following code:

import numpy as np
from sklearn.gaussian_process import GaussianProcess

X = np.random.rand(100, 3)
y = np.random.rand(100)

gp = GaussianProcess().fit(X, y)

gp.predict(X, batch_size=5)

Results in the error

'float' object cannot be interpreted as an integer

Because of:

C:\...\lib\site-packages\sklearn\gaussian_process\gaussian_process.py in predict(self, X, eval_MSE, batch_size)
    520 
    521                 y = np.zeros(n_eval)
--> 522                 for k in range(max(1, n_eval / batch_size)):
    523                     batch_from = k * batch_size
    524                     batch_to = min([(k + 1) * batch_size + 1, n_eval + 1])

TypeError: 'float' object cannot be interpreted as an integer

Activity

  1. glouppe commented on Mar 4, 2016

    @glouppe
    Contributor

    GaussianProcess has been deprecated in 0.18. If this is possible for you, please update to the dev version, where will now find GaussianProcessRegressor instead.

  2. stmax82 commented on Mar 4, 2016

    @stmax82
    Author

    oh thanks, I didn't know the GaussianProcess class was deprecated (there's no warning anywhere). Wish I could try the new one in 0.18, but I cannot use dev versions in production.

    Will there be a 0.17.2 release before 0.18? The fix would be trivial - I think replacing the division "/" by "//" should do it..

  3. nelson-liu commented on Mar 4, 2016

    @nelson-liu
    Contributor
  4. glouppe commented on Mar 4, 2016

    @glouppe
    Contributor

    No, this is correct. The new GP implementation has been added after the 0.17 release, and therefore the old implementation will be deprecated in 0.20, two release cycles after the next 0.18 release.

    GaussianProcess is deprecated starting from 0.18 but it is still there until 0.20, where it will be entirely removied.

  5. nelson-liu commented on Mar 4, 2016

    @nelson-liu
    Contributor

    ah that makes sense, thanks for the info.

  6. added a commit that references this issue on Sep 4, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions