Spaces:
Runtime error
Runtime error
Commit
·
3bde512
1
Parent(s):
619e946
Update README.md
Browse files
README.md
CHANGED
@@ -90,18 +90,13 @@ references = [
|
|
90 |
{'head': 'A醛賦活緊緻精華', 'tail': 'Serum', 'head_type': 'product', 'tail_type': 'category', 'type': 'belongs_to'},
|
91 |
]
|
92 |
]
|
93 |
-
|
94 |
-
# Example references (ground truth)
|
95 |
predictions = [
|
96 |
[
|
97 |
{"head": "phipigments", "head_type": "product", "type": "sell", "tail": "國際認證之色乳", "tail_type": "product"},
|
98 |
{"head": "tinadaviespigments", "head_type": "brand", "type": "sell", "tail": "國際認證之色乳", "tail_type": "product"},
|
99 |
]
|
100 |
]
|
101 |
-
|
102 |
-
# Calculate evaluation scores using the loaded metric
|
103 |
evaluation_scores = module.compute(predictions=predictions, references=references, mode = "strict", only_all=True,relation_types = [])
|
104 |
-
|
105 |
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 |
```
|
@@ -117,18 +112,13 @@ references = [
|
|
117 |
{'head': 'A醛賦活緊緻精華', 'tail': 'Serum', 'head_type': 'product', 'tail_type': 'category', 'type': 'belongs_to'},
|
118 |
]
|
119 |
]
|
120 |
-
|
121 |
-
# Example references (ground truth)
|
122 |
predictions = [
|
123 |
[
|
124 |
{"head": "phipigments", "head_type": "product", "type": "sell", "tail": "國際認證之色乳", "tail_type": "product"},
|
125 |
{"head": "tinadaviespigments", "head_type": "brand", "type": "sell", "tail": "國際認證之色乳", "tail_type": "product"},
|
126 |
]
|
127 |
]
|
128 |
-
|
129 |
-
# Calculate evaluation scores using the loaded metric
|
130 |
evaluation_scores = module.compute(predictions=predictions, references=references, mode = "strict", only_all=True,relation_types = [])
|
131 |
-
|
132 |
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 |
```
|
@@ -137,7 +127,6 @@ Example3 : two or more prediction and reference, mode = boundaries, only output
|
|
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"},
|
@@ -148,8 +137,6 @@ references = [
|
|
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"},
|
@@ -160,10 +147,7 @@ predictions = [
|
|
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 |
```
|
@@ -182,8 +166,6 @@ references = [
|
|
182 |
{'head': 'A醛賦活緊緻精華', 'tail': 'Serum', 'head_type': 'product', 'tail_type': 'category', 'type': 'belongs_to'},
|
183 |
]
|
184 |
]
|
185 |
-
|
186 |
-
# Example references (ground truth)
|
187 |
predictions = [
|
188 |
[
|
189 |
{"head": "phipigments", "head_type": "product", "type": "sell", "tail": "國際認證之色乳", "tail_type": "product"},
|
|
|
90 |
{'head': 'A醛賦活緊緻精華', 'tail': 'Serum', 'head_type': 'product', 'tail_type': 'category', 'type': 'belongs_to'},
|
91 |
]
|
92 |
]
|
|
|
|
|
93 |
predictions = [
|
94 |
[
|
95 |
{"head": "phipigments", "head_type": "product", "type": "sell", "tail": "國際認證之色乳", "tail_type": "product"},
|
96 |
{"head": "tinadaviespigments", "head_type": "brand", "type": "sell", "tail": "國際認證之色乳", "tail_type": "product"},
|
97 |
]
|
98 |
]
|
|
|
|
|
99 |
evaluation_scores = module.compute(predictions=predictions, references=references, mode = "strict", only_all=True,relation_types = [])
|
|
|
100 |
print(evaluation_scores)
|
101 |
>>> {'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}
|
102 |
```
|
|
|
112 |
{'head': 'A醛賦活緊緻精華', 'tail': 'Serum', 'head_type': 'product', 'tail_type': 'category', 'type': 'belongs_to'},
|
113 |
]
|
114 |
]
|
|
|
|
|
115 |
predictions = [
|
116 |
[
|
117 |
{"head": "phipigments", "head_type": "product", "type": "sell", "tail": "國際認證之色乳", "tail_type": "product"},
|
118 |
{"head": "tinadaviespigments", "head_type": "brand", "type": "sell", "tail": "國際認證之色乳", "tail_type": "product"},
|
119 |
]
|
120 |
]
|
|
|
|
|
121 |
evaluation_scores = module.compute(predictions=predictions, references=references, mode = "strict", only_all=True,relation_types = [])
|
|
|
122 |
print(evaluation_scores)
|
123 |
>>> {'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}
|
124 |
```
|
|
|
127 |
```python
|
128 |
metric_path = "Ikala-allen/relation_extraction"
|
129 |
module = evaluate.load(metric_path)
|
|
|
130 |
references = [
|
131 |
[
|
132 |
{"head": "phipigments", "head_type": "brand", "type": "sell", "tail": "國際認證之色乳", "tail_type": "product"},
|
|
|
137 |
{'head': 'A醛賦活緊緻精華', 'tail': 'Serum', 'head_type': 'product', 'tail_type': 'category', 'type': 'belongs_to'},
|
138 |
]
|
139 |
]
|
|
|
|
|
140 |
predictions = [
|
141 |
[
|
142 |
{"head": "phipigments", "head_type": "product", "type": "sell", "tail": "國際認證之色乳", "tail_type": "product"},
|
|
|
147 |
{'head': 'SNTAIWAN', 'tail': '大馬士革玫瑰有機光燦系列', 'head_type': 'brand', 'tail_type': 'product', 'type': 'sell'}
|
148 |
]
|
149 |
]
|
|
|
|
|
150 |
evaluation_scores = module.compute(predictions=predictions, references=references, mode = "boundaries", only_all = False, relation_types = [])
|
|
|
151 |
print(evaluation_scores)
|
152 |
>>> {'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}}
|
153 |
```
|
|
|
166 |
{'head': 'A醛賦活緊緻精華', 'tail': 'Serum', 'head_type': 'product', 'tail_type': 'category', 'type': 'belongs_to'},
|
167 |
]
|
168 |
]
|
|
|
|
|
169 |
predictions = [
|
170 |
[
|
171 |
{"head": "phipigments", "head_type": "product", "type": "sell", "tail": "國際認證之色乳", "tail_type": "product"},
|