mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-10 12:32:40 +02:00
some tifying in the models classes
This commit is contained in:
parent
cd3bcee11c
commit
63ab143e7c
6 changed files with 15 additions and 26 deletions
|
|
@ -22,8 +22,12 @@ class Bernoulli(Likelihood):
|
||||||
.. See also::
|
.. See also::
|
||||||
likelihood.py, for the parent class
|
likelihood.py, for the parent class
|
||||||
"""
|
"""
|
||||||
def __init__(self, gp_link=None, analytical_mean=False, analytical_variance=False):
|
def __init__(self, gp_link=None):
|
||||||
super(Bernoulli, self).__init__(gp_link, analytical_mean, analytical_variance)
|
if gp_link is None:
|
||||||
|
gp_link = link_functions.Probit()
|
||||||
|
|
||||||
|
super(Bernoulli, self).__init__(gp_link, 'Bernoulli')
|
||||||
|
|
||||||
if isinstance(gp_link , (link_functions.Heaviside, link_functions.Probit)):
|
if isinstance(gp_link , (link_functions.Heaviside, link_functions.Probit)):
|
||||||
self.log_concave = True
|
self.log_concave = True
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
# Copyright (c) 2013, Ricardo Andrade
|
# Copyright (c) 2013, Ricardo Andrade
|
||||||
|
# Copyright (c) 2013, the GPy Authors (see AUTHORS.txt)
|
||||||
# Licensed under the BSD 3-clause license (see LICENSE.txt)
|
# Licensed under the BSD 3-clause license (see LICENSE.txt)
|
||||||
|
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from ..core import GP
|
from ..core import GP
|
||||||
from .. import likelihoods
|
from .. import likelihoods
|
||||||
|
|
@ -15,27 +15,16 @@ class GPClassification(GP):
|
||||||
|
|
||||||
:param X: input observations
|
:param X: input observations
|
||||||
:param Y: observed values, can be None if likelihood is not None
|
:param Y: observed values, can be None if likelihood is not None
|
||||||
:param likelihood: a GPy likelihood, defaults to Binomial with probit link_function
|
|
||||||
:param kernel: a GPy kernel, defaults to rbf
|
:param kernel: a GPy kernel, defaults to rbf
|
||||||
:param normalize_X: whether to normalize the input data before computing (predictions will be in original scales)
|
|
||||||
:type normalize_X: False|True
|
|
||||||
:param normalize_Y: whether to normalize the input data before computing (predictions will be in original scales)
|
|
||||||
:type normalize_Y: False|True
|
|
||||||
|
|
||||||
.. Note:: Multiple independent outputs are allowed using columns of Y
|
.. Note:: Multiple independent outputs are allowed using columns of Y
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self,X,Y=None,likelihood=None,kernel=None,normalize_X=False,normalize_Y=False):
|
def __init__(self, X, Y, kernel=None):
|
||||||
if kernel is None:
|
if kernel is None:
|
||||||
kernel = kern.rbf(X.shape[1])
|
kernel = kern.rbf(X.shape[1])
|
||||||
|
|
||||||
if likelihood is None:
|
likelihood = likelihoods.Bernoulli()
|
||||||
noise_model = likelihoods.binomial()
|
|
||||||
likelihood = likelihoods.EP(Y, noise_model)
|
|
||||||
elif Y is not None:
|
|
||||||
if not all(Y.flatten() == likelihood.data.flatten()):
|
|
||||||
raise Warning, 'likelihood.data and Y are different.'
|
|
||||||
|
|
||||||
GP.__init__(self, X, likelihood, kernel, normalize_X=normalize_X)
|
GP.__init__(self, X=X, Y=Y, kernel=kernel, likelihood=likelihood, name='gp_classification')
|
||||||
self.ensure_default_constraints()
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
# Copyright (c) 2013, Ricardo Andrade
|
# Copyright (c) 2013, Ricardo Andrade
|
||||||
# Licensed under the BSD 3-clause license (see LICENSE.txt)
|
# Licensed under the BSD 3-clause license (see LICENSE.txt)
|
||||||
|
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from ..core import GP
|
from ..core import GP
|
||||||
from .. import likelihoods
|
from .. import likelihoods
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ class GPRegression(GP):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, X, Y, kernel=None):
|
def __init__(self, X, Y, kernel=None):
|
||||||
|
|
||||||
if kernel is None:
|
if kernel is None:
|
||||||
kernel = kern.rbf(X.shape[1])
|
kernel = kern.rbf(X.shape[1])
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,6 @@
|
||||||
'''
|
# ## Copyright (c) 2012, GPy authors (see AUTHORS.txt).
|
||||||
Created on 17 Jul 2013
|
# Licensed under the BSD 3-clause license (see LICENSE.txt)
|
||||||
|
|
||||||
@author: maxz
|
|
||||||
'''
|
|
||||||
from GPy.core.model import Model
|
from GPy.core.model import Model
|
||||||
import itertools
|
import itertools
|
||||||
import numpy
|
import numpy
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,6 @@
|
||||||
'''
|
# ## Copyright (c) 2013, GPy authors (see AUTHORS.txt).
|
||||||
Created on 10 Apr 2013
|
# Licensed under the BSD 3-clause license (see LICENSE.txt)
|
||||||
|
|
||||||
@author: Max Zwiessele
|
|
||||||
'''
|
|
||||||
from GPy.core import Model
|
from GPy.core import Model
|
||||||
from GPy.core import SparseGP
|
from GPy.core import SparseGP
|
||||||
from GPy.util.linalg import PCA
|
from GPy.util.linalg import PCA
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue