Skip to content

Commit

Permalink
add tests for metrics
Browse files Browse the repository at this point in the history
Signed-off-by: lilacheden <lilach.edel@gmail.com>
  • Loading branch information
lilacheden committed Feb 20, 2024
1 parent 1a754b8 commit 1104a44
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/library/test_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
F1Micro,
F1MicroMultiLabel,
F1Weighted,
KendallTauMetric,
RocAuc,
Rouge,
Squad,
TokenOverlap,
Expand Down Expand Up @@ -388,6 +390,26 @@ def test_token_overlap(self):
for target, value in global_targets.items():
self.assertAlmostEqual(value, outputs[0]["score"]["global"][target])

def test_roc_auc(self):
metric = RocAuc()
predictions = ["0.2", "0.8", "1.0"]
references = [["1.0"], ["0.0"], ["1.0"]]
outputs = apply_metric(
metric=metric, predictions=predictions, references=references
)
global_target = 0.5
self.assertAlmostEqual(global_target, outputs[0]["score"]["global"]["score"])

def test_kendalltau(self):
metric = KendallTauMetric()
predictions = ["1.0", "2.0", "1.0"]
references = [["-1.0"], ["1.0"], ["0.0"]]
outputs = apply_metric(
metric=metric, predictions=predictions, references=references
)
global_target = 0.81649658092772
self.assertAlmostEqual(global_target, outputs[0]["score"]["global"]["score"])


class TestConfidenceIntervals(UnitxtTestCase):
def test_confidence_interval_off(self):
Expand Down

0 comments on commit 1104a44

Please sign in to comment.