Class: Riffer::Evals::RunResult
- Inherits:
-
Object
- Object
- Riffer::Evals::RunResult
- Defined in:
- lib/riffer/evals/run_result.rb
Overview
Instance Attribute Summary collapse
-
#scenario_results ⇒ Object
readonly
Per-scenario evaluation results.
Instance Method Summary collapse
-
#initialize(scenario_results:) ⇒ RunResult
constructor
Initializes a new run result.
-
#scores ⇒ Object
Returns average scores keyed by evaluator class across all scenarios.
-
#to_h ⇒ Object
Returns a hash representation of the run result.
Constructor Details
Instance Attribute Details
#scenario_results ⇒ Object (readonly)
Per-scenario evaluation results.
16 17 18 |
# File 'lib/riffer/evals/run_result.rb', line 16 def scenario_results @scenario_results end |
Instance Method Details
#scores ⇒ Object
Returns average scores keyed by evaluator class across all scenarios.
– : () -> Hash[singleton(Riffer::Evals::Evaluator), Float]
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/riffer/evals/run_result.rb', line 30 def scores return {} if scenario_results.empty? totals = Hash.new(0.0) counts = Hash.new(0) scenario_results.each do |scenario| scenario.scores.each do |evaluator, score| totals[evaluator] += score counts[evaluator] += 1 end end totals.each_with_object({}) do |(evaluator, total), hash| hash[evaluator] = total / counts[evaluator] end end |
#to_h ⇒ Object
Returns a hash representation of the run result.
– : () -> Hash[Symbol, untyped]
52 53 54 55 56 57 |
# File 'lib/riffer/evals/run_result.rb', line 52 def to_h { scores: scores.transform_keys(&:name), scenario_results: scenario_results.map(&:to_h) } end |