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

Fix handling of empty sets in set matching metrics #23

Closed
wgantt opened this issue Dec 22, 2023 · 2 comments
Closed

Fix handling of empty sets in set matching metrics #23

wgantt opened this issue Dec 22, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@wgantt
Copy link
Collaborator

wgantt commented Dec 22, 2023

Hi @wanmok and @ctongfei. In using this package for another project, I noticed that the current implementation of the set matching metrics gives undesired behavior in the case where:

  • matching is one-to-one
  • either the predicted or the reference set (but not both) is empty
  • the inner metric is not discrete (so this line is not triggered)

In such a case, it’s possible to reach this line with a gram “matrix” that is a 1D array rather than a 2D array, yielding an error like the following when the call to spo.linear_sum_assignment is made:

File "/brtx/601-nvme2/wgantt/.conda/envs/ote/lib/python3.10/site-packages/metametric/core/matching.py", line 30, in score
    row_idx, col_idx = spo.linear_sum_assignment(
ValueError: expected a matrix (2-D array), got a 1 array

It feels like we should just add logic to return 0 if we reach here and either x or y is empty. What do you think?

@wgantt wgantt assigned ctongfei and unassigned ctongfei Dec 22, 2023
@wgantt wgantt added the bug Something isn't working label Dec 22, 2023
@ctongfei
Copy link
Collaborator

@wgantt I think that you are right. If either x or y is empty, we should bypass the following logic and just return 0.

@ctongfei
Copy link
Collaborator

Fixed by #24 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants