Class: DSPy::Evaluate::BatchEvaluationResult

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/dspy/evaluate.rb

Overview

Batch evaluation results with aggregated metrics

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(results:, aggregated_metrics:) ⇒ BatchEvaluationResult

Returns a new instance of BatchEvaluationResult.



86
87
88
89
90
91
92
# File 'lib/dspy/evaluate.rb', line 86

def initialize(results:, aggregated_metrics:)
  @results = results.freeze
  @aggregated_metrics = aggregated_metrics.freeze
  @total_examples = results.length
  @passed_examples = results.count(&:passed)
  @pass_rate = @total_examples > 0 ? @passed_examples.to_f / @total_examples : 0.0
end

Instance Attribute Details

#aggregated_metricsObject (readonly)

Returns the value of attribute aggregated_metrics.



69
70
71
# File 'lib/dspy/evaluate.rb', line 69

def aggregated_metrics
  @aggregated_metrics
end

#pass_rateObject (readonly)

Returns the value of attribute pass_rate.



78
79
80
# File 'lib/dspy/evaluate.rb', line 78

def pass_rate
  @pass_rate
end

#passed_examplesObject (readonly)

Returns the value of attribute passed_examples.



75
76
77
# File 'lib/dspy/evaluate.rb', line 75

def passed_examples
  @passed_examples
end

#resultsObject (readonly)

Returns the value of attribute results.



66
67
68
# File 'lib/dspy/evaluate.rb', line 66

def results
  @results
end

#total_examplesObject (readonly)

Returns the value of attribute total_examples.



72
73
74
# File 'lib/dspy/evaluate.rb', line 72

def total_examples
  @total_examples
end

Instance Method Details

#to_hObject



95
96
97
98
99
100
101
102
103
# File 'lib/dspy/evaluate.rb', line 95

def to_h
  {
    total_examples: @total_examples,
    passed_examples: @passed_examples,
    pass_rate: @pass_rate,
    aggregated_metrics: @aggregated_metrics,
    results: @results.map(&:to_h)
  }
end