mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-06-14 15:25:15 +02:00
Not needed
This commit is contained in:
parent
67d3ba6700
commit
bf9e6cbd5f
3 changed files with 0 additions and 173 deletions
|
|
@ -1,53 +0,0 @@
|
|||
import pylab as pb
|
||||
import numpy as np
|
||||
import GPy
|
||||
pb.ion()
|
||||
pb.close('all')
|
||||
|
||||
"""
|
||||
Simple 1D classification example
|
||||
:param seed : seed value for data generation (default is 4).
|
||||
:type seed: int
|
||||
"""
|
||||
seed=10000
|
||||
|
||||
#data = GPy.util.datasets.toy_linear_1d_classification(seed=seed)
|
||||
#X = data['X']
|
||||
#Y = data['Y'][:, 0:1]
|
||||
#Y[Y == -1] = 0
|
||||
|
||||
|
||||
|
||||
X = np.vstack((np.random.uniform(0,10,(10,1)),np.random.uniform(7,17,(10,1)),np.random.uniform(15,25,(10,1))))
|
||||
Y = np.vstack((np.zeros((10,1)),np.ones((10,1)),np.zeros((10,1))))
|
||||
|
||||
# Kernel object
|
||||
kernel = GPy.kern.rbf(1) + GPy.kern.white(1)
|
||||
|
||||
# Likelihood object
|
||||
distribution = GPy.likelihoods.likelihood_functions.probit()
|
||||
likelihood = GPy.likelihoods.EP(Y,distribution)
|
||||
|
||||
Z = np.random.uniform(X.min(),X.max(),(10,1))
|
||||
#Z = np.array([0,20])[:,None]
|
||||
print Z
|
||||
|
||||
# Model definition
|
||||
m = GPy.models.generalized_FITC(X,likelihood=likelihood,kernel=kernel,Z=Z,normalize_X=False)
|
||||
m.set('len',2.)
|
||||
|
||||
m.ensure_default_constraints()
|
||||
# Optimize
|
||||
#m.constrain_fixed('iip')
|
||||
m.update_likelihood_approximation()
|
||||
print m.checkgrad(verbose=1)
|
||||
# Parameters optimization:
|
||||
#m.optimize()
|
||||
m.pseudo_EM() #FIXME
|
||||
|
||||
# Plot
|
||||
pb.subplot(211)
|
||||
m.plot_f()
|
||||
pb.subplot(212)
|
||||
m.plot()
|
||||
print(m)
|
||||
|
|
@ -1,67 +0,0 @@
|
|||
import pylab as pb
|
||||
import numpy as np
|
||||
import GPy
|
||||
pb.close('all')
|
||||
|
||||
seed=10000
|
||||
"""Run a Gaussian process classification on the crescent data. The demonstration calls the basic GP classification model and uses EP to approximate the likelihood.
|
||||
|
||||
:param model_type: type of model to fit ['Full', 'FITC', 'DTC'].
|
||||
: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
|
||||
"""
|
||||
|
||||
data = GPy.util.datasets.crescent_data(seed=seed)
|
||||
|
||||
# Kernel object
|
||||
kernel = GPy.kern.rbf(data['X'].shape[1]) + GPy.kern.white(data['X'].shape[1])
|
||||
|
||||
# Likelihood object
|
||||
distribution = GPy.likelihoods.likelihood_functions.probit()
|
||||
likelihood = GPy.likelihoods.EP(data['Y'],distribution)
|
||||
|
||||
sample = np.random.randint(0,data['X'].shape[0],10)
|
||||
Z = data['X'][sample,:]
|
||||
# create sparse GP EP model
|
||||
m = GPy.models.generalized_FITC(data['X'],likelihood=likelihood,kernel=kernel,Z=Z)
|
||||
m.ensure_default_constraints()
|
||||
m.set('len',10.)
|
||||
|
||||
#m.update_likelihood_approximation()
|
||||
|
||||
# optimize
|
||||
#m.optimize()
|
||||
m.pseudo_EM()
|
||||
print(m)
|
||||
|
||||
# plot
|
||||
m.plot()
|
||||
fitc = m
|
||||
|
||||
pb.figure()
|
||||
# Kernel object
|
||||
kernel = GPy.kern.rbf(data['X'].shape[1]) + GPy.kern.white(data['X'].shape[1])
|
||||
|
||||
# Likelihood object
|
||||
distribution = GPy.likelihoods.likelihood_functions.probit()
|
||||
likelihood = GPy.likelihoods.EP(data['Y'],distribution)
|
||||
|
||||
#sample = np.random.randint(0,data['X'].shape[0],10)
|
||||
#Z = data['X'][sample,:]
|
||||
# create sparse GP EP model
|
||||
m = GPy.models.sparse_GP(data['X'],likelihood=likelihood,kernel=kernel,Z=Z)
|
||||
m.ensure_default_constraints()
|
||||
m.set('len',10.)
|
||||
|
||||
#m.update_likelihood_approximation()
|
||||
|
||||
# optimize
|
||||
#m.optimize()
|
||||
m.pseudo_EM()
|
||||
print(m)
|
||||
|
||||
# plot
|
||||
m.plot()
|
||||
variational = m
|
||||
|
|
@ -1,53 +0,0 @@
|
|||
import pylab as pb
|
||||
import numpy as np
|
||||
import GPy
|
||||
pb.ion()
|
||||
pb.close('all')
|
||||
|
||||
N = 400
|
||||
M = 10
|
||||
# sample inputs and outputs
|
||||
X = np.random.uniform(-3.,3.,(N,1))
|
||||
Y = np.sin(X)+np.random.randn(N,1)*0.05
|
||||
|
||||
"""Run a 1D example of a sparse GP regression."""
|
||||
"""
|
||||
rbf = GPy.kern.rbf(1)
|
||||
noise = GPy.kern.white(1)
|
||||
kernel = rbf + noise
|
||||
Z = np.random.uniform(-3,3,(M,1))
|
||||
likelihood = GPy.likelihoods.Gaussian(Y)
|
||||
m = GPy.models.sparse_GP(X, likelihood, kernel, Z)
|
||||
m.scale_factor=10000
|
||||
m.constrain_positive('(variance|lengthscale|precision)')
|
||||
m.checkgrad(verbose=1)
|
||||
m.optimize('tnc', messages = 1)
|
||||
pb.figure()
|
||||
m.plot()
|
||||
|
||||
variational = m
|
||||
"""
|
||||
|
||||
# construct kernel
|
||||
rbf = GPy.kern.rbf(1)
|
||||
noise = GPy.kern.white(1)
|
||||
kernel = rbf + noise
|
||||
#Z = np.random.uniform(-3,3,(M,1))
|
||||
Z = variational.Z
|
||||
likelihood = GPy.likelihoods.Gaussian(Y)
|
||||
# create simple GP model
|
||||
m = GPy.models.generalized_FITC(X, likelihood, kernel, Z=Z)
|
||||
m.constrain_positive('(variance|lengthscale|precision)')
|
||||
#m.constrain_fixed('iip')
|
||||
m.checkgrad(verbose=1)
|
||||
m.optimize('tnc', messages = 1)
|
||||
#pb.figure()
|
||||
#m.plot()
|
||||
"""
|
||||
Xnew = X.copy().flatten()
|
||||
Xnew.sort()
|
||||
Xnew = Xnew[:,None]
|
||||
mean,var,low,up = m.predict(Xnew)
|
||||
GPy.util.plot.gpplot(Xnew,mean,low,up)
|
||||
fitc = m
|
||||
"""
|
||||
Loading…
Add table
Add a link
Reference in a new issue