diff --git a/GPy/core/gp.py b/GPy/core/gp.py index 977882ac..1e2e3611 100644 --- a/GPy/core/gp.py +++ b/GPy/core/gp.py @@ -578,7 +578,7 @@ class GP(Model): mag[n] = np.sqrt(np.linalg.det(G[n, :, :])) return mag - def posterior_samples_f(self,X, size=10, **predict_kwargs): + def posterior_samples_f(self,X, size=10, **predict_kwargs): """ Samples the posterior GP at the points X. @@ -589,7 +589,8 @@ class GP(Model): :returns: set of simulations :rtype: np.ndarray (Nnew x D x samples) """ - m, v = self._raw_predict(X, full_cov=True, **predict_kwargs) + predict_kwargs["full_cov"] = True # Always use the full covariance for posterior samples. + m, v = self._raw_predict(X, **predict_kwargs) if self.normalizer is not None: m, v = self.normalizer.inverse_mean(m), self.normalizer.inverse_variance(v) diff --git a/GPy/plotting/gpy_plot/gp_plots.py b/GPy/plotting/gpy_plot/gp_plots.py index a12fc858..202ccfe7 100644 --- a/GPy/plotting/gpy_plot/gp_plots.py +++ b/GPy/plotting/gpy_plot/gp_plots.py @@ -208,10 +208,10 @@ 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 - plots = [pl().plot(canvas, Xgrid[:, free_dims], samples[:, s], label=label if s==0 else None, **kwargs) for s in range(samples.shape[-1])] + 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 - plots = [pl().surface(canvas, x, y, samples[:, s].reshape(resolution, resolution), **kwargs) for s in range(samples.shape[-1])] + 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) diff --git a/GPy/plotting/gpy_plot/plot_util.py b/GPy/plotting/gpy_plot/plot_util.py index 7bd1723f..96a1db42 100644 --- a/GPy/plotting/gpy_plot/plot_util.py +++ b/GPy/plotting/gpy_plot/plot_util.py @@ -81,8 +81,8 @@ def helper_predict_with_model(self, Xgrid, plot_raw, apply_link, percentiles, wh else: percentiles = [] if samples > 0: - fsamples = self.posterior_samples(Xgrid, full_cov=True, size=samples, **predict_kw) - fsamples = fsamples[which_data_ycols] if fsamples.ndim == 3 else fsamples + fsamples = self.posterior_samples(Xgrid, size=samples, **predict_kw) + fsamples = fsamples[:, which_data_ycols, :] else: fsamples = None @@ -95,12 +95,9 @@ def helper_predict_with_model(self, Xgrid, plot_raw, apply_link, percentiles, wh retmu[:, [i]] = self.likelihood.gp_link.transf(mu[:, [i]]) for perc in percs: perc[:, [i]] = self.likelihood.gp_link.transf(perc[:, [i]]) - if fsamples is not None and fsamples.ndim == 3: + if fsamples is not None: for s in range(fsamples.shape[-1]): - fsamples[i, :, s] = self.likelihood.gp_link.transf(fsamples[i, :, s]) - elif fsamples is not None: - for s in range(fsamples.shape[-1]): - fsamples[:, s] = self.likelihood.gp_link.transf(fsamples[:, s]) + fsamples[:, i, s] = self.likelihood.gp_link.transf(fsamples[:, i, s]) return retmu, percs, fsamples def helper_for_plot_data(self, X, plot_limits, visible_dims, fixed_inputs, resolution): diff --git a/GPy/testing/baseline/bayesian_gplvm_gradient.npz b/GPy/testing/baseline/bayesian_gplvm_gradient.npz index 37c46b7a..1aca64d4 100644 Binary files a/GPy/testing/baseline/bayesian_gplvm_gradient.npz and b/GPy/testing/baseline/bayesian_gplvm_gradient.npz differ diff --git a/GPy/testing/baseline/bayesian_gplvm_inducing.npz b/GPy/testing/baseline/bayesian_gplvm_inducing.npz index 7ac5c1c9..01030a19 100644 Binary files a/GPy/testing/baseline/bayesian_gplvm_inducing.npz and b/GPy/testing/baseline/bayesian_gplvm_inducing.npz differ diff --git a/GPy/testing/baseline/bayesian_gplvm_inducing_3d.npz b/GPy/testing/baseline/bayesian_gplvm_inducing_3d.npz index d5a3b391..cdd06e7a 100644 Binary files a/GPy/testing/baseline/bayesian_gplvm_inducing_3d.npz and b/GPy/testing/baseline/bayesian_gplvm_inducing_3d.npz differ diff --git a/GPy/testing/baseline/bayesian_gplvm_latent.npz b/GPy/testing/baseline/bayesian_gplvm_latent.npz index 710ab07e..2e19707c 100644 Binary files a/GPy/testing/baseline/bayesian_gplvm_latent.npz and b/GPy/testing/baseline/bayesian_gplvm_latent.npz differ diff --git a/GPy/testing/baseline/bayesian_gplvm_latent_3d.npz b/GPy/testing/baseline/bayesian_gplvm_latent_3d.npz index 0d50befe..3424eeb1 100644 Binary files a/GPy/testing/baseline/bayesian_gplvm_latent_3d.npz and b/GPy/testing/baseline/bayesian_gplvm_latent_3d.npz differ diff --git a/GPy/testing/baseline/bayesian_gplvm_magnification.npz b/GPy/testing/baseline/bayesian_gplvm_magnification.npz index 411ab821..0aec4d87 100644 Binary files a/GPy/testing/baseline/bayesian_gplvm_magnification.npz and b/GPy/testing/baseline/bayesian_gplvm_magnification.npz differ diff --git a/GPy/testing/baseline/coverage_3d_plot.npz b/GPy/testing/baseline/coverage_3d_plot.npz index 4df41bde..99958e70 100644 Binary files a/GPy/testing/baseline/coverage_3d_plot.npz and b/GPy/testing/baseline/coverage_3d_plot.npz differ diff --git a/GPy/testing/baseline/coverage_annotation_interact.npz b/GPy/testing/baseline/coverage_annotation_interact.npz index ae102c5e..2f974bcd 100644 Binary files a/GPy/testing/baseline/coverage_annotation_interact.npz and b/GPy/testing/baseline/coverage_annotation_interact.npz differ diff --git a/GPy/testing/baseline/coverage_gradient.npz b/GPy/testing/baseline/coverage_gradient.npz index 54d289e8..b30ed37e 100644 Binary files a/GPy/testing/baseline/coverage_gradient.npz and b/GPy/testing/baseline/coverage_gradient.npz differ diff --git a/GPy/testing/baseline/coverage_imshow_interact.npz b/GPy/testing/baseline/coverage_imshow_interact.npz index b270db72..b9e01e67 100644 Binary files a/GPy/testing/baseline/coverage_imshow_interact.npz and b/GPy/testing/baseline/coverage_imshow_interact.npz differ diff --git a/GPy/testing/baseline/gp_2d_data.npz b/GPy/testing/baseline/gp_2d_data.npz index 6cfde842..2d88e6dc 100644 Binary files a/GPy/testing/baseline/gp_2d_data.npz and b/GPy/testing/baseline/gp_2d_data.npz differ diff --git a/GPy/testing/baseline/gp_2d_in_error.npz b/GPy/testing/baseline/gp_2d_in_error.npz index 3bbfc02f..fb13ff42 100644 Binary files a/GPy/testing/baseline/gp_2d_in_error.npz and b/GPy/testing/baseline/gp_2d_in_error.npz differ diff --git a/GPy/testing/baseline/gp_2d_inducing.npz b/GPy/testing/baseline/gp_2d_inducing.npz index 931e2cd4..9943cbff 100644 Binary files a/GPy/testing/baseline/gp_2d_inducing.npz and b/GPy/testing/baseline/gp_2d_inducing.npz differ diff --git a/GPy/testing/baseline/gp_2d_mean.npz b/GPy/testing/baseline/gp_2d_mean.npz index f4619bfd..86a72f61 100644 Binary files a/GPy/testing/baseline/gp_2d_mean.npz and b/GPy/testing/baseline/gp_2d_mean.npz differ diff --git a/GPy/testing/baseline/gp_3d_data.npz b/GPy/testing/baseline/gp_3d_data.npz index eae953dd..0c6e7bed 100644 Binary files a/GPy/testing/baseline/gp_3d_data.npz and b/GPy/testing/baseline/gp_3d_data.npz differ diff --git a/GPy/testing/baseline/gp_3d_inducing.npz b/GPy/testing/baseline/gp_3d_inducing.npz index c0bd33b7..082062d3 100644 Binary files a/GPy/testing/baseline/gp_3d_inducing.npz and b/GPy/testing/baseline/gp_3d_inducing.npz differ diff --git a/GPy/testing/baseline/gp_3d_mean.npz b/GPy/testing/baseline/gp_3d_mean.npz index 09a35cd0..abc4a951 100644 Binary files a/GPy/testing/baseline/gp_3d_mean.npz and b/GPy/testing/baseline/gp_3d_mean.npz differ diff --git a/GPy/testing/baseline/gp_class_likelihood.npz b/GPy/testing/baseline/gp_class_likelihood.npz index 40c95423..779ec008 100644 Binary files a/GPy/testing/baseline/gp_class_likelihood.npz and b/GPy/testing/baseline/gp_class_likelihood.npz differ diff --git a/GPy/testing/baseline/gp_class_raw.npz b/GPy/testing/baseline/gp_class_raw.npz index 207196bd..e85c9103 100644 Binary files a/GPy/testing/baseline/gp_class_raw.npz and b/GPy/testing/baseline/gp_class_raw.npz differ diff --git a/GPy/testing/baseline/gp_class_raw_link.npz b/GPy/testing/baseline/gp_class_raw_link.npz index 5ff15ea2..c4e876fe 100644 Binary files a/GPy/testing/baseline/gp_class_raw_link.npz and b/GPy/testing/baseline/gp_class_raw_link.npz differ diff --git a/GPy/testing/baseline/gp_conf.npz b/GPy/testing/baseline/gp_conf.npz index 801d4c1c..3c6a0fb9 100644 Binary files a/GPy/testing/baseline/gp_conf.npz and b/GPy/testing/baseline/gp_conf.npz differ diff --git a/GPy/testing/baseline/gp_data.npz b/GPy/testing/baseline/gp_data.npz index d25fa6cf..31874b2d 100644 Binary files a/GPy/testing/baseline/gp_data.npz and b/GPy/testing/baseline/gp_data.npz differ diff --git a/GPy/testing/baseline/gp_density.npz b/GPy/testing/baseline/gp_density.npz index e3fed380..0b14196c 100644 Binary files a/GPy/testing/baseline/gp_density.npz and b/GPy/testing/baseline/gp_density.npz differ diff --git a/GPy/testing/baseline/gp_in_error.npz b/GPy/testing/baseline/gp_in_error.npz index 971372ad..e96bee82 100644 Binary files a/GPy/testing/baseline/gp_in_error.npz and b/GPy/testing/baseline/gp_in_error.npz differ diff --git a/GPy/testing/baseline/gp_mean.npz b/GPy/testing/baseline/gp_mean.npz index 34553aa2..38d3b32f 100644 Binary files a/GPy/testing/baseline/gp_mean.npz and b/GPy/testing/baseline/gp_mean.npz differ diff --git a/GPy/testing/baseline/gp_out_error.npz b/GPy/testing/baseline/gp_out_error.npz index 1f7d9a9d..0bc63d5f 100644 Binary files a/GPy/testing/baseline/gp_out_error.npz and b/GPy/testing/baseline/gp_out_error.npz differ diff --git a/GPy/testing/baseline/gp_samples.npz b/GPy/testing/baseline/gp_samples.npz index 36668c74..f47b14f8 100644 Binary files a/GPy/testing/baseline/gp_samples.npz and b/GPy/testing/baseline/gp_samples.npz differ diff --git a/GPy/testing/baseline/gplvm_gradient.npz b/GPy/testing/baseline/gplvm_gradient.npz index affb3339..8e7fce34 100644 Binary files a/GPy/testing/baseline/gplvm_gradient.npz and b/GPy/testing/baseline/gplvm_gradient.npz differ diff --git a/GPy/testing/baseline/gplvm_latent.npz b/GPy/testing/baseline/gplvm_latent.npz index 2ce41632..ebf171e2 100644 Binary files a/GPy/testing/baseline/gplvm_latent.npz and b/GPy/testing/baseline/gplvm_latent.npz differ diff --git a/GPy/testing/baseline/gplvm_latent_3d.npz b/GPy/testing/baseline/gplvm_latent_3d.npz index e772b631..2ad0dfc2 100644 Binary files a/GPy/testing/baseline/gplvm_latent_3d.npz and b/GPy/testing/baseline/gplvm_latent_3d.npz differ diff --git a/GPy/testing/baseline/gplvm_magnification.npz b/GPy/testing/baseline/gplvm_magnification.npz index 9909c5d5..0d1ac512 100644 Binary files a/GPy/testing/baseline/gplvm_magnification.npz and b/GPy/testing/baseline/gplvm_magnification.npz differ diff --git a/GPy/testing/baseline/kern_ARD.npz b/GPy/testing/baseline/kern_ARD.npz index c2bed84e..23878762 100644 Binary files a/GPy/testing/baseline/kern_ARD.npz and b/GPy/testing/baseline/kern_ARD.npz differ diff --git a/GPy/testing/baseline/kern_cov_1d.npz b/GPy/testing/baseline/kern_cov_1d.npz index be277cb3..9a3ae27f 100644 Binary files a/GPy/testing/baseline/kern_cov_1d.npz and b/GPy/testing/baseline/kern_cov_1d.npz differ diff --git a/GPy/testing/baseline/kern_cov_2d.npz b/GPy/testing/baseline/kern_cov_2d.npz index 12697c91..51ee481c 100644 Binary files a/GPy/testing/baseline/kern_cov_2d.npz and b/GPy/testing/baseline/kern_cov_2d.npz differ diff --git a/GPy/testing/baseline/kern_cov_3d.npz b/GPy/testing/baseline/kern_cov_3d.npz index e07a8154..a631b730 100644 Binary files a/GPy/testing/baseline/kern_cov_3d.npz and b/GPy/testing/baseline/kern_cov_3d.npz differ diff --git a/GPy/testing/baseline/kern_cov_no_lim.npz b/GPy/testing/baseline/kern_cov_no_lim.npz index 5c9171ca..1f399330 100644 Binary files a/GPy/testing/baseline/kern_cov_no_lim.npz and b/GPy/testing/baseline/kern_cov_no_lim.npz differ diff --git a/GPy/testing/baseline/sparse_gp_class_likelihood.npz b/GPy/testing/baseline/sparse_gp_class_likelihood.npz index aab87332..9661f3bb 100644 Binary files a/GPy/testing/baseline/sparse_gp_class_likelihood.npz and b/GPy/testing/baseline/sparse_gp_class_likelihood.npz differ diff --git a/GPy/testing/baseline/sparse_gp_class_raw.npz b/GPy/testing/baseline/sparse_gp_class_raw.npz index 1a8d3dd2..1b730c35 100644 Binary files a/GPy/testing/baseline/sparse_gp_class_raw.npz and b/GPy/testing/baseline/sparse_gp_class_raw.npz differ diff --git a/GPy/testing/baseline/sparse_gp_class_raw_link.npz b/GPy/testing/baseline/sparse_gp_class_raw_link.npz index d0962d67..aa4ccda5 100644 Binary files a/GPy/testing/baseline/sparse_gp_class_raw_link.npz and b/GPy/testing/baseline/sparse_gp_class_raw_link.npz differ diff --git a/GPy/testing/baseline/sparse_gp_data_error.npz b/GPy/testing/baseline/sparse_gp_data_error.npz index e9574ce1..6e1430b8 100644 Binary files a/GPy/testing/baseline/sparse_gp_data_error.npz and b/GPy/testing/baseline/sparse_gp_data_error.npz differ diff --git a/GPy/testing/plotting_tests.py b/GPy/testing/plotting_tests.py index a80ccf48..b5ae0037 100644 --- a/GPy/testing/plotting_tests.py +++ b/GPy/testing/plotting_tests.py @@ -38,7 +38,7 @@ from nose import SkipTest try: import matplotlib - matplotlib.use('agg') + # matplotlib.use('agg') except ImportError: # matplotlib not installed from nose import SkipTest @@ -367,13 +367,13 @@ def test_classification(): m = GPy.models.GPClassification(X, Y>Y.mean()) #m.optimize() _, ax = plt.subplots() - m.plot(plot_raw=False, apply_link=False, ax=ax) + m.plot(plot_raw=False, apply_link=False, ax=ax, samples=3) m.plot_errorbars_trainset(plot_raw=False, apply_link=False, ax=ax) _, ax = plt.subplots() - m.plot(plot_raw=True, apply_link=False, ax=ax) + m.plot(plot_raw=True, apply_link=False, ax=ax, samples=3) m.plot_errorbars_trainset(plot_raw=True, apply_link=False, ax=ax) _, ax = plt.subplots() - m.plot(plot_raw=True, apply_link=True, ax=ax) + m.plot(plot_raw=True, apply_link=True, ax=ax, samples=3) m.plot_errorbars_trainset(plot_raw=True, apply_link=True, ax=ax) for do_test in _image_comparison(baseline_images=['gp_class_{}'.format(sub) for sub in ["likelihood", "raw", 'raw_link']], extensions=extensions): yield (do_test, ) diff --git a/appveyor.yml b/appveyor.yml index 2d1aca22..5a51d782 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -11,8 +11,8 @@ environment: MINICONDA: C:\Miniconda35-x64 - PYTHON_VERSION: 3.6 MINICONDA: C:\Miniconda36-x64 - - PYTHON_VERSION: 3.7 - MINICONDA: C:\Miniconda36-x64 +# - PYTHON_VERSION: 3.7 +# MINICONDA: C:\Miniconda36-x64 #configuration: # - Debug