update eval.
This commit is contained in:
parent
fb630e3a79
commit
20e9de9a44
2
setup.py
2
setup.py
@ -46,7 +46,7 @@ setup(
|
||||
"jieba>=0.39",
|
||||
"loguru",
|
||||
"Pillow",
|
||||
'pytrec_eval',
|
||||
# 'pytrec_eval',
|
||||
# "hnswlib",
|
||||
# "opencv-python",
|
||||
],
|
||||
|
@ -9,15 +9,6 @@ This package contains implementations of pairwise similarity queries.
|
||||
# bring classes directly into package namespace, to save some typing
|
||||
from similarities.version import __version__
|
||||
from similarities.similarity import Similarity
|
||||
from similarities.utils import (
|
||||
cos_sim,
|
||||
dot_score,
|
||||
semantic_search,
|
||||
community_detection,
|
||||
pairwise_dot_score,
|
||||
pairwise_cos_sim
|
||||
)
|
||||
|
||||
from similarities.fastsim import AnnoySimilarity, HnswlibSimilarity
|
||||
from similarities.literalsim import (
|
||||
SimHashSimilarity,
|
||||
@ -32,3 +23,6 @@ from similarities.imagesim import (
|
||||
ClipSimilarity,
|
||||
SiftSimilarity
|
||||
)
|
||||
from similarities.data_loader import SearchDataLoader
|
||||
from similarities import evaluation
|
||||
from similarities import utils
|
||||
|
@ -2,9 +2,9 @@
|
||||
"""
|
||||
refer: https://github.com/UKPLab/beir/blob/main/beir/datasets/data_loader.py
|
||||
"""
|
||||
import pytrec_eval
|
||||
from typing import List, Dict, Tuple
|
||||
|
||||
from loguru import logger
|
||||
from typing import Type, List, Dict, Union, Tuple
|
||||
|
||||
|
||||
def mrr(qrels: Dict[str, Dict[str, int]],
|
||||
@ -127,6 +127,11 @@ def evaluate(
|
||||
results: Dict[str, Dict[str, float]],
|
||||
k_values: List[int] = (1, 3, 5, 10, 100)) -> Tuple[
|
||||
Dict[str, float], Dict[str, float], Dict[str, float], Dict[str, float]]:
|
||||
try:
|
||||
import pytrec_eval
|
||||
except ImportError:
|
||||
raise ImportError("Please install pytrec_eval to use this function, eg. `pip install pytrec_eval`")
|
||||
|
||||
ndcg = {}
|
||||
_map = {}
|
||||
recall = {}
|
||||
|
Loading…
Reference in New Issue
Block a user