GPy.plotting.gpy_plot package

Submodules

GPy.plotting.gpy_plot.data_plots module

plot_data(self, which_data_rows='all', which_data_ycols='all', visible_dims=None, projection='2d', label=None, **plot_kwargs)[source]
Plot the training data
  • For higher dimensions than two, use fixed_inputs to plot the data points with some of the inputs fixed.

Can plot only part of the data using which_data_rows and which_data_ycols.

Parameters:
  • which_data_rows ('all' or a slice object to slice self.X, self.Y) – which of the training data to plot (default all)
  • which_data_ycols ('all' or a list of integers) – when the data has several columns (independant outputs), only plot these
  • visible_dims (a numpy array) – an array specifying the input dimensions to plot (maximum two)
  • projection ({'2d','3d'}) – whether to plot in 2d or 3d. This only applies when plotting two dimensional inputs!
  • label (str) – the label for the plot
  • plot_kwargs (kwargs) – kwargs for the data plot for the plotting library you are using
Returns list:

of plots created.

plot_data_error(self, which_data_rows='all', which_data_ycols='all', visible_dims=None, projection='2d', label=None, **error_kwargs)[source]

Plot the training data input error.

For higher dimensions than two, use fixed_inputs to plot the data points with some of the inputs fixed.

Can plot only part of the data using which_data_rows and which_data_ycols.

Parameters:
  • which_data_rows ('all' or a slice object to slice self.X, self.Y) – which of the training data to plot (default all)
  • which_data_ycols ('all' or a list of integers) – when the data has several columns (independant outputs), only plot these
  • visible_dims (a numpy array) – an array specifying the input dimensions to plot (maximum two)
  • projection ({'2d','3d'}) – whether to plot in 2d or 3d. This only applies when plotting two dimensional inputs!
  • error_kwargs (dict) – kwargs for the error plot for the plotting library you are using
  • label (str) – the label for the plot
  • plot_kwargs (kwargs) – kwargs for the data plot for the plotting library you are using
Returns list:

of plots created.

plot_errorbars_trainset(self, which_data_rows='all', which_data_ycols='all', fixed_inputs=None, plot_raw=False, apply_link=False, label=None, projection='2d', predict_kw=None, **plot_kwargs)[source]

Plot the errorbars of the GP likelihood on the training data. These are the errorbars after the appropriate approximations according to the likelihood are done.

This also works for heteroscedastic likelihoods.

Give the Y_metadata in the predict_kw if you need it.

Parameters:
  • which_data_rows ('all' or a slice object to slice self.X, self.Y) – which of the training data to plot (default all)
  • which_data_ycols – when the data has several columns (independant outputs), only plot these
  • fixed_inputs (a list of tuples) – a list of tuple [(i,v), (i,v)...], specifying that input dimension i should be set to value v.
  • predict_kwargs (dict) – kwargs for the prediction used to predict the right quantiles.
  • plot_kwargs (kwargs) – kwargs for the data plot for the plotting library you are using
plot_inducing(self, visible_dims=None, projection='2d', label='inducing', legend=True, **plot_kwargs)[source]

Plot the inducing inputs of a sparse gp model

Parameters:
  • visible_dims (array-like) – an array specifying the input dimensions to plot (maximum two)
  • plot_kwargs (kwargs) – keyword arguments for the plotting library

GPy.plotting.gpy_plot.gp_plots module

plot(self, plot_limits=None, fixed_inputs=None, resolution=None, plot_raw=False, apply_link=False, which_data_ycols='all', which_data_rows='all', visible_dims=None, levels=20, samples=0, samples_likelihood=0, lower=2.5, upper=97.5, plot_data=True, plot_inducing=True, plot_density=False, predict_kw=None, projection='2d', legend=True, **kwargs)[source]

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.

