PythonDataScienceHandbook
PythonDataScienceHandbook copied to clipboard
04.03-Errorbars
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.
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