Skip to content

Commit

Permalink
test api with metrics and postprocessors override
Browse files Browse the repository at this point in the history
Signed-off-by: Elron Bandel <elron.bandel@ibm.com>
  • Loading branch information
elronbandel committed Mar 14, 2024
1 parent b2106c1 commit 4c1c6db
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/library/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,15 @@ def test_evaluate(self):
predictions = ["2.5", "2.5", "2.2", "3", "4"]
results = evaluate(predictions, dataset["train"])
self.assertAlmostEqual(results[0]["score"]["global"]["score"], 0.026, 3)

def test_evaluate_with_metrics_external_setup(self):
dataset = load_dataset(
"card=cards.stsb,template=templates.regression.two_texts.simple,max_train_instances=5,max_validation_instances=5,max_test_instances=5,metrics=[metrics.accuracy],postprocessors=[processors.first_character]"
)
self.assertEqual(dataset["train"][0]["metrics"], ["metrics.accuracy"])
self.assertEqual(
dataset["train"][0]["postprocessors"], ["processors.first_character"]
)
predictions = ["2.5", "2.5", "2.2", "3", "4"]
results = evaluate(predictions, dataset["train"])
self.assertAlmostEqual(results[0]["score"]["global"]["score"], 0.2, 3)

0 comments on commit 4c1c6db

Please sign in to comment.