CDCgov / cfa-abc-calibration

Apache License 2.0
1 stars 0 forks source link

Added collate function for distances results and inputs #14

Closed KOVALW closed 1 month ago

KOVALW commented 1 month ago

Overview

The target distances and list of accepted simulations during the ABC algorithm are separate attributes of the SimulationBundle and are therefore difficult to work with, requiring extra manipulation steps to compare the acceptance and distance as a function of the input parameters.

Changes

Added the function collate_accept as a setter function in SimulationBundle that generates a polars DataFrame from the calculated distances dictionary and joins these results to the initial parameter inputs for quick diagnostics and manipulation. The simulation column is then checked for existing in the accept dictionary keys for fast filtering of the distance results.

This function is then tested in the toy model workflow developed earlier to ensure that the accepted logical column exists, that the number of TRUE values is equivalent to the number of accepted simulations, and that no simulations listed as accepted in the DataFrame have a distance greater than the threshold tolerance of the ABC-SMC step.

Next steps

Unittest was used for testing to follow previous implementation. Analogous tests should be implemented in Pytest.