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

Nested MetricCollection #1000

Closed
tsteffek opened this issue May 1, 2022 · 2 comments · Fixed by #1003
Closed

Nested MetricCollection #1000

tsteffek opened this issue May 1, 2022 · 2 comments · Fixed by #1003
Labels
enhancement New feature or request
Milestone

Comments

@tsteffek
Copy link

tsteffek commented May 1, 2022

🚀 Feature

Allowing MetricCollection to contain other MetricCollections for even less boilerplate and coding effort.

Motivation

When using both micro and macro metrics I either need to call two different collections or provide the collection with a dictionary of names, which could easily be created by appending a post-/prefix to the metric name.

Pitch

I envision something like:

metrics = MetricCollection([
    MetricCollection([
        StatScores(reduce='macro'),
        F1Score(reduce='macro')
    ], postfix='_macro'),
    MetricCollection([
        StatScores(reduce='micro'),
        F1Score(reduce='micro')
    ], postfix='_micro'),
], prefix='valmetrics/')

I want a nested collection to be treated like any other metric. Ideally nested collections would also make use of compute_groups.

Alternatives

The same functionality can already be achieved by:

metrics = MetricCollection({
    'statscores_macro': StatScores(reduce='macro'),
    'f1_macro': F1Score(reduce='macro'),
    'statscores_micro': StatScores(reduce='micro'),
    'f1_micro': F1Score(reduce='micro')
}, prefix='valmetrics/')

But I think accepting nested collections would make for a more convenient interface.
(It would probably be the easiest solution to just generate this version if presented with nested collections.)

@tsteffek tsteffek added the enhancement New feature or request label May 1, 2022
@github-actions
Copy link

github-actions bot commented May 1, 2022

Hi! thanks for your contribution!, great first issue!

@SkafteNicki
Copy link
Member

cc: @Borda and @justusschock
Seems like a good idea to me, but it will not work with the compute group feature we just implemented.

@Borda Borda added this to the v0.9 milestone May 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants