mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-04 01:02:39 +02:00
[inducing] 3d added
This commit is contained in:
parent
cfae854f88
commit
57d2f98570
7 changed files with 68 additions and 30 deletions
|
|
@ -159,7 +159,7 @@ def _plot_data_error(self, canvas, which_data_rows='all',
|
|||
|
||||
return plots
|
||||
|
||||
def plot_inducing(self, visible_dims=None, projection='2d', label=None, **plot_kwargs):
|
||||
def plot_inducing(self, visible_dims=None, projection='2d', label='inducing', **plot_kwargs):
|
||||
"""
|
||||
Plot the inducing inputs of a sparse gp model
|
||||
|
||||
|
|
@ -168,7 +168,7 @@ def plot_inducing(self, visible_dims=None, projection='2d', label=None, **plot_k
|
|||
"""
|
||||
canvas, kwargs = pl().new_canvas(projection=projection, **plot_kwargs)
|
||||
plots = _plot_inducing(self, canvas, visible_dims, projection, label, **kwargs)
|
||||
return pl().add_to_canvas(canvas, plots)
|
||||
return pl().add_to_canvas(canvas, plots, legend=label is not None)
|
||||
|
||||
def _plot_inducing(self, canvas, visible_dims, projection, label, **plot_kwargs):
|
||||
if visible_dims is None:
|
||||
|
|
@ -182,15 +182,15 @@ def _plot_inducing(self, canvas, visible_dims, projection, label, **plot_kwargs)
|
|||
#one dimensional plotting
|
||||
if len(free_dims) == 1:
|
||||
update_not_existing_kwargs(plot_kwargs, pl().defaults.inducing_1d) # @UndefinedVariable
|
||||
plots['inducing'] = pl().plot_axis_lines(canvas, Z[:, free_dims], **plot_kwargs)
|
||||
plots['inducing'] = pl().plot_axis_lines(canvas, Z[:, free_dims], label=label, **plot_kwargs)
|
||||
#2D plotting
|
||||
elif len(free_dims) == 2 and projection == '3d':
|
||||
update_not_existing_kwargs(plot_kwargs, pl().defaults.inducing_3d) # @UndefinedVariable
|
||||
plots['inducing'] = pl().plot_axis_lines(canvas, Z[:, free_dims], **plot_kwargs)
|
||||
plots['inducing'] = pl().plot_axis_lines(canvas, Z[:, free_dims], label=label, **plot_kwargs)
|
||||
elif len(free_dims) == 2:
|
||||
update_not_existing_kwargs(plot_kwargs, pl().defaults.inducing_2d) # @UndefinedVariable
|
||||
plots['inducing'] = pl().scatter(canvas, Z[:, free_dims[0]], Z[:, free_dims[1]],
|
||||
**plot_kwargs)
|
||||
label=label, **plot_kwargs)
|
||||
elif len(free_dims) == 0:
|
||||
pass #Nothing to plot!
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -46,9 +46,12 @@ def plot_mean(self, plot_limits=None, fixed_inputs=None,
|
|||
"""
|
||||
Plot the mean of the GP.
|
||||
|
||||
You can deactivate the legend for this one plot by supplying None to label.
|
||||
|
||||
Give the Y_metadata in the predict_kw if you need it.
|
||||
|
||||
|
||||
|
||||
:param plot_limits: The limits of the plot. If 1D [xmin,xmax], if 2D [[xmin,ymin],[xmax,ymax]]. Defaluts to data limits
|
||||
:type plot_limits: np.array
|
||||
:param fixed_inputs: a list of tuple [(i,v), (i,v)...], specifying that input dimension i should be set to value v.
|
||||
|
|
@ -112,8 +115,11 @@ def plot_confidence(self, lower=2.5, upper=97.5, plot_limits=None, fixed_inputs=
|
|||
E.g. the 95% confidence interval is $2.5, 97.5$.
|
||||
Note: Only implemented for one dimension!
|
||||
|
||||
You can deactivate the legend for this one plot by supplying None to label.
|
||||
|
||||
Give the Y_metadata in the predict_kw if you need it.
|
||||
|
||||
|
||||
:param float lower: the lower percentile to plot
|
||||
:param float upper: the upper percentile to plot
|
||||
:param plot_limits: The limits of the plot. If 1D [xmin,xmax], if 2D [[xmin,ymin],[xmax,ymax]]. Defaluts to data limits
|
||||
|
|
@ -134,7 +140,7 @@ def plot_confidence(self, lower=2.5, upper=97.5, plot_limits=None, fixed_inputs=
|
|||
(lower, upper),
|
||||
ycols, predict_kw)
|
||||
plots = _plot_confidence(self, canvas, helper_data, helper_prediction, label, **kwargs)
|
||||
return pl().add_to_canvas(canvas, plots)
|
||||
return pl().add_to_canvas(canvas, plots, legend=label is not None)
|
||||
|
||||
def _plot_confidence(self, canvas, helper_data, helper_prediction, label, **kwargs):
|
||||
_, _, _, _, free_dims, Xgrid, _, _, _, _, _ = helper_data
|
||||
|
|
@ -162,9 +168,12 @@ def plot_samples(self, plot_limits=None, fixed_inputs=None,
|
|||
"""
|
||||
Plot the mean of the GP.
|
||||
|
||||
You can deactivate the legend for this one plot by supplying None to label.
|
||||
|
||||
Give the Y_metadata in the predict_kw if you need it.
|
||||
|
||||
|
||||
|
||||
:param plot_limits: The limits of the plot. If 1D [xmin,xmax], if 2D [[xmin,ymin],[xmax,ymax]]. Defaluts to data limits
|
||||
:type plot_limits: np.array
|
||||
:param fixed_inputs: a list of tuple [(i,v), (i,v)...], specifying that input dimension i should be set to value v.
|
||||
|
|
@ -221,8 +230,12 @@ def plot_density(self, plot_limits=None, fixed_inputs=None,
|
|||
E.g. the 95% confidence interval is $2.5, 97.5$.
|
||||
Note: Only implemented for one dimension!
|
||||
|
||||
You can deactivate the legend for this one plot by supplying None to label.
|
||||
|
||||
Give the Y_metadata in the predict_kw if you need it.
|
||||
|
||||
|
||||
|
||||
:param plot_limits: The limits of the plot. If 1D [xmin,xmax], if 2D [[xmin,ymin],[xmax,ymax]]. Defaluts to data limits
|
||||
:type plot_limits: np.array
|
||||
:param fixed_inputs: a list of tuple [(i,v), (i,v)...], specifying that input dimension i should be set to value v.
|
||||
|
|
@ -271,10 +284,13 @@ def plot(self, plot_limits=None, fixed_inputs=None,
|
|||
plot_data=True, plot_inducing=True, plot_density=False,
|
||||
predict_kw=None, projection='2d', legend=False, **kwargs):
|
||||
"""
|
||||
Convinience function for plotting the fit of a GP.
|
||||
Convenience function for plotting the fit of a GP.
|
||||
|
||||
You can deactivate the legend for this one plot by supplying None to label.
|
||||
|
||||
Give the Y_metadata in the predict_kw if you need it.
|
||||
|
||||
|
||||
If you want fine graned control use the specific plotting functions supplied in the model.
|
||||
|
||||
:param plot_limits: The limits of the plot. If 1D [xmin,xmax], if 2D [[xmin,ymin],[xmax,ymax]]. Defaluts to data limits
|
||||
|
|
@ -298,6 +314,8 @@ def plot(self, plot_limits=None, fixed_inputs=None,
|
|||
:param bool plot_inducing: plot inducing inputs?
|
||||
:param bool plot_density: plot density instead of the confidence interval?
|
||||
:param dict predict_kw: the keyword arguments for the prediction. If you want to plot a specific kernel give dict(kern=<specific kernel>) in here
|
||||
:param {2d|3d} projection: plot in 2d or 3d?
|
||||
:param bool legend: convenience, whether to put a legend on the plot or not.
|
||||
"""
|
||||
canvas, _ = pl().new_canvas(projection=projection, **kwargs)
|
||||
helper_data = helper_for_plot_data(self, plot_limits, visible_dims, fixed_inputs, resolution)
|
||||
|
|
@ -341,8 +359,11 @@ def plot_f(self, plot_limits=None, fixed_inputs=None,
|
|||
|
||||
If you want fine graned control use the specific plotting functions supplied in the model.
|
||||
|
||||
You can deactivate the legend for this one plot by supplying None to label.
|
||||
|
||||
Give the Y_metadata in the predict_kw if you need it.
|
||||
|
||||
|
||||
:param plot_limits: The limits of the plot. If 1D [xmin,xmax], if 2D [[xmin,ymin],[xmax,ymax]]. Defaluts to data limits
|
||||
:type plot_limits: np.array
|
||||
:param fixed_inputs: a list of tuple [(i,v), (i,v)...], specifying that input dimension i should be set to value v.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue