Skip to content

ENH: Matthews correlation coefficient metric throws needless/misleading runtime warning #1937

@27359794

Description

@27359794

The formula for the Matthews correlation coefficient metric involves a division. In certain cases, the denominator of this division can be 0. In this situation, one of numpy's functions called by metrics.matthews_corrcoef throws a warning:

RuntimeWarning: invalid value encountered in divide

However, as Wikipedia states on the page for the metric, "If any of the four sums in the denominator is zero, the denominator can be arbitrarily set to one; this results in a Matthews correlation coefficient of zero, which can be shown to be the correct limiting value."

I think metrics.matthews_corrcoef should detect if the denominator will be 0 (this is a trivial property to check), and if so, set it to 1, instead of triggering a runtime warning and returning the right value (0) anyway.

Metadata

Metadata

Assignees

No one assigned

    Labels

    EasyWell-defined and straightforward way to resolveEnhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions