Commit 474073af authored by JessicaOjo's avatar JessicaOjo
Browse files

add manual accuracy scores

parent 5a506454
...@@ -32,7 +32,7 @@ metric_list: ...@@ -32,7 +32,7 @@ metric_list:
ignore_case: true ignore_case: true
ignore_punctuation: true ignore_punctuation: true
- metric: acc - metric: acc
aggregation: mean aggregation: !function utils.manual_accuracy_score
higher_is_better: true higher_is_better: true
ignore_case: true ignore_case: true
ignore_punctuation: true ignore_punctuation: true
......
from sklearn.metrics import f1_score from sklearn.metrics import f1_score, accuracy_score
def doc_to_text(doc): def doc_to_text(doc):
...@@ -30,3 +30,12 @@ def weighted_f1_score(items): ...@@ -30,3 +30,12 @@ def weighted_f1_score(items):
preds = unzipped_list[1] preds = unzipped_list[1]
fscore = f1_score(golds, preds, average="weighted") fscore = f1_score(golds, preds, average="weighted")
return fscore return fscore
def manual_accuracy_score(items):
unzipped_list = list(zip(*items))
golds = unzipped_list[0]
preds = unzipped_list[1]
accuracy = accuracy_score(golds, preds)
return accuracy
...@@ -25,13 +25,13 @@ filter_list: ...@@ -25,13 +25,13 @@ filter_list:
"neutral": ['neutral']} "neutral": ['neutral']}
metric_list: metric_list:
- metric: f1 - metric: f1
aggregation: !function utils.weighted_f1_score aggregation:
average: weighted average: weighted
higher_is_better: True higher_is_better: True
ignore_case: true ignore_case: true
ignore_punctuation: true ignore_punctuation: true
- metric: acc - metric: acc
aggregation: mean aggregation: !function utils.manual_accuracy_score
higher_is_better: true higher_is_better: true
ignore_case: true ignore_case: true
ignore_punctuation: true ignore_punctuation: true
......
from sklearn.metrics import f1_score from sklearn.metrics import f1_score, accuracy_score
def doc_to_text(doc): def doc_to_text(doc):
...@@ -30,3 +30,12 @@ def weighted_f1_score(items): ...@@ -30,3 +30,12 @@ def weighted_f1_score(items):
preds = unzipped_list[1] preds = unzipped_list[1]
fscore = f1_score(golds, preds, average="weighted") fscore = f1_score(golds, preds, average="weighted")
return fscore return fscore
def manual_accuracy_score(items):
unzipped_list = list(zip(*items))
golds = unzipped_list[0]
preds = unzipped_list[1]
accuracy = accuracy_score(golds, preds)
return accuracy
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment