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

feat: model prediction API and yield table changes #267

Merged
merged 16 commits into from
Aug 25, 2021

Conversation

alexander-held
Copy link
Member

@alexander-held alexander-held commented Aug 25, 2021

This changes the visualization.data_mc API. Previously, this function took an optional fit_results argument to steer which model prediction is included in plots. The generation of the model prediction is now factored out into a separate function: model_utils.prediction.

old:

cabinetry.visualize.data_mc(model, data, fit_results=fit_results)

new:

model_pred = cabinetry.model_utils.prediction(model, fit_results=fit_results)
cabinetry.visualize.data_mc(model_pred, data)

If the optional fit_results is not passed, the pre-fit prediction is generated instead. The new approach allows for more control over the model prediction, and users can customize it as needed. Model predictions have also a label attribute that shows up on plots and be used to construct paths to save figures.

The yield table generation is split out from visualize.data_mc into a new function: tabulate.yields. It uses the same API, also taking a model prediction and data as arguments.

Both visualize.data_mc and tabulate.yields have new optional channels arguments, taking either a string specifying a channel or a list of strings. If provided, only channels matching the values are included in the plots and tables.

A few new internal functions are added to model_utils to collect functionality used in multiple places.

Breaking changes:

  • visualize.data_mc now requires a model prediction instead of a model
* breaking change: visualize.data_mc now requires model prediction argument
* new function model_utils.prediction to generate model predictions
* yield tables removed from visualize.data_mc, now available via new function tabulate.yields
* visualize.data_mc and tabulate.yields support a new optional channels argument
* refactored fit module, result containers split out into submodule

@codecov
Copy link

codecov bot commented Aug 25, 2021

Codecov Report

Merging #267 (405d86d) into master (726f92c) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #267   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           18        19    +1     
  Lines         1764      1798   +34     
  Branches       270       278    +8     
=========================================
+ Hits          1764      1798   +34     
Impacted Files Coverage Δ
src/cabinetry/cli/__init__.py 100.00% <100.00%> (ø)
src/cabinetry/fit/__init__.py 100.00% <100.00%> (ø)
src/cabinetry/fit/results_containers.py 100.00% <100.00%> (ø)
src/cabinetry/model_utils.py 100.00% <100.00%> (ø)
src/cabinetry/tabulate.py 100.00% <100.00%> (ø)
src/cabinetry/visualize/__init__.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 726f92c...405d86d. Read the comment docs.

@alexander-held alexander-held merged commit 5220056 into master Aug 25, 2021
@alexander-held alexander-held deleted the feat/model-prediction-api branch August 25, 2021 19:21
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.

None yet

1 participant