Skip to content
This repository was archived by the owner on Nov 17, 2023. It is now read-only.
This repository was archived by the owner on Nov 17, 2023. It is now read-only.

python metric strings other than accuracy? #1107

@jmschrei

Description

@jmschrei

The code for create in metric.py doesn't seem to allow strings to be used for metrics other than accuracy. It checks to see if the type is a string, and if so, checks to see if it's accuracy, and if not, raises an error.

def create(metric):
    """Create an evaluation metric.
    Parameters
    ----------
    metric : str or callable
        The name of the metric, or a function
        providing statistics given pred, label NDArray.
    """
    if callable(metric):
        return CustomMetric(metric)
    if not isinstance(metric, string_types):
        raise TypeError('metric should either be callable or str')
    if metric == 'acc' or metric == 'accuracy':
        return Accuracy()
    else:
        raise ValueError('Cannot find metric %s' % metric)

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