Spaces:
Runtime error
Runtime error
Commit
·
24a5443
1
Parent(s):
82009ff
Update README.md
Browse files
README.md
CHANGED
|
@@ -23,15 +23,8 @@ This metric can be used in relation extraction evaluation.
|
|
| 23 |
This metric takes 2 inputs, prediction and references(ground truth). Both of them are a list of list of dictionary of entity's name and entity's type:
|
| 24 |
```
|
| 25 |
>>> import evaluate
|
| 26 |
-
|
| 27 |
-
load metric
|
| 28 |
-
|
| 29 |
>>> metric_path = "Ikala-allen/relation_extraction"
|
| 30 |
>>> module = evaluate.load(metric_path)
|
| 31 |
-
|
| 32 |
-
Define your predictions and references
|
| 33 |
-
Example references (ground truth)
|
| 34 |
-
|
| 35 |
>>> references = [
|
| 36 |
... [
|
| 37 |
... {"head": "phip igments", "head_type": "brand", "type": "sell", "tail": "國際認證之色乳", "tail_type": "product"},
|
|
@@ -39,8 +32,6 @@ Example references (ground truth)
|
|
| 39 |
... ]
|
| 40 |
... ]
|
| 41 |
|
| 42 |
-
Example predictions
|
| 43 |
-
|
| 44 |
>>> predictions = [
|
| 45 |
... [
|
| 46 |
... {"head": "phipigments", "head_type": "product", "type": "sell", "tail": "國際認證之色乳", "tail_type": "product"},
|
|
@@ -48,8 +39,6 @@ Example predictions
|
|
| 48 |
... ]
|
| 49 |
... ]
|
| 50 |
|
| 51 |
-
Calculate evaluation scores using the loaded metric
|
| 52 |
-
|
| 53 |
>>> evaluation_scores = module.compute(predictions=predictions, references=references)
|
| 54 |
>>> print(evaluation_scores)
|
| 55 |
{'sell': {'tp': 1, 'fp': 1, 'fn': 1, 'p': 50.0, 'r': 50.0, 'f1': 50.0}, 'ALL': {'tp': 1, 'fp': 1, 'fn': 1, 'p': 50.0, 'r': 50.0, 'f1': 50.0, 'Macro_f1': 50.0, 'Macro_p': 50.0, 'Macro_r': 50.0}}
|
|
@@ -92,28 +81,18 @@ Example of only one prediction and reference:
|
|
| 92 |
```python
|
| 93 |
>>> metric_path = "Ikala-allen/relation_extraction"
|
| 94 |
>>> module = evaluate.load(metric_path)
|
| 95 |
-
|
| 96 |
-
Define your predictions and references
|
| 97 |
-
Example references (ground truth)
|
| 98 |
-
|
| 99 |
>>> references = [
|
| 100 |
... [
|
| 101 |
... {"head": "phip igments", "head_type": "brand", "type": "sell", "tail": "國際認證之色乳", "tail_type": "product"},
|
| 102 |
... {"head": "tinadaviespigments", "head_type": "brand", "type": "sell", "tail": "國際認證之色乳", "tail_type": "product"},
|
| 103 |
... ]
|
| 104 |
... ]
|
| 105 |
-
|
| 106 |
-
Example predictions
|
| 107 |
-
|
| 108 |
>>> predictions = [
|
| 109 |
... [
|
| 110 |
... {"head": "phipigments", "head_type": "product", "type": "sell", "tail": "國際認證之色乳", "tail_type": "product"},
|
| 111 |
... {"head": "tinadaviespigments", "head_type": "brand", "type": "sell", "tail": "國際認證之色乳", "tail_type": "product"},
|
| 112 |
... ]
|
| 113 |
... ]
|
| 114 |
-
|
| 115 |
-
Calculate evaluation scores using the loaded metric
|
| 116 |
-
|
| 117 |
>>> evaluation_scores = module.compute(predictions=predictions, references=references)
|
| 118 |
>>> print(evaluation_scores)
|
| 119 |
{'sell': {'tp': 1, 'fp': 1, 'fn': 1, 'p': 50.0, 'r': 50.0, 'f1': 50.0}, 'ALL': {'tp': 1, 'fp': 1, 'fn': 1, 'p': 50.0, 'r': 50.0, 'f1': 50.0, 'Macro_f1': 50.0, 'Macro_p': 50.0, 'Macro_r': 50.0}}
|
|
@@ -123,22 +102,14 @@ Example with two or more prediction and reference:
|
|
| 123 |
```python
|
| 124 |
>>> metric_path = "Ikala-allen/relation_extraction"
|
| 125 |
>>> module = evaluate.load(metric_path)
|
| 126 |
-
|
| 127 |
-
Define your predictions and references
|
| 128 |
-
Example references (ground truth)
|
| 129 |
-
|
| 130 |
>>> references = [
|
| 131 |
... [
|
| 132 |
... {"head": "phip igments", "head_type": "brand", "type": "sell", "tail": "國際認證之色乳", "tail_type": "product"},
|
| 133 |
... {"head": "tinadaviespigments", "head_type": "brand", "type": "sell", "tail": "國際認證之色乳", "tail_type": "product"},
|
| 134 |
... ],[
|
| 135 |
-
... {'head': 'SABONTAIWAN', 'tail': '大馬士革玫瑰有機光燦系列', 'head_type': 'brand', 'tail_type': 'product', 'type': 'sell'}
|
| 136 |
-
... {'head': 'SABONTAIWAN', 'tail': '大馬士革玫瑰有機光燦系列', 'head_type': 'brand', 'tail_type': 'product', 'type': 'sell'}
|
| 137 |
... ]
|
| 138 |
... ]
|
| 139 |
-
|
| 140 |
-
Example predictions
|
| 141 |
-
|
| 142 |
>>> predictions = [
|
| 143 |
... [
|
| 144 |
... {"head": "phipigments", "head_type": "product", "type": "sell", "tail": "國際認證之色乳", "tail_type": "product"},
|
|
@@ -148,9 +119,6 @@ Example predictions
|
|
| 148 |
... {'head': 'SNTAIWAN', 'tail': '大馬士革玫瑰有機光燦系列', 'head_type': 'brand', 'tail_type': 'product', 'type': 'sell'}
|
| 149 |
... ]
|
| 150 |
... ]
|
| 151 |
-
|
| 152 |
-
Calculate evaluation scores using the loaded metric
|
| 153 |
-
|
| 154 |
>>> evaluation_scores = module.compute(predictions=predictions, references=references)
|
| 155 |
>>> print(evaluation_scores)
|
| 156 |
{'sell': {'tp': 2, 'fp': 2, 'fn': 1, 'p': 50.0, 'r': 66.66666666666667, 'f1': 57.142857142857146}, 'ALL': {'tp': 2, 'fp': 2, 'fn': 1, 'p': 50.0, 'r': 66.66666666666667, 'f1': 57.142857142857146, 'Macro_f1': 57.142857142857146, 'Macro_p': 50.0, 'Macro_r': 66.66666666666667}}
|
|
|
|
| 23 |
This metric takes 2 inputs, prediction and references(ground truth). Both of them are a list of list of dictionary of entity's name and entity's type:
|
| 24 |
```
|
| 25 |
>>> import evaluate
|
|
|
|
|
|
|
|
|
|
| 26 |
>>> metric_path = "Ikala-allen/relation_extraction"
|
| 27 |
>>> module = evaluate.load(metric_path)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
>>> references = [
|
| 29 |
... [
|
| 30 |
... {"head": "phip igments", "head_type": "brand", "type": "sell", "tail": "國際認證之色乳", "tail_type": "product"},
|
|
|
|
| 32 |
... ]
|
| 33 |
... ]
|
| 34 |
|
|
|
|
|
|
|
| 35 |
>>> predictions = [
|
| 36 |
... [
|
| 37 |
... {"head": "phipigments", "head_type": "product", "type": "sell", "tail": "國際認證之色乳", "tail_type": "product"},
|
|
|
|
| 39 |
... ]
|
| 40 |
... ]
|
| 41 |
|
|
|
|
|
|
|
| 42 |
>>> evaluation_scores = module.compute(predictions=predictions, references=references)
|
| 43 |
>>> print(evaluation_scores)
|
| 44 |
{'sell': {'tp': 1, 'fp': 1, 'fn': 1, 'p': 50.0, 'r': 50.0, 'f1': 50.0}, 'ALL': {'tp': 1, 'fp': 1, 'fn': 1, 'p': 50.0, 'r': 50.0, 'f1': 50.0, 'Macro_f1': 50.0, 'Macro_p': 50.0, 'Macro_r': 50.0}}
|
|
|
|
| 81 |
```python
|
| 82 |
>>> metric_path = "Ikala-allen/relation_extraction"
|
| 83 |
>>> module = evaluate.load(metric_path)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
>>> references = [
|
| 85 |
... [
|
| 86 |
... {"head": "phip igments", "head_type": "brand", "type": "sell", "tail": "國際認證之色乳", "tail_type": "product"},
|
| 87 |
... {"head": "tinadaviespigments", "head_type": "brand", "type": "sell", "tail": "國際認證之色乳", "tail_type": "product"},
|
| 88 |
... ]
|
| 89 |
... ]
|
|
|
|
|
|
|
|
|
|
| 90 |
>>> predictions = [
|
| 91 |
... [
|
| 92 |
... {"head": "phipigments", "head_type": "product", "type": "sell", "tail": "國際認證之色乳", "tail_type": "product"},
|
| 93 |
... {"head": "tinadaviespigments", "head_type": "brand", "type": "sell", "tail": "國際認證之色乳", "tail_type": "product"},
|
| 94 |
... ]
|
| 95 |
... ]
|
|
|
|
|
|
|
|
|
|
| 96 |
>>> evaluation_scores = module.compute(predictions=predictions, references=references)
|
| 97 |
>>> print(evaluation_scores)
|
| 98 |
{'sell': {'tp': 1, 'fp': 1, 'fn': 1, 'p': 50.0, 'r': 50.0, 'f1': 50.0}, 'ALL': {'tp': 1, 'fp': 1, 'fn': 1, 'p': 50.0, 'r': 50.0, 'f1': 50.0, 'Macro_f1': 50.0, 'Macro_p': 50.0, 'Macro_r': 50.0}}
|
|
|
|
| 102 |
```python
|
| 103 |
>>> metric_path = "Ikala-allen/relation_extraction"
|
| 104 |
>>> module = evaluate.load(metric_path)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
>>> references = [
|
| 106 |
... [
|
| 107 |
... {"head": "phip igments", "head_type": "brand", "type": "sell", "tail": "國際認證之色乳", "tail_type": "product"},
|
| 108 |
... {"head": "tinadaviespigments", "head_type": "brand", "type": "sell", "tail": "國際認證之色乳", "tail_type": "product"},
|
| 109 |
... ],[
|
| 110 |
+
... {'head': 'SABONTAIWAN', 'tail': '大馬士革玫瑰有機光燦系列', 'head_type': 'brand', 'tail_type': 'product', 'type': 'sell'}
|
|
|
|
| 111 |
... ]
|
| 112 |
... ]
|
|
|
|
|
|
|
|
|
|
| 113 |
>>> predictions = [
|
| 114 |
... [
|
| 115 |
... {"head": "phipigments", "head_type": "product", "type": "sell", "tail": "國際認證之色乳", "tail_type": "product"},
|
|
|
|
| 119 |
... {'head': 'SNTAIWAN', 'tail': '大馬士革玫瑰有機光燦系列', 'head_type': 'brand', 'tail_type': 'product', 'type': 'sell'}
|
| 120 |
... ]
|
| 121 |
... ]
|
|
|
|
|
|
|
|
|
|
| 122 |
>>> evaluation_scores = module.compute(predictions=predictions, references=references)
|
| 123 |
>>> print(evaluation_scores)
|
| 124 |
{'sell': {'tp': 2, 'fp': 2, 'fn': 1, 'p': 50.0, 'r': 66.66666666666667, 'f1': 57.142857142857146}, 'ALL': {'tp': 2, 'fp': 2, 'fn': 1, 'p': 50.0, 'r': 66.66666666666667, 'f1': 57.142857142857146, 'Macro_f1': 57.142857142857146, 'Macro_p': 50.0, 'Macro_r': 66.66666666666667}}
|