scikit-learn/scikit-learn — pull request #1990 by jnothman (2013-05-22 13:29:20+00:00)
Title: [WIP] rewrite precision_recall_fscore_support

`precision_recall_fscore_support` was getting gargantuan, because the similarities between the different input formats and metric variations weren't being exploited; rather, almost everything was special-cased. As a result, some bugs and inconsistencies crept in (admittedly on my watch as a reviewer).

This implementation:
* is much smaller and less nested in code, and should be faster in some cases, building upon vectorized multilabel support in #1985, #1987.
* deprecates `pos_label` and introduces `neg_label`, which allows micro-averaging to be interesting in the multiclass case (see #1983).
* has not yet implemented support for the `labels` argument, largely because I don't know what it means (see #1989). It's not hard to implement, but I wish it were deprecated in favour of stating a convention regarding label ordering in the `average=None` case.
* has not yet fixed some broken tests for multilabel `average='samples'`
* currently assumes P and R go to 0 when their denominators are 0. I think this is incorrect behaviour, but it is backward-compatible (except with the `average='samples'` implementation; again, whoops): precision should be perfect when recalling nothing; recall should be perfect when there are no instances to retrieve. (And not realising that scikit-learn had adopted the 0 approach, I suggested in the documentation that 1 should be used.)