-
Notifications
You must be signed in to change notification settings - Fork 0
Metrics averageprecision
The precision-recall curve summarised as one number — but as a sum over its steps, not as the
area under it. Walk the samples from the highest score down; every time the recall moves, add how
much it moved times the precision at that point. 1 means every positive sample outranks every
negative one.
This is deliberately not a trapezoid. scikit-learn's auc(recall, precision) over the same
curve interpolates between two neighbouring thresholds as though the curve were a straight line
there, which it is not, and the result comes out optimistic. Measured on y_true = [0, 0, 1, 1]
and y_score = [0.1, 0.4, 0.35, 0.8]: the sum is 0.8333… and the trapezoid 0.7916…. On a row
whose scores are all tied the gap is wider still — 0.5 against 0.75. Reproducing the wrong one
of the two is the mistake this type exists to avoid, and the frozen corpus carries the trapezoid
beside every binary case so a test can assert the two never converge by accident.
Where RocAuc asks how well the ranking separates the two classes
over the whole range of thresholds, this asks how much of the top of the ranking is positive — which
is the question worth asking when positives are rare, because a ROC curve barely moves when a few
thousand negatives are ranked above a handful of positives and a precision-recall curve collapses.
Over a boolean matrix — one label per column, the shape
LabelRankingAveragePrecision and its two siblings take — each
column is scored on its own and the columns are then combined.
AveragePrecision.PerLabel returns them uncombined.
Averaging |
What it does |
|---|---|
Macro |
The plain mean of the per-label scores, a column no sample carries included at its 0. |
Micro |
The whole matrix read as one binary problem, row by row. A sample's weight repeats across its labels. |
Weighted |
The per-label scores averaged by how much positive weight each label carries. |
Averaging.Binary scores one positive label of two and means nothing over a matrix, so it is
refused rather than silently treated as Macro.
average='samples' is not offered. scikit-learn has a fourth mode that averages over rows
rather than columns, and it has no member in this package's Averaging — which
Precision, Recall,
F1 and FBeta share, and none of them
implements it either. Adding a member here would promise it on four types that do not have it.
Each is a weight vector the reference itself struggles with, and each is measured on both sides
rather than reasoned about. They are listed on
AveragePrecision.Score, beside the numbers.
| Member | What it does |
|---|---|
AveragePrecision.Score |
The step sum over the precision-recall curve, binary or over a label matrix. |
AveragePrecision.PerLabel |
One score per label of a matrix, uncombined. |
- 0001-target-framework
- 0002-unicode-comparison-unit
- 0003-provenance-and-licensing
- 0004-levenshtein-myers-backlog
- 0005-hamming-jellyfish-divergence
- 0006-ratcliff-autojunk
- 0007-metaphone-scope
- 0008-italian-enza-nltk-divergence
- 0009-sample-consumes-a-local-feed
- 0010-stop-word-list-provenance
- 0011-persistence-format
- 0012-per-package-versioning
- 0013-sentencepiece-parity-scope
- 0014-precompiled-normalizer
- 0015-sonar-rules-in-the-build
- 0016-metrics-package-placement
- 0017-bpe-parity-scope
- 0018-multiclass-roc-auc-parallelism-is-opt-in
- 0019-the-net-analysers-run-in-the-build-too
- 0020-normalize-is-a-projection-not-a-parameter
- 0021-multioutput-is-a-method-not-an-enum
- 0022-added-token-matching-flags
- 0023-byte-level-decode-substitutes
- 0024-weighted-median-averages-within-scikit-learns-epsilon
- 0025-quickselect-replaces-a-full-sort-for-the-median
- 0026-r2-and-explainedvariance-split-their-undefined-cases-differently
- 0027-r2-and-explainedvariance-vectorize-only-a-single-output
- 0028-log1p-is-kahans-identity-not-math-log-1-plus-x
- 0029-balanced-accuracy-adjusted-is-left-to-ieee-754-at-the-edge
- 0030-cohen-kappa-keeps-scikit-learns-expected-matrix-orientation
- 0031-nosamplecorrect-mirrors-numpys-float64-upcast
- 0032-fbeta-substitutes-tp-predicted-and-support-algebraically
- 0033-compensated-sum-is-neumaiers-variant
- 0034-dropout-is-refused-for-want-of-a-user
- 0035-a-null-pre-split-is-removed-with-invert-not-isolated
- 0036-a-member-may-ship-without-an-oracle-if-it-says-so
- 0037-the-guards-run-before-the-commit
- 0038-the-gate-confronts-an-exception-tag-with-the-page-that-documents-it
- 0039-mutual-information-returns-zero-on-an-empty-input
- 0040-a-curve-is-a-sealed-class-per-curve
- 0041-one-sample-file-per-public-class
- 0042-phonetic-encoders-refuse-a-null-word
- 0043-the-equality-table-is-sized-to-the-pattern
- 0044-compression-belongs-to-the-caller
- 0045-a-console-call-carries-its-reason-on-the-line
- 0046-check-adr-immutable-runs-in-ci-only
- 0047-one-gate-per-kernel-not-one-per-alphabet
- 0048-the-gate-depends-on-the-kernel-and-the-alphabet
- 0049-two-gates-per-kernel-tested-where-the-width-is-known
- 0050-the-sentencepiece-bpe-lineage-stays-a-bpe-model
- benchmark_latest
- decisions
- equivalence
- matplotlib
- migration
- nightly_run
- numpy
- pandas
- performance
- pytorch
- seaborn
- sklearn
- statsmodels