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

restructure aggregation of InstanceMetric , enabling to expand grouping and filtering option on to GlobalMetric #752

Closed
wants to merge 12 commits into from

Conversation

dafnapension
Copy link
Collaborator

@dafnapension dafnapension commented Apr 4, 2024

No description provided.

Copy link

codecov bot commented Apr 4, 2024

Codecov Report

Attention: Patch coverage is 96.17834% with 12 lines in your changes are missing coverage. Please review.

Project coverage is 91.98%. Comparing base (5783d76) to head (22bbb8e).
Report is 43 commits behind head on main.

❗ Current head 22bbb8e differs from pull request most recent head eb7f439. Consider uploading reports for the commit eb7f439 to get more accurate results

Files Patch % Lines
src/unitxt/metrics.py 95.34% 12 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #752      +/-   ##
==========================================
+ Coverage   91.48%   91.98%   +0.50%     
==========================================
  Files         100      103       +3     
  Lines       10169    10668     +499     
==========================================
+ Hits         9303     9813     +510     
+ Misses        866      855      -11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@dafnapension dafnapension changed the title allow global metrics on subsets of instances, defined by FilterByCondition-s Draft for a scheme to allow global metrics on subsets of instances, defined by FilterByCondition-s Apr 5, 2024
@dafnapension dafnapension changed the title Draft for a scheme to allow global metrics on subsets of instances, defined by FilterByCondition-s Allow global metrics on subsets of instances, defined by FilterByCondition-s Apr 5, 2024
@dafnapension dafnapension force-pushed the filtered_global_metric branch 2 times, most recently from 86b451f to fc9e9fa Compare April 5, 2024 19:49
@yoavkatz
Copy link
Member

yoavkatz commented Apr 8, 2024

@elronbandel , @dafnapension

There are currently additional ways to group metrics (note I'm not sure if they are the best way either), but my general message is we see how add functionality without expanding the APIs of metrics more and more.

We should have one recommended way to group, and if we implement a new one, and replace other uses.

The proposed method here allows arbitrary conditions, buts requires listing them specifically. On the other hand, grouping by field value as done today is more natural is some cases, where the options are not known.

Another suggestion is to share the proposed specification before the PR, so feedback can be given early.

@dafnapension
Copy link
Collaborator Author

dafnapension commented Apr 9, 2024

Hi @yoavkatz , I hope the current suggestion for a class that takes care of splitting/grouping is more in the direction you had in mind.
I think that if accepted, this class could also play a role in GlobalMetric (as it does in the current PR), and perhaps will unify all the different grouping that are currently tailored to Accuracy (and only to it).
Another issue that I think we may want to address is the name of the score stored in ["score"]["global"] for this groupped version of the evaluation.
I vote for generating children to ["score"]["global"], each child named by the group it represents (as suggested in this PR) and inside this child, things will look exactly as they look now (no splitting / grouping whats so ever) in ["global"]

# InstanceMetric's compute_instance_scores(stream)


class Aggregator(Artifact):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this related to this PR?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A start of an attempt to unify the aggregators over the InstanceMetrics

@yoavkatz
Copy link
Member

yoavkatz commented Apr 9, 2024

Hi @yoavkatz , I hope the current suggestion for a class that takes care of splitting/grouping is more in the direction you had in mind. I think that if accepted, this class could also play a role in GlobalMetric (as it does in the current PR), and perhaps will unify all the different grouping that are currently tailored to Accuracy (and only to it). Another issue that I think we may want to address is the name of the score stored in ["score"]["global"] for this groupped version of the evaluation. I vote for generating children to ["score"]["global"], each child named by the group it represents (as suggested in this PR) and inside this child, things will look exactly as they look now (no splitting / grouping whats so ever) in ["global"]

Yes. I think better. Elron said there is a grander design, which we should review.

@dafnapension dafnapension force-pushed the filtered_global_metric branch 3 times, most recently from 4de3b42 to 93d2d07 Compare April 29, 2024 10:02
@dafnapension dafnapension changed the title Allow global metrics on subsets of instances, defined by FilterByCondition-s restructure aggregation of InstanceMetric , attempting to expand grouping option to GlobalMetric Apr 29, 2024
@dafnapension dafnapension changed the title restructure aggregation of InstanceMetric , attempting to expand grouping option to GlobalMetric restructure aggregation of InstanceMetric , aiming to expand grouping option to GlobalMetric Apr 29, 2024
@dafnapension dafnapension force-pushed the filtered_global_metric branch 2 times, most recently from 2421f96 to 400fa81 Compare May 1, 2024 09:13
@dafnapension
Copy link
Collaborator Author

dafnapension commented May 2, 2024

Hi @elronbandel and @yoavkatz,
I suggest here a simplifying restructure of the different variations of instance-metric-aggregation (grouping - and then which ci, filtering, control-comparison) such that: (1) they are independent, and hence filtering and control-comparison are now applicable to the whole stream, and not only when grouping, and (2) easily applicable to GlobalMetric as well, as demonstrated in the tests I added, since the 'engine' of these variations now sits in MetricWithConfidenceInterval, and to BulkInstanceMetric too.
Please see if this makes sense.
MetricWithConfidenceInterval thus becomes the manager of all the work-along-the-instances for metric evaluation (as opposed to within each instance): filtering - grouping - aggregating over individual instance scores - and computing of CI.

@dafnapension dafnapension changed the title restructure aggregation of InstanceMetric , aiming to expand grouping option to GlobalMetric restructure aggregation of InstanceMetric , enabling to expand grouping and filtering option on to GlobalMetric May 4, 2024
@dafnapension dafnapension force-pushed the filtered_global_metric branch 9 times, most recently from 42b8709 to 1267565 Compare May 6, 2024 08:35
@dafnapension dafnapension force-pushed the filtered_global_metric branch 8 times, most recently from 7fb3522 to a7326e5 Compare May 10, 2024 20:14
Signed-off-by: dafnapension <dafnashein@yahoo.com>
Signed-off-by: dafnapension <dafnashein@yahoo.com>
… moved to MetricWithConfidence on the way to expand to global

Signed-off-by: dafnapension <dafnashein@yahoo.com>
Signed-off-by: dafnapension <dafnashein@yahoo.com>
Signed-off-by: dafnapension <dafnashein@yahoo.com>
…patibility

Signed-off-by: dafnapension <dafnashein@yahoo.com>
Signed-off-by: dafnapension <dafnashein@yahoo.com>
…atenate when combining groups' scores

Signed-off-by: dafnapension <dafnashein@yahoo.com>
Signed-off-by: dafnapension <dafnashein@yahoo.com>
Signed-off-by: dafnapension <dafnashein@yahoo.com>
…gregating_function

Signed-off-by: dafnapension <dafnashein@yahoo.com>
Signed-off-by: dafnapension <dafnashein@yahoo.com>
@dafnapension
Copy link
Collaborator Author

replaced by #845

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

2 participants