From 589aeda88cc938a537ecb5a5df34dd276bae5a37 Mon Sep 17 00:00:00 2001 From: Alan Saul Date: Mon, 15 Apr 2013 15:44:29 +0100 Subject: [PATCH] Should be working now, needed to change relative path names --- GPy/examples/classification.py | 3 +-- GPy/examples/laplace_approximations.py | 29 +++++++++++--------------- GPy/likelihoods/__init__.py | 2 +- 3 files changed, 14 insertions(+), 20 deletions(-) diff --git a/GPy/examples/classification.py b/GPy/examples/classification.py index 5df019e4..4899e75e 100644 --- a/GPy/examples/classification.py +++ b/GPy/examples/classification.py @@ -17,8 +17,7 @@ def crescent_data(seed=default_seed): #FIXME :param seed : seed value for data generation. :type seed: int :param inducing : number of inducing variables (only used for 'FITC' or 'DTC'). - :type inducing: int - """ + :type inducing: int """ data = GPy.util.datasets.crescent_data(seed=seed) diff --git a/GPy/examples/laplace_approximations.py b/GPy/examples/laplace_approximations.py index 5b1331b6..07801150 100644 --- a/GPy/examples/laplace_approximations.py +++ b/GPy/examples/laplace_approximations.py @@ -1,10 +1,6 @@ import GPy import numpy as np import matplotlib.pyplot as plt -from scipy.stats import t, norm -from coxGP.python.likelihoods.Laplace import Laplace -from coxGP.python.likelihoods.likelihood_function import student_t - def timing(): real_var = 0.1 @@ -28,15 +24,14 @@ def timing(): edited_real_sd = real_sd kernel1 = GPy.kern.rbf(X.shape[1]) - t_distribution = student_t(deg_free, sigma=edited_real_sd) - corrupt_stu_t_likelihood = Laplace(Yc.copy(), t_distribution, rasm=True) + t_distribution = GPy.likelihoods.likelihood_functions.student_t(deg_free, sigma=edited_real_sd) + corrupt_stu_t_likelihood = GPy.likelihoods.Laplace(Yc.copy(), t_distribution, rasm=True) m = GPy.models.GP(X, corrupt_stu_t_likelihood, kernel1) m.ensure_default_constraints() m.update_likelihood_approximation() m.optimize() the_is[a] = m.likelihood.i - #import ipdb; ipdb.set_trace() ### XXX BREAKPOINT print the_is print np.mean(the_is) @@ -116,8 +111,8 @@ def student_t_approx(): edited_real_sd = real_sd print "Clean student t, rasm" - t_distribution = student_t(deg_free, sigma=edited_real_sd) - stu_t_likelihood = Laplace(Y.copy(), t_distribution, rasm=True) + t_distribution = GPy.likelihoods.likelihood_functions.student_t(deg_free, sigma=edited_real_sd) + stu_t_likelihood = GPy.likelihoods.Laplace(Y.copy(), t_distribution, rasm=True) m = GPy.models.GP(X, stu_t_likelihood, kernel6) m.ensure_default_constraints() m.update_likelihood_approximation() @@ -129,8 +124,8 @@ def student_t_approx(): plt.ylim(-2.5, 2.5) print "Corrupt student t, rasm" - t_distribution = student_t(deg_free, sigma=edited_real_sd) - corrupt_stu_t_likelihood = Laplace(Yc.copy(), t_distribution, rasm=True) + t_distribution = GPy.likelihoods.likelihood_functions.student_t(deg_free, sigma=edited_real_sd) + corrupt_stu_t_likelihood = GPy.likelihoods.Laplace(Yc.copy(), t_distribution, rasm=True) m = GPy.models.GP(X, corrupt_stu_t_likelihood, kernel4) m.ensure_default_constraints() m.update_likelihood_approximation() @@ -142,8 +137,8 @@ def student_t_approx(): plt.ylim(-2.5, 2.5) print "Clean student t, ncg" - t_distribution = student_t(deg_free, sigma=edited_real_sd) - stu_t_likelihood = Laplace(Y, t_distribution, rasm=False) + t_distribution = GPy.likelihoods.likelihood_functions.student_t(deg_free, sigma=edited_real_sd) + stu_t_likelihood = GPy.likelihoods.Laplace(Y, t_distribution, rasm=False) m = GPy.models.GP(X, stu_t_likelihood, kernel3) m.ensure_default_constraints() m.update_likelihood_approximation() @@ -155,8 +150,8 @@ def student_t_approx(): plt.ylim(-2.5, 2.5) print "Corrupt student t, ncg" - t_distribution = student_t(deg_free, sigma=edited_real_sd) - corrupt_stu_t_likelihood = Laplace(Yc.copy(), t_distribution, rasm=False) + t_distribution = GPy.likelihoods.likelihood_functions.student_t(deg_free, sigma=edited_real_sd) + corrupt_stu_t_likelihood = GPy.likelihoods.Laplace(Yc.copy(), t_distribution, rasm=False) m = GPy.models.GP(X, corrupt_stu_t_likelihood, kernel5) m.ensure_default_constraints() m.update_likelihood_approximation() @@ -169,8 +164,8 @@ def student_t_approx(): ###with a student t distribution, since it has heavy tails it should work well - ###likelihood_function = student_t(deg_free, sigma=real_var) - ###lap = Laplace(Y, likelihood_function) + ###likelihood_functions = student_t(deg_free, sigma=real_var) + ###lap = Laplace(Y, likelihood_functions) ###cov = kernel.K(X) ###lap.fit_full(cov) diff --git a/GPy/likelihoods/__init__.py b/GPy/likelihoods/__init__.py index 83413255..9becb1b1 100644 --- a/GPy/likelihoods/__init__.py +++ b/GPy/likelihoods/__init__.py @@ -1,4 +1,4 @@ from EP import EP from Gaussian import Gaussian -# TODO: from Laplace import Laplace +from Laplace import Laplace import likelihood_functions as functions