From ded01ed65c4a071368b6d60e59aae35ecb9161c4 Mon Sep 17 00:00:00 2001 From: Ilias Bilionis Date: Mon, 10 Aug 2015 17:18:53 -0400 Subject: [PATCH] Removed dir ib_tests --- ib_tests/test_regression.py | 37 -------------- ib_tests/test_transformation_of_pdf.py | 67 -------------------------- ib_tests/test_transformation_plot.py | 24 --------- 3 files changed, 128 deletions(-) delete mode 100644 ib_tests/test_regression.py delete mode 100644 ib_tests/test_transformation_of_pdf.py delete mode 100644 ib_tests/test_transformation_plot.py diff --git a/ib_tests/test_regression.py b/ib_tests/test_regression.py deleted file mode 100644 index 742948c1..00000000 --- a/ib_tests/test_regression.py +++ /dev/null @@ -1,37 +0,0 @@ -""" -Test the regression we get with the new transformations. - -Author: - Ilias Bilionis - -Date: - 3/8/2015 - -""" - - -import sys -import os -# Make sure we load the GP that is here -sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) -import GPy -import matplotlib.pyplot as plt -import numpy as np -import triangle - - -if __name__ == '__main__': - m = GPy.examples.regression.olympic_marathon_men(optimize=True) - plt.show(block=True) - print m - mcmc = GPy.inference.mcmc.samplers.Metropolis_Hastings(m) - mcmc.sample(Ntotal=100000, Nburn=10000, Nthin=100, tune_interval=1000, tune_throughout=True) - samples = np.array(mcmc.chains[-1]) - fig = triangle.corner(samples) - m.plot() - fig = plt.figure() - for i in xrange(samples.shape[1]): - ax = fig.add_subplot(samples.shape[1], 1, i + 1) - ax.plot(samples[:, i], linewidth=1.5) - plt.show(block=True) - diff --git a/ib_tests/test_transformation_of_pdf.py b/ib_tests/test_transformation_of_pdf.py deleted file mode 100644 index 8da16b21..00000000 --- a/ib_tests/test_transformation_of_pdf.py +++ /dev/null @@ -1,67 +0,0 @@ -""" -Test the transformation of a PDF. - -Author: - Ilias Bilionis - -Date: - 8/4/2015 - -""" - - -import sys -import os -# Make sure we load the GP that is here -sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) -print 'trying' -import GPy -print 'done' -import matplotlib.pyplot as plt -import numpy as np -import scipy.stats as st -import scipy.integrate as integrate - - -class TestModel(GPy.core.Model): - def __init__(self): - GPy.core.Model.__init__(self, 'test_model') - theta = GPy.core.Param('theta', 1.) - self.link_parameter(theta) - - def log_likelihood(self): - return 0. - - -if __name__ == '__main__': - m = TestModel() - prior = GPy.priors.LogGaussian(0., .9) - m.theta.set_prior(prior) - - # The following should return the PDF in terms of the transformed quantities - p_phi = lambda(phi): np.exp(-m._objective_grads(phi)[0]) - - # Let's look at the transformation phi = log(exp(theta - 1)) - trans = GPy.constraints.Exponent() - m.theta.constrain(trans) - # Plot the transformed probability density - phi = np.linspace(-8, 8, 100) - fig, ax = plt.subplots() - # Let's draw some samples of theta and transform them so that we see - # which one is right - theta_s = prior.rvs(10000) - # Transform it to the new variables - phi_s = trans.finv(theta_s) - # And draw their histogram - ax.hist(phi_s, normed=True, bins=100, alpha=0.25, label='Empirical') - # This is to be compared to the PDF of the model expressed in terms of these new - # variables - ax.plot(phi, [p_phi(p) for p in phi], label='Transformed PDF', linewidth=2) - ax.set_xlim(-3, 10) - ax.set_xlabel(r'transformed $\theta$', fontsize=16) - ax.set_ylabel('PDF', fontsize=16) - plt.legend(loc='best') - # Now let's test the gradients - m.checkgrad(verbose=True) - # And show the plot - plt.show(block=True) diff --git a/ib_tests/test_transformation_plot.py b/ib_tests/test_transformation_plot.py deleted file mode 100644 index 7dea83bd..00000000 --- a/ib_tests/test_transformation_plot.py +++ /dev/null @@ -1,24 +0,0 @@ -""" -Tests whether or not the tansformation plot works as expected. -It does not work on the normal build. - -Author: - Ilias Bilionis - -Date: - 3/8/2015 -""" - - -import sys -import os -# Make sure we load the GP that is here -sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) -import GPy -import matplotlib.pyplot as plt - - -if __name__ == '__main__': - f = GPy.constraints.Logexp() - f.plot() - plt.show(block=True)