mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-08 19:42:39 +02:00
made input_ubncertainty plotting work, modified example a little
This commit is contained in:
parent
eb5f2ff5f0
commit
1c51eae954
2 changed files with 20 additions and 7 deletions
|
|
@ -286,6 +286,9 @@ class sparse_GP(GPBase):
|
|||
fig = pb.figure(num=fignum)
|
||||
ax = fig.add_subplot(111)
|
||||
|
||||
if which_data is 'all':
|
||||
which_data = slice(None)
|
||||
|
||||
GPBase.plot(self, samples=0, plot_limits=None, which_data='all', which_parts='all', resolution=None, levels=20, ax=ax)
|
||||
if self.X.shape[1] == 1:
|
||||
if self.has_uncertain_inputs:
|
||||
|
|
|
|||
|
|
@ -310,6 +310,8 @@ def sparse_GP_regression_2D(N = 400, M = 50, max_nb_eval_optim=100):
|
|||
|
||||
def uncertain_inputs_sparse_regression(max_nb_eval_optim=100):
|
||||
"""Run a 1D example of a sparse GP regression with uncertain inputs."""
|
||||
fig, axes = pb.subplots(1,2,figsize=(12,5))
|
||||
|
||||
# sample inputs and outputs
|
||||
S = np.ones((20,1))
|
||||
X = np.random.uniform(-3.,3.,(20,1))
|
||||
|
|
@ -319,14 +321,22 @@ def uncertain_inputs_sparse_regression(max_nb_eval_optim=100):
|
|||
|
||||
k = GPy.kern.rbf(1) + GPy.kern.white(1)
|
||||
|
||||
# create simple GP model
|
||||
m = GPy.models.sparse_GP_regression(X, Y, kernel=k, Z=Z, X_variance=S)
|
||||
|
||||
# contrain all parameters to be positive
|
||||
# create simple GP model - no input uncertainty on this one
|
||||
m = GPy.models.sparse_GP_regression(X, Y, kernel=k, Z=Z)
|
||||
m.ensure_default_constraints()
|
||||
m.optimize('scg', messages=1, max_f_eval=max_nb_eval_optim)
|
||||
m.plot(ax=axes[0])
|
||||
axes[0].set_title('no input uncertainty')
|
||||
|
||||
# optimize and plot
|
||||
m.optimize('tnc', messages=1, max_f_eval=max_nb_eval_optim)
|
||||
m.plot()
|
||||
|
||||
#the same model with uncertainty
|
||||
m = GPy.models.sparse_GP_regression(X, Y, kernel=k, Z=Z, X_variance=S)
|
||||
m.ensure_default_constraints()
|
||||
m.optimize('scg', messages=1, max_f_eval=max_nb_eval_optim)
|
||||
m.plot(ax=axes[1])
|
||||
axes[1].set_title('with input uncertainty')
|
||||
print(m)
|
||||
|
||||
fig.canvas.draw()
|
||||
|
||||
return m
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue