diff --git a/.travis.yml b/.travis.yml index 9a738047..7897b009 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,6 +29,7 @@ install: - echo $PATH - source install_retry.sh - pip install codecov +- pip install coveralls - pip install pypandoc - pip install git+git://github.com/BRML/climin.git - pip install autograd @@ -40,6 +41,7 @@ script: after_success: - codecov + - coveralls before_deploy: - cd doc diff --git a/GPy/kern/src/kern.py b/GPy/kern/src/kern.py index 4379fb71..c6f62bd9 100644 --- a/GPy/kern/src/kern.py +++ b/GPy/kern/src/kern.py @@ -211,6 +211,12 @@ class Kern(Parameterized): def input_sensitivity(self, summarize=True): """ Returns the sensitivity for each dimension of this kernel. + + This is an arbitrary measurement based on the parameters + of the kernel per dimension and scaling in general. + + Use this as relative measurement, not for absolute comparison between + kernels. """ return np.zeros(self.input_dim) diff --git a/GPy/kern/src/prod.py b/GPy/kern/src/prod.py index 674365ba..ab3df431 100644 --- a/GPy/kern/src/prod.py +++ b/GPy/kern/src/prod.py @@ -99,7 +99,7 @@ class Prod(CombinationKernel): def input_sensitivity(self, summarize=True): if summarize: - i_s = np.zeros((self.input_dim)) + i_s = np.ones((self.input_dim)) for k in self.parts: i_s[k._all_dims_active] *= k.input_sensitivity(summarize) return i_s diff --git a/GPy/kern/src/stationary.py b/GPy/kern/src/stationary.py index 1ce8084f..b6b13d47 100644 --- a/GPy/kern/src/stationary.py +++ b/GPy/kern/src/stationary.py @@ -51,6 +51,10 @@ class Stationary(Kern): The lengthscale(s) and variance parameters are added to the structure automatically. + Thanks to @strongh: + In Stationary, a covariance function is defined in GPy as stationary when it depends only on the l2-norm |x_1 - x_2 |. + However this is the typical definition of isotropy, while stationarity is usually a bit more relaxed. + The more common version of stationarity is that the covariance is a function of x_1 - x_2 (See e.g. R&W first paragraph of section 4.1). """ def __init__(self, input_dim, variance, lengthscale, ARD, active_dims, name, useGPU=False): diff --git a/GPy/mappings/additive.py b/GPy/mappings/additive.py index 1c86b680..0fb72ca4 100644 --- a/GPy/mappings/additive.py +++ b/GPy/mappings/additive.py @@ -23,9 +23,10 @@ class Additive(Mapping): assert(mapping1.input_dim==mapping2.input_dim) assert(mapping1.output_dim==mapping2.output_dim) input_dim, output_dim = mapping1.input_dim, mapping1.output_dim - Mapping.__init__(self, input_dim=input_dim, output_dim=output_dim) + super(Additive, self).__init__(input_dim=input_dim, output_dim=output_dim) self.mapping1 = mapping1 self.mapping2 = mapping2 + self.link_parameters(self.mapping1, self.mapping2) def f(self, X): return self.mapping1.f(X) + self.mapping2.f(X) diff --git a/GPy/mappings/linear.py b/GPy/mappings/linear.py index c105dd81..26504830 100644 --- a/GPy/mappings/linear.py +++ b/GPy/mappings/linear.py @@ -33,7 +33,7 @@ class Linear(Mapping): return np.dot(X, self.A) def update_gradients(self, dL_dF, X): - self.A.gradient = np.dot( X.T, dL_dF) + self.A.gradient = np.dot(X.T, dL_dF) def gradients_X(self, dL_dF, X): return np.dot(dL_dF, self.A.T) diff --git a/GPy/testing/b-gplvm-save.npz b/GPy/testing/b-gplvm-save.npz new file mode 100644 index 00000000..bcbe84d7 Binary files /dev/null and b/GPy/testing/b-gplvm-save.npz differ diff --git a/GPy/testing/baseline/bayesian_gplvm_gradient.npz b/GPy/testing/baseline/bayesian_gplvm_gradient.npz index f3b56c49..b48db887 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 2ad1866a..82e44f54 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 02c89096..e55b4b01 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 3fba9c06..3e27bc64 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 a4f4edad..b4da4571 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 cd5ff303..dd83f22d 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 cdf55bc8..6372cb73 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 437ad498..16fd4e38 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 32eaf6c6..a55dd97b 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 78dd7755..55dd013c 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 773660eb..0c703f69 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 00ca4eca..beb00720 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 ce6404fc..2a249e27 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 238dc028..dd9ef64d 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 1f52eab4..e190118a 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 676a16e5..b6316363 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 1a5eed42..ae0a36ca 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 6db3e8ff..288b15ef 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 f49a775f..08bb56df 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 231adca7..01490f4c 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 d178b5c0..3eaf087e 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 fef7d0f5..2a4606df 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 9bf3d757..6a3235fa 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 eb693591..072fbc12 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 e47dad83..432b2c25 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 967e322d..4e86a06d 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 5f19e9c4..774a576b 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 14ca0cfd..fb6a1658 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 fcd07f97..fac4cca9 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 448362ae..2fe42704 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 7275a82a..fb84f382 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 77bedd3d..7735251e 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 285e2e6d..3bb0ac83 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 d65d1d65..78a5930b 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 b98bda42..a76f302f 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 aa4b9512..019db745 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 5aee4612..8d9f1731 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 7c9404c8..d6634501 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 9512e9e7..0d09f5ae 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 beaea488..d6396b8a 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/meanfunc_tests.py b/GPy/testing/meanfunc_tests.py index 815c024f..53482a7a 100644 --- a/GPy/testing/meanfunc_tests.py +++ b/GPy/testing/meanfunc_tests.py @@ -28,10 +28,49 @@ class MFtests(unittest.TestCase): A linear mean function with parameters that we'll learn alongside the kernel """ + X = np.linspace(-1,10,50).reshape(-1,1) + + Y = 3-np.abs((X-6)) + Y += .5*np.cos(3*X) + 0.3*np.random.randn(*X.shape) + + mf = GPy.mappings.PiecewiseLinear(1, 1, [-1,1], [9,2]) + + k =GPy.kern.RBF(1) + lik = GPy.likelihoods.Gaussian() + m = GPy.core.GP(X, Y, kernel=k, likelihood=lik, mean_function=mf) + self.assertTrue(m.checkgrad()) + + def test_parametric_mean_function_composition(self): + """ + A linear mean function with parameters that we'll learn alongside the kernel + """ + X = np.linspace(0,10,50).reshape(-1,1) Y = np.sin(X) + 0.5*np.cos(3*X) + 0.1*np.random.randn(*X.shape) + 3*X - mf = GPy.mappings.Linear(1,1) + mf = GPy.mappings.Compound(GPy.mappings.Linear(1,1), + GPy.mappings.Kernel(1, 1, np.random.normal(0,1,(1,1)), + GPy.kern.RBF(1)) + ) + + k =GPy.kern.RBF(1) + lik = GPy.likelihoods.Gaussian() + m = GPy.core.GP(X, Y, kernel=k, likelihood=lik, mean_function=mf) + self.assertTrue(m.checkgrad()) + + def test_parametric_mean_function_additive(self): + """ + A linear mean function with parameters that we'll learn alongside the kernel + """ + + X = np.linspace(0,10,50).reshape(-1,1) + Y = np.sin(X) + 0.5*np.cos(3*X) + 0.1*np.random.randn(*X.shape) + 3*X + + mf = GPy.mappings.Additive(GPy.mappings.Constant(1,1,3), + GPy.mappings.Additive(GPy.mappings.MLP(1,1), + GPy.mappings.Identity(1,1) + ) + ) k =GPy.kern.RBF(1) lik = GPy.likelihoods.Gaussian() diff --git a/GPy/testing/plotting_tests.py b/GPy/testing/plotting_tests.py index 4922a3ec..f115c801 100644 --- a/GPy/testing/plotting_tests.py +++ b/GPy/testing/plotting_tests.py @@ -74,12 +74,13 @@ except ImportError: extensions = ['npz'] +basedir = os.path.dirname(os.path.relpath(os.path.abspath(__file__))) + def _image_directories(): """ Compute the baseline and result image directories for testing *func*. Create the result directory if it doesn't exist. """ - basedir = os.path.dirname(os.path.relpath(os.path.abspath(__file__))) #module_name = __init__.__module__ #mods = module_name.split('.') #basedir = os.path.join(*mods) @@ -349,7 +350,9 @@ def test_sparse(): m = GPy.models.SparseGPRegression(X, Y, X_variance=np.ones_like(X)*0.1) #m.optimize() #m.plot_inducing() - m.plot_data() + _, ax = plt.subplots() + m.plot_data(ax=ax) + m.plot_data_error(ax=ax) for do_test in _image_comparison(baseline_images=['sparse_gp_{}'.format(sub) for sub in ['data_error']], extensions=extensions): yield (do_test, ) @@ -397,31 +400,39 @@ def test_sparse_classification(): yield (do_test, ) def test_gplvm(): - from ..examples.dimensionality_reduction import _simulate_matern - from ..kern import RBF - from ..models import GPLVM + from GPy.models import GPLVM np.random.seed(12345) matplotlib.rcParams.update(matplotlib.rcParamsDefault) #matplotlib.rcParams[u'figure.figsize'] = (4,3) matplotlib.rcParams[u'text.usetex'] = False - Q = 3 + #Q = 3 # Define dataset - N = 10 - k1 = GPy.kern.RBF(5, variance=1, lengthscale=1./np.random.dirichlet(np.r_[10,10,10,0.1,0.1]), ARD=True) - k2 = GPy.kern.RBF(5, variance=1, lengthscale=1./np.random.dirichlet(np.r_[10,0.1,10,0.1,10]), ARD=True) - k3 = GPy.kern.RBF(5, variance=1, lengthscale=1./np.random.dirichlet(np.r_[0.1,0.1,10,10,10]), ARD=True) - X = np.random.normal(0, 1, (N, 5)) - A = np.random.multivariate_normal(np.zeros(N), k1.K(X), Q).T - B = np.random.multivariate_normal(np.zeros(N), k2.K(X), Q).T - C = np.random.multivariate_normal(np.zeros(N), k3.K(X), Q).T + #N = 60 + #k1 = GPy.kern.RBF(5, variance=1, lengthscale=1./np.random.dirichlet(np.r_[10,10,10,0.1,0.1]), ARD=True) + #k2 = GPy.kern.RBF(5, variance=1, lengthscale=1./np.random.dirichlet(np.r_[10,0.1,10,0.1,10]), ARD=True) + #k3 = GPy.kern.RBF(5, variance=1, lengthscale=1./np.random.dirichlet(np.r_[0.1,0.1,10,10,10]), ARD=True) + #X = np.random.normal(0, 1, (N, 5)) + #A = np.random.multivariate_normal(np.zeros(N), k1.K(X), Q).T + #B = np.random.multivariate_normal(np.zeros(N), k2.K(X), Q).T + #C = np.random.multivariate_normal(np.zeros(N), k3.K(X), Q).T + #Y = np.vstack((A,B,C)) + #labels = np.hstack((np.zeros(A.shape[0]), np.ones(B.shape[0]), np.ones(C.shape[0])*2)) - Y = np.vstack((A,B,C)) - labels = np.hstack((np.zeros(A.shape[0]), np.ones(B.shape[0]), np.ones(C.shape[0])*2)) + #k = RBF(Q, ARD=True, lengthscale=2) # + kern.white(Q, _np.exp(-2)) # + kern.bias(Q) + pars = np.load(os.path.join(basedir, 'b-gplvm-save.npz')) + Y = pars['Y'] + Q = pars['Q'] + labels = pars['labels'] + + import warnings + with warnings.catch_warnings(record=True) as w: + warnings.simplefilter('always') # always print + m = GPLVM(Y, Q, initialize=False) + m.update_model(False) + m.initialize_parameter() + m[:] = pars['gplvm_p'] + m.update_model(True) - k = RBF(Q, ARD=True, lengthscale=2) # + kern.white(Q, _np.exp(-2)) # + kern.bias(Q) - m = GPLVM(Y, Q, init="PCA", kernel=k) - m.kern.lengthscale[:] = [1./.3, 1./.1, 1./.7] - m.likelihood.variance = .001 #m.optimize(messages=0) np.random.seed(111) m.plot_latent(labels=labels) @@ -436,31 +447,40 @@ def test_gplvm(): yield (do_test, ) def test_bayesian_gplvm(): - from ..examples.dimensionality_reduction import _simulate_matern - from ..kern import RBF from ..models import BayesianGPLVM np.random.seed(12345) matplotlib.rcParams.update(matplotlib.rcParamsDefault) #matplotlib.rcParams[u'figure.figsize'] = (4,3) matplotlib.rcParams[u'text.usetex'] = False - Q = 3 + #Q = 3 # Define dataset - N = 10 - k1 = GPy.kern.RBF(5, variance=1, lengthscale=1./np.random.dirichlet(np.r_[10,10,10,0.1,0.1]), ARD=True) - k2 = GPy.kern.RBF(5, variance=1, lengthscale=1./np.random.dirichlet(np.r_[10,0.1,10,0.1,10]), ARD=True) - k3 = GPy.kern.RBF(5, variance=1, lengthscale=1./np.random.dirichlet(np.r_[0.1,0.1,10,10,10]), ARD=True) - X = np.random.normal(0, 1, (N, 5)) - A = np.random.multivariate_normal(np.zeros(N), k1.K(X), Q).T - B = np.random.multivariate_normal(np.zeros(N), k2.K(X), Q).T - C = np.random.multivariate_normal(np.zeros(N), k3.K(X), Q).T + #N = 10 + #k1 = GPy.kern.RBF(5, variance=1, lengthscale=1./np.random.dirichlet(np.r_[10,10,10,0.1,0.1]), ARD=True) + #k2 = GPy.kern.RBF(5, variance=1, lengthscale=1./np.random.dirichlet(np.r_[10,0.1,10,0.1,10]), ARD=True) + #k3 = GPy.kern.RBF(5, variance=1, lengthscale=1./np.random.dirichlet(np.r_[0.1,0.1,10,10,10]), ARD=True) + #X = np.random.normal(0, 1, (N, 5)) + #A = np.random.multivariate_normal(np.zeros(N), k1.K(X), Q).T + #B = np.random.multivariate_normal(np.zeros(N), k2.K(X), Q).T + #C = np.random.multivariate_normal(np.zeros(N), k3.K(X), Q).T - Y = np.vstack((A,B,C)) - labels = np.hstack((np.zeros(A.shape[0]), np.ones(B.shape[0]), np.ones(C.shape[0])*2)) + #Y = np.vstack((A,B,C)) + #labels = np.hstack((np.zeros(A.shape[0]), np.ones(B.shape[0]), np.ones(C.shape[0])*2)) + + #k = RBF(Q, ARD=True, lengthscale=2) # + kern.white(Q, _np.exp(-2)) # + kern.bias(Q) + pars = np.load(os.path.join(basedir, 'b-gplvm-save.npz')) + Y = pars['Y'] + Q = pars['Q'] + labels = pars['labels'] + + import warnings + with warnings.catch_warnings(record=True) as w: + warnings.simplefilter('always') # always print + m = BayesianGPLVM(Y, Q, initialize=False) + m.update_model(False) + m.initialize_parameter() + m[:] = pars['bgplvm_p'] + m.update_model(True) - k = RBF(Q, ARD=True, lengthscale=2) # + kern.white(Q, _np.exp(-2)) # + kern.bias(Q) - m = BayesianGPLVM(Y, Q, init="PCA", kernel=k) - m.kern.lengthscale[:] = [1./.3, 1./.1, 1./.7] - m.likelihood.variance = .001 #m.optimize(messages=0) np.random.seed(111) m.plot_inducing(projection='2d') diff --git a/GPy/util/datasets.py b/GPy/util/datasets.py index 2d1d3244..af8912ac 100644 --- a/GPy/util/datasets.py +++ b/GPy/util/datasets.py @@ -98,7 +98,7 @@ def data_available(dataset_name=None): try: from itertools import zip_longest except ImportError: - from itertools import zip_longest as zip_longest + from itertools import izip_longest as zip_longest dr = data_resources[dataset_name] zip_urls = (dr['files'], ) if 'save_names' in dr: zip_urls += (dr['save_names'], ) @@ -1033,14 +1033,18 @@ def singlecell_rna_seq_deng(dataset='singlecell_deng'): data = inner.RPKM.to_frame() data.columns = [file_info.name[:-18]] gene_info = inner.Refseq_IDs.to_frame() - gene_info.columns = [file_info.name[:-18]] + gene_info.columns = ['NCBI Reference Sequence'] else: data[file_info.name[:-18]] = inner.RPKM - gene_info[file_info.name[:-18]] = inner.Refseq_IDs + #gene_info[file_info.name[:-18]] = inner.Refseq_IDs # Strip GSM number off data index rep = re.compile('GSM\d+_') - data.columns = data.columns.to_series().apply(lambda row: row[rep.match(row).end():]) + + from pandas import MultiIndex + columns = MultiIndex.from_tuples([row.split('_', 1) for row in data.columns]) + columns.names = ['GEO Accession', 'index'] + data.columns = columns data = data.T # make sure the same index gets used diff --git a/README.md b/README.md index 4df7bbe1..e0e715a9 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ The Gaussian processes framework in Python. * Travis-CI [unit-tests](https://travis-ci.org/SheffieldML/GPy) * [![licence](https://img.shields.io/badge/licence-BSD-blue.svg)](http://opensource.org/licenses/BSD-3-Clause) -[![develstat](https://travis-ci.org/SheffieldML/GPy.svg?branch=devel)](https://travis-ci.org/SheffieldML/GPy) [![appveyor](https://ci.appveyor.com/api/projects/status/662o6tha09m2jix3/branch/deploy?svg=true)](https://ci.appveyor.com/project/mzwiessele/gpy/branch/deploy) [![covdevel](http://codecov.io/github/SheffieldML/GPy/coverage.svg?branch=devel)](http://codecov.io/github/SheffieldML/GPy?branch=devel) [![Research software impact](http://depsy.org/api/package/pypi/GPy/badge.svg)](http://depsy.org/package/python/GPy) [![Code Health](https://landscape.io/github/SheffieldML/GPy/devel/landscape.svg?style=flat)](https://landscape.io/github/SheffieldML/GPy/devel) +[![develstat](https://travis-ci.org/SheffieldML/GPy.svg?branch=devel)](https://travis-ci.org/SheffieldML/GPy) [![appveyor](https://ci.appveyor.com/api/projects/status/662o6tha09m2jix3/branch/deploy?svg=true)](https://ci.appveyor.com/project/mzwiessele/gpy/branch/deploy) [![coverallsdevel](https://coveralls.io/repos/github/SheffieldML/GPy/badge.svg?branch=devel)](https://coveralls.io/github/SheffieldML/GPy?branch=devel) [![covdevel](http://codecov.io/github/SheffieldML/GPy/coverage.svg?branch=devel)](http://codecov.io/github/SheffieldML/GPy?branch=devel) [![Research software impact](http://depsy.org/api/package/pypi/GPy/badge.svg)](http://depsy.org/package/python/GPy) [![Code Health](https://landscape.io/github/SheffieldML/GPy/devel/landscape.svg?style=flat)](https://landscape.io/github/SheffieldML/GPy/devel) ## Updated Structure diff --git a/appveyor.yml b/appveyor.yml index 5a0f0577..f7f7b7ab 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,6 +1,8 @@ environment: pip_access: secure: 8/ZjXFwtd1S7ixd7PJOpptupKKEDhm2da/q3unabJ00= + COVERALLS_REPO_TOKEN: + secure: d3Luic/ESkGaWnZrvWZTKrzO+xaVwJWaRCEP0F+K/9DQGPSRZsJ/Du5g3s4XF+tS gpy_version: 1.2.1 matrix: - PYTHON_VERSION: 2.7 @@ -25,6 +27,7 @@ install: - python -m pip install paramz - python -m pip install nose-show-skipped - python -m pip install coverage + - python -m pip install coveralls - python -m pip install codecov - python -m pip install twine - "python setup.py develop" diff --git a/travis_tests.py b/travis_tests.py index 3c1c5c95..16713962 100644 --- a/travis_tests.py +++ b/travis_tests.py @@ -36,5 +36,5 @@ matplotlib.use('agg') import nose, warnings with warnings.catch_warnings(): warnings.simplefilter("ignore") - nose.main('GPy', defaultTest='GPy/testing/', argv=['', '--show-skipped']) + nose.main('GPy', defaultTest='GPy/testing', argv=['', '--show-skipped'])