File size: 688 Bytes
4560eb1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import unittest

from metrics.geometric_mean.geometric_mean import GeometricMean

geometric_mean = GeometricMean()


class TestGeometricMean(unittest.TestCase):
    def test_gmean(self):
        refs = [0, 1, 2, 0, 1, 2]
        preds = [0, 1, 2, 0, 1, 2]
        geometric_mean_score = geometric_mean.compute(predictions=preds, references=refs)
        print(geometric_mean_score)
        self.assertTrue(geometric_mean_score == {'geometric-mean': 1.0})

        refs = [0, 2, 1, 0, 0, 1]
        preds = [0, 1, 2, 0, 1, 2]
        geometric_mean_score = geometric_mean.compute(predictions=preds, references=refs)
        self.assertTrue(geometric_mean_score == {'geometric-mean': 0.0})