Parameters:
  • plot_limits (np.array) – The limits of the plot. If 1D [xmin,xmax], if 2D [[xmin,ymin],[xmax,ymax]]. Defaluts to data limits
  • fixed_inputs (a list of tuples) – a list of tuple [(i,v), (i,v)...], specifying that input dimension i should be set to value v.
  • resolution (int) – The resolution of the prediction [default:200]
  • plot_raw (bool) – plot the latent function (usually denoted f) only?
  • apply_link (bool) – whether to apply the link function of the GP to the raw prediction.
  • which_data_ycols ('all' or a list of integers) – when the data has several columns (independant outputs), only plot these
  • which_data_rows ('all' or a slice object to slice self.X, self.Y) – which of the training data to plot (default all)
  • visible_dims (array-like) – which columns of the input X (!) to plot (array-like or list of ints)
  • levels (int) – the number of levels in the density (number bigger then 1, where 35 is smooth and 1 is the same as plot_confidence). You can go higher then 50 if the result is not smooth enough for you.
  • samples (int) – the number of samples to draw from the GP and plot into the plot. This will allways be samples from the latent function.
  • samples_likelihood (int) – the number of samples to draw from the GP and apply the likelihood noise. This is usually not what you want!
  • lower (float) – the lower percentile to plot
  • upper (float) – the upper percentile to plot
  • plot_data (bool) – plot the data into the plot?
  • plot_inducing (bool) – plot inducing inputs?
  • plot_density (bool) – plot density instead of the confidence interval?
  • predict_kw (dict) – the keyword arguments for the prediction. If you want to plot a specific kernel give dict(kern=<specific kernel>) in here
  • projection ({2d|3d}) – plot in 2d or 3d?
  • legend (bool) – convenience, whether to put a legend on the plot or not.
plot_confidence(self, lower=2.5, upper=97.5, plot_limits=None, fixed_inputs=None, resolution=None, plot_raw=False, apply_link=False, visible_dims=None, which_data_ycols='all', label='gp confidence', predict_kw=None, **kwargs)[source]

Plot the confidence interval between the percentiles lower and upper. 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.

Parameters:
  • lower (float) – the lower percentile to plot
  • upper (float) – the upper percentile to plot
  • plot_limits (np.array) – The limits of the plot. If 1D [xmin,xmax], if 2D [[xmin,ymin],[xmax,ymax]]. Defaluts to data limits
  • fixed_inputs (a list of tuples) – a list of tuple [(i,v), (i,v)...], specifying that input dimension i should be set to value v.
  • resolution (int) – The resolution of the prediction [default:200]
  • plot_raw (bool) – plot the latent function (usually denoted f) only?
  • apply_link (bool) – whether to apply the link function of the GP to the raw prediction.
  • visible_dims (array-like) – which columns of the input X (!) to plot (array-like or list of ints)
  • which_data_ycols (array-like) – which columns of the output y (!) to plot (array-like or list of ints)
  • predict_kw (dict) – the keyword arguments for the prediction. If you want to plot a specific kernel give dict(kern=<specific kernel>) in here
plot_density(self, plot_limits=None, fixed_inputs=None, resolution=None, plot_raw=False, apply_link=False, visible_dims=None, which_data_ycols='all', levels=35, label='gp density', predict_kw=None, **kwargs)[source]

Plot the confidence interval between the percentiles lower and upper. 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.

Parameters:
  • plot_limits (np.array) – The limits of the plot. If 1D [xmin,xmax], if 2D [[xmin,ymin],[xmax,ymax]]. Defaluts to data limits
  • fixed_inputs (a list of tuples) – a list of tuple [(i,v), (i,v)...], specifying that input dimension i should be set to value v.
  • resolution (int) – The resolution of the prediction [default:200]
  • plot_raw (bool) – plot the latent function (usually denoted f) only?
  • apply_link (bool) – whether to apply the link function of the GP to the raw prediction.
  • visible_dims (array-like) – which columns of the input X (!) to plot (array-like or list of ints)
  • which_data_ycols (array-like) – which columns of y to plot (array-like or list of ints)
  • levels (int) – the number of levels in the density (number bigger then 1, where 35 is smooth and 1 is the same as plot_confidence). You can go higher then 50 if the result is not smooth enough for you.
  • predict_kw (dict) – the keyword arguments for the prediction. If you want to plot a specific kernel give dict(kern=<specific kernel>) in here
plot_f(self, plot_limits=None, fixed_inputs=None, resolution=None, apply_link=False, which_data_ycols='all', which_data_rows='all', visible_dims=None, levels=20, samples=0, lower=2.5, upper=97.5, plot_density=False, plot_data=True, plot_inducing=True, projection='2d', legend=True, predict_kw=None, **kwargs)[source]

Convinience function for plotting the fit of a GP. This is the same as plot, except it plots the latent function fit of the GP!

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.

