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

Document significance of macro vs micro averaging #1874

Closed
robmarkcole opened this issue Feb 9, 2024 · 3 comments · Fixed by #1914
Closed

Document significance of macro vs micro averaging #1874

robmarkcole opened this issue Feb 9, 2024 · 3 comments · Fixed by #1914
Labels
documentation Improvements or additions to documentation good first issue A good issue for a new contributor to work on
Milestone

Comments

@robmarkcole
Copy link
Contributor

robmarkcole commented Feb 9, 2024

Issue

In the segmentation trainer, MulticlassAccuracy MulticlassJaccardIndex uses average="micro" rather than the torchmetrics default macro.

From slack: Macro weights per patch (what is the average accuracy of each patch?), whereas micro weights per pixel (what is the average accuracy of each pixel across the entire dataset?). These two metrics very greatly when the number of nodata pixels varies between patches. If one patch is mostly nodata pixels, and another patch is mostly data pixels, then macro will take the average of the two patches, while micro will sum up all pixels

Macro might be okay for some applications (such as pre-chipped datasets) but is definitely not what you want for others (such as geospatial datasets)

Further discussion: proposal: add both macro and micro and just name them appropriately OA vs AA - Overall (micro) Accuracy (OA). Average (macro) Accuracy (AA)

Fix

Refine the description above and document at https://torchgeo.readthedocs.io/en/stable/api/trainers.html#torchgeo.trainers.SemanticSegmentationTask.configure_metrics

@robmarkcole robmarkcole added the documentation Improvements or additions to documentation label Feb 9, 2024
@adamjstewart adamjstewart added the good first issue A good issue for a new contributor to work on label Feb 9, 2024
@jdilger
Copy link
Contributor

jdilger commented Feb 27, 2024

Hey there, I'd be happy to take this on. It seems pretty straightforward, but is there anything I should be aware of when building the docs?

@adamjstewart
Copy link
Collaborator

Everything you need to know is here: https://torchgeo.readthedocs.io/en/stable/user/contributing.html#documentation

Although you probably don't actually need to build the docs yourself, this is a pretty straightforward update and CI will test the docs for you.

Note that one of our other users has suggested adding both OA and AA, so the docs may need to change in the near future.

@jdilger
Copy link
Contributor

jdilger commented Feb 27, 2024

Ok sounds great. I submitted a PR that covers the micro accuracy. I'd be keen to add the option for AA if it's picked for implementation (or even updating the docs again).

@adamjstewart adamjstewart added this to the 0.5.2 milestone Feb 28, 2024
@isaaccorley isaaccorley modified the milestones: 0.5.2, 0.5.3 Mar 2, 2024
@adamjstewart adamjstewart modified the milestones: 0.5.3, 0.6.0, 0.5.2 Mar 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation good first issue A good issue for a new contributor to work on
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants