Skip to content

Conversation

@albertvillanova
Copy link
Member

Currently, multilabel metrics are not supported because predictions and references are defined as Value("int32").

This PR creates a new feature type OptionalSequence which can act as either Value("int32") or Sequence(Value("int32")), depending on the data passed.

Close #2554.

@albertvillanova albertvillanova marked this pull request as draft July 5, 2021 08:30
@albertvillanova albertvillanova marked this pull request as ready for review July 5, 2021 09:29
@lhoestq
Copy link
Member

lhoestq commented Jul 6, 2021

Hi ! Thanks for the fix :)

If I understand correctly, OptionalSequence doesn't have an associated arrow type that we know in advance unlike the other feature types, because it depends on the type of the examples.

For example, I tested this and it raises an error:

import datasets as ds
import pyarrow as pa

features = ds.Features({"a": ds.features.OptionalSequence(ds.Value("int32"))})
batch = {"a": [[0]]}

writer = ds.ArrowWriter(features=features, stream=pa.BufferOutputStream())
writer.write_batch(batch)
# ArrowInvalid: Could not convert [0] with type list: tried to convert to int

This error happens because features.type is StructType(struct<a: int32>).

Another way to add support for multilabel would be to have several configurations for these metrics. By default it would set the features without sequences, and for the multi label configuration it would use features with sequences. Let me know what you think

@albertvillanova
Copy link
Member Author

Hi @lhoestq, thanks for your feedback :)

Definitely, your suggested approach is simpler. I am going to refactor all my PR unless we could envision some other use cases where an OptionalSequence might be convenient, but for now I can't think of any...

Copy link
Member

@lhoestq lhoestq left a comment

Choose a reason for hiding this comment

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

Great thanks :)

@lhoestq lhoestq merged commit 8dcf377 into huggingface:master Jul 8, 2021
@albertvillanova albertvillanova added this to the 1.10 milestone Jul 12, 2021
@fcakyon
Copy link

fcakyon commented Jul 29, 2022

@albertvillanova @lhoestq I couldnt find the related docs in F1 card: https://huggingface.co/spaces/evaluate-metric/f1

How do I perform multilabel F1 evaluation using evaluate package?

@albertvillanova
Copy link
Member Author

I was going to transfer your question to the evaluate GitHub repository, but I saw you have already done it (and even opened a PR):

Thanks, @fcakyon.

@fcakyon
Copy link

fcakyon commented Jul 29, 2022

Sorry to bomb you on multiple channels 😅 @albertvillanova, I have solved my problems, and opened a PR so that others also don't get confused 👍

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.

Multilabel metrics not supported

3 participants