From f724ec1e742671eadfa0f4385d5105c7b3f60fe5 Mon Sep 17 00:00:00 2001 From: kohlhaasrebecca <rebecca.kohlhaas@outlook.com> Date: Fri, 28 Jun 2024 15:24:34 +0200 Subject: [PATCH] User guide for active learning --- docs/source/al_description.rst | 34 +++++++++++++++++++++++ examples/user_guide/example_user_guide.py | 16 +++++++++++ 2 files changed, 50 insertions(+) diff --git a/docs/source/al_description.rst b/docs/source/al_description.rst index c1d5e99f2..7922be0f8 100644 --- a/docs/source/al_description.rst +++ b/docs/source/al_description.rst @@ -25,3 +25,37 @@ The tradeoff between exploration and exploitation is defined by **tradeoff-schem Example ======= We take the engine from :any:`surrogate_description` and change the settings to perform sequential training. + +This mainly changes the ``Engine``. +We set the ``method`` to ``'sequential'`` to indicate that active learning should be performed. +For this example we start with the 10 initial samples from :any:`surrogate_description` and increase this iteratively to the number of samples given in ``n_max_samples``. +The parameter ``n_new_samples`` sets the number of new samples that are chosen in each iteration, while ``mod_LOO_threshold`` sets an additional stopping condition. + +>>> ExpDesign.method = 'sequential' +>>> ExpDesign.n_max_samples = 14 +>>> ExpDesign.n_new_samples = 1 +>>> ExpDesign.mod_LOO_threshold = 1e-16 + +Here we do not set a ``tradeoff_scheme``. +This will result in all samples being chosen based on the exploration weights. + +>>> ExpDesign.tradeoff_scheme = None + +As the proposed samples come from the exploration method, we still need to define this. + +>>> ExpDesign.explore_method = 'random' +>>> ExpDesign.n_canddidate = 1000 +>>> ExpDesign.n_cand_groups = 4 + +For the exploitation method we use a variance-based method, as no data is given. + +>>> ExpDesign.exploit_method = 'VarOptDesign' +>>> ExpDesign.util_func = 'EIGF' + +Once all properties are set, we can assemble the engine and start it. +This time we use ``train_sequential``. + +>>> Engine_ = Engine(MetaMod, Model, ExpDesign) +>>> Engine_.start_engine() +>>> Engine_.train_sequential() + \ No newline at end of file diff --git a/examples/user_guide/example_user_guide.py b/examples/user_guide/example_user_guide.py index 563850ddc..0a1f5ed06 100644 --- a/examples/user_guide/example_user_guide.py +++ b/examples/user_guide/example_user_guide.py @@ -77,6 +77,22 @@ if __name__ == '__main__': mean, stdev = Engine_.eval_metamodel(nsamples = 10) mean, stdev = Engine_.MetaModel.eval_metamodel(samples) + #### Active learning + ExpDesign.method = 'sequential' + + # Set the sampling parameters + ExpDesign.n_new_samples = 1 + ExpDesign.n_max_samples = 14 + ExpDesign.mod_LOO_threshold = 1e-16 + ExpDesign.tradeoff_scheme = None + ExpDesign.explore_method = 'random' + ExpDesign.n_canddidate = 1000 + ExpDesign.n_cand_groups = 4 + ExpDesign.exploit_method = 'VarOptDesign' + ExpDesign.util_func = 'EIGF' + Engine_ = Engine(MetaMod, Model, ExpDesign) + Engine_.start_engine() + Engine_.train_sequential() #### Postprocessing PostProc = PostProcessing(Engine_) -- GitLab