Parameters:
  • plot_limits (np.array) – The limits of the plot. If 1D [xmin,xmax], if 2D [[xmin,ymin],[xmax,ymax]]. Defaluts to data limits
  • fixed_inputs (a list of tuples) – a list of tuple [(i,v), (i,v)...], specifying that input dimension i should be set to value v.
  • resolution (int) – The resolution of the prediction [default:200]
  • apply_link (bool) – whether to apply the link function of the GP to the raw prediction.
  • which_data_ycols ('all' or a list of integers) – when the data has several columns (independant outputs), only plot these
  • which_data_rows ('all' or a slice object to slice self.X, self.Y) – which of the training data to plot (default all)
  • visible_dims (array-like) – an array specifying the input dimensions to plot (maximum two)
  • levels (int) – the number of levels in the density (number bigger then 1, where 35 is smooth and 1 is the same as plot_confidence). You can go higher then 50 if the result is not smooth enough for you.
  • samples (int) – the number of samples to draw from the GP and plot into the plot. This will allways be samples from the latent function.
  • lower (float) – the lower percentile to plot
  • upper (float) – the upper percentile to plot
  • plot_data (bool) – plot the data into the plot?
  • plot_inducing (bool) – plot inducing inputs?
  • plot_density (bool) – plot density instead of the confidence interval?
  • predict_kw (dict) – the keyword arguments for the prediction. If you want to plot a specific kernel give dict(kern=<specific kernel>) in here
  • error_kwargs (dict) – kwargs for the error plot for the plotting library you are using
  • plot_kwargs (kwargs) – kwargs for the data plot for the plotting library you are using
plot_mean(self, plot_limits=None, fixed_inputs=None, resolution=None, plot_raw=False, apply_link=False, visible_dims=None, which_data_ycols='all', levels=20, projection='2d', label='gp mean', predict_kw=None, **kwargs)[source]

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.

Parameters:
  • plot_limits (np.array) – The limits of the plot. If 1D [xmin,xmax], if 2D [[xmin,ymin],[xmax,ymax]]. Defaluts to data limits
  • fixed_inputs (a list of tuples) – a list of tuple [(i,v), (i,v)...], specifying that input dimension i should be set to value v.
  • resolution (int) – The resolution of the prediction [defaults are 1D:200, 2D:50]
  • plot_raw (bool) – plot the latent function (usually denoted f) only?
  • apply_link (bool) – whether to apply the link function of the GP to the raw prediction.
  • which_data_ycols (array-like) – which columns of y to plot (array-like or list of ints)
  • levels (int) – for 2D plotting, the number of contour levels to use is
  • projection ({'2d','3d'}) – whether to plot in 2d or 3d. This only applies when plotting two dimensional inputs!
  • label (str) – the label for the plot.
  • predict_kw (dict) – the keyword arguments for the prediction. If you want to plot a specific kernel give dict(kern=<specific kernel>) in here
plot_samples(self, plot_limits=None, fixed_inputs=None, resolution=None, plot_raw=True, apply_link=False, visible_dims=None, which_data_ycols='all', samples=3, projection='2d', label='gp_samples', predict_kw=None, **kwargs)[source]

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.

Parameters:
  • plot_limits (np.array) – The limits of the plot. If 1D [xmin,xmax], if 2D [[xmin,ymin],[xmax,ymax]]. Defaluts to data limits
  • fixed_inputs (a list of tuples) – a list of tuple [(i,v), (i,v)...], specifying that input dimension i should be set to value v.
  • resolution (int) – The resolution of the prediction [defaults are 1D:200, 2D:50]
  • plot_raw (bool) – plot the latent function (usually denoted f) only? This is usually what you want!
  • apply_link (bool) – whether to apply the link function of the GP to the raw prediction.
  • visible_dims (array-like) – which columns of the input X (!) to plot (array-like or list of ints)
  • which_data_ycols (array-like) – which columns of y to plot (array-like or list of ints)
  • predict_kw (dict) – the keyword arguments for the prediction. If you want to plot a specific kernel give dict(kern=<specific kernel>) in here
  • levels (int) – for 2D plotting, the number of contour levels to use is

GPy.plotting.gpy_plot.inference_plots module

plot_optimizer(optimizer, **kwargs)[source]
plot_sgd_traces(optimizer)[source]

GPy.plotting.gpy_plot.kernel_plots module

plot_ARD(kernel, filtering=None, legend=False, canvas=None, **kwargs)[source]

If an ARD kernel is present, plot a bar representation using matplotlib

