Evaluation.summarize:v0
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
import weave
from weave.flow.obj import Object
from weave.scorers.classification_scorer import transpose
from weave.scorers.base_scorer import get_scorer_attributes
from weave.scorers.base_scorer import auto_summarize
class EvaluationResults(Object):
rows: weave.Table
@weave.op()
async def summarize(self, eval_table: EvaluationResults) -> dict:
eval_table_rows = list(eval_table.rows)
cols = transpose(eval_table_rows)
summary = {}
for name, vals in cols.items():
if name == "scores":
scorers = self._post_init_scorers
for scorer in scorers:
scorer_attributes = get_scorer_attributes(scorer)
scorer_name = scorer_attributes.scorer_name
summarize_fn = scorer_attributes.summarize_fn
scorer_stats = transpose(vals)
score_table = scorer_stats[scorer_name]
scored = summarize_fn(score_table)