Pythondatasciencehandbook: 04.03-Errorbars

Created on 14 Jan 2019  路  5Comments  路  Source: jakevdp/PythonDataScienceHandbook

from sklearn.gaussian_process import GaussianProcess

Which show the Error message: ImportError: cannot import name 'GaussianProcess'
It may be raised by this function has been removed from the latest sklearn module. I check the latest API Reference.
Gaussian Processes section has only gaussian_process.GaussianProcessClassifier() and gaussian_process.GaussianProcessRegressor(), which seem differs from the function from the book.

Most helpful comment

from sklearn.gaussian_process import GaussianProcessRegressor

# define the model and draw some data
model = lambda x: x * np.sin(x)
xdata = np.array([1, 3, 5, 6, 8])
ydata = model(xdata)

# Compute the Gaussian process fit
gp = GaussianProcessRegressor()
gp.fit(xdata[:, np.newaxis], ydata)

xfit = np.linspace(0, 10, 1000)
yfit, y_std = gp.predict(xfit[:, np.newaxis], return_std=True)
dyfit = 2 * np.sqrt(y_std)  # 2*sigma ~ 95% confidence region

All 5 comments

Hello, I have the same question as yours, and I want to get the same result as the book, how do I modify the code?

scikit-learn 0.18 completely changed _Gaussian Process_ API, implementation and documentation. Not clear how to reproduce the old results using the new GaussionProcessRegressor

from sklearn.gaussian_process import GaussianProcessRegressor

# define the model and draw some data
model = lambda x: x * np.sin(x)
xdata = np.array([1, 3, 5, 6, 8])
ydata = model(xdata)

# Compute the Gaussian process fit
gp = GaussianProcessRegressor()
gp.fit(xdata[:, np.newaxis], ydata)

xfit = np.linspace(0, 10, 1000)
yfit, y_std = gp.predict(xfit[:, np.newaxis], return_std=True)
dyfit = 2 * np.sqrt(y_std)  # 2*sigma ~ 95% confidence region

Hey guys, having the same problem. Did anyone solved it as in new API there is only Classifier or Regressor as it was mentioned before.

I think y_std equals to sigma (sigma means standard deviation), so

- dyfit = 2 * np.sqrt(y_std)  # 2*sigma ~ 95% confidence region
+ dyfit = 2 * y_std  # 2*sigma ~ 95% confidence region
Was this page helpful?
0 / 5 - 0 ratings

Related issues

marco-vene picture marco-vene  路  3Comments

musicus picture musicus  路  3Comments

ajasja picture ajasja  路  17Comments

edvakf picture edvakf  路  29Comments

fgypas picture fgypas  路  6Comments