Parameters:
  • fignum – figure number of the plot
  • filtering (list of names to use for ARD plot) – list of names, which to use for plotting ARD parameters. Only kernels which match names in the list of names in filtering will be used for plotting.
plot_covariance(kernel, x=None, label=None, plot_limits=None, visible_dims=None, resolution=None, projection='2d', levels=20, **kwargs)[source]

Plot a kernel covariance w.r.t. another x.

Parameters:
  • x (array-like) – the value to use for the other kernel argument (kernels are a function of two variables!)
  • plot_limits (Either (xmin, xmax) for 1D or (xmin, xmax, ymin, ymax) / ((xmin, xmax), (ymin, ymax)) for 2D) – the range over which to plot the kernel
  • visible_dims (array-like) – input dimensions (!) to use for x. Make sure to select 2 or less dimensions to plot.
  • projection ({2d|3d}) – What projection shall we use to plot the kernel?
  • levels (int) – for 2D projection, how many levels for the contour plot to use?
  • kwargs – valid kwargs for your specific plotting library
Resolution:

the resolution of the lines used in plotting. for 2D this defines the grid for kernel evaluation.

GPy.plotting.gpy_plot.latent_plots module

plot_latent(self, labels=None, which_indices=None, resolution=60, legend=True, plot_limits=None, updates=False, kern=None, marker='<>^vsd', num_samples=1000, projection='2d', scatter_kwargs=None, **imshow_kwargs)[source]

Plot the latent space of the GP on the inputs. This is the density of the GP posterior as a grey scale and the scatter plot of the input dimemsions selected by which_indices.

