Spaces:
Runtime error
Runtime error
Update fbeta_score.py
Browse files- fbeta_score.py +11 -12
fbeta_score.py
CHANGED
@@ -46,6 +46,7 @@ _KWARGS_DESCRIPTION = """
|
|
46 |
Args:
|
47 |
predictions (`list` of `int`): Predicted labels.
|
48 |
references (`list` of `int`): Ground truth labels.
|
|
|
49 |
labels (`list` of `int`): The set of labels to include when `average` is not set to `'binary'`, and the order of the labels if `average` is `None`. Labels present in the data can be excluded, for example to calculate a multiclass average ignoring a majority negative class. Labels not present in the data will result in 0 components in a macro average. For multilabel targets, labels are column indices. By default, all labels in `predictions` and `references` are used in sorted order. Defaults to None.
|
50 |
pos_label (`int`): The class to be considered the positive class, in the case where `average` is set to `binary`. Defaults to 1.
|
51 |
average (`string`): This parameter is required for multiclass/multilabel targets. If set to `None`, the scores for each class are returned. Otherwise, this determines the type of averaging performed on the data. Defaults to `'binary'`.
|
@@ -55,20 +56,18 @@ Args:
|
|
55 |
- 'weighted': Calculate metrics for each label, and find their average weighted by support (the number of true instances for each label). This alters `'macro'` to account for label imbalance. This option can result in an F-score that is not between precision and recall.
|
56 |
- 'samples': Calculate metrics for each instance, and find their average (only meaningful for multilabel classification).
|
57 |
sample_weight (`list` of `float`): Sample weights Defaults to None.
|
58 |
-
|
59 |
-
|
60 |
Returns:
|
61 |
-
|
62 |
The F-beta score is the weighted harmonic mean of precision and recall, reaching its optimal value at 1 and its worst value at 0.
|
63 |
|
64 |
-
Examples:
|
65 |
-
|
66 |
-
>>> f_beta = evaluate.load("leslyarun/f_beta")
|
67 |
-
>>> results = f_beta.compute(references=[0, 1], predictions=[0, 1])
|
68 |
-
>>> print(results)
|
69 |
-
{'f_beta_score': 1.0}
|
70 |
|
71 |
-
|
|
|
|
|
|
|
|
|
72 |
"""
|
73 |
|
74 |
|
@@ -84,9 +83,9 @@ class F_Beta(evaluate.Metric):
|
|
84 |
# This defines the format of each prediction and reference
|
85 |
features=datasets.Features({
|
86 |
'predictions': datasets.Value('int32'),
|
87 |
-
'references': datasets.Value('int32')
|
88 |
-
'beta': datasets.Value('float32')
|
89 |
}),
|
|
|
90 |
# Homepage of the module for documentation
|
91 |
homepage="https://huggingface.co/spaces/leslyarun/fbeta_score",
|
92 |
# Additional links to the codebase or references
|
|
|
46 |
Args:
|
47 |
predictions (`list` of `int`): Predicted labels.
|
48 |
references (`list` of `int`): Ground truth labels.
|
49 |
+
beta (`float`): Determines the weight of recall in the combined score.
|
50 |
labels (`list` of `int`): The set of labels to include when `average` is not set to `'binary'`, and the order of the labels if `average` is `None`. Labels present in the data can be excluded, for example to calculate a multiclass average ignoring a majority negative class. Labels not present in the data will result in 0 components in a macro average. For multilabel targets, labels are column indices. By default, all labels in `predictions` and `references` are used in sorted order. Defaults to None.
|
51 |
pos_label (`int`): The class to be considered the positive class, in the case where `average` is set to `binary`. Defaults to 1.
|
52 |
average (`string`): This parameter is required for multiclass/multilabel targets. If set to `None`, the scores for each class are returned. Otherwise, this determines the type of averaging performed on the data. Defaults to `'binary'`.
|
|
|
56 |
- 'weighted': Calculate metrics for each label, and find their average weighted by support (the number of true instances for each label). This alters `'macro'` to account for label imbalance. This option can result in an F-score that is not between precision and recall.
|
57 |
- 'samples': Calculate metrics for each instance, and find their average (only meaningful for multilabel classification).
|
58 |
sample_weight (`list` of `float`): Sample weights Defaults to None.
|
59 |
+
|
|
|
60 |
Returns:
|
61 |
+
fbeta_score (`float` (if average is not None) or `array` of `float`, shape =\ [n_unique_labels]): of the positive class in binary classification or weighted average of the F1 scores of each class for the multiclass task.
|
62 |
The F-beta score is the weighted harmonic mean of precision and recall, reaching its optimal value at 1 and its worst value at 0.
|
63 |
|
64 |
+
Examples:
|
|
|
|
|
|
|
|
|
|
|
65 |
|
66 |
+
Example 1-A simple binary example
|
67 |
+
>>> f_beta = evaluate.load("leslyarun/f_beta")
|
68 |
+
>>> results = f_beta.compute(references=[0, 1], predictions=[0, 1])
|
69 |
+
>>> print(results)
|
70 |
+
{'f_beta_score': 1.0}
|
71 |
"""
|
72 |
|
73 |
|
|
|
83 |
# This defines the format of each prediction and reference
|
84 |
features=datasets.Features({
|
85 |
'predictions': datasets.Value('int32'),
|
86 |
+
'references': datasets.Value('int32')
|
|
|
87 |
}),
|
88 |
+
'beta': datasets.Value('float32')
|
89 |
# Homepage of the module for documentation
|
90 |
homepage="https://huggingface.co/spaces/leslyarun/fbeta_score",
|
91 |
# Additional links to the codebase or references
|