jaccard_similarity / tests.py
Ruchin's picture
Adding jaccard similarity
246690c
test_cases = [
{
"predictions": [0, 0],
"references": [1, 1],
"result": {"jaccard_similarity": 0.0}
},
{
"predictions": [1, 1],
"references": [1, 1],
"result": {"jaccard_similarity": 1.0}
},
{
"predictions": [1, 0],
"references": [1, 1],
"result": {"jaccard_similarity": 0.5}
},
{
"predictions": [0, 1, 2, 3],
"references": [0, 1, 2, 3],
"result": {"jaccard_similarity": 1.0}
},
{
"predictions": [0, 1, 2, 3],
"references": [3, 2, 1, 0],
"result": {"jaccard_similarity": 1.0}
},
{
"predictions": [0, 0, 1, 1],
"references": [1, 1, 1, 1],
"result": {"jaccard_similarity": 0.5}
},
{
"predictions": [0, 0, 0, 1],
"references": [1, 1, 1, 1],
"result": {"jaccard_similarity": 0.25}
},
{
"predictions": [0, 1, 2, 3],
"references": [0, 1, 2, 3],
"result": {"jaccard_similarity": 1.0},
"kwargs": {"average": "macro"}
},
{
"predictions": [0, 0, 1, 1],
"references": [1, 1, 1, 1],
"result": {"jaccard_similarity": 0.5},
"kwargs": {"average": "binary", "pos_label": 1}
},
{
"predictions": [0, 1, 2, 0],
"references": [0, 1, 1, 2],
"result": {"jaccard_similarity": 0.375},
"kwargs": {"average": "weighted"}
},
{
"predictions": [[1, 1, 1], [1, 0, 0]],
"references": [[0, 1, 1], [1, 1, 0]],
"result": {"jaccard_similarity": 0.5833333333333334},
"kwargs": {"average": "samples"}
},
{
"predictions": [[1, 1, 1], [1, 0, 0]],
"references": [[0, 1, 1], [1, 1, 0]],
"result": {"jaccard_similarity": 0.6666666666666666},
"kwargs": {"average": "macro"}
},
{
"predictions": [[1, 1, 1], [1, 0, 0]],
"references": [[0, 1, 1], [1, 1, 0]],
"result": {"jaccard_similarity": [0.5, 0.5, 1.0]},
"kwargs": {"average": None}
},
]