Parameters:
  • labels (array-like) – a label for each data point (row) of the inputs
  • int) which_indices ((int,) – which input dimensions to plot against each other
  • resolution (int) – the resolution at which we predict the magnification factor
  • legend (bool) – whether to plot the legend on the figure
  • plot_limits ((xmin, xmax, ymin, ymax) or ((xmin, xmax), (ymin, ymax))) – the plot limits for the plot
  • updates (bool) – if possible, make interactive updates using the specific library you are using

:param Kern kern: the kernel to use for prediction :param str marker: markers to use - cycle if more labels then markers are given :param int num_samples: the number of samples to plot maximally. We do a stratified subsample from the labels, if the number of samples (in X) is higher then num_samples. :param imshow_kwargs: the kwargs for the imshow (magnification factor) :param scatter_kwargs: the kwargs for the scatter plots

plot_latent_inducing(self, which_indices=None, legend=False, plot_limits=None, marker=None, projection='2d', **kwargs)[source]

Plot a scatter plot of the inducing inputs.

Parameters:
  • which_indices ([int]) – which input dimensions to plot against each other
  • legend (bool) – whether to plot the legend on the figure
  • plot_limits ((xmin, xmax, ymin, ymax) or ((xmin, xmax), (ymin, ymax))) – the plot limits for the plot
  • marker (str) – marker to use [default is custom arrow like]
  • kwargs – the kwargs for the scatter plots
  • projection (str) – for now 2d or 3d projection (other projections can be implemented, see developer documentation)
plot_latent_scatter(self, labels=None, which_indices=None, legend=True, plot_limits=None, marker='<>^vsd', num_samples=1000, projection='2d', **kwargs)[source]

Plot a scatter plot of the latent space.

Parameters:
  • labels (array-like) – a label for each data point (row) of the inputs
  • int) which_indices ((int,) – which input dimensions to plot against each other
  • legend (bool) – whether to plot the legend on the figure
  • plot_limits ((xmin, xmax, ymin, ymax) or ((xmin, xmax), (ymin, ymax))) – the plot limits for the plot
  • marker (str) – markers to use - cycle if more labels then markers are given
  • kwargs – the kwargs for the scatter plots
plot_magnification(self, labels=None, which_indices=None, resolution=60, marker='<>^vsd', legend=True, plot_limits=None, updates=False, mean=True, covariance=True, kern=None, num_samples=1000, scatter_kwargs=None, plot_scatter=True, **imshow_kwargs)[source]

Plot the magnification factor of the GP on the inputs. This is the density of the GP as a gray scale.

Parameters:
  • labels (array-like) – a label for each data point (row) of the inputs
  • int) which_indices ((int,) – which input dimensions to plot against each other
  • resolution (int) – the resolution at which we predict the magnification factor
  • marker (str) – markers to use - cycle if more labels then markers are given
  • legend (bool) – whether to plot the legend on the figure
  • plot_limits ((xmin, xmax, ymin, ymax) or ((xmin, xmax), (ymin, ymax))) – the plot limits for the plot
  • updates (bool) – if possible, make interactive updates using the specific library you are using
  • mean (bool) – use the mean of the Wishart embedding for the magnification factor
  • covariance (bool) – use the covariance of the Wishart embedding for the magnification factor

:param Kern kern: the kernel to use for prediction :param int num_samples: the number of samples to plot maximally. We do a stratified subsample from the labels, if the number of samples (in X) is higher then num_samples. :param imshow_kwargs: the kwargs for the imshow (magnification factor) :param kwargs: the kwargs for the scatter plots

plot_steepest_gradient_map(self, output_labels=None, data_labels=None, which_indices=None, resolution=15, legend=True, plot_limits=None, updates=False, kern=None, marker='<>^vsd', num_samples=1000, annotation_kwargs=None, scatter_kwargs=None, **imshow_kwargs)[source]

Plot the latent space of the GP on the inputs. This is the density of the GP posterior as a grey scale and the scatter plot of the input dimemsions selected by which_indices.

Parameters:
  • labels (array-like) – a label for each data point (row) of the inputs
  • int) which_indices ((int,) – which input dimensions to plot against each other
  • resolution (int) – the resolution at which we predict the magnification factor
  • legend (bool) – whether to plot the legend on the figure, if int plot legend columns on legend
  • plot_limits ((xmin, xmax, ymin, ymax) or ((xmin, xmax), (ymin, ymax))) – the plot limits for the plot
  • updates (bool) – if possible, make interactive updates using the specific library you are using

:param Kern kern: the kernel to use for prediction :param str marker: markers to use - cycle if more labels then markers are given :param int num_samples: the number of samples to plot maximally. We do a stratified subsample from the labels, if the number of samples (in X) is higher then num_samples. :param imshow_kwargs: the kwargs for the imshow (magnification factor) :param annotation_kwargs: the kwargs for the annotation plot :param scatter_kwargs: the kwargs for the scatter plots

GPy.plotting.gpy_plot.plot_util module

find_best_layout_for_subplots(num_subplots)[source]
get_fixed_dims(fixed_inputs)[source]

Work out the fixed dimensions from the fixed_inputs list of tuples.

get_free_dims(model, visible_dims, fixed_dims)[source]

work out what the inputs are for plotting (1D or 2D)

The visible dimensions are the dimensions, which are visible. the fixed_dims are the fixed dimensions for this.

The free_dims are then the visible dims without the fixed dims.

get_which_data_rows(model, which_data_rows)[source]

Helper to get the data rows to plot.

get_which_data_ycols(model, which_data_ycols)[source]

Helper to get the data columns to plot.

get_x_y_var(model)[source]

Either the the data from a model as X the inputs, X_variance the variance of the inputs ([default: None]) and Y the outputs

If (X, X_variance, Y) is given, this just returns.

Returns:(X, X_variance, Y)
helper_for_plot_data(self, X, plot_limits, visible_dims, fixed_inputs, resolution)[source]

Figure out the data, free_dims and create an Xgrid for the prediction.

This is only implemented for two dimensions for now!

helper_predict_with_model(self, Xgrid, plot_raw, apply_link, percentiles, which_data_ycols, predict_kw, samples=0)[source]

Make the right decisions for prediction with a model based on the standard arguments of plotting.

This is quite complex and will take a while to understand, so do not change anything in here lightly!!!

in_ipynb()[source]
scatter_label_generator(labels, X, visible_dims, marker=None)[source]
subsample_X(X, labels, num_samples=1000)[source]

Stratified subsampling if labels are given. This means due to rounding errors you might get a little differences between the num_samples and the returned subsampled X.

update_not_existing_kwargs(to_update, update_from)[source]

This function updates the keyword aguments from update_from in to_update, only if the keys are not set in to_update.

This is used for updated kwargs from the default dicts.

x_frame1D(X, plot_limits=None, resolution=None)[source]

Internal helper function for making plots, returns a set of input values to plot as well as lower and upper limits

x_frame2D(X, plot_limits=None, resolution=None)[source]

Internal helper function for making plots, returns a set of input values to plot as well as lower and upper limits

Module contents