added metrics
Browse files- my_metrics.py +7 -0
- tasks.py +2 -1
my_metrics.py
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import sklearn.metrics
|
2 |
+
import numpy as np
|
3 |
+
|
4 |
+
def f1_macro(targets, predictions):
|
5 |
+
targets, predictions = np.asarray(targets).astype(str), np.asarray(predictions).astype(str)
|
6 |
+
return {"f1_macro": 100*sklearn.metrics.f1_score(targets, predictions, average='macro')}
|
7 |
+
|
tasks.py
CHANGED
@@ -4,6 +4,7 @@ import functools
|
|
4 |
import seqio
|
5 |
import tensorflow_datasets as tfds
|
6 |
from t5.evaluation import metrics
|
|
|
7 |
from t5.data import preprocessors
|
8 |
import t5
|
9 |
import tensorflow.compat.v1 as tf
|
@@ -59,7 +60,7 @@ seqio.TaskRegistry.add(
|
|
59 |
categorise_preprocessor,
|
60 |
seqio.preprocessors.tokenize_and_append_eos,
|
61 |
],
|
62 |
-
|
63 |
output_features=DEFAULT_OUTPUT_FEATURES,
|
64 |
)
|
65 |
|
|
|
4 |
import seqio
|
5 |
import tensorflow_datasets as tfds
|
6 |
from t5.evaluation import metrics
|
7 |
+
import mymetrics
|
8 |
from t5.data import preprocessors
|
9 |
import t5
|
10 |
import tensorflow.compat.v1 as tf
|
|
|
60 |
categorise_preprocessor,
|
61 |
seqio.preprocessors.tokenize_and_append_eos,
|
62 |
],
|
63 |
+
metric_fns=[metrics.accuracy,my_metrics.f1_macro,metrics.bleu],
|
64 |
output_features=DEFAULT_OUTPUT_FEATURES,
|
65 |
)
|
66 |
|