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.



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

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.



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

def aggregated_metrics
  @aggregated_metrics
end

#pass_rateObject (readonly)

Returns the value of attribute pass_rate.



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

def pass_rate
  @pass_rate
end

#passed_examplesObject (readonly)

Returns the value of attribute passed_examples.



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

def passed_examples
  @passed_examples
end

#resultsObject (readonly)

Returns the value of attribute results.



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

def results
  @results
end

#total_examplesObject (readonly)

Returns the value of attribute total_examples.



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

def total_examples
  @total_examples
end

Instance Method Details

#to_hObject



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

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