

def brendan_faces(optimize=True, verbose=True, plot=True):
    import GPy
    import pods
    data = pods.datasets.brendan_faces()
    Q = 2
    Y = data['Y']
    Yn = (Y - Y.mean())
    Yn /= Yn.std()
    m = GPy.models.BayesianGPLVM(Yn, Q, num_inducing=20)
    if optimize:
        m.optimize('bfgs', messages=verbose, max_iters=1000)
    if plot:
        ax = m.plot_latent(which_indices=(0, 1))
        y = m.Y[0, :]
        data_show = GPy.plotting.matplot_dep.visualize.image_show(y[None, :], dimensions=(20, 28), transpose=True, order='F', invert=False, scale=False)
        lvm = GPy.plotting.matplot_dep.visualize.lvm(m.X.mean[0, :].copy(), m, data_show, ax)
        raw_input('Press enter to finish')
    return m

dataset/ETHPy150Open SheffieldML/GPy/GPy/examples/dimensionality_reduction.py brendan_faces/original