mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-05 01:32:40 +02:00
Merge branch 'devel' into params
This commit is contained in:
commit
4f56506aa6
60 changed files with 1944 additions and 596 deletions
|
|
@ -10,31 +10,11 @@ import numpy as np
|
|||
import GPy
|
||||
|
||||
default_seed = 10000
|
||||
def crescent_data(seed=default_seed, kernel=None): # FIXME
|
||||
"""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)
|
||||
Y = data['Y']
|
||||
Y[Y.flatten()==-1] = 0
|
||||
|
||||
m = GPy.models.GPClassification(data['X'], Y)
|
||||
#m.update_likelihood_approximation()
|
||||
#m.optimize()
|
||||
m.pseudo_EM()
|
||||
print(m)
|
||||
m.plot()
|
||||
return m
|
||||
|
||||
def oil(num_inducing=50, max_iters=100, kernel=None):
|
||||
"""
|
||||
Run a Gaussian process classification on the three phase oil data. The demonstration calls the basic GP classification model and uses EP to approximate the likelihood.
|
||||
|
||||
"""
|
||||
data = GPy.util.datasets.oil()
|
||||
X = data['X']
|
||||
|
|
@ -64,8 +44,10 @@ def oil(num_inducing=50, max_iters=100, kernel=None):
|
|||
def toy_linear_1d_classification(seed=default_seed):
|
||||
"""
|
||||
Simple 1D classification example
|
||||
:param seed : seed value for data generation (default is 4).
|
||||
|
||||
:param seed: seed value for data generation (default is 4).
|
||||
:type seed: int
|
||||
|
||||
"""
|
||||
|
||||
data = GPy.util.datasets.toy_linear_1d_classification(seed=seed)
|
||||
|
|
@ -92,8 +74,10 @@ def toy_linear_1d_classification(seed=default_seed):
|
|||
def sparse_toy_linear_1d_classification(num_inducing=10,seed=default_seed):
|
||||
"""
|
||||
Sparse 1D classification example
|
||||
:param seed : seed value for data generation (default is 4).
|
||||
|
||||
:param seed: seed value for data generation (default is 4).
|
||||
:type seed: int
|
||||
|
||||
"""
|
||||
|
||||
data = GPy.util.datasets.toy_linear_1d_classification(seed=seed)
|
||||
|
|
@ -118,61 +102,13 @@ def sparse_toy_linear_1d_classification(num_inducing=10,seed=default_seed):
|
|||
|
||||
return m
|
||||
|
||||
def sparse_crescent_data(num_inducing=10, seed=default_seed, kernel=None):
|
||||
"""
|
||||
Run a Gaussian process classification with DTC approxiamtion 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)
|
||||
Y = data['Y']
|
||||
Y[Y.flatten()==-1]=0
|
||||
|
||||
m = GPy.models.SparseGPClassification(data['X'], Y, kernel=kernel, num_inducing=num_inducing)
|
||||
m['.*len'] = 10.
|
||||
#m.update_likelihood_approximation()
|
||||
#m.optimize()
|
||||
m.pseudo_EM()
|
||||
print(m)
|
||||
m.plot()
|
||||
return m
|
||||
|
||||
def FITC_crescent_data(num_inducing=10, seed=default_seed):
|
||||
"""
|
||||
Run a Gaussian process classification with FITC approximation on the crescent data. The demonstration 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 num_inducing: int
|
||||
"""
|
||||
|
||||
data = GPy.util.datasets.crescent_data(seed=seed)
|
||||
Y = data['Y']
|
||||
Y[Y.flatten()==-1]=0
|
||||
|
||||
m = GPy.models.FITCClassification(data['X'], Y,num_inducing=num_inducing)
|
||||
m.constrain_bounded('.*len',1.,1e3)
|
||||
m['.*len'] = 3.
|
||||
#m.update_likelihood_approximation()
|
||||
#m.optimize()
|
||||
m.pseudo_EM()
|
||||
print(m)
|
||||
m.plot()
|
||||
return m
|
||||
|
||||
|
||||
def toy_heaviside(seed=default_seed):
|
||||
"""
|
||||
Simple 1D classification example using a heavy side gp transformation
|
||||
:param seed : seed value for data generation (default is 4).
|
||||
|
||||
:param seed: seed value for data generation (default is 4).
|
||||
:type seed: int
|
||||
|
||||
"""
|
||||
|
||||
data = GPy.util.datasets.toy_linear_1d_classification(seed=seed)
|
||||
|
|
@ -198,3 +134,35 @@ def toy_heaviside(seed=default_seed):
|
|||
|
||||
return m
|
||||
|
||||
def crescent_data(model_type='Full', num_inducing=10, seed=default_seed, kernel=None):
|
||||
"""
|
||||
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 inducing: number of inducing variables (only used for 'FITC' or 'DTC').
|
||||
:type inducing: int
|
||||
:param seed: seed value for data generation.
|
||||
:type seed: int
|
||||
:param kernel: kernel to use in the model
|
||||
:type kernel: a GPy kernel
|
||||
"""
|
||||
data = GPy.util.datasets.crescent_data(seed=seed)
|
||||
Y = data['Y']
|
||||
Y[Y.flatten()==-1] = 0
|
||||
|
||||
if model_type == 'Full':
|
||||
m = GPy.models.GPClassification(data['X'], Y,kernel=kernel)
|
||||
|
||||
elif model_type == 'DTC':
|
||||
m = GPy.models.SparseGPClassification(data['X'], Y, kernel=kernel, num_inducing=num_inducing)
|
||||
m['.*len'] = 10.
|
||||
|
||||
elif model_type == 'FITC':
|
||||
m = GPy.models.FITCClassification(data['X'], Y, kernel=kernel, num_inducing=num_inducing)
|
||||
m['.*len'] = 3.
|
||||
|
||||
m.pseudo_EM()
|
||||
print(m)
|
||||
m.plot()
|
||||
|
||||
return m
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ def multiple_optima(gene_number=937, resolution=80, model_restarts=10, seed=1000
|
|||
length_scales = np.linspace(0.1, 60., resolution)
|
||||
log_SNRs = np.linspace(-3., 4., resolution)
|
||||
|
||||
data = GPy.util.datasets.della_gatta_TRP63_gene_expression(gene_number)
|
||||
data = GPy.util.datasets.della_gatta_TRP63_gene_expression(data_set='della_gatta',gene_number=gene_number)
|
||||
# data['Y'] = data['Y'][0::2, :]
|
||||
# data['X'] = data['X'][0::2, :]
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue