GPy/GPy/models/sparse_gp_classification.py

47 lines
1.8 KiB
Python
Raw Normal View History

2013-06-04 18:55:55 +01:00
# Copyright (c) 2013, Ricardo Andrade
# Licensed under the BSD 3-clause license (see LICENSE.txt)
import numpy as np
2013-06-05 14:39:32 +01:00
from ..core import SparseGP
2013-06-04 18:55:55 +01:00
from .. import likelihoods
from .. import kern
from ..likelihoods import likelihood
2014-04-16 11:04:16 +01:00
from ..inference.latent_function_inference import expectation_propagation_dtc
2013-06-04 18:55:55 +01:00
2013-06-05 14:39:32 +01:00
class SparseGPClassification(SparseGP):
2013-06-04 18:55:55 +01:00
"""
sparse Gaussian Process model for classification
2013-06-05 14:11:28 +01:00
This is a thin wrapper around the sparse_GP class, with a set of sensible defaults
2013-06-04 18:55:55 +01:00
:param X: input observations
:param Y: observed values
2013-06-05 14:11:49 +01:00
:param likelihood: a GPy likelihood, defaults to Binomial with probit link_function
2013-06-04 18:55:55 +01:00
: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)
: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
:rtype: model object
"""
2014-04-16 11:04:16 +01:00
#def __init__(self, X, Y=None, likelihood=None, kernel=None, normalize_X=False, normalize_Y=False, Z=None, num_inducing=10):
def __init__(self, X, Y=None, likelihood=None, kernel=None, Z=None, num_inducing=10, Y_metadata=None):
2013-06-04 18:55:55 +01:00
if kernel is None:
2014-04-16 11:04:16 +01:00
kernel = kern.RBF(X.shape[1])
2013-06-04 18:55:55 +01:00
2014-04-16 11:04:16 +01:00
likelihood = likelihoods.Bernoulli()
2013-06-04 18:55:55 +01:00
if Z is None:
2013-06-05 15:29:45 +01:00
i = np.random.permutation(X.shape[0])[:num_inducing]
2013-06-04 18:55:55 +01:00
Z = X[i].copy()
else:
assert Z.shape[1] == X.shape[1]
2013-06-04 18:55:55 +01:00
2014-04-16 11:04:16 +01:00
SparseGP.__init__(self, X, Y, Z, kernel, likelihood, inference_method=expectation_propagation_dtc.EPDTC(), name='SparseGPClassification',Y_metadata=Y_metadata)
#def __init__(self, X, Y, Z, kernel, likelihood, inference_method=None, name='sparse gp', Y_metadata=None):