Datasets:

ArXiv:
data / eval_utils.py
Elron's picture
Upload eval_utils.py with huggingface_hub
020896f verified
raw
history blame
672 Bytes
from typing import List
import pandas as pd
from .operator import SequentialOperator
from .stream import MultiStream
def evaluate(dataset: pd.DataFrame, metric_names: List[str]):
result = dataset.copy()
# prepare the input stream
for metric_name in metric_names:
multi_stream = MultiStream.from_iterables(
{"test": dataset.to_dict("records")}, copying=True
)
metrics_operator = SequentialOperator(steps=[metric_name])
instances = list(metrics_operator(multi_stream)["test"])
result[metric_name] = [
instance["score"]["instance"]["score"] for instance in instances
]
return result