Skip to content

Potentially Misleading Error Message for multiclass_precision #198

Open
@adrianjoshua-strutt

Description

@adrianjoshua-strutt

📚 The doc issue

Hi!

I encountered the following warning message while working with the multiclass_precision function:

WARNING:root:tensor([[1],
        [2],
        [3]]) classes have zero instances in both the predictions and the ground truth labels. Precision is still logged as zero.

Here is a minimal example that produces this warning:

import torch
import torcheval.metrics

print(torcheval.metrics.functional.classification.precision.multiclass_precision(
    input = torch.tensor([
        [1, 0, 0, 0],
        [1, 0, 0, 0],
        [1, 0, 0, 0],
        [1, 0, 0, 0],
    ]),
    target = torch.tensor([
        0, 1, 2, 3
    ]),
    num_classes = 4,
    average = None,
))

I find the message somewhat misleading, as it implies that there are zero instances for certain classes in both predictions and ground truth labels. However, the ground truth labels do contain instances for each class, while only the predictions have zero instances. This led to me thinking that my ground truth labels were incorrect.

Thanks !

Suggest a potential alternative/fix

If I am not getting something wrong here, the message could be changed to:


WARNING:root:tensor([[1],
        [2],
        [3]]) classes have zero instances in either the predictions or the ground truth labels. Precision is still logged as zero.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions