-
-
Notifications
You must be signed in to change notification settings - Fork 26k
[MRG+1] Add average precision definitions and cross references #9583
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
2f9b2d5
6b2f66c
879dfd7
3daba6a
ec47120
f7e7cc1
169a2a6
0c0f4bf
c46a4d5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,7 +40,9 @@ def auc(x, y, reorder=False): | |
"""Compute Area Under the Curve (AUC) using the trapezoidal rule | ||
|
||
This is a general function, given points on a curve. For computing the | ||
area under the ROC-curve, see :func:`roc_auc_score`. | ||
area under the ROC-curve, see :func:`roc_auc_score`. For an alternative | ||
way to summarize a precision-recall curve, see | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand. AUC is area under the ROC curve, not PR curve. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @amueller Per What change do you recommend? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. never mind, I think your version is fine. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm updating the |
||
:func:`average_precision_score`. | ||
|
||
Parameters | ||
---------- | ||
|
@@ -68,7 +70,8 @@ def auc(x, y, reorder=False): | |
|
||
See also | ||
-------- | ||
roc_auc_score : Computes the area under the ROC curve | ||
roc_auc_score : Compute the area under the ROC curve | ||
average_precision_score : Compute average precision from prediction scores | ||
precision_recall_curve : | ||
Compute precision-recall pairs for different probability thresholds | ||
""" | ||
|
@@ -108,6 +111,19 @@ def average_precision_score(y_true, y_score, average="macro", | |
sample_weight=None): | ||
"""Compute average precision (AP) from prediction scores | ||
|
||
AP summarizes a precision-recall curve as the weighted mean of precisions | ||
achieved at each threshold, with the increase in recall from the previous | ||
threshold used as the weight: | ||
|
||
.. math:: | ||
\\text{AP} = \\sum_n (R_n - R_{n-1}) P_n | ||
|
||
where :math:`P_n` and :math:`R_n` are the precision and recall at the nth | ||
threshold [1]_. This implementation is not interpolated and is different | ||
from computing the area under the precision-recall curve with the | ||
trapezoidal rule, which uses linear interpolation and can be too | ||
optimistic. | ||
|
||
Note: this implementation is restricted to the binary classification task | ||
or multilabel classification task. | ||
|
||
|
@@ -149,17 +165,12 @@ def average_precision_score(y_true, y_score, average="macro", | |
References | ||
---------- | ||
.. [1] `Wikipedia entry for the Average precision | ||
<http://en.wikipedia.org/wiki/Average_precision>`_ | ||
.. [2] `Stanford Information Retrieval book | ||
<http://nlp.stanford.edu/IR-book/html/htmledition/ | ||
evaluation-of-ranked-retrieval-results-1.html>`_ | ||
.. [3] `The PASCAL Visual Object Classes (VOC) Challenge | ||
<http://citeseerx.ist.psu.edu/viewdoc/ | ||
download?doi=10.1.1.157.5766&rep=rep1&type=pdf>`_ | ||
<http://en.wikipedia.org/w/index.php?title=Information_retrieval& | ||
oldid=793358396#Average_precision>`_ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why did you remove the references? I think these references should go into the user guide and we should explain exactly the relation between different approaches. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I originally found it confusing to reference alternative implementations without explicitly stating they different from the AP implementation here. I'll add them to the user guide. I could also add them back here and present them as alternative interpolated approaches. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree. References in the implementation should be specific to the implementation. The user guide can give more commentary. |
||
|
||
See also | ||
-------- | ||
roc_auc_score : Area under the ROC curve | ||
roc_auc_score : Compute the area under the ROC curve | ||
|
||
precision_recall_curve : | ||
Compute precision-recall pairs for different probability thresholds | ||
|
@@ -190,7 +201,8 @@ def _binary_uninterpolated_average_precision( | |
|
||
|
||
def roc_auc_score(y_true, y_score, average="macro", sample_weight=None): | ||
"""Compute Area Under the Curve (AUC) from prediction scores | ||
"""Compute Area Under the Receiver Operating Characteristic Curve (ROC AUC) | ||
from prediction scores. | ||
|
||
Note: this implementation is restricted to the binary classification task | ||
or multilabel classification task in label indicator format. | ||
|
@@ -239,7 +251,7 @@ def roc_auc_score(y_true, y_score, average="macro", sample_weight=None): | |
-------- | ||
average_precision_score : Area under the precision-recall curve | ||
|
||
roc_curve : Compute Receiver operating characteristic (ROC) | ||
roc_curve : Compute Receiver operating characteristic (ROC) curve | ||
|
||
Examples | ||
-------- | ||
|
@@ -396,6 +408,12 @@ def precision_recall_curve(y_true, probas_pred, pos_label=None, | |
Increasing thresholds on the decision function used to compute | ||
precision and recall. | ||
|
||
See also | ||
-------- | ||
average_precision_score : Compute average precision from prediction scores | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe also add roc_curve? but also fine as-is. |
||
|
||
roc_curve : Compute Receiver operating characteristic (ROC) curve | ||
|
||
Examples | ||
-------- | ||
>>> import numpy as np | ||
|
@@ -477,7 +495,7 @@ def roc_curve(y_true, y_score, pos_label=None, sample_weight=None, | |
|
||
See also | ||
-------- | ||
roc_auc_score : Compute Area Under the Curve (AUC) from prediction scores | ||
roc_auc_score : Compute the area under the ROC curve | ||
|
||
Notes | ||
----- | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe emphasize that they lead to different results?