mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-10 04:22:38 +02:00
[examples] added bgplvm stochastic example and parameter for dimensionality
This commit is contained in:
parent
191cf82c0f
commit
5d772a8c11
1 changed files with 32 additions and 2 deletions
|
|
@ -393,12 +393,12 @@ def ssgplvm_simulation(optimize=True, verbose=1,
|
||||||
|
|
||||||
def bgplvm_simulation_missing_data(optimize=True, verbose=1,
|
def bgplvm_simulation_missing_data(optimize=True, verbose=1,
|
||||||
plot=True, plot_sim=False,
|
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 import kern
|
||||||
from GPy.models.bayesian_gplvm_minibatch import BayesianGPLVMMiniBatch
|
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)
|
_, _, Ylist = _simulate_matern(D1, D2, D3, N, num_inducing, plot_sim)
|
||||||
Y = Ylist[0]
|
Y = Ylist[0]
|
||||||
k = kern.Linear(Q, ARD=True) # + kern.white(Q, _np.exp(-2)) # + kern.bias(Q)
|
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')
|
m.kern.plot_ARD('BGPLVM Simulation ARD Parameters')
|
||||||
return m
|
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):
|
def mrd_simulation(optimize=True, verbose=True, plot=True, plot_sim=True, **kw):
|
||||||
from GPy import kern
|
from GPy import kern
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue