ragas icon indicating copy to clipboard operation
ragas copied to clipboard

Question: per-sample scores in original form from an EvaluationResult

Open GautamTalksDev opened this issue 3 months ago • 1 comments

Hi,

Building an adapter that reads Ragas results and binds them to a pre-registration committed before the eval ran.

Is there a supported way to get per-sample metric scores out of an EvaluationResult in their original numeric form, without going through a pandas conversion? I need to avoid a float round trip before a threshold comparison.

Context: https://gist.github.com/GautamTalksDev/89898dc6c9670beba627efc33faac163

GautamTalksDev avatar Aug 26 '26 23:08 GautamTalksDev

I think the supported path is to use the EvaluationResult object directly, not to_pandas().

evaluate(...) builds EvaluationResult.scores as a list of per-row dictionaries, in dataset order. That preserves the in-memory Python values returned by each metric before any DataFrame conversion:

result = evaluate(...)

rows = result.scores
first_row_score = rows[0]["faithfulness"]

faithfulness_scores = result["faithfulness"]

For thresholding, I would use result.scores when you need row alignment, or result[metric_name] when you only need one metric column. Then bind scores back to the original sample by index or, preferably, by an explicit sample id field in your EvaluationDataset. Ragas does not currently add a stable row id to each score row for you.

One caveat for a pre-registration/audit workflow: this is the in-memory score surface, not a full provenance contract. I would persist the score rows together with the sample id, metric name/config, package version, and run/experiment id before applying the threshold.

GioiaZheng avatar Sep 11 '26 16:09 GioiaZheng