4. Code Overview¶
4.1. Modules in COMBO¶
Instruction to import the modules in COMBO:
Relative import 'gp', should be 'combo.gp' (relative-import)
Relative import 'opt', should be 'combo.opt' (relative-import)
Relative import 'blm', should be 'combo.blm' (relative-import)
Relative import 'misc', should be 'combo.misc' (relative-import)
Relative import 'search', should be 'combo.search' (relative-import)
Relative import 'predictor', should be 'combo.predictor' (relative-import)
Relative import 'variable', should be 'combo.variable' (relative-import)
4.2. Structure of COMBO¶
The files in each directory:
|-- blm
| |-- basis
| | |-- fourier.py
| | `-- __init__.py
| |-- core
| | |-- __init__.py
| | `-- model.py
| |-- inf
| | |-- exact.py
| | `-- __init__.py
| |-- __init__.py
| |-- lik
| | |-- gauss.py
| | |-- __init__.py
| | |-- linear.py
| | `-- _src
| | |-- cov.py
| | `-- __init__.py
| |-- predictor.py
| `-- prior
| |-- gauss.py
| `-- __init__.py
|-- gp
| |-- core
| | |-- __init__.py
| | |-- learning.py
| | |-- model.py
| | `-- prior.py
| |-- cov
| | |-- gauss.py
| | |-- gauss.pyc
| | |-- __init__.py
| | `-- _src
| | |-- enhance_gauss.c
| | |-- enhance_gauss.pyx
| | |-- __init__.py
| | `-- __init__.pyc
| |-- inf
| | |-- exact.py
| | `-- __init__.py
| |-- __init__.py
| |-- lik
| | |-- gauss.py
| | `-- __init__.py
| |-- mean
| | |-- const.py
| | |-- __init__.py
| | `-- zero.py
| `-- predictor.py
|-- __init__.py
|-- misc
| |-- centering.py
| |-- gauss_elim.py
| |-- __init__.py
| |-- set_config.py
| `-- _src
| |-- cholupdate.c
| |-- cholupdate.pyx
| |-- diagAB.c
| |-- diagAB.pyx
| |-- __init__.py
| |-- logsumexp.c
| |-- logsumexp.pyx
| |-- traceAB.c
| `-- traceAB.pyx
|-- opt
| |-- adam.py
| `-- __init__.py
|-- predictor.py
|-- search
| |-- call_simulator.py
| |-- discrete
| | |-- __init__.py
| | |-- policy.py
| | `-- results.py
| |-- __init__.py
| |-- score.py
| `-- utility.py
`-- variable.py
4.3. Classes and functions in COMBO¶
4.3.1. variable object¶
COMBO defines a python class called variable to setup and handle the dataset in the training and testing. From a python script, variable object can be created like this:
>>>from combo.variable import variable
>>>import numpy as np
>>>X= np.array([[1,2,3,4], [5,6,7,8], [9,10,11,12]])
>>>t=np.array([[1], [5], [9]])
>>>Z=np.array([[2,6,3,4], [9,6,10,8], [22,10,11,12]])
>>>vtest=variable(X,t,Z)
>>>print vtest.X
-
class
combo.variable.variable¶ -
-
t¶ -
array_like
-
Z¶ -
array_like
-
get_subset(index)¶
-
delete(num_row)¶
-
add(X, t, Z)¶
-
delete_X(num_row)¶
-
delete_t(num_row)¶
-
delete_Z(num_row)¶
-
add_X(X)¶
-
add_t(t)¶
-
add_Z(Z)¶
-
save(filename)¶
-
load(filename)¶
-
-
class
combo.predictor.base_predictor¶ -
config¶
-
model¶
-
fit()¶
-
prepare()¶
-
delete_stats()¶
-
get_basis()¶
-
get_post_fmean()¶
-
get_post_fcov()¶
-
get_post_params()¶
-
get_post_samples()¶
-
-
combo.misc.centering(X)¶ standardize the data X and remove the columns with zero value
\[X_{1,1\sigma}=\frac{X_{i}-\bar{X}_S}{\sigma_{X,S}}\]Parameters: X – input data Return type: return the standardized data for the columns with non-zero values
-
combo.misc.gauss_elim(L, t)¶ Parameters: - L –
- t –
Return type: return
-
combo.misc.set_config.boolean(str)¶ Parameters: str – Return type: return a boolean value
-
combo.search.utility.show_search_results(history, N)¶ Parameters: - history –
- N –
-
combo.search.utility.show_start_message_multi_search(N, score=None)¶ Parameters: - N –
- score –
-
combo.search.utility.show_interactive_mode(simulator, history)¶ Parameters: - simulator –
- history –
-
combo.search.utility.is_learning(n, interval)¶ Parameters: - n –
- interval –
-
combo.search.call_simulator(simu, action)¶ Parameters: - simu –
- action –
-
combo.search.score.EI(predictor, training, test, fmax=None)¶ Parameters: - predictor –
- training –
- test –
- fmax –
Return type: return score
-
combo.search.score.PI(predictor, training, test, fmax=None)¶ Parameters: - predictor –
- training –
- test –
- fmax –
Return type: return score
-
combo.search.score.TS(predictor, training, test, alpha=1)¶ Parameters: - predictor –
- training –
- test –
- alpha –
Return type: return score
-
class
combo.search.discrete.policy.policy¶ -
set_seed()¶
-
delete_actions()¶
-
write()¶
-
random_search()¶
-
bayes_search()¶
-
get_score()¶
-
get_marginal_score()¶
-
get_actions()¶
-
get_random_action()¶
-
load()¶
-
export_predictor()¶
-
export_training()¶
-
export_history()¶
-
_set_predictor()¶
-
_init_predictor()¶
-
_set_training()¶
-
_set_unchosed_actions()¶
-
_set_test()¶
-
_set_config()¶
-
-
class
combo.search.discrete.results.history¶ -
write()¶
-
export_sequence_best_fx()¶
-
export_all_sequence_best_fx()¶
-
save()¶
-
load()¶
-
-
class
combo.gp.predictor.predictor¶ -
fit()¶
-
get_basis()¶
-
get_post_params()¶
-
prepare()¶
-
delete_stats()¶
-
get_post_fmean()¶
-
get_post_fcov()¶
-
get_post_samples()¶
-
get_predict_samples()¶
-
-
class
combo.gp.core.learning.online¶ -
run()¶
-
one_run()¶
-
disp_marlik()¶
-
init_params_search()¶
-
get_one_update()¶
-
-
class
combo.gp.core.model.model¶ -
cat_params()¶
-
decomp_params()¶
-
set_params()¶
-
sub_sampling()¶
-
export_blm()¶
-
eval_marlik()¶
-
get_grad_marlik()¶
-
get_params_bound()¶
-
prepare()¶
-
get_post_fmean()¶
-
get_post_fcov()¶
-
post_sampling()¶
-
predict_sampling()¶
-
print_params()¶
-
get_cand_params()¶
-
fit()¶
-
-
class
combo.gp.core.prior¶ -
cat_params()¶
-
decomp_params()¶
-
get_mean()¶
-
get_cov()¶
-
get_grad_mean()¶
-
get_grad_cov()¶
-
set_params()¶
-
set_mean_params()¶
-
set_cov_params()¶
-
sampling()¶
-
-
class
combo.gp.cov.gauss.gauss¶ -
cat_params()¶
-
print_params()¶
-
prepare()¶
-
get_grad()¶
-
get_cov()¶
-
set_params()¶
-
supp_params()¶
-
decomp_params()¶
-
save()¶
-
load()¶
-
get_params_bound()¶
-
cat_params()
-
rand_expans()¶
-
get_cand_params()¶
-
-
combo.gp.inf.exact.eval_marlik(gp, X, t, params = None)¶ Parameters: - gp –
- X –
- t –
- params –
Return type: return marlik
-
combo.gp.inf.exact.get_grad_marlik(gp, X, t, params = None)¶ Parameters: - gp –
- X –
- t –
- params –
Return type: return grad_marlik
-
combo.gp.inf.exact.prepare(gp, X, t, params = None)¶ Parameters: - gp –
- X –
- t –
- params –
Return type: return stats
-
combo.gp.inf.get_post_fmean(gp, X, t, params = None)¶ Parameters: - gp –
- X –
- t –
- params –
Return type: return G.dot(alpha) + fmu
-
combo.gp.inf.get_post_fcov(gp, X, t, params = None, diag = True)¶ Parameters: - gp –
- X –
- t –
- params –
- diag –
Return type: post_cov
-
class
combo.gp.lik.gauss.gauss¶ -
supp_params()¶
-
trans_params()¶
-
get_params_bound()¶
-
get_cov()¶
-
get_grad()¶
-
set_params()¶
-
get_cand_params()¶
-
sampling()¶
-
-
class
combo.gp.mean.const.const¶ -
supp_params()¶
-
get_params_bound()¶
-
get_mean()¶
-
get_grad()¶
-
set_params()¶
-
init_params()¶
-
get_cand_params()¶
-
-
class
combo.blm.predictor.predictor¶ -
fit()¶
-
prepare()¶
-
delete_stats()¶
-
get_basis()¶
-
get_post_fmean()¶
-
get_post_fcov()¶
-
get_post_params()¶
-
get_post_samples()¶
-
get_predict_samples()¶
-
update()¶
-
-
class
combo.blm.basis.fourier¶ -
get_basis()¶
-
set_params()¶
-
show()¶
-
_check_params()¶
-
_check_len_params()¶
-
-
class
combo.blm.core.model.model¶ -
prepare()¶
-
update_stats()¶
-
get_post_params_mean()¶
-
get_post_fmean()¶
-
sampling()¶
-
post_sampling()¶
-
predict_sampling()¶
-
get_post_fcov()¶
-
_set_options()¶
-
_init_prior()¶
-
-
combo.blm.inf.exact.prepare(blm, X, t, Psi = None)¶ Parameters: - blm –
- X –
- t –
- Psi –
-
combo.blm.inf.exact.update_stats(blm, x, t, Psi = None)¶ Parameters: - blm –
- x –
- t –
- Psi –
Return type: return ( L, b, alpha )
-
combo.blm.inf.exact.sampling(blm, w_mu = None, N=1, alpha = 1.0)¶ Parameters: - blm –
- w_mu –
- N –
- alpha –
Return type: return (invLz.transpose() + w_mu).transpose()
-
combo.blm.inf.exact.get_post_params_mean(blm)¶ Parameters: blm – Return type: return blm.stats[2] * blm.lik.cov.prec
-
combo.blm.inf.exact.get_post_fmean(blm, X, Psi = None, w = None)¶ Parameters: - blm –
- X –
- Psi –
- w –
Return type: return Psi.dot(w) + blm.lik.linear.bias
-
combo.blm.inf.exact.get_post_fcov(blm, X, Psi = None, diag = True)¶ Parameters: - blm –
- X –
- Psi –
- diag –
Return type: return fcov
-
class
combo.blm.lik.gauss.gauss¶ -
get_cov()¶
-
get_prec()¶
-
get_basis()¶
-
get_mean()¶
-
set_params()¶
-
set_bias()¶
-
sampling()¶
-