Skip to content
Snippets Groups Projects
Commit b8a548a7 authored by kohlhaasrebecca's avatar kohlhaasrebecca
Browse files

[docs] Basic BMC user guide

parent d9a56ff1
No related branches found
No related tags found
2 merge requests!32Merge last changes for new release,!31Finalize webpage and bug fixes
Showing
with 157 additions and 20 deletions
...@@ -17,19 +17,11 @@ bayesvalidrox.surrogate\_models.engine.Engine ...@@ -17,19 +17,11 @@ bayesvalidrox.surrogate\_models.engine.Engine
.. autosummary:: .. autosummary::
~Engine.__init__ ~Engine.__init__
~Engine.choose_next_sample
~Engine.dual_annealing
~Engine.eval_metamodel ~Engine.eval_metamodel
~Engine.run_util_func
~Engine.start_engine ~Engine.start_engine
~Engine.tradeoff_weights
~Engine.train_normal ~Engine.train_normal
~Engine.train_seq_design ~Engine.train_seq_design
~Engine.train_sequential ~Engine.train_sequential
~Engine.util_AlphOptDesign
~Engine.util_BayesianActiveDesign
~Engine.util_BayesianDesign
~Engine.util_VarBasedDesign
......
...@@ -9,15 +9,6 @@ bayesvalidrox.surrogate\_models.engine ...@@ -9,15 +9,6 @@ bayesvalidrox.surrogate\_models.engine
.. rubric:: Functions
.. autosummary::
:toctree:
hellinger_distance
logpdf
subdomain
......
bayesvalidrox.surrogate\_models bayesvalidrox.surrogate\_models
=============================== ===============================
.. automodule:: bayesvalidrox.surrogate_models .. automodule:: bayesvalidrox.surrogate_models
...@@ -41,5 +41,6 @@ bayesvalidrox.surrogate\_models ...@@ -41,5 +41,6 @@ bayesvalidrox.surrogate\_models
bayesvalidrox.surrogate_models.orthogonal_matching_pursuit bayesvalidrox.surrogate_models.orthogonal_matching_pursuit
bayesvalidrox.surrogate_models.reg_fast_ard bayesvalidrox.surrogate_models.reg_fast_ard
bayesvalidrox.surrogate_models.reg_fast_laplace bayesvalidrox.surrogate_models.reg_fast_laplace
bayesvalidrox.surrogate_models.sequential_design
bayesvalidrox.surrogate_models.surrogate_models bayesvalidrox.surrogate_models.surrogate_models
bayesvalidrox.surrogate\_models.sequential\_design.SequentialDesign
===================================================================
.. currentmodule:: bayesvalidrox.surrogate_models.sequential_design
.. autoclass:: SequentialDesign
:members:
:show-inheritance:
:inherited-members:
.. automethod:: __init__
.. rubric:: Methods
.. autosummary::
~SequentialDesign.__init__
~SequentialDesign.choose_next_sample
~SequentialDesign.dual_annealing
~SequentialDesign.run_util_func
~SequentialDesign.start_seqdesign
~SequentialDesign.tradeoff_weights
~SequentialDesign.util_AlphOptDesign
~SequentialDesign.util_BayesianActiveDesign
~SequentialDesign.util_BayesianDesign
~SequentialDesign.util_VarBasedDesign
\ No newline at end of file
bayesvalidrox.surrogate\_models.sequential\_design.hellinger\_distance
======================================================================
.. currentmodule:: bayesvalidrox.surrogate_models.sequential_design
.. autofunction:: hellinger_distance
\ No newline at end of file
bayesvalidrox.surrogate\_models.sequential\_design.logpdf
=========================================================
.. currentmodule:: bayesvalidrox.surrogate_models.sequential_design
.. autofunction:: logpdf
\ No newline at end of file
bayesvalidrox.surrogate\_models.sequential\_design
==================================================
.. automodule:: bayesvalidrox.surrogate_models.sequential_design
.. rubric:: Functions
.. autosummary::
:toctree:
hellinger_distance
logpdf
subdomain
.. rubric:: Classes
.. autosummary::
:toctree:
:template: custom-class-template.rst
SequentialDesign
bayesvalidrox.surrogate\_models.sequential\_design.subdomain
============================================================
.. currentmodule:: bayesvalidrox.surrogate_models.sequential_design
.. autofunction:: subdomain
\ No newline at end of file
...@@ -18,5 +18,66 @@ Bayesian multi-model comparison ...@@ -18,5 +18,66 @@ Bayesian multi-model comparison
Example Example
======= =======
To perform model comparison, we first need to define the set of competing models. To perform model comparison, we first need to define the set of competing models.
For this, we create two additional models based on the example model from :any:`model_description`. For this, we create an additional model in the file ``model2.py`` based on the example model from :any:`model_description`.
The first of these models
\ No newline at end of file >>> def model2(samples, x_values):
>>> poly = samples[0]*np.power(x_values, 3)
>>> outputs = {'A': poly, 'x_values': x_values}
>>> return outputs
Then we can build another surrogate for this model, following the same code as for the surrogate in :any:`surrogate_description`.
>>> Model2 = PyLinkForwardModel()
>>> Model2.link_type = 'Function'
>>> Model2.py_file = 'model2'
>>> Model2.name = 'model2'
>>> Model2.Output.names = ['A']
>>> Model2.func_args = {'x_values': x_values}
>>> Model2.store = False
>>> MetaMod2 = MetaModel(Inputs)
>>> MetaMod2.meta_model_type = 'aPCE'
>>> MetaMod2.pce_reg_method = 'FastARD'
>>> MetaMod2.pce_deg = 3
>>> MetaMod2.pce_q_norm = 1
>>> ExpDesign2 = ExpDesigns(Inputs)
>>> ExpDesign2.n_init_samples = 30
>>> ExpDesign2.sampling_method = 'random'
>>> Engine_2 = Engine(MetaMod2, Model2, ExpDesign2)
>>> Engine_2.train_normal()
To perform model comparison we use the class :any:`bayesvalidrox.bayes_inference.bayes_model_comparison.BayesModelComparison`.
>>> from bayesvalidrox import BayesModelComparison`
We collect the engines that should be compared in a dictionary, and assign them names.
>>> meta_models = {
>>> "linear": Engine_,
>>> "degthree": Engine_2
>>> }
Then we create an object of class ``BayesModelComparison``.
>>> BayesOpts = BayesModelComparison()
As the comparison uses the class :any:`bayesvalidrox.bayes_inference.bayes_inference.BayesInference`, we can also set the properties for this class as well.
These are collected in a dictionary and given to the function calls that perform the model comparison.
In this example we use the following settings.
>>> opts_bootstrap = {
>>> "bootstrap": True,
>>> "n_samples": 100,
>>> "Discrepancy": DiscrepancyOpts,
>>> "emulator": True,
>>> "plot_post_pred": False
>>> }
Now we can run the full model comparison.
>>> output_dict = BayesOpts.model_comparison_all(meta_models, opts_bootstrap)
The created plots are saved in the folder ``Outputs_Comparison``.
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment