-
Notifications
You must be signed in to change notification settings - Fork 134
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
Add metric MultiManager and MetricPlotter #811
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to work really well, comments are mostly documentation issues. I think you also need to remove the old SimpleManager
from test_pcrbmetric and test_uncertaintymetric to stop tests failing.
…racks input to SimpleManager
…nager class with no changes yet.
…ack-truth metrics. change inputs to MultiManager to dicts instead of sets
… merge them together
…e_metric() method to switch if statements
… from SimpleManager
add new plot_metrics method to Plotter class. add new plot_timeseries parameter to Plotter.__init__ which defaults to False and sets fig axes to 'equal'. must be set to True to display axes correctly when plotting timeseries data including metrics.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding overall comments for each file to summarise changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update single sensor management tutorial to work with updated metrics, MultiManager, and MetricPlotter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update multi sensor management tutorial to work with updated metrics, MultiManager, and MetricPlotter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update optimised sensor management tutorial to work with updated metrics, MultiManager, and MetricPlotter
stonesoup/dataassociator/base.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
correct typos in DataAssociator base class
stonesoup/metricgenerator/base.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
correct typos in MetricGenerator base class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new Metrics example to show updated metrics, MultiManager, and MetricPlotter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update Multitracker example to work with updated metrics, MultiManager, and MetricPlotter
docs/examples/ParticleFlow.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update Gromov Particle flow example to work with updated metrics, MultiManager, and MetricPlotter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update multi-sensor fusion example to work with updated metrics, MultiManager, and MetricPlotter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update track stitching example to work with updated metrics, MultiManager, and MetricPlotter
docs/examples/MTT_3D_Platform.py
Outdated
ylabel="Sum of covariance matrix norms") | ||
fig3 = MetricPlotter() | ||
fig3.plot_metrics(metrics, generator_names=['Uncertainty metric']) | ||
fig3.fig.axes[0].set_title(label='Track uncertainty over time') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add set_title
as a MetricPlotter method? This will allow a user not to have to worry about "fig.axes[0]" and allows the MetricPlotter to be extended to plotly in the future.
Co-authored-by: James Wright <69153443+jswright-dstl@users.noreply.github.com>
Co-authored-by: James Wright <69153443+jswright-dstl@users.noreply.github.com>
minor additions/corrections in metrics example Co-authored-by: James Wright <69153443+jswright-dstl@users.noreply.github.com>
…ne-Soup into add-metric-multimanager
The breaking change makes this difficult to merge at this point. However, it may be possible to make it backwards compatible fairly easy:
I've not tried this, but something like this should work or at least be a good start. |
stonesoup/metricgenerator/manager.py
Outdated
generators = self.generators if isinstance(self.generators, list) else [self.generators] | ||
|
||
for generator in generators: | ||
if isinstance(generator, SIAPMetrics): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Referencing to specific metric here doesn't seem appropriate. Why does this need to be done?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe I added it in as an attempt to save unnecessary computation but not entirely sure. I think it can be removed easily. Will do so and test.
edit: nope, was to avoid an error. now updated with improved code, no hard-coding.
stonesoup/metricgenerator/manager.py
Outdated
def display_basic_metrics(self): | ||
""" | ||
Print basic metrics generated for each :class:`BasicMetrics` generator. | ||
""" | ||
for generator_name, generator in self.metrics.items(): | ||
if "Number of targets" in generator.keys(): | ||
print(f'\nGenerator: {generator_name}') | ||
for metric_key, metric in generator.items(): | ||
if isinstance(metric.generator, BasicMetrics): | ||
print(f"{metric.title}: {metric.value}") | ||
|
||
def get_siap_averages(self, generator_name): | ||
""" | ||
Get SIAP averages metrics from SIAP metric generator specified by generator_name | ||
|
||
Returns | ||
---------- | ||
: dict of :class`SIAPMetrics` averages | ||
""" | ||
siap_metrics = self.metrics[generator_name] | ||
siap_averages = {siap_metrics.get(metric) for metric in siap_metrics | ||
if metric.startswith("SIAP") and not metric.endswith(" at times")} | ||
|
||
return siap_averages |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These methods also seem specific to the name or specific metric. A different approach is needed here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had to remove the methods as they're too specific to each metric type.
update documentation of MetricManager and Metrics to include information about input parameters for different methods. Also remove hard-coded reference to SIAP metrics in associate_tracks method of MetricManager as requested in review.
Add SimpleManager MetricManager class back in and make backwards compatible with new updates to all Metrics Generators related to MultiManager. Update MultiManager parent class to work with SimpleManager and return data from SimpleManager in original format.
allow simplemanager add_data method to add data with any number of kwargs instead of requiring all kwargs.
add simplemanager tests back into test_manager and update all metrics tests files so that they use default generator_name, tracks_key, and truths_key arguments where relevant now that default values are available.
update indentation in manager.py and fix compute_metric method of abstract dummy metric generator class in test_manager.
remove methods from MultiManager and instances of use in tutorials/examples to avoid hard-coding any references to specific MetricGenerators in MetricManager code.
- MultiManager can take multiple metric generators of the same type and multiple sets of the same type to generate metrics. - Have made SimpleManager metric manager subclass of MultiManager class so this will be a breaking change. - All metrics that take in track and truth can now also take in 2 tracks. - Additional functionality added to MultiManager through new methods to help easier extraction of metrics and insights. - New MetricPlotter class created to make plotting metrics easier.
Update: