2015-04-08 17:28:51 +08:00
|
|
|
"""
|
2010-12-09 15:44:36 +08:00
|
|
|
=========================================================
|
2010-11-25 05:48:36 +08:00
|
|
|
Gaussian Processes regression: basic introductory example
|
2010-12-09 15:44:36 +08:00
|
|
|
=========================================================
|
2010-11-14 18:55:52 +08:00
|
|
|
|
2015-04-15 21:21:47 +08:00
|
|
|
A simple one-dimensional regression example computed in two different ways:
|
2012-02-02 23:35:55 +08:00
|
|
|
|
2015-04-02 21:23:56 +08:00
|
|
|
1. A noise-free case
|
2015-04-15 21:21:47 +08:00
|
|
|
2. A noisy case with known noise-level per datapoint
|
2012-02-02 23:35:55 +08:00
|
|
|
|
2015-04-02 21:23:56 +08:00
|
|
|
In both cases, the kernel's parameters are estimated using the maximum
|
2012-02-02 23:35:55 +08:00
|
|
|
likelihood principle.
|
2010-11-15 01:44:34 +08:00
|
|
|
|
2012-02-02 23:35:55 +08:00
|
|
|
The figures illustrate the interpolating property of the Gaussian Process
|
2010-11-15 01:44:34 +08:00
|
|
|
model as well as its probabilistic nature in the form of a pointwise 95%
|
|
|
|
|
confidence interval.
|
2012-02-02 23:35:55 +08:00
|
|
|
|
2015-08-12 02:26:37 +08:00
|
|
|
Note that the parameter ``alpha`` is applied as a Tikhonov
|
2015-04-02 21:23:56 +08:00
|
|
|
regularization of the assumed covariance between the training points.
|
2010-11-14 18:55:52 +08:00
|
|
|
"""
|
2013-02-01 22:04:03 +08:00
|
|
|
print(__doc__)
|
2010-11-15 01:44:34 +08:00
|
|
|
|
2010-11-17 05:57:54 +08:00
|
|
|
# Author: Vincent Dubourg <vincent.dubourg@gmail.com>
|
2012-02-02 23:35:55 +08:00
|
|
|
# Jake Vanderplas <vanderplas@astro.washington.edu>
|
2015-04-02 21:23:56 +08:00
|
|
|
# Jan Hendrik Metzen <jhm@informatik.uni-bremen.de>s
|
2016-04-01 08:25:31 +08:00
|
|
|
# License: BSD 3 clause
|
2010-11-14 18:55:52 +08:00
|
|
|
|
|
|
|
|
import numpy as np
|
[MRG+1] Fix: Replace pylab with matplotlib.pyplot #6754 (#6762)
* Fix: Replace pylab with matplotlib.pyplot #6754
- one instance of 22 occurrences of pylab replaced with matplotlib.pyplot
- bench_glm.py now free of pylab references
- code executes properly
* Fix: Replace pylab with matplotlib.pyplot #6754
- one instance of 21 remaining occurrences of pylab replaced with
matplotlib.pyplot
- bench_glmnet.py now free of pylab references
- code does not execute for extraneous reason: ImportError: No module named
glmnet.elastic_net
* Fix: Replace pylab with matplotlib.pyplot #6754
- one instance of 19 occurrences of pylab replaced with matplotlib.pyplot
- bench_lasso.py now free of pylab references
- code executes properly
* Fix: Replace pylab with matplotlib.pyplot #6754
- one instance of 18 occurrences of pylab replaced with matplotlib.pyplot
- bench_plot_neighbors.py now free of pylab references
- code executes properly
* Fix: Replace pylab with matplotlib.pyplot #6754
- one instance of 17 occurrences of pylab replaced with matplotlib.pyplot
- bench_plot_omp_lars.py now free of pylab references
- code does not execute for extraneous reasons:
- File "bench_plot_omp_lars.py", line 111, in <module>
- ax = fig.add_subplot(1, 2, i)
- ValueError: num must be 1 <= num <= 2, not 0
- line 111 should probably be ax = fig.add_subplot(1, 2, i+1)
* Fix: Replace pylab with matplotlib.pyplot #6754
- bench_plot_parallel_pairwise.py now free of pylab references
- code executes properly
* Fix: Replace pylab with matplotlib.pyplot #6754
- bench_plot_ward.py now free of pylab references
- code executes properly
* Fix: Replace pylab with matplotlib.pyplot #6754
- bench_sgd_regression.py now free of pylab references
- code executes properly
* Fix: Replace pylab with matplotlib.pyplot #6754
- bench_tree.py now free of pylab references
- code executes properly
* refactor: Replace pl with plt
- replace instances of pl (as on import pylab as pl)
with plt (as in import matplotlib.pyplot as plt)
- bench_glm.py clean
* refactor: Replace pl with plt
- replace instances of pl (as on import pylab as pl)
with plt (as in import matplotlib.pyplot as plt)
- bench_glm.py clean of pl
- code does not execute for extraneous reasons
* refactor: Replace pl with plt
- replace instances of pl (as on import pylab as pl)
with plt (as in import matplotlib.pyplot as plt)
- bench_lasso.py clean of pl
- code executes properly
* refactor: Replace pl with plt
- replace instances of pl (as on import pylab as pl)
with plt (as in import matplotlib.pyplot as plt)
- bench_plot_neighbors.py clean of pl
- code executes properly
* refactor: Replace pl with plt
- replace instances of pl (as on import pylab as pl)
with plt (as in import matplotlib.pyplot as plt)
- bench_plot_omp_lars.py clean of pl
- code does not execute for extraneous reasons
* fix: Fix bug that prevented graphs from displaying
* refactor: Replace pl with plt
- replace instances of pl (as on import pylab as pl)
with plt (as in import matplotlib.pyplot as plt)
- bench_plot_parallel_pairwise.py clean of pl
- code executes properly
* refactor: Replace pl with plt
- replace instances of pl (as on import pylab as pl)
with plt (as in import matplotlib.pyplot as plt)
- bench_plot_ward.py clean of pl
- code executes properly
* refactor: Replace pl with plt
- replace instances of pl (as on import pylab as pl)
with plt (as in import matplotlib.pyplot as plt)
- bench_sgd_regression.py clean of pl
- code executes properly
* refactor: Replace pl with plt
- replace instances of pl (as on import pylab as pl)
with plt (as in import matplotlib.pyplot as plt)
- bench_tree.py clean of pl
- code executes properly
* docs: removed pylab references from comments
* docs: removed all pylab references
- replaced with matplotlib.pyplot
- pl --> plt
* docs: removed pylab references from comments
- replaced with matplotlib.pyplot
- pl --> plt
* docs: removed all pylab references
- replaced with matplotlib.pyplot
- pl --> plt
* refactor: Replace pl with plt
- replace instances of pl (as on import pylab as pl)
with plt (as in import matplotlib.pyplot as plt)
- mlcomp_sparse_document_classification.py clean of pl
* refactor: Replace pl with plt
- replace instances of pl (as on import pylab as pl)
with plt (as in import matplotlib.pyplot as plt)
- plot_gpr_noisy_targets.py clean of pl
- code does not execute for extraneous reasons
- File "examples/gaussian_process/plot_gpr_noisy_targets.py", line 31, in
<module>
- from sklearn.gaussian_process import GaussianProcessRegressor
- ImportError: cannot import name GaussianProcessRegressor
* refactor: Replace pl with plt
- replace instances of pl (as on import pylab as pl)
with plt (as in import matplotlib.pyplot as plt)
- plot_gpc_isoprobability.py clean of pl
- code does not execute for extraneous reasons
- File "examples/gaussian_process/plot_gpc_isoprobability.py", line 24, in
<module>
- from sklearn.gaussian_process import GaussianProcessClassifier
- ImportError: cannot import name GaussianProcessClassifier
* docs: removed all pylab references
- replaced with matplotlib.pyplot
- pl --> plt
* docs: removed all pylab references
- replaced with matplotlib.pyplot
* refactor: Replace pl with plt
- replace instances of pl (as on import pylab as pl)
with plt (as in import matplotlib.pyplot as plt)
- plot_sparse_coding.py clean of pl
- code executes properly
* docs: removed all pylab references
- replaced with matplotlib.pyplot
* docs: removed all pylab references
- replaced with matplotlib.pyplot
* style: Indent properly
* style: indent properly
* style: Indent properly
* docs: Add missing .pyplot
* docs: Fix typo
* style: Indent properly
2016-05-10 17:34:33 +08:00
|
|
|
from matplotlib import pyplot as plt
|
2010-11-14 18:55:52 +08:00
|
|
|
|
2015-04-02 21:23:56 +08:00
|
|
|
from sklearn.gaussian_process import GaussianProcessRegressor
|
|
|
|
|
from sklearn.gaussian_process.kernels import RBF, ConstantKernel as C
|
|
|
|
|
|
2012-02-02 23:35:55 +08:00
|
|
|
np.random.seed(1)
|
2010-11-15 01:44:34 +08:00
|
|
|
|
2012-02-17 23:49:48 +08:00
|
|
|
|
2010-12-09 15:44:36 +08:00
|
|
|
def f(x):
|
2010-12-13 06:40:13 +08:00
|
|
|
"""The function to predict."""
|
2010-12-09 15:44:36 +08:00
|
|
|
return x * np.sin(x)
|
2010-11-14 18:55:52 +08:00
|
|
|
|
2015-08-31 02:32:32 +08:00
|
|
|
# ----------------------------------------------------------------------
|
2012-02-02 23:35:55 +08:00
|
|
|
# First the noiseless case
|
2010-11-19 15:26:17 +08:00
|
|
|
X = np.atleast_2d([1., 3., 5., 6., 7., 8.]).T
|
2010-11-14 18:55:52 +08:00
|
|
|
|
|
|
|
|
# Observations
|
2010-11-24 06:22:12 +08:00
|
|
|
y = f(X).ravel()
|
2010-11-14 18:55:52 +08:00
|
|
|
|
2010-11-15 01:44:34 +08:00
|
|
|
# Mesh the input space for evaluations of the real function, the prediction and
|
|
|
|
|
# its MSE
|
2010-11-19 15:26:17 +08:00
|
|
|
x = np.atleast_2d(np.linspace(0, 10, 1000)).T
|
2010-11-14 18:55:52 +08:00
|
|
|
|
2018-04-24 07:32:25 +08:00
|
|
|
# Instantiate a Gaussian Process model
|
2015-04-02 21:23:56 +08:00
|
|
|
kernel = C(1.0, (1e-3, 1e3)) * RBF(10, (1e-2, 1e2))
|
2015-08-10 23:59:50 +08:00
|
|
|
gp = GaussianProcessRegressor(kernel=kernel, n_restarts_optimizer=9)
|
2010-11-14 18:55:52 +08:00
|
|
|
|
|
|
|
|
# Fit to data using Maximum Likelihood Estimation of the parameters
|
2010-11-24 06:22:12 +08:00
|
|
|
gp.fit(X, y)
|
2010-11-14 18:55:52 +08:00
|
|
|
|
|
|
|
|
# Make the prediction on the meshed x-axis (ask for MSE as well)
|
2015-04-02 21:23:56 +08:00
|
|
|
y_pred, sigma = gp.predict(x, return_std=True)
|
2010-11-14 18:55:52 +08:00
|
|
|
|
2010-11-15 01:44:34 +08:00
|
|
|
# Plot the function, the prediction and the 95% confidence interval based on
|
|
|
|
|
# the MSE
|
2017-09-14 17:42:58 +08:00
|
|
|
plt.figure()
|
2019-01-05 12:22:36 +08:00
|
|
|
plt.plot(x, f(x), 'r:', label=r'$f(x) = x\,\sin(x)$')
|
2019-02-08 20:13:34 +08:00
|
|
|
plt.plot(X, y, 'r.', markersize=10, label='Observations')
|
|
|
|
|
plt.plot(x, y_pred, 'b-', label='Prediction')
|
[MRG+1] Fix: Replace pylab with matplotlib.pyplot #6754 (#6762)
* Fix: Replace pylab with matplotlib.pyplot #6754
- one instance of 22 occurrences of pylab replaced with matplotlib.pyplot
- bench_glm.py now free of pylab references
- code executes properly
* Fix: Replace pylab with matplotlib.pyplot #6754
- one instance of 21 remaining occurrences of pylab replaced with
matplotlib.pyplot
- bench_glmnet.py now free of pylab references
- code does not execute for extraneous reason: ImportError: No module named
glmnet.elastic_net
* Fix: Replace pylab with matplotlib.pyplot #6754
- one instance of 19 occurrences of pylab replaced with matplotlib.pyplot
- bench_lasso.py now free of pylab references
- code executes properly
* Fix: Replace pylab with matplotlib.pyplot #6754
- one instance of 18 occurrences of pylab replaced with matplotlib.pyplot
- bench_plot_neighbors.py now free of pylab references
- code executes properly
* Fix: Replace pylab with matplotlib.pyplot #6754
- one instance of 17 occurrences of pylab replaced with matplotlib.pyplot
- bench_plot_omp_lars.py now free of pylab references
- code does not execute for extraneous reasons:
- File "bench_plot_omp_lars.py", line 111, in <module>
- ax = fig.add_subplot(1, 2, i)
- ValueError: num must be 1 <= num <= 2, not 0
- line 111 should probably be ax = fig.add_subplot(1, 2, i+1)
* Fix: Replace pylab with matplotlib.pyplot #6754
- bench_plot_parallel_pairwise.py now free of pylab references
- code executes properly
* Fix: Replace pylab with matplotlib.pyplot #6754
- bench_plot_ward.py now free of pylab references
- code executes properly
* Fix: Replace pylab with matplotlib.pyplot #6754
- bench_sgd_regression.py now free of pylab references
- code executes properly
* Fix: Replace pylab with matplotlib.pyplot #6754
- bench_tree.py now free of pylab references
- code executes properly
* refactor: Replace pl with plt
- replace instances of pl (as on import pylab as pl)
with plt (as in import matplotlib.pyplot as plt)
- bench_glm.py clean
* refactor: Replace pl with plt
- replace instances of pl (as on import pylab as pl)
with plt (as in import matplotlib.pyplot as plt)
- bench_glm.py clean of pl
- code does not execute for extraneous reasons
* refactor: Replace pl with plt
- replace instances of pl (as on import pylab as pl)
with plt (as in import matplotlib.pyplot as plt)
- bench_lasso.py clean of pl
- code executes properly
* refactor: Replace pl with plt
- replace instances of pl (as on import pylab as pl)
with plt (as in import matplotlib.pyplot as plt)
- bench_plot_neighbors.py clean of pl
- code executes properly
* refactor: Replace pl with plt
- replace instances of pl (as on import pylab as pl)
with plt (as in import matplotlib.pyplot as plt)
- bench_plot_omp_lars.py clean of pl
- code does not execute for extraneous reasons
* fix: Fix bug that prevented graphs from displaying
* refactor: Replace pl with plt
- replace instances of pl (as on import pylab as pl)
with plt (as in import matplotlib.pyplot as plt)
- bench_plot_parallel_pairwise.py clean of pl
- code executes properly
* refactor: Replace pl with plt
- replace instances of pl (as on import pylab as pl)
with plt (as in import matplotlib.pyplot as plt)
- bench_plot_ward.py clean of pl
- code executes properly
* refactor: Replace pl with plt
- replace instances of pl (as on import pylab as pl)
with plt (as in import matplotlib.pyplot as plt)
- bench_sgd_regression.py clean of pl
- code executes properly
* refactor: Replace pl with plt
- replace instances of pl (as on import pylab as pl)
with plt (as in import matplotlib.pyplot as plt)
- bench_tree.py clean of pl
- code executes properly
* docs: removed pylab references from comments
* docs: removed all pylab references
- replaced with matplotlib.pyplot
- pl --> plt
* docs: removed pylab references from comments
- replaced with matplotlib.pyplot
- pl --> plt
* docs: removed all pylab references
- replaced with matplotlib.pyplot
- pl --> plt
* refactor: Replace pl with plt
- replace instances of pl (as on import pylab as pl)
with plt (as in import matplotlib.pyplot as plt)
- mlcomp_sparse_document_classification.py clean of pl
* refactor: Replace pl with plt
- replace instances of pl (as on import pylab as pl)
with plt (as in import matplotlib.pyplot as plt)
- plot_gpr_noisy_targets.py clean of pl
- code does not execute for extraneous reasons
- File "examples/gaussian_process/plot_gpr_noisy_targets.py", line 31, in
<module>
- from sklearn.gaussian_process import GaussianProcessRegressor
- ImportError: cannot import name GaussianProcessRegressor
* refactor: Replace pl with plt
- replace instances of pl (as on import pylab as pl)
with plt (as in import matplotlib.pyplot as plt)
- plot_gpc_isoprobability.py clean of pl
- code does not execute for extraneous reasons
- File "examples/gaussian_process/plot_gpc_isoprobability.py", line 24, in
<module>
- from sklearn.gaussian_process import GaussianProcessClassifier
- ImportError: cannot import name GaussianProcessClassifier
* docs: removed all pylab references
- replaced with matplotlib.pyplot
- pl --> plt
* docs: removed all pylab references
- replaced with matplotlib.pyplot
* refactor: Replace pl with plt
- replace instances of pl (as on import pylab as pl)
with plt (as in import matplotlib.pyplot as plt)
- plot_sparse_coding.py clean of pl
- code executes properly
* docs: removed all pylab references
- replaced with matplotlib.pyplot
* docs: removed all pylab references
- replaced with matplotlib.pyplot
* style: Indent properly
* style: indent properly
* style: Indent properly
* docs: Add missing .pyplot
* docs: Fix typo
* style: Indent properly
2016-05-10 17:34:33 +08:00
|
|
|
plt.fill(np.concatenate([x, x[::-1]]),
|
|
|
|
|
np.concatenate([y_pred - 1.9600 * sigma,
|
|
|
|
|
(y_pred + 1.9600 * sigma)[::-1]]),
|
|
|
|
|
alpha=.5, fc='b', ec='None', label='95% confidence interval')
|
|
|
|
|
plt.xlabel('$x$')
|
|
|
|
|
plt.ylabel('$f(x)$')
|
|
|
|
|
plt.ylim(-10, 20)
|
|
|
|
|
plt.legend(loc='upper left')
|
2010-11-14 18:55:52 +08:00
|
|
|
|
2015-08-31 02:32:32 +08:00
|
|
|
# ----------------------------------------------------------------------
|
2012-02-02 23:35:55 +08:00
|
|
|
# now the noisy case
|
|
|
|
|
X = np.linspace(0.1, 9.9, 20)
|
|
|
|
|
X = np.atleast_2d(X).T
|
|
|
|
|
|
|
|
|
|
# Observations and noise
|
|
|
|
|
y = f(X).ravel()
|
|
|
|
|
dy = 0.5 + 1.0 * np.random.random(y.shape)
|
|
|
|
|
noise = np.random.normal(0, dy)
|
|
|
|
|
y += noise
|
|
|
|
|
|
2018-01-19 07:34:01 +08:00
|
|
|
# Instantiate a Gaussian Process model
|
|
|
|
|
gp = GaussianProcessRegressor(kernel=kernel, alpha=dy ** 2,
|
2015-04-02 21:23:56 +08:00
|
|
|
n_restarts_optimizer=10)
|
2012-02-02 23:35:55 +08:00
|
|
|
|
|
|
|
|
# Fit to data using Maximum Likelihood Estimation of the parameters
|
|
|
|
|
gp.fit(X, y)
|
|
|
|
|
|
|
|
|
|
# Make the prediction on the meshed x-axis (ask for MSE as well)
|
2015-04-02 21:23:56 +08:00
|
|
|
y_pred, sigma = gp.predict(x, return_std=True)
|
2012-02-02 23:35:55 +08:00
|
|
|
|
|
|
|
|
# Plot the function, the prediction and the 95% confidence interval based on
|
|
|
|
|
# the MSE
|
2017-09-14 17:42:58 +08:00
|
|
|
plt.figure()
|
2019-01-05 12:22:36 +08:00
|
|
|
plt.plot(x, f(x), 'r:', label=r'$f(x) = x\,\sin(x)$')
|
2019-02-08 20:13:34 +08:00
|
|
|
plt.errorbar(X.ravel(), y, dy, fmt='r.', markersize=10, label='Observations')
|
|
|
|
|
plt.plot(x, y_pred, 'b-', label='Prediction')
|
[MRG+1] Fix: Replace pylab with matplotlib.pyplot #6754 (#6762)
* Fix: Replace pylab with matplotlib.pyplot #6754
- one instance of 22 occurrences of pylab replaced with matplotlib.pyplot
- bench_glm.py now free of pylab references
- code executes properly
* Fix: Replace pylab with matplotlib.pyplot #6754
- one instance of 21 remaining occurrences of pylab replaced with
matplotlib.pyplot
- bench_glmnet.py now free of pylab references
- code does not execute for extraneous reason: ImportError: No module named
glmnet.elastic_net
* Fix: Replace pylab with matplotlib.pyplot #6754
- one instance of 19 occurrences of pylab replaced with matplotlib.pyplot
- bench_lasso.py now free of pylab references
- code executes properly
* Fix: Replace pylab with matplotlib.pyplot #6754
- one instance of 18 occurrences of pylab replaced with matplotlib.pyplot
- bench_plot_neighbors.py now free of pylab references
- code executes properly
* Fix: Replace pylab with matplotlib.pyplot #6754
- one instance of 17 occurrences of pylab replaced with matplotlib.pyplot
- bench_plot_omp_lars.py now free of pylab references
- code does not execute for extraneous reasons:
- File "bench_plot_omp_lars.py", line 111, in <module>
- ax = fig.add_subplot(1, 2, i)
- ValueError: num must be 1 <= num <= 2, not 0
- line 111 should probably be ax = fig.add_subplot(1, 2, i+1)
* Fix: Replace pylab with matplotlib.pyplot #6754
- bench_plot_parallel_pairwise.py now free of pylab references
- code executes properly
* Fix: Replace pylab with matplotlib.pyplot #6754
- bench_plot_ward.py now free of pylab references
- code executes properly
* Fix: Replace pylab with matplotlib.pyplot #6754
- bench_sgd_regression.py now free of pylab references
- code executes properly
* Fix: Replace pylab with matplotlib.pyplot #6754
- bench_tree.py now free of pylab references
- code executes properly
* refactor: Replace pl with plt
- replace instances of pl (as on import pylab as pl)
with plt (as in import matplotlib.pyplot as plt)
- bench_glm.py clean
* refactor: Replace pl with plt
- replace instances of pl (as on import pylab as pl)
with plt (as in import matplotlib.pyplot as plt)
- bench_glm.py clean of pl
- code does not execute for extraneous reasons
* refactor: Replace pl with plt
- replace instances of pl (as on import pylab as pl)
with plt (as in import matplotlib.pyplot as plt)
- bench_lasso.py clean of pl
- code executes properly
* refactor: Replace pl with plt
- replace instances of pl (as on import pylab as pl)
with plt (as in import matplotlib.pyplot as plt)
- bench_plot_neighbors.py clean of pl
- code executes properly
* refactor: Replace pl with plt
- replace instances of pl (as on import pylab as pl)
with plt (as in import matplotlib.pyplot as plt)
- bench_plot_omp_lars.py clean of pl
- code does not execute for extraneous reasons
* fix: Fix bug that prevented graphs from displaying
* refactor: Replace pl with plt
- replace instances of pl (as on import pylab as pl)
with plt (as in import matplotlib.pyplot as plt)
- bench_plot_parallel_pairwise.py clean of pl
- code executes properly
* refactor: Replace pl with plt
- replace instances of pl (as on import pylab as pl)
with plt (as in import matplotlib.pyplot as plt)
- bench_plot_ward.py clean of pl
- code executes properly
* refactor: Replace pl with plt
- replace instances of pl (as on import pylab as pl)
with plt (as in import matplotlib.pyplot as plt)
- bench_sgd_regression.py clean of pl
- code executes properly
* refactor: Replace pl with plt
- replace instances of pl (as on import pylab as pl)
with plt (as in import matplotlib.pyplot as plt)
- bench_tree.py clean of pl
- code executes properly
* docs: removed pylab references from comments
* docs: removed all pylab references
- replaced with matplotlib.pyplot
- pl --> plt
* docs: removed pylab references from comments
- replaced with matplotlib.pyplot
- pl --> plt
* docs: removed all pylab references
- replaced with matplotlib.pyplot
- pl --> plt
* refactor: Replace pl with plt
- replace instances of pl (as on import pylab as pl)
with plt (as in import matplotlib.pyplot as plt)
- mlcomp_sparse_document_classification.py clean of pl
* refactor: Replace pl with plt
- replace instances of pl (as on import pylab as pl)
with plt (as in import matplotlib.pyplot as plt)
- plot_gpr_noisy_targets.py clean of pl
- code does not execute for extraneous reasons
- File "examples/gaussian_process/plot_gpr_noisy_targets.py", line 31, in
<module>
- from sklearn.gaussian_process import GaussianProcessRegressor
- ImportError: cannot import name GaussianProcessRegressor
* refactor: Replace pl with plt
- replace instances of pl (as on import pylab as pl)
with plt (as in import matplotlib.pyplot as plt)
- plot_gpc_isoprobability.py clean of pl
- code does not execute for extraneous reasons
- File "examples/gaussian_process/plot_gpc_isoprobability.py", line 24, in
<module>
- from sklearn.gaussian_process import GaussianProcessClassifier
- ImportError: cannot import name GaussianProcessClassifier
* docs: removed all pylab references
- replaced with matplotlib.pyplot
- pl --> plt
* docs: removed all pylab references
- replaced with matplotlib.pyplot
* refactor: Replace pl with plt
- replace instances of pl (as on import pylab as pl)
with plt (as in import matplotlib.pyplot as plt)
- plot_sparse_coding.py clean of pl
- code executes properly
* docs: removed all pylab references
- replaced with matplotlib.pyplot
* docs: removed all pylab references
- replaced with matplotlib.pyplot
* style: Indent properly
* style: indent properly
* style: Indent properly
* docs: Add missing .pyplot
* docs: Fix typo
* style: Indent properly
2016-05-10 17:34:33 +08:00
|
|
|
plt.fill(np.concatenate([x, x[::-1]]),
|
|
|
|
|
np.concatenate([y_pred - 1.9600 * sigma,
|
|
|
|
|
(y_pred + 1.9600 * sigma)[::-1]]),
|
|
|
|
|
alpha=.5, fc='b', ec='None', label='95% confidence interval')
|
|
|
|
|
plt.xlabel('$x$')
|
|
|
|
|
plt.ylabel('$f(x)$')
|
|
|
|
|
plt.ylim(-10, 20)
|
|
|
|
|
plt.legend(loc='upper left')
|
|
|
|
|
|
|
|
|
|
plt.show()
|