mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-06-05 14:55:15 +02:00
Merge branch 'devel' of github.com:SheffieldML/GPy into devel
This commit is contained in:
commit
956e014b8d
5 changed files with 10 additions and 58 deletions
|
|
@ -298,7 +298,7 @@ def mrd_simulation(optimize=True, plot=True, plot_sim=True, **kw):
|
||||||
|
|
||||||
if optimize:
|
if optimize:
|
||||||
print "Optimizing Model:"
|
print "Optimizing Model:"
|
||||||
m.optimize('scg', messages=1, max_iters=5e4, max_f_eval=5e4, gtol=.05)
|
m.optimize('scg', messages=1, max_iters=1e3, max_f_eval=1e3, gtol=.1)
|
||||||
if plot:
|
if plot:
|
||||||
m.plot_X_1d("MRD Latent Space 1D")
|
m.plot_X_1d("MRD Latent Space 1D")
|
||||||
m.plot_scales("MRD Scales")
|
m.plot_scales("MRD Scales")
|
||||||
|
|
|
||||||
|
|
@ -1,47 +0,0 @@
|
||||||
# Copyright (c) 2012, GPy authors (see AUTHORS.txt).
|
|
||||||
# Licensed under the BSD 3-clause license (see LICENSE.txt)
|
|
||||||
|
|
||||||
|
|
||||||
"""
|
|
||||||
Gaussian Processes + Expectation Propagation - Poisson Likelihood
|
|
||||||
"""
|
|
||||||
import pylab as pb
|
|
||||||
import numpy as np
|
|
||||||
import GPy
|
|
||||||
|
|
||||||
default_seed=10000
|
|
||||||
|
|
||||||
def toy_poisson_1d(seed=default_seed):
|
|
||||||
"""
|
|
||||||
Simple 1D classification example
|
|
||||||
:param seed : seed value for data generation (default is 4).
|
|
||||||
:type seed: int
|
|
||||||
"""
|
|
||||||
|
|
||||||
X = np.arange(0,100,5)[:,None]
|
|
||||||
F = np.round(np.sin(X/18.) + .1*X) + np.arange(5,25)[:,None]
|
|
||||||
E = np.random.randint(-5,5,20)[:,None]
|
|
||||||
Y = F + E
|
|
||||||
|
|
||||||
kernel = GPy.kern.rbf(1)
|
|
||||||
distribution = GPy.likelihoods.likelihood_functions.Poisson()
|
|
||||||
likelihood = GPy.likelihoods.EP(Y,distribution)
|
|
||||||
|
|
||||||
m = GPy.models.GP(X,likelihood,kernel)
|
|
||||||
m.ensure_default_constraints()
|
|
||||||
|
|
||||||
# Approximate likelihood
|
|
||||||
m.update_likelihood_approximation()
|
|
||||||
|
|
||||||
# Optimize and plot
|
|
||||||
m.optimize()
|
|
||||||
#m.EPEM FIXME
|
|
||||||
print m
|
|
||||||
|
|
||||||
# Plot
|
|
||||||
pb.subplot(211)
|
|
||||||
m.plot_f() #GP plot
|
|
||||||
pb.subplot(212)
|
|
||||||
m.plot() #Output plot
|
|
||||||
|
|
||||||
return m
|
|
||||||
|
|
@ -21,7 +21,7 @@ class LikelihoodFunction(object):
|
||||||
if link == self._analytical:
|
if link == self._analytical:
|
||||||
self.moments_match = self._moments_match_analytical
|
self.moments_match = self._moments_match_analytical
|
||||||
else:
|
else:
|
||||||
assert isinstance(link,link_functions.link_function)
|
assert isinstance(link,link_functions.LinkFunction)
|
||||||
self.link = link
|
self.link = link
|
||||||
self.moments_match = self._moments_match_numerical
|
self.moments_match = self._moments_match_numerical
|
||||||
|
|
||||||
|
|
@ -79,7 +79,7 @@ class Binomial(LikelihoodFunction):
|
||||||
$$
|
$$
|
||||||
"""
|
"""
|
||||||
def __init__(self,link=None):
|
def __init__(self,link=None):
|
||||||
self._analytical = link_functions.probit
|
self._analytical = link_functions.Probit
|
||||||
if not link:
|
if not link:
|
||||||
link = self._analytical
|
link = self._analytical
|
||||||
super(Binomial, self).__init__(link)
|
super(Binomial, self).__init__(link)
|
||||||
|
|
@ -146,7 +146,7 @@ class Poisson(LikelihoodFunction):
|
||||||
def __init__(self,link=None):
|
def __init__(self,link=None):
|
||||||
self._analytical = None
|
self._analytical = None
|
||||||
if not link:
|
if not link:
|
||||||
link = link_functions.log()
|
link = link_functions.Log()
|
||||||
super(Poisson, self).__init__(link)
|
super(Poisson, self).__init__(link)
|
||||||
|
|
||||||
def _distribution(self,gp,obs):
|
def _distribution(self,gp,obs):
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import pylab as pb
|
||||||
from ..util.plot import gpplot
|
from ..util.plot import gpplot
|
||||||
from ..util.univariate_Gaussian import std_norm_pdf,std_norm_cdf
|
from ..util.univariate_Gaussian import std_norm_pdf,std_norm_cdf
|
||||||
|
|
||||||
class link_function(object):
|
class LinkFunction(object):
|
||||||
"""
|
"""
|
||||||
Link function class for doing non-Gaussian likelihoods approximation
|
Link function class for doing non-Gaussian likelihoods approximation
|
||||||
|
|
||||||
|
|
@ -19,7 +19,7 @@ class link_function(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class identity(link_function):
|
class Identity(LinkFunction):
|
||||||
def transf(self,mu):
|
def transf(self,mu):
|
||||||
return mu
|
return mu
|
||||||
|
|
||||||
|
|
@ -29,7 +29,7 @@ class identity(link_function):
|
||||||
def log_inv_transf(self,f):
|
def log_inv_transf(self,f):
|
||||||
return np.log(f)
|
return np.log(f)
|
||||||
|
|
||||||
class log(link_function):
|
class Log(LinkFunction):
|
||||||
|
|
||||||
def transf(self,mu):
|
def transf(self,mu):
|
||||||
return np.log(mu)
|
return np.log(mu)
|
||||||
|
|
@ -40,7 +40,7 @@ class log(link_function):
|
||||||
def log_inv_transf(self,f):
|
def log_inv_transf(self,f):
|
||||||
return f
|
return f
|
||||||
|
|
||||||
class log_ex_1(link_function):
|
class Log_ex_1(LinkFunction):
|
||||||
def transf(self,mu):
|
def transf(self,mu):
|
||||||
return np.log(np.exp(mu) - 1)
|
return np.log(np.exp(mu) - 1)
|
||||||
|
|
||||||
|
|
@ -50,11 +50,10 @@ class log_ex_1(link_function):
|
||||||
def log_inv_tranf(self,f):
|
def log_inv_tranf(self,f):
|
||||||
return np.log(np.log(np.exp(f)+1))
|
return np.log(np.log(np.exp(f)+1))
|
||||||
|
|
||||||
class probit(link_function):
|
class Probit(LinkFunction):
|
||||||
|
|
||||||
def inv_transf(self,f):
|
def inv_transf(self,f):
|
||||||
return std_norm_cdf(f)
|
return std_norm_cdf(f)
|
||||||
|
|
||||||
def log_inv_transf(self,f):
|
def log_inv_transf(self,f):
|
||||||
return np.log(std_norm_cdf(f))
|
return np.log(std_norm_cdf(f))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ class FITCClassification(FITC):
|
||||||
|
|
||||||
:param X: input observations
|
:param X: input observations
|
||||||
:param Y: observed values
|
:param Y: observed values
|
||||||
:param likelihood: a GPy likelihood, defaults to Binomial with probit link_function
|
:param likelihood: a GPy likelihood, defaults to Binomial with probit link function
|
||||||
:param kernel: a GPy kernel, defaults to rbf+white
|
:param kernel: a GPy kernel, defaults to rbf+white
|
||||||
:param normalize_X: whether to normalize the input data before computing (predictions will be in original scales)
|
:param normalize_X: whether to normalize the input data before computing (predictions will be in original scales)
|
||||||
:type normalize_X: False|True
|
:type normalize_X: False|True
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue