Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First runner manipulating statistical model #47

Merged
merged 12 commits into from
Jul 21, 2023
Merged

First runner manipulating statistical model #47

merged 12 commits into from
Jul 21, 2023

Conversation

dachengx
Copy link
Collaborator

@dachengx dachengx commented Jul 19, 2023

Trying to resolve #3 and #16

What does the code in this PR do / what does it improve?

The runner manipulates the statistical model.

It:

  1. initializes statistical model
  2. generates or read toy data
  3. saves toy data if needed
  4. fits parameters
  5. writes output file

Can you briefly describe how it works?

The changes except in runner.py is only some format changes, not crucial.

likelihood_config should be contained in statistical_model_args if needed.
fit_guesses is defined in Parameters.

Can you give a minimal working example (or illustrate with a figure)?

from alea.runner import Runner

parameter_definition = {
    'mu': {
        'fit_guess': 0.0,
        'fittable': True,
        'nominal_value': 0.0
    },
    'sigma': {
        'fit_guess': 1.0,
        'fit_limits': [
            0,
            None
        ],
        'fittable': True,
        'nominal_value': 1.0
    }
}

toydata-generating runner:

generate_runner = Runner(
    statistical_model='alea.examples.gaussian_model.GaussianModel',
    parameter_definition=config['parameter_definition'],
    poi='mu',
    hypotheses=['free', 'null', 'true'],
    common_generate_values={'sigma': 1.},
    true_generate_values={'mu': 1., 'sigma': 1.},
    n_mc=3,
    toydata_file=toydata_file,
    toydata_mode='generate_and_write',
    output_file='test_toymc_generate.hdf5',
)
generate_runner.run()

toydata-reading runner:

read_runner = Runner(
    statistical_model='alea.examples.gaussian_model.GaussianModel',
    parameter_definition=config['parameter_definition'],
    poi='mu',
    hypotheses=['free', 'null', 'true'],
    common_generate_values={'sigma': 1.},
    true_generate_values={'mu': 1., 'sigma': 1.},
    n_mc=3,
    toydata_file=toydata_file,
    toydata_mode='read',
    output_file='test_toymc_read.hdf5',
)
read_runner.run()

What are the potential drawbacks of the codes?

Things should be implemented later:

  1. ancillary measurement terms stored in and read from toy file
  2. confidential intervals
  3. handle multiple likelihoods

Please include the following if applicable:

  • Update the docstring(s)
  • Update the documentation
  • Tests to check the (new) code is working as desired.
  • Does it solve one of the open issues on github?

Notes on testing

  • Until the automated tests pass, please mark the PR as a draft.

All italic comments can be removed from this template.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit

pep8

alea/runner.py|75 col 1| D102 Missing docstring in public method
alea/runner.py|75 col 5| WPS615 Found unpythonic getter or setter
alea/runner.py|90 col 70| C812 missing trailing comma
alea/runner.py|100 col 1| D102 Missing docstring in public method
alea/runner.py|103 col 9| WPS221 Found line with high Jones Complexity: 15 > 14
alea/runner.py|105 col 22| WPS510 Found in used with a non-set container
alea/runner.py|113 col 48| WPS441 Found control variable used after block: ea
alea/runner.py|124 col 1| D102 Missing docstring in public method
alea/runner.py|128 col 1| D102 Missing docstring in public method
alea/runner.py|158 col 101| E501 line too long (105 > 100 characters)
alea/runner.py|175 col 1| D102 Missing docstring in public method
alea/statistical_model.py|60 col 9| E121 continuation line under-indented for hanging indent
alea/statistical_model.py|60 col 9| E125 continuation line with same indent as next logical line
alea/examples/gaussian_model.py|14 col 5| E125 continuation line with same indent as next logical line
alea/examples/gaussian_model.py|14 col 9| E121 continuation line under-indented for hanging indent

alea/blueice_extended_model.py Outdated Show resolved Hide resolved
alea/blueice_extended_model.py Outdated Show resolved Hide resolved
alea/blueice_extended_model.py Outdated Show resolved Hide resolved
alea/blueice_extended_model.py Outdated Show resolved Hide resolved
alea/blueice_extended_model.py Outdated Show resolved Hide resolved
alea/runner.py Outdated Show resolved Hide resolved
alea/runner.py Outdated Show resolved Hide resolved
alea/runner.py Outdated Show resolved Hide resolved
alea/runner.py Outdated Show resolved Hide resolved
alea/runner.py Outdated Show resolved Hide resolved
@dachengx dachengx changed the title First runner First runner manipulating statistical model Jul 19, 2023
alea/blueice_extended_model.py Outdated Show resolved Hide resolved
alea/blueice_extended_model.py Outdated Show resolved Hide resolved
alea/blueice_extended_model.py Outdated Show resolved Hide resolved
alea/blueice_extended_model.py Outdated Show resolved Hide resolved
alea/blueice_extended_model.py Outdated Show resolved Hide resolved
alea/runner.py Show resolved Hide resolved
alea/statistical_model.py Show resolved Hide resolved
alea/statistical_model.py Show resolved Hide resolved
alea/examples/gaussian_model.py Show resolved Hide resolved
alea/examples/gaussian_model.py Show resolved Hide resolved
alea/blueice_extended_model.py Show resolved Hide resolved
alea/blueice_extended_model.py Show resolved Hide resolved
alea/blueice_extended_model.py Show resolved Hide resolved
alea/blueice_extended_model.py Show resolved Hide resolved
alea/runner.py Show resolved Hide resolved
alea/runner.py Show resolved Hide resolved
alea/runner.py Show resolved Hide resolved
alea/runner.py Show resolved Hide resolved
alea/runner.py Show resolved Hide resolved
alea/runner.py Show resolved Hide resolved
alea/runner.py Show resolved Hide resolved
alea/runner.py Show resolved Hide resolved
alea/runner.py Show resolved Hide resolved
alea/runner.py Show resolved Hide resolved
alea/runner.py Show resolved Hide resolved
alea/runner.py Show resolved Hide resolved
alea/runner.py Show resolved Hide resolved
@dachengx dachengx requested review from kdund and hammannr July 19, 2023 14:26
@kdund
Copy link
Collaborator

kdund commented Jul 21, 2023

Quite a bit of linting-- are you using an automatic tool for it, @dachengx ?
If so, could you run that tool on main, and make a PR for all the linting there? That way, there will be fewer changes highlighted here.

@dachengx dachengx removed request for kdund and hammannr July 21, 2023 17:35
@dachengx
Copy link
Collaborator Author

Quite a bit of linting-- are you using an automatic tool for it, @dachengx ? If so, could you run that tool on main, and make a PR for all the linting there? That way, there will be fewer changes highlighted here.

A new PR is copped here: #49

@kdund kdund merged commit 9c176a9 into main Jul 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve naming of toydata_mode
2 participants