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

Hierarchical: restructuring and add relative to InnerCalculatorCollector #1245

Merged
merged 66 commits into from
Jan 12, 2024

Conversation

Doresic
Copy link
Contributor

@Doresic Doresic commented Dec 12, 2023

Complete restructuring of the hierarchical module.

  • The formerly named hierarchical module which optimizes scaling, offset, and noise of relative data was renamed to relative. Classes used by all non-quantitative data type hierarchical algorithms (ordinal, relative, and semiquantitative) were moved to base_... files, while the classes and functions related specifically to relative data (scaling and offset problem, calculator, solver etc...) were moved to the hierarchical relative sub-module.

  • Renamed the former optimal_scaling module used for ordinal data to ordinal to remove any confusion regarding a similar name of scaling parameters for relative data.

  • Renamed the former spline_approximation module to semiquantitative. Now all hierarchical submodules are called after the data they integrate with rather than the method they use.

  • A lot of Class renaming to fit the renaming already mentioned.

  • Included the relative method (scaling and offset) into the InnerCalculatorCollector. Now, one can have a PEtab problem containing all three types of observables: relative, ordinal, and semiquantitative observables.

  • Added hierarchical PEtab validation to prevent things like specifying relative observables with semiquantitative data etc...

  • Fixed visualizations, docs, and tests to work with the renaming.

  • The RelativeCalculator has two operating modes: call_amici_twice and calculate_directly. The former is the old implementation of the calculator. It simulates the model twice. However, this can be used only if relative data is the only non-quantitative data type. In this case, one can use 2nd order sensitivities and adjoint sensitivity analysis as before. These two are not implemented for the latter mode calculate_directly. This mode will simulate only once, and calculate the objective function and gradient directly (but only for the relative data, not other data). It can be used only with forward sensitivity analysis since it uses sensitivities in the gradient calculation.

Doresic and others added 18 commits August 7, 2023 13:41
Inner parameters were not being stored when the result was stored. This was due to a problem with putting a dictionary into an HDF5 format. I've transformed it into 2 lists now: a INNER_PARAMETERS_VALUES and INNER_PARAMETER_NAMES list.
- Restructuring of the hierarchical scaling+offset method. The base classes used by all non-quantitative and semi-quantitative data types are put in the `base_...` files. All classes related to the scaling+offset method (for relative data) is moved to the `relative` folder, analogous to other data types.
- Renaming: the naming scheme doesn't follow the method, but the data type now. It's more direct and removes the ambiguity of `OptimalScaling` for ordinal data and `scaling_offset` for relative data.
- Optimal scaling -> ordinal
- Spline approximation -> semiquantitative
- Scaling + offset -> relative
@Doresic Doresic changed the base branch from main to develop December 12, 2023 15:49
@codecov-commenter
Copy link

codecov-commenter commented Dec 12, 2023

Codecov Report

Attention: 102 lines in your changes are missing coverage. Please review.

Comparison is base (8d9cf12) 84.59% compared to head (407dece) 84.28%.

Files Patch % Lines
pypesto/hierarchical/petab.py 44.28% 39 Missing ⚠️
pypesto/hierarchical/relative/calculator.py 77.92% 17 Missing ⚠️
pypesto/hierarchical/base_problem.py 83.69% 15 Missing ⚠️
pypesto/visualize/spline_approximation.py 30.76% 9 Missing ⚠️
pypesto/hierarchical/relative/problem.py 64.70% 6 Missing ⚠️
pypesto/petab/importer.py 87.09% 4 Missing ⚠️
pypesto/hierarchical/inner_calculator_collector.py 94.64% 3 Missing ⚠️
pypesto/hierarchical/relative/solver.py 96.49% 2 Missing ⚠️
...ypesto/hierarchical/semiquantitative/calculator.py 66.66% 2 Missing ⚠️
pypesto/hierarchical/ordinal/calculator.py 80.00% 1 Missing ⚠️
... and 4 more

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1245      +/-   ##
===========================================
- Coverage    84.59%   84.28%   -0.32%     
===========================================
  Files          148      151       +3     
  Lines        12122    12331     +209     
===========================================
+ Hits         10255    10393     +138     
- Misses        1867     1938      +71     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Doresic Doresic marked this pull request as ready for review January 8, 2024 15:22
Copy link
Contributor

@FFroehlich FFroehlich left a comment

Choose a reason for hiding this comment

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

Only looked at changes in pypesto/petab/importer.py and complained about files where I don't think I should be codeowner.

pypesto/petab/importer.py Outdated Show resolved Hide resolved
pypesto/petab/importer.py Outdated Show resolved Hide resolved
pypesto/petab/importer.py Outdated Show resolved Hide resolved
pypesto/testing/examples.py Show resolved Hide resolved
test/run_notebook.sh Show resolved Hide resolved
doc/example/ordinal_data.ipynb Show resolved Hide resolved
doc/example/relative_data.ipynb Outdated Show resolved Hide resolved
doc/example/semiquantitative_data.ipynb Outdated Show resolved Hide resolved
pypesto/C.py Show resolved Hide resolved
Copy link
Member

@dweindl dweindl left a comment

Choose a reason for hiding this comment

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

Thanks for cleaning that up.

Smaller pull requests strongly preferred.

Looks good as far as I can tell.

doc/example/censored_data.ipynb Outdated Show resolved Hide resolved
pypesto/hierarchical/__init__.py Outdated Show resolved Hide resolved
pypesto/hierarchical/base_problem.py Outdated Show resolved Hide resolved
pypesto/hierarchical/base_problem.py Outdated Show resolved Hide resolved
pypesto/hierarchical/base_problem.py Outdated Show resolved Hide resolved
pypesto/hierarchical/petab.py Outdated Show resolved Hide resolved
pypesto/hierarchical/petab.py Show resolved Hide resolved
pypesto/hierarchical/relative/problem.py Outdated Show resolved Hide resolved
pypesto/hierarchical/relative/solver.py Outdated Show resolved Hide resolved
pypesto/hierarchical/relative/solver.py Outdated Show resolved Hide resolved
Copy link
Contributor

@stephanmg stephanmg left a comment

Choose a reason for hiding this comment

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

Looks good, and thanks for cleaning up the code. See my comments.

@m-philipps
Copy link
Contributor

Is there an option to pre-view the documentation?

@Doresic
Copy link
Contributor Author

Doresic commented Jan 9, 2024

Is there an option to pre-view the documentation?

Yes, it should be possible by clicking on the readthedocs test and then view Docs (if it runs successfully). @m-philipps

.github/CODEOWNERS Outdated Show resolved Hide resolved
@Doresic Doresic merged commit ebdf99c into develop Jan 12, 2024
18 checks passed
@Doresic Doresic deleted the collect_hierarchical_calculators branch January 12, 2024 09:20
This was referenced Jan 30, 2024
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.

Hierarchical optimization: avoid extra simulations
8 participants