[examples] added bgplvm stochastic example and parameter for dimensionality

This commit is contained in:
Max Zwiessele 2015-12-03 08:48:28 +00:00
parent 191cf82c0f
commit 5d772a8c11

View file

@ -393,12 +393,12 @@ def ssgplvm_simulation(optimize=True, verbose=1,
def bgplvm_simulation_missing_data(optimize=True, verbose=1,
plot=True, plot_sim=False,
max_iters=2e4, percent_missing=.1,
max_iters=2e4, percent_missing=.1, d=13,
):
from GPy import kern
from GPy.models.bayesian_gplvm_minibatch import BayesianGPLVMMiniBatch
D1, D2, D3, N, num_inducing, Q = 13, 5, 8, 400, 3, 4
D1, D2, D3, N, num_inducing, Q = d, 5, 8, 400, 3, 4
_, _, Ylist = _simulate_matern(D1, D2, D3, N, num_inducing, plot_sim)
Y = Ylist[0]
k = kern.Linear(Q, ARD=True) # + kern.white(Q, _np.exp(-2)) # + kern.bias(Q)
@ -421,6 +421,36 @@ def bgplvm_simulation_missing_data(optimize=True, verbose=1,
m.kern.plot_ARD('BGPLVM Simulation ARD Parameters')
return m
def bgplvm_simulation_missing_data_stochastics(optimize=True, verbose=1,
plot=True, plot_sim=False,
max_iters=2e4, percent_missing=.1, d=13, batchsize=2,
):
from GPy import kern
from GPy.models.bayesian_gplvm_minibatch import BayesianGPLVMMiniBatch
D1, D2, D3, N, num_inducing, Q = d, 5, 8, 400, 3, 4
_, _, Ylist = _simulate_matern(D1, D2, D3, N, num_inducing, plot_sim)
Y = Ylist[0]
k = kern.Linear(Q, ARD=True) # + kern.white(Q, _np.exp(-2)) # + kern.bias(Q)
inan = _np.random.binomial(1, percent_missing, size=Y.shape).astype(bool) # 80% missing data
Ymissing = Y.copy()
Ymissing[inan] = _np.nan
m = BayesianGPLVMMiniBatch(Ymissing, Q, init="random", num_inducing=num_inducing,
kernel=k, missing_data=True, stochastic=True, batchsize=batchsize)
m.Yreal = Y
if optimize:
print("Optimizing model:")
m.optimize('bfgs', messages=verbose, max_iters=max_iters,
gtol=.05)
if plot:
m.X.plot("BGPLVM Latent Space 1D")
m.kern.plot_ARD('BGPLVM Simulation ARD Parameters')
return m
def mrd_simulation(optimize=True, verbose=True, plot=True, plot_sim=True, **kw):
from GPy import kern