From 680fd29ba4f42cba5e8878f719b1226b78e1568c Mon Sep 17 00:00:00 2001 From: bobturneruk Date: Thu, 2 Apr 2020 15:51:41 +0100 Subject: [PATCH] rst "markup" --- .../gp_kronecker_gaussian_regression.py | 13 +++---- GPy/models/gp_multiout_regression.py | 7 ++-- GPy/models/gp_multiout_regression_md.py | 8 +++-- GPy/models/gp_var_gauss.py | 10 ++---- GPy/models/gradient_checker.py | 34 ++++++++++--------- GPy/plotting/gpy_plot/latent_plots.py | 21 ++++++++---- 6 files changed, 51 insertions(+), 42 deletions(-) diff --git a/GPy/models/gp_kronecker_gaussian_regression.py b/GPy/models/gp_kronecker_gaussian_regression.py index 44177b16..a8addf73 100644 --- a/GPy/models/gp_kronecker_gaussian_regression.py +++ b/GPy/models/gp_kronecker_gaussian_regression.py @@ -18,14 +18,11 @@ class GPKroneckerGaussianRegression(Model): The noise must be iid Gaussian. - See Stegle et al. - @inproceedings{stegle2011efficient, - title={Efficient inference in matrix-variate gaussian models with $\\backslash$ iid observation noise}, - author={Stegle, Oliver and Lippert, Christoph and Mooij, Joris M and Lawrence, Neil D and Borgwardt, Karsten M}, - booktitle={Advances in Neural Information Processing Systems}, - pages={630--638}, - year={2011} - } + See [stegle_et_al_2011]_. + + .. rubric:: References + + .. [stegle_et_al_2011] Stegle, O.; Lippert, C.; Mooij, J.M.; Lawrence, N.D.; Borgwardt, K.:Efficient inference in matrix-variate Gaussian models with \iid observation noise. In: Advances in Neural Information Processing Systems, 2011, Pages 630-638 """ def __init__(self, X1, X2, Y, kern1, kern2, noise_var=1., name='KGPR'): diff --git a/GPy/models/gp_multiout_regression.py b/GPy/models/gp_multiout_regression.py index ede6095e..816fc0d7 100644 --- a/GPy/models/gp_multiout_regression.py +++ b/GPy/models/gp_multiout_regression.py @@ -15,9 +15,11 @@ class GPMultioutRegression(SparseGP): """ Gaussian Process model for multi-output regression without missing data - This is an implementation of Latent Variable Multiple Output Gaussian Processes (LVMOGP) in [Dai et al. 2017]. + This is an implementation of Latent Variable Multiple Output Gaussian Processes (LVMOGP) in [Dai_et_al_2017]_. - Zhenwen Dai, Mauricio A. Alvarez and Neil D. Lawrence. Efficient Modeling of Latent Information in Supervised Learning using Gaussian Processes. In NIPS, 2017. + .. rubric:: References + + .. [Dai_et_al_2017] Dai, Z.; Alvarez, M.A.; Lawrence, N.D: Efficient Modeling of Latent Information in Supervised Learning using Gaussian Processes. In NIPS, 2017. :param X: input observations. :type X: numpy.ndarray @@ -42,6 +44,7 @@ class GPMultioutRegression(SparseGP): :param int qU_var_c_W_dim: the dimensionality of the covariance of q(U) for the GP regression. If it is smaller than the number of inducing points, it represents a low-rank parameterization of the covariance matrix. :param str init: the choice of initialization: 'GP' or 'rand'. With 'rand', the model is initialized randomly. With 'GP', the model is initialized through a protocol as follows: (1) fits a sparse GP (2) fits a BGPLVM based on the outcome of sparse GP (3) initialize the model based on the outcome of the BGPLVM. :param str name: the name of the model + """ def __init__(self, X, Y, Xr_dim, kernel=None, kernel_row=None, Z=None, Z_row=None, X_row=None, Xvariance_row=None, num_inducing=(10,10), qU_var_r_W_dim=None, qU_var_c_W_dim=None, init='GP', name='GPMR'): diff --git a/GPy/models/gp_multiout_regression_md.py b/GPy/models/gp_multiout_regression_md.py index 36d24c48..3eb91114 100644 --- a/GPy/models/gp_multiout_regression_md.py +++ b/GPy/models/gp_multiout_regression_md.py @@ -16,9 +16,11 @@ class GPMultioutRegressionMD(SparseGP): """ Gaussian Process model for multi-output regression with missing data - This is an implementation of Latent Variable Multiple Output Gaussian Processes (LVMOGP) in [Dai et al. 2017]. This model targets at the use case, in which each output dimension is observed at a different set of inputs. The model takes a different data format: the inputs and outputs observations of all the output dimensions are stacked together correspondingly into two matrices. An extra array is used to indicate the index of output dimension for each data point. The output dimensions are indexed using integers from 0 to D-1 assuming there are D output dimensions. + This is an implementation of Latent Variable Multiple Output Gaussian Processes (LVMOGP) in [Dai_et_al_2017]_. This model targets at the use case, in which each output dimension is observed at a different set of inputs. The model takes a different data format: the inputs and outputs observations of all the output dimensions are stacked together correspondingly into two matrices. An extra array is used to indicate the index of output dimension for each data point. The output dimensions are indexed using integers from 0 to D-1 assuming there are D output dimensions. - Zhenwen Dai, Mauricio A. Alvarez and Neil D. Lawrence. Efficient Modeling of Latent Information in Supervised Learning using Gaussian Processes. In NIPS, 2017. + .. rubric:: References + + .. [Dai_et_al_2017] Dai, Z.; Alvarez, M.A.; Lawrence, N.D: Efficient Modeling of Latent Information in Supervised Learning using Gaussian Processes. In NIPS, 2017. :param X: input observations. :type X: numpy.ndarray @@ -46,6 +48,8 @@ class GPMultioutRegressionMD(SparseGP): :param str init: the choice of initialization: 'GP' or 'rand'. With 'rand', the model is initialized randomly. With 'GP', the model is initialized through a protocol as follows: (1) fits a sparse GP (2) fits a BGPLVM based on the outcome of sparse GP (3) initialize the model based on the outcome of the BGPLVM. :param boolean heter_noise: whether assuming heteroscedastic noise in the model, boolean :param str name: the name of the model + + """ def __init__(self, X, Y, indexD, Xr_dim, kernel=None, kernel_row=None, Z=None, Z_row=None, X_row=None, Xvariance_row=None, num_inducing=(10,10), qU_var_r_W_dim=None, qU_var_c_W_dim=None, init='GP', heter_noise=False, name='GPMRMD'): diff --git a/GPy/models/gp_var_gauss.py b/GPy/models/gp_var_gauss.py index 4c8fa7ef..6a61b604 100644 --- a/GPy/models/gp_var_gauss.py +++ b/GPy/models/gp_var_gauss.py @@ -13,13 +13,9 @@ class GPVariationalGaussianApproximation(GP): """ The Variational Gaussian Approximation revisited - @article{Opper:2009, - title = {The Variational Gaussian Approximation Revisited}, - author = {Opper, Manfred and Archambeau, C{\'e}dric}, - journal = {Neural Comput.}, - year = {2009}, - pages = {786--792}, - } + .. rubric:: References + + .. [opper_archambeau_2009] Opper, M.; Archambeau, C.; The Variational Gaussian Approximation Revisited. Neural Comput. 2009, pages 786-792. """ def __init__(self, X, Y, kernel, likelihood, Y_metadata=None): diff --git a/GPy/models/gradient_checker.py b/GPy/models/gradient_checker.py index f7c17376..904b88c6 100644 --- a/GPy/models/gradient_checker.py +++ b/GPy/models/gradient_checker.py @@ -39,28 +39,30 @@ class GradientChecker(Model): a list of names with the same length is expected. :param args: Arguments passed as f(x, *args, **kwargs) and df(x, *args, **kwargs) - Examples: - --------- + .. rubric:: Examples + + Initialisation:: + from GPy.models import GradientChecker N, M, Q = 10, 5, 3 - Sinusoid: + Sinusoid:: - X = numpy.random.rand(N, Q) - grad = GradientChecker(numpy.sin,numpy.cos,X,'x') - grad.checkgrad(verbose=1) + X = numpy.random.rand(N, Q) + grad = GradientChecker(numpy.sin,numpy.cos,X,'x') + grad.checkgrad(verbose=1) - Using GPy: + Using GPy:: - X, Z = numpy.random.randn(N,Q), numpy.random.randn(M,Q) - kern = GPy.kern.linear(Q, ARD=True) + GPy.kern.rbf(Q, ARD=True) - grad = GradientChecker(kern.K, - lambda x: 2*kern.dK_dX(numpy.ones((1,1)), x), - x0 = X.copy(), - names='X') - grad.checkgrad(verbose=1) - grad.randomize() - grad.checkgrad(verbose=1) + X, Z = numpy.random.randn(N,Q), numpy.random.randn(M,Q) + kern = GPy.kern.linear(Q, ARD=True) + GPy.kern.rbf(Q, ARD=True) + grad = GradientChecker(kern.K, + lambda x: 2*kern.dK_dX(numpy.ones((1,1)), x), + x0 = X.copy(), + names='X') + grad.checkgrad(verbose=1) + grad.randomize() + grad.checkgrad(verbose=1) """ super(GradientChecker, self).__init__(name='GradientChecker') if isinstance(x0, (list, tuple)) and names is None: diff --git a/GPy/plotting/gpy_plot/latent_plots.py b/GPy/plotting/gpy_plot/latent_plots.py index f76fda1c..a749f0c1 100644 --- a/GPy/plotting/gpy_plot/latent_plots.py +++ b/GPy/plotting/gpy_plot/latent_plots.py @@ -89,7 +89,8 @@ def plot_latent_scatter(self, labels=None, Plot a scatter plot of the latent space. :param array-like labels: a label for each data point (row) of the inputs - :param (int, int) which_indices: which input dimensions to plot against each other + :param which_indices: which input dimensions to plot against each other + :type which_indices: (int, int) :param bool legend: whether to plot the legend on the figure :param plot_limits: the plot limits for the plot :type plot_limits: (xmin, xmax, ymin, ymax) or ((xmin, xmax), (ymin, ymax)) @@ -174,7 +175,8 @@ def plot_magnification(self, labels=None, which_indices=None, density of the GP as a gray scale. :param array-like labels: a label for each data point (row) of the inputs - :param (int, int) which_indices: which input dimensions to plot against each other + :param which_indices: which input dimensions to plot against each other + :type which_indices: (int, int) :param int resolution: the resolution at which we predict the magnification factor :param str marker: markers to use - cycle if more labels then markers are given :param bool legend: whether to plot the legend on the figure @@ -183,7 +185,8 @@ def plot_magnification(self, labels=None, which_indices=None, :param bool updates: if possible, make interactive updates using the specific library you are using :param bool mean: use the mean of the Wishart embedding for the magnification factor :param bool covariance: use the covariance of the Wishart embedding for the magnification factor - :param :py:class:`~GPy.kern.Kern` kern: the kernel to use for prediction + :param kern: the kernel to use for prediction + :type kern: :py:class:`~GPy.kern.Kern` :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 @@ -248,13 +251,15 @@ def plot_latent(self, labels=None, which_indices=None, scatter plot of the input dimemsions selected by which_indices. :param array-like labels: a label for each data point (row) of the inputs - :param (int, int) which_indices: which input dimensions to plot against each other + :param which_indices: which input dimensions to plot against each other + :type which_indices: (int, int) :param int resolution: the resolution at which we predict the magnification factor :param bool legend: whether to plot the legend on the figure :param plot_limits: the plot limits for the plot :type plot_limits: (xmin, xmax, ymin, ymax) or ((xmin, xmax), (ymin, ymax)) :param bool updates: if possible, make interactive updates using the specific library you are using - :param :py:class:`~GPy.kern.Kern` kern: the kernel to use for prediction + :param kern: the kernel to use for prediction + :type kern: :py:class:`~GPy.kern.Kern` :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) @@ -316,13 +321,15 @@ def plot_steepest_gradient_map(self, output_labels=None, data_labels=None, which scatter plot of the input dimemsions selected by which_indices. :param array-like labels: a label for each data point (row) of the inputs - :param (int, int) which_indices: which input dimensions to plot against each other + :param which_indices: which input dimensions to plot against each other + :type which_indices: (int, int) :param int resolution: the resolution at which we predict the magnification factor :param bool legend: whether to plot the legend on the figure, if int plot legend columns on legend :param plot_limits: the plot limits for the plot :type plot_limits: (xmin, xmax, ymin, ymax) or ((xmin, xmax), (ymin, ymax)) :param bool updates: if possible, make interactive updates using the specific library you are using - :param :py:class:`~GPy.kern.Kern` kern: the kernel to use for prediction + :param kern: the kernel to use for prediction + :type kern: :py:class:`~GPy.kern.Kern` :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)