class RubyLLM::Evaluation::Report
A run’s trials and summary. Persist with save for review and comparisons.
Attributes
Returns the criterion definitions and evaluator identities captured for this run.
Returns the unique run identifier.
Returns the evaluation class name.
Returns the UTC time the run started.
Returns the trials in dataset and repetition order.
Public Instance Methods
Source
# File lib/ruby_llm/evaluation/report.rb, line 43 def cost ruby_llm_usage_cost end
Returns the Cost aggregate across every case and repetition.
Source
# File lib/ruby_llm/evaluation/report.rb, line 48 def counts totals = trials.map(&:status).tally %i[passed failed measured unassessed error].to_h { |status| [status, totals.fetch(status, 0)] } end
Returns trial counts keyed by status.
Source
# File lib/ruby_llm/evaluation/report.rb, line 33 def each(&) trials.each(&) end
Yields each trial, or returns an Enumerator.
Source
# File lib/ruby_llm/evaluation/report.rb, line 54 def pass_rate trials.empty? ? nil : counts[:passed].fdiv(trials.size) end
Returns the passing fraction of all trials, including errors and ungraded measurements.
Source
# File lib/ruby_llm/evaluation/report.rb, line 59 def passed? trials.any? && trials.all?(&:passed?) end
Returns true only when the run is nonempty and every trial passed.
Source
# File lib/ruby_llm/evaluation/report.rb, line 70 def save(path) File.write(path, JSON.pretty_generate(to_h)) path end
Writes a JSON report and returns the supplied path.
Source
# File lib/ruby_llm/evaluation/report.rb, line 64 def to_h { id:, name:, started_at: started_at.iso8601, definitions:, counts:, pass_rate:, tokens: tokens.to_h, cost: cost.to_h, trials: trials.map(&:to_h) } end
Returns all trial evidence, measurements, and run identity as a Hash.
Source
# File lib/ruby_llm/evaluation/report.rb, line 76 def to_s rows = trials.map { |trial| trial_description(trial) } [name, *rows, counts.map { |status, count| "#{count} #{status}" }.join(', ')].join("\n") end
Returns a readable per-case report followed by counts.