How to use the easyvvuq.analysis.EnsembleBoot function in easyvvuq

To help you get started, we’ve selected a few easyvvuq examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github UCL-CCS / EasyVVUQ / tests / test_worker.py View on Github external
# you that 'nothing has been collated' or something to that effect.
    ####

    print("Runs list after encoding and execution:")
    pprint(my_campaign.list_runs())

    # Collate all data into one pandas data frame
    my_campaign.collate()
    print("data:", my_campaign.get_collation_result())

    # Create a BasicStats analysis element and apply it to the campaign
    stats = uq.analysis.BasicStats(qoi_cols=['Dist', 'lastvx', 'lastvy'])
    my_campaign.apply_analysis(stats)
    print("stats:\n", my_campaign.get_last_analysis())

    bootstrap = uq.analysis.EnsembleBoot(groupby=['Dist'], qoi_cols=['lastv'])
    with pytest.raises(RuntimeError, match=r".* lastv"):
        my_campaign.apply_analysis(bootstrap)

    # Print the campaign log
    pprint(my_campaign._log)

    print("All completed?", my_campaign.all_complete())
github UCL-CCS / EasyVVUQ / tests / test_gauss.py View on Github external
# TODO: Assert no. samples in db = number_of_samples*number_of_replicas

    my_campaign.populate_runs_dir()

    assert(len(my_campaign.get_campaign_runs_dir()) > 0)
    runs_dir = my_campaign.get_campaign_runs_dir()
    assert(os.path.exists(runs_dir))
    assert(os.path.isdir(runs_dir))

    my_campaign.apply_for_each_run_dir(
        uq.actions.ExecuteLocal("tests/gauss/gauss_json.py gauss_in.json"))

    my_campaign.collate()

    # Create an EnsembleBoot analysis element and apply it to the campaign
    stats = uq.analysis.EnsembleBoot(groupby=["mu"], qoi_cols=["Value"])
    my_campaign.apply_analysis(stats)
    print("stats:", my_campaign.get_last_analysis())
github UCL-CCS / EasyVVUQ / tests / test_integration.py View on Github external
"bias2": {
            "type": "file", "path": "tests/gauss/bias2.txt",
            "common": False, "exists_local": True,
            "target": "",
            "group": ""
        }
    }
    encoder = uq.encoders.GenericEncoder(template_fname='tests/gauss/gauss.template',
                                         target_filename='gauss_in.json')
    fixtures_encoder = uq.encoders.ApplyFixtures(fixtures=fixtures)
    encoder_with_fixtures = uq.encoders.MultiEncoder(encoder, fixtures_encoder)

    decoder = GaussDecoder(target_filename=params['out_file']['default'])
    collater = uq.collate.AggregateSamples(average=False)
    actions = uq.actions.ExecuteLocal("tests/gauss/gauss_json.py gauss_in.json")
    stats = uq.analysis.EnsembleBoot(groupby=["mu"], qoi_cols=["Value"])
    vary = {
        "mu": cp.Uniform(1.0, 100.0),
    }
    sampler = uq.sampling.RandomSampler(vary=vary)
    campaign(tmpdir, 'gauss', 'gauss', params, encoder, decoder, sampler,
             collater, actions, stats, vary, 2, 2)
    encoder = GaussEncoder(target_filename='gauss_in.json')
    campaign(tmpdir, 'gauss', 'gauss', params, encoder, decoder, sampler,
             collater, actions, stats, vary, 2, 2)
    campaign(tmpdir, 'gauss', 'gauss', params, encoder_with_fixtures, decoder, sampler,
             collater, actions, stats, vary, 2, 2)
    campaign(tmpdir, 'gauss', 'gauss', params, encoder_with_fixtures, decoder, sampler,
             collater, actions, stats, vary, 2, 2, db_type='json')
github UCL-CCS / EasyVVUQ / tests / test_gauss_custom_encoder.py View on Github external
# TODO: Assert no. samples in db = number_of_samples*number_of_replicas

    my_campaign.populate_runs_dir()

    assert (len(my_campaign.get_campaign_runs_dir()) > 0)
    runs_dir = my_campaign.get_campaign_runs_dir()
    assert (os.path.exists(runs_dir))
    assert (os.path.isdir(runs_dir))

    my_campaign.apply_for_each_run_dir(
        uq.actions.ExecuteLocal("tests/gauss/gauss_json.py gauss_in.json"))

    my_campaign.collate()

    # Create a EnsembleBoot analysis element and apply it to the campaign
    stats = uq.analysis.EnsembleBoot(groupby=["mu"], qoi_cols=["Value"])
    my_campaign.apply_analysis(stats)
    print("stats:", my_campaign.get_last_analysis())
github UCL-CCS / EasyVVUQ / docs / tutorial_files / easyvvuq_restart_campaign_tutorial.py View on Github external
# 11. Load state in new campaign object
print("Reloading campaign...")
reloaded_campaign = uq.Campaign(state_file="campaign_state.json", work_dir=".")

# 12. Draw some more samples, execute the runs, and collate onto existing dataframe
reloaded_campaign.draw_samples(num_samples=1, replicas=5)
reloaded_campaign.populate_runs_dir()
my_campaign.apply_for_each_run_dir(uq.actions.ExecuteLocal(cmd, interpret='python3'))
reloaded_campaign.collate()

# 13. Print the list of runs again
pprint(reloaded_campaign.list_runs())

# 14. Run Analysis
#     - Calculate bootstrap statistics for collated data
stats = uq.analysis.EnsembleBoot(groupby=["mu"], qoi_cols=["Value"])
my_campaign.apply_analysis(stats)
print("stats:\n", my_campaign.get_last_analysis())
github UCL-CCS / EasyVVUQ / docs / tutorial_files / easyvvuq_gauss_tutorial.py View on Github external
# 6. Create run input directories
my_campaign.populate_runs_dir()

print(my_campaign)

# 7. Run Application
#    - gauss is executed for each sample
my_campaign.apply_for_each_run_dir(uq.actions.ExecuteLocal(cmd,
                                                           interpret='python3'))

# 8. Collate output
my_campaign.collate()

# 9. Run Analysis
#     - Calculate bootstrap statistics for collated data
stats = uq.analysis.EnsembleBoot(groupby=["mu"], qoi_cols=["Value"])
my_campaign.apply_analysis(stats)
print("stats:\n", my_campaign.get_last_analysis())