File size: 672 Bytes
d730802 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
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
|