mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-04 01:02:39 +02:00
[test] coverage increased
This commit is contained in:
parent
2e4be065d1
commit
844c24247b
26 changed files with 63 additions and 46 deletions
|
|
@ -134,24 +134,23 @@ def _plot_data_error(self, canvas, which_data_rows='all',
|
|||
plots = {}
|
||||
|
||||
if X_variance is not None:
|
||||
plots['xerrorplot'] = []
|
||||
plots['input_error'] = []
|
||||
#one dimensional plotting
|
||||
if len(free_dims) == 1:
|
||||
for d in ycols:
|
||||
update_not_existing_kwargs(error_kwargs, pl().defaults.xerrorbar)
|
||||
plots['xerrorplot'].append(pl().xerrorbar(canvas, X[rows, free_dims].flatten(), Y[rows, d].flatten(),
|
||||
plots['input_error'].append(pl().xerrorbar(canvas, X[rows, free_dims].flatten(), Y[rows, d].flatten(),
|
||||
2 * np.sqrt(X_variance[rows, free_dims].flatten()), label=label,
|
||||
**error_kwargs))
|
||||
#2D plotting
|
||||
elif len(free_dims) == 2:
|
||||
update_not_existing_kwargs(error_kwargs, pl().defaults.xerrorbar) # @UndefinedVariable
|
||||
for d in ycols:
|
||||
plots['xerrorplot'].append(pl().xerrorbar(canvas, X[rows, free_dims[0]].flatten(), Y[rows, d].flatten(),
|
||||
2 * np.sqrt(X_variance[rows, free_dims[0]].flatten()), label=label,
|
||||
**error_kwargs))
|
||||
plots['yerrorplot'].append(pl().xerrorbar(canvas, X[rows, free_dims[1]].flatten(), Y[rows, d].flatten(),
|
||||
2 * np.sqrt(X_variance[rows, free_dims[1]].flatten()), label=label,
|
||||
**error_kwargs))
|
||||
plots['input_error'].append(pl().xerrorbar(canvas, X[rows, free_dims[0]].flatten(), X[rows, free_dims[1]].flatten(),
|
||||
2 * np.sqrt(X_variance[rows, free_dims[0]].flatten()), label=label,
|
||||
**error_kwargs))
|
||||
plots['input_error'].append(pl().yerrorbar(canvas, X[rows, free_dims[0]].flatten(), X[rows, free_dims[1]].flatten(),
|
||||
2 * np.sqrt(X_variance[rows, free_dims[1]].flatten()), label=label,
|
||||
**error_kwargs))
|
||||
elif len(free_dims) == 0:
|
||||
pass #Nothing to plot!
|
||||
else:
|
||||
|
|
@ -244,7 +243,7 @@ def _plot_errorbars_trainset(self, canvas,
|
|||
|
||||
plots = []
|
||||
|
||||
if len(free_dims)<=2:
|
||||
if len(free_dims)<=2 and projection=='2d':
|
||||
update_not_existing_kwargs(plot_kwargs, pl().defaults.yerrorbar)
|
||||
if predict_kw is None:
|
||||
predict_kw = {}
|
||||
|
|
@ -259,21 +258,20 @@ def _plot_errorbars_trainset(self, canvas,
|
|||
np.vstack([mu[rows, d] - percs[0][rows, d], percs[1][rows, d] - mu[rows,d]]),
|
||||
label=label,
|
||||
**plot_kwargs))
|
||||
elif len(free_dims) == 2:
|
||||
for d in ycols:
|
||||
plots.append(pl().yerrorbar(canvas, X[rows,free_dims[0]], X[rows,free_dims[1]],
|
||||
np.vstack([mu[rows, d] - percs[0][rows, d], percs[1][rows, d] - mu[rows,d]]),
|
||||
color=Y[rows,d],
|
||||
label=label,
|
||||
**plot_kwargs))
|
||||
plots.append(pl().xerrorbar(canvas, X[rows,free_dims[0]], X[rows,free_dims[1]],
|
||||
np.vstack([mu[rows, d] - percs[0][rows, d], percs[1][rows, d] - mu[rows,d]]),
|
||||
color=Y[rows,d],
|
||||
label=label,
|
||||
**plot_kwargs))
|
||||
pass #Nothing to plot!
|
||||
# elif len(free_dims) == 2:
|
||||
# for d in ycols:
|
||||
# plots.append(pl().yerrorbar(canvas, X[rows,free_dims[0]], X[rows,free_dims[1]],
|
||||
# np.vstack([mu[rows, d] - percs[0][rows, d], percs[1][rows, d] - mu[rows,d]]),
|
||||
# #color=Y[rows,d],
|
||||
# label=label,
|
||||
# **plot_kwargs))
|
||||
# plots.append(pl().xerrorbar(canvas, X[rows,free_dims[0]], X[rows,free_dims[1]],
|
||||
# np.vstack([mu[rows, d] - percs[0][rows, d], percs[1][rows, d] - mu[rows,d]]),
|
||||
# #color=Y[rows,d],
|
||||
# label=label,
|
||||
# **plot_kwargs))
|
||||
else:
|
||||
raise NotImplementedError("Cannot plot in more then one dimension.")
|
||||
raise NotImplementedError("Cannot plot in more then one dimensions, or 3d")
|
||||
return dict(yerrorbars=plots)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -205,15 +205,13 @@ def _plot_samples(self, canvas, helper_data, helper_prediction, projection,
|
|||
if len(free_dims)==1:
|
||||
# 1D plotting:
|
||||
update_not_existing_kwargs(kwargs, pl().defaults.samples_1d) # @UndefinedVariable
|
||||
return dict(gpmean=[pl().plot(canvas, Xgrid[:, free_dims], samples, label=label, **kwargs)])
|
||||
plots = [pl().plot(canvas, Xgrid[:, free_dims], samples[:, s], label=label if s==0 else None, **kwargs) for s in range(samples.shape[-1])]
|
||||
elif len(free_dims)==2 and projection=='3d':
|
||||
update_not_existing_kwargs(kwargs, pl().defaults.samples_3d) # @UndefinedVariable
|
||||
for s in range(samples.shape[-1]):
|
||||
return dict(gpmean=[pl().surface(canvas, x,
|
||||
y, samples[:, s].reshape(resolution, resolution),
|
||||
**kwargs)])
|
||||
plots = [pl().surface(canvas, x, y, samples[:, s].reshape(resolution, resolution), **kwargs) for s in range(samples.shape[-1])]
|
||||
else:
|
||||
pass # Nothing to plot!
|
||||
return dict(gpmean=plots)
|
||||
else:
|
||||
raise RuntimeError('Cannot plot mean in more then 1 input dimensions')
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue