Spaces:
Runtime error
Runtime error
chanelcolgate
commited on
Commit
·
ded291e
1
Parent(s):
611243d
modified: average_precision.py
Browse files- README.md +28 -9
- average_precision.py +27 -4
README.md
CHANGED
@@ -3,7 +3,7 @@ title: Average Precision
|
|
3 |
tags:
|
4 |
- evaluate
|
5 |
- metric
|
6 |
-
description: "
|
7 |
sdk: gradio
|
8 |
sdk_version: 3.19.1
|
9 |
app_file: app.py
|
@@ -12,19 +12,38 @@ pinned: false
|
|
12 |
|
13 |
# Metric Card for Average Precision
|
14 |
|
15 |
-
***Module Card Instructions:*** *Fill out the following subsections. Feel free to take a look at existing metric cards if you'd like examples.*
|
16 |
-
|
17 |
-
## Metric Description
|
18 |
-
*Give a brief overview of this metric, including what task(s) it is usually used for, if any.*
|
19 |
-
|
20 |
## How to Use
|
21 |
-
|
|
|
22 |
|
23 |
-
|
|
|
|
|
24 |
|
25 |
### Inputs
|
26 |
-
*List all input arguments in the format below*
|
27 |
- **input_field** *(type): Definition of input, with explanation if necessary. State any default value(s).*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
|
29 |
### Output Values
|
30 |
|
|
|
3 |
tags:
|
4 |
- evaluate
|
5 |
- metric
|
6 |
+
description: "Average precision score."
|
7 |
sdk: gradio
|
8 |
sdk_version: 3.19.1
|
9 |
app_file: app.py
|
|
|
12 |
|
13 |
# Metric Card for Average Precision
|
14 |
|
|
|
|
|
|
|
|
|
|
|
15 |
## How to Use
|
16 |
+
```python
|
17 |
+
import evaluate
|
18 |
|
19 |
+
metric = evaluate.load("chanelcolgate/average_precision")
|
20 |
+
results = metric.compute(references=references, prediction_scores=prediction_scores)
|
21 |
+
```
|
22 |
|
23 |
### Inputs
|
|
|
24 |
- **input_field** *(type): Definition of input, with explanation if necessary. State any default value(s).*
|
25 |
+
- **y_true** *(`ndarray` of shape (n_samples,) or (n_samples, n_classes)): True binary labels or binary label indicators.
|
26 |
+
- **y_score** *(`ndarray` of shape (n_samples,) or (n_samples, n_classes)):
|
27 |
+
Target scores, can either be probability estimates of the positive class, confidence values, or non-thresholded measure of decisions (as returned by :term:`decision_function` on some classifiers).
|
28 |
+
- **average**: {'micro', 'samples', 'weighted', 'macro'} or None, default='macro`
|
29 |
+
|
30 |
+
If ``None``, the scores for each class are returned. Otherwise, this determines the type of averaging performed on the data:
|
31 |
+
|
32 |
+
``'micro'``:
|
33 |
+
Calculate metrics globally by considering each element of the label indicator matrix as a label.
|
34 |
+
|
35 |
+
``'macro'``:
|
36 |
+
Calculate metrics for each label, and find their unweighted mean This does not take label imbalance into account.
|
37 |
+
|
38 |
+
``'weighted'``:
|
39 |
+
Calculate metrics for each label, and find their average, weighted by support (the number of true instances for each label).
|
40 |
+
|
41 |
+
``'samples'``:
|
42 |
+
Calculate metrics for each label, and find their average
|
43 |
+
Will be ignored when ``y_true`` is binary.
|
44 |
+
- **pos_label** *(`int` or `str`, default=1): The label of the positive class. Only applied to binary ``y_true``. For multilabel-indicator ``y_true``, ``pos_label`` is fixed to 1.
|
45 |
+
- **sample_weight** *(`array-like` of shape (n_samples,), default=None): Sample weights.
|
46 |
+
|
47 |
|
48 |
### Output Values
|
49 |
|
average_precision.py
CHANGED
@@ -56,10 +56,33 @@ Note: this implementation is restricted to the binary classification task or
|
|
56 |
multilabel classification task.
|
57 |
Read more in the :ref:`User Guide <precision_recall_f_measure_metrics`.
|
58 |
Args:
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
Returns:
|
64 |
accuracy: description of the first score,
|
65 |
another_score: description of the second score,
|
|
|
56 |
multilabel classification task.
|
57 |
Read more in the :ref:`User Guide <precision_recall_f_measure_metrics`.
|
58 |
Args:
|
59 |
+
y_true: ndarray of shape (n_samples,) or (n_samples, n_classes)
|
60 |
+
True binary labels or binary label indicators.
|
61 |
+
y_score: ndarray of shape (n_samples,) or (n_samples, n_classes)
|
62 |
+
Target scores, can either be probability estimates of the positive
|
63 |
+
class, confidence values, or non-thresholded measure of decisions
|
64 |
+
(as returned by :term:`decision_function` on some classifiers).
|
65 |
+
average: {'micro', 'samples', 'weighted', 'macro'} or None, \
|
66 |
+
default='macro'
|
67 |
+
If ``None``, the scores for each class are retruned. Otherwise,
|
68 |
+
this determines the type of averaging performed on the data:
|
69 |
+
``'micro'``:
|
70 |
+
Calculate metrics globally be considering each element of the label
|
71 |
+
indicator matrix as a label.
|
72 |
+
``'macro'``:
|
73 |
+
Calculate metrics for each label, and find their unweighted
|
74 |
+
mean. This does not take label imbalance into account.
|
75 |
+
``'weighted'``:
|
76 |
+
Calculate metrics for each label, and find their average, weighted
|
77 |
+
by support (the number of true instances for each label).
|
78 |
+
``'samples'``:
|
79 |
+
Calculate metrics for each instance, and find their average.
|
80 |
+
Will be ignored when ``y_true`` is binary.
|
81 |
+
pos_label: int or str, default=1
|
82 |
+
The label of the positive class. Only applied to binary ``y_true``.
|
83 |
+
For multilabel-indicator ``y_true``, ``pos_label`` is fixed to 1.
|
84 |
+
sample_weight: array_like of shape (n_samples,), default=None
|
85 |
+
Sample weights.
|
86 |
Returns:
|
87 |
accuracy: description of the first score,
|
88 |
another_score: description of the second score,
|