PythonDataScienceHandbook icon indicating copy to clipboard operation
PythonDataScienceHandbook copied to clipboard

04.03-Errorbars

Open freesinger opened this issue 5 years ago • 5 comments

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.

freesinger avatar Jan 14 '19 17:01 freesinger

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?

ghost avatar Apr 12 '19 07:04 ghost

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

slonik-az avatar Dec 16 '19 20:12 slonik-az

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

jhhuang96 avatar Dec 29 '19 06:12 jhhuang96

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.

RabigaM avatar Jan 09 '20 15:01 RabigaM

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

yamaimo avatar Apr 25 '20 01:04 yamaimo