@@ -0,0 +1,2904 @@
+%22%22%22%0AThis program is free software; you can redistribute it and/or modify%0Ait under the terms of the GNU General Public License as published by%0Athe Free Software Foundation; either version 3 of the License, or%0A(at your option) any later version.%0A%0AWritten (W) 2013 Heiko Strathmann%0A%22%22%22%0Afrom main.distribution.Gaussian import Gaussian%0Afrom main.experiments.SingleChainExperiment import SingleChainExperiment%0Afrom main.gp.GPData import GPData%0Afrom main.gp.mcmc.PseudoMarginalHyperparameterDistribution import %5C%0A    PseudoMarginalHyperparameterDistribution%0Afrom main.kernel.GaussianKernel import GaussianKernel%0Afrom main.mcmc.MCMCChain import MCMCChain%0Afrom main.mcmc.MCMCParams import MCMCParams%0Afrom main.mcmc.output.PlottingOutput import PlottingOutput%0Afrom main.mcmc.output.StatisticsOutput import StatisticsOutput%0Afrom main.mcmc.samplers.AdaptiveMetropolisLearnScale import %5C%0A    AdaptiveMetropolisLearnScale%0Afrom main.mcmc.samplers.KameleonWindowLearnScale import KameleonWindowLearnScale%0Afrom numpy.lib.twodim_base import eye%0Afrom numpy.linalg.linalg import cholesky%0Afrom numpy.ma.core import mean, ones, shape, asarray, zeros%0Afrom numpy.ma.extras import cov%0Afrom numpy.random import permutation, seed%0Afrom scipy.linalg.basic import solve_triangular%0Aimport os%0Aimport sys%0A    %0Aif __name__ == '__main__':%0A    # load data%0A    data,labels=GPData.get_glass_data()%0A%0A    # throw away some data%0A    n=250%0A    seed(1)%0A    idx=permutation(len(data))%0A    idx=idx%5B:n%5D%0A    data=data%5Bidx%5D%0A    labels=labels%5Bidx%5D%0A    %0A    # normalise and whiten dataset%0A    data-=mean(data, 0)%0A    L=cholesky(cov(data.T))%0A    data=solve_triangular(L, data.T, lower=True).T%0A    dim=shape(data)%5B1%5D%0A%0A    # prior on theta and posterior target estimate%0A    theta_prior=Gaussian(mu=0*ones(dim), Sigma=eye(dim)*5)%0A    target=PseudoMarginalHyperparameterDistribution(data, labels, %5C%0A                                                    n_importance=100, prior=theta_prior, %5C%0A                                                    ridge=1e-3)%0A    %0A    # create sampler%0A    burnin=10000%0A    num_iterations=burnin+20000%0A    kernel = GaussianKernel(sigma=5.0)%0A    sampler=KameleonWindowLearnScale(target, kernel, stop_adapt=burnin)%0A#    sampler=AdaptiveMetropolisLearnScale(target, sample_discard=200)%0A    #sampler=StandardMetropolis(target)%0A    %0A    # posterior mode derived by initial tests%0A    start=zeros(target.dimension)%0A    params = MCMCParams(start=start, num_iterations=num_iterations, burnin=burnin)%0A    %0A    # create MCMC chain%0A    chain=MCMCChain(sampler, params)%0A    chain.append_mcmc_output(StatisticsOutput(print_from=0, lag=100))%0A    chain.append_mcmc_output(PlottingOutput(plot_from=0, lag=500))%0A    %0A    # create experiment instance to store results%0A    experiment_dir = str(os.path.abspath(sys.argv%5B0%5D)).split(os.sep)%5B-1%5D.split(%22.%22)%5B0%5D + os.sep%0A    experiment = SingleChainExperiment(chain, experiment_dir)%0A    %0A    experiment.run()

add glass dataset experiment