File size: 871 Bytes
60e41bb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from waterleaf.evaluation import score_predictions


def test_evaluation_reports_species_genus_and_top_three_accuracy():
    rows = [
        {
            "expected": "Lavandula angustifolia",
            "predictions": [
                "Lavandula angustifolia",
                "Salvia officinalis",
                "Salvia rosmarinus",
            ],
        },
        {
            "expected": "Salvia officinalis",
            "predictions": [
                "Salvia rosmarinus",
                "Salvia officinalis",
            ],
        },
        {
            "expected": "Rosa canina",
            "predictions": ["Rosa rubiginosa"],
        },
    ]

    metrics = score_predictions(rows)

    assert metrics["count"] == 3
    assert metrics["species_top_1"] == 1 / 3
    assert metrics["species_top_3"] == 2 / 3
    assert metrics["genus_top_1"] == 1.0