Krystal
Krystal

Reputation: 39

Gaussian Process Regressor scikit learn does not recognise 'eval_MSE=True'

I am using Gaussian Process Regressor scikit learn to predit data for the models. While using gp, I also need to find uncertainity in each value present in the dataset. The documentation suggests to use "gp.predict(self, X, eval_MSE=True)". I used the same 'eval_MSE' in the code available online to test, but it gives me this error.

TypeError: predict() got an unexpected keyword argument 'eval_MSE'

The code I used for testing:

gp = GaussianProcessRegressor(corr='squared_exponential', theta0=1e-1,
                     thetaL=1e-3, thetaU=1,
                     nugget=(dy / y) ** 2,
                     random_start=100)

gp.fit(X, y)

y_pred, MSE = gp.predict(x, eval_MSE=True)

sigma = np.sqrt(MSE)

Can anyone provide a solution for this?

Upvotes: 3

Views: 1068

Answers (1)

Xopi García
Xopi García

Reputation: 386

Either go back to previous version of scikitlearn: GaussianProcess.predict ... or you adapt to the newest: GaussianProcessClassifier.predict

Not only the predict arguments has changed, but the name of the classifier itself, the input arguments, etc.

Summary from previous links:

  • Old GaussianProcess (version 0.17):

    class sklearn.gaussian_process.GaussianProcess(regr='constant', corr='squared_exponential', beta0=None, storage_mode='full', verbose=False, theta0=0.1, thetaL=None, thetaU=None, optimizer='fmin_cobyla', random_start=1, normalize=True, nugget=2.2204460492503131e-15, random_state=None)

    predict(X, eval_MSE=False, batch_size=None)

  • New GaussianProcessClassifier:

    class sklearn.gaussian_process.GaussianProcessClassifier(kernel=None, *, optimizer='fmin_l_bfgs_b', n_restarts_optimizer=0, max_iter_predict=100, warm_start=False, copy_X_train=True, random_state=None, multi_class='one_vs_rest', n_jobs=None)

    predict(X)

Upvotes: 2

Related Questions