Skip to content

GaussianProcess batch predict fail on py3 #7329

Closed
ccphillippi/scikit-learn
#1

Description

@zhengruifeng

Description

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

Steps/Code to Reproduce

import numpy as np
import sklearn.datasets
from sklearn import gaussian_process

digits = sklearn.datasets.load_digits()

X = digits.data
y = digits.target

indices = np.arange(X.shape[0])
np.random.shuffle(indices)
X = X[indices]
y = y[indices]
X_train = X[:1000]
y_train = y[:1000]
X_test = X[1000:]
y_test = y[1000:]

gp = gaussian_process.GaussianProcess()
gp.fit(X_train, y_train)

gp.predict(X_test, batch_size=100)

Expected Results

No error is thrown.

Actual Results

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-13-b96b929502ec> in <module>()
----> 1 gp.predict(X_test, batch_size=100)

/usr/local/lib/python3.5/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

Versions

scikit-learn (0.17.1)
Python 3.5.2

Activity

  1. nelson-liu commented on Sep 2, 2016

    @nelson-liu
    Contributor

    Duplicate of #6483
    GaussianProcess will be deprecated in the next release (0.18). If possible, run the code on latest master and use GaussianProcessRegressor .

  2. zhengruifeng commented on Sep 2, 2016

    @zhengruifeng
    ContributorAuthor

    @nelson-liu Thanks. I will close this issue and pr.

  3. zhengruifeng commented on Sep 2, 2016

    @zhengruifeng
    ContributorAuthor

    @nelson-liu Although it will be deprecated in (0.18), I think this PR may be useful before removal of GaussianProcess. So I reopen this PR.

  4. added a commit that references this issue on Sep 4, 2016
    62a675a
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