@@ -0,0 +1,2188 @@
+#!/usr/bin/python%0A# -*- coding: utf-8 -*-%0A%0Ar%22%22%22%0A==========================================================%0AComparing Bayesian Inference and MAP estimation%0A==========================================================%0A%0A%22%22%22%0Aprint(__doc__)%0A%0A# Author: Jan Hendrik Metzen %3Cjhm@informatik.uni-bremen.de%3E%0A# Licence: BSD 3 clause%0A%0A%0Aimport numpy as np%0Aimport matplotlib.pyplot as plt%0A%0Afrom sklearn.learning_curve import learning_curve%0Afrom skgp.estimators import GaussianProcess, BayesianGaussianProcess%0A%0Anp.random.seed(1)%0A%0A%0Adef f(X):%0A    %22%22%22 Target function for GPR.%0A%0A    Note that one dimension (X%5B:, 3%5D) is irrelevant and should thus be ignored%0A    by ARD. Furthermore, the values x in R%5E3 and%0A    x + %5Calpha (1, 2 , 0) + %5Cbeta (1, 0, 2) have the same value for all x and%0A    all alpha and beta. This can be exploited by FAD.%0A    %22%22%22%0A    return np.tanh(2 * X%5B:, 0%5D - X%5B:, 1%5D - X%5B:, 2%5D)%0A%0AXtrain = np.random.random((100, 6)) * 2 - 1%0Aytrain = f(Xtrain)%0A%0Aplt.figure()%0Acolors = %5B'r', 'g', 'b', 'c', 'm'%5D%0Alabels = %7BTrue: %22Bayesian GP%22, False: %22Standard GP%22%7D%0Afor i, bayesian in enumerate(labels.keys()):%0A    model = GaussianProcess(corr='squared_exponential',%0A                            theta0=%5B1.0%5D * 12, thetaL=%5B1e-4%5D * 12,%0A                            thetaU=%5B1e2%5D * 12)%0A    if bayesian:%0A        model = BayesianGaussianProcess(model, n_posterior_samples=25,%0A                                        n_burnin=250, n_sampling_steps=25)%0A%0A    train_sizes, train_scores, test_scores = %5C%0A        learning_curve(model, Xtrain, ytrain, scoring=%22mean_squared_error%22,%0A                       cv=10, n_jobs=1)%0A    test_scores = -test_scores  # Scores correspond to negative MSE%0A    test_scores_mean = np.mean(test_scores, axis=1)%0A    test_scores_min = np.min(test_scores, axis=1)%0A    test_scores_max = np.max(test_scores, axis=1)%0A%0A    plt.plot(train_sizes, test_scores_mean, label=labels%5Bbayesian%5D,%0A             color=colors%5Bi%5D)%0A    plt.fill_between(train_sizes, test_scores_min, test_scores_max,%0A                     alpha=0.2, color=colors%5Bi%5D)%0A%0Aplt.legend(loc=%22best%22)%0Aplt.title(%22Learning Curve%22)%0Aplt.xlabel(%22Training examples%22)%0Aplt.ylabel(%22Mean Squared Error%22)%0Aplt.yscale(%22symlog%22, linthreshy=1e-10)%0Aplt.show()%0A

ADD Preliminary plot_bayesian_gp example