Spaces:
Runtime error
Runtime error
Ikala-allen
commited on
Commit
•
5199800
1
Parent(s):
46c9e1a
Update README.md
Browse files
README.md
CHANGED
@@ -79,7 +79,7 @@ Output Example:
|
|
79 |
Remind : Macro_f1、Macro_p、Macro_r、p、r、f1 are always a number between 0 and 1. And tp、fp、fn depend on how many data inputs.
|
80 |
|
81 |
### Examples
|
82 |
-
Example1 : only one prediction and reference, mode = strict,
|
83 |
```python
|
84 |
metric_path = "Ikala-allen/relation_extraction"
|
85 |
module = evaluate.load(metric_path)
|
@@ -106,7 +106,7 @@ print(evaluation_scores)
|
|
106 |
>>> {'tp': 1, 'fp': 1, 'fn': 2, 'p': 50.0, 'r': 33.333333333333336, 'f1': 40.0, 'Macro_f1': 25.0, 'Macro_p': 25.0, 'Macro_r': 25.0}
|
107 |
```
|
108 |
|
109 |
-
Example2 : only one prediction and reference, mode = boundaries,
|
110 |
```python
|
111 |
metric_path = "Ikala-allen/relation_extraction"
|
112 |
module = evaluate.load(metric_path)
|
@@ -133,7 +133,42 @@ print(evaluation_scores)
|
|
133 |
>>> {'tp': 2, 'fp': 0, 'fn': 1, 'p': 100.0, 'r': 66.66666666666667, 'f1': 80.0, 'Macro_f1': 50.0, 'Macro_p': 50.0, 'Macro_r': 50.0}
|
134 |
```
|
135 |
|
136 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
137 |
```python
|
138 |
>>> metric_path = "Ikala-allen/relation_extraction"
|
139 |
>>> module = evaluate.load(metric_path)
|
|
|
79 |
Remind : Macro_f1、Macro_p、Macro_r、p、r、f1 are always a number between 0 and 1. And tp、fp、fn depend on how many data inputs.
|
80 |
|
81 |
### Examples
|
82 |
+
Example1 : only one prediction and reference, mode = strict, only output ALL relation score
|
83 |
```python
|
84 |
metric_path = "Ikala-allen/relation_extraction"
|
85 |
module = evaluate.load(metric_path)
|
|
|
106 |
>>> {'tp': 1, 'fp': 1, 'fn': 2, 'p': 50.0, 'r': 33.333333333333336, 'f1': 40.0, 'Macro_f1': 25.0, 'Macro_p': 25.0, 'Macro_r': 25.0}
|
107 |
```
|
108 |
|
109 |
+
Example2 : only one prediction and reference, mode = boundaries, only output ALL relation score
|
110 |
```python
|
111 |
metric_path = "Ikala-allen/relation_extraction"
|
112 |
module = evaluate.load(metric_path)
|
|
|
133 |
>>> {'tp': 2, 'fp': 0, 'fn': 1, 'p': 100.0, 'r': 66.66666666666667, 'f1': 80.0, 'Macro_f1': 50.0, 'Macro_p': 50.0, 'Macro_r': 50.0}
|
134 |
```
|
135 |
|
136 |
+
Example3 : two or more prediction and reference, mode = boundaries, only output = False, output all relation type
|
137 |
+
```python
|
138 |
+
metric_path = "Ikala-allen/relation_extraction"
|
139 |
+
module = evaluate.load(metric_path)
|
140 |
+
# Define your predictions and references
|
141 |
+
references = [
|
142 |
+
[
|
143 |
+
{"head": "phipigments", "head_type": "brand", "type": "sell", "tail": "國際認證之色乳", "tail_type": "product"},
|
144 |
+
{"head": "tinadaviespigments", "head_type": "brand", "type": "sell", "tail": "國際認證之色乳", "tail_type": "product"},
|
145 |
+
],
|
146 |
+
[
|
147 |
+
{'head': 'SABONTAIWAN', 'tail': '大馬士革玫瑰有機光燦系列', 'head_type': 'brand', 'tail_type': 'product', 'type': 'sell'},
|
148 |
+
{'head': 'A醛賦活緊緻精華', 'tail': 'Serum', 'head_type': 'product', 'tail_type': 'category', 'type': 'belongs_to'},
|
149 |
+
]
|
150 |
+
]
|
151 |
+
|
152 |
+
# Example references (ground truth)
|
153 |
+
predictions = [
|
154 |
+
[
|
155 |
+
{"head": "phipigments", "head_type": "product", "type": "sell", "tail": "國際認證之色乳", "tail_type": "product"},
|
156 |
+
{"head": "tinadaviespigments", "head_type": "brand", "type": "sell", "tail": "國際認證之色乳", "tail_type": "product"},
|
157 |
+
],
|
158 |
+
[
|
159 |
+
{'head': 'SABONTAIWAN', 'tail': '大馬士革玫瑰有機光燦系列', 'head_type': 'brand', 'tail_type': 'product', 'type': 'sell'},
|
160 |
+
{'head': 'SNTAIWAN', 'tail': '大馬士革玫瑰有機光燦系列', 'head_type': 'brand', 'tail_type': 'product', 'type': 'sell'}
|
161 |
+
]
|
162 |
+
]
|
163 |
+
|
164 |
+
# Calculate evaluation scores using the loaded metric
|
165 |
+
evaluation_scores = module.compute(predictions=predictions, references=references, mode = "boundaries", only_all = False, relation_types = [])
|
166 |
+
|
167 |
+
print(evaluation_scores)
|
168 |
+
>>> {'sell': {'tp': 3, 'fp': 1, 'fn': 0, 'p': 75.0, 'r': 100.0, 'f1': 85.71428571428571}, 'belongs_to': {'tp': 0, 'fp': 0, 'fn': 1, 'p': 0, 'r': 0, 'f1': 0}, 'ALL': {'tp': 3, 'fp': 1, 'fn': 1, 'p': 75.0, 'r': 75.0, 'f1': 75.0, 'Macro_f1': 42.857142857142854, 'Macro_p': 37.5, 'Macro_r': 50.0}}
|
169 |
+
```
|
170 |
+
|
171 |
+
Example 4 with two or more prediction and reference:
|
172 |
```python
|
173 |
>>> metric_path = "Ikala-allen/relation_extraction"
|
174 |
>>> module = evaluate.load(metric_path)
|