Class: Riffer::Evals::Result
- Inherits:
-
Object
- Object
- Riffer::Evals::Result
- Defined in:
- lib/riffer/evals/result.rb
Overview
Represents the result of a single evaluation.
Instance Attribute Summary collapse
-
#evaluator ⇒ Object
readonly
The evaluator class that produced this result.
-
#higher_is_better ⇒ Object
readonly
Whether higher scores are better for this evaluator.
-
#metadata ⇒ Object
readonly
Additional metadata from the evaluation.
-
#reason ⇒ Object
readonly
Human-readable explanation of the score.
-
#score ⇒ Object
readonly
The evaluation score (0.0 to 1.0).
Instance Method Summary collapse
-
#initialize(evaluator:, score:, reason: nil, metadata: {}, higher_is_better: true) ⇒ Result
constructor
Raises Riffer::ArgumentError if
scoreis not between 0.0 and 1.0. -
#to_h ⇒ Object
Returns a hash representation of the result.
Constructor Details
#initialize(evaluator:, score:, reason: nil, metadata: {}, higher_is_better: true) ⇒ Result
Raises Riffer::ArgumentError if score is not between 0.0 and 1.0. – : (evaluator: singleton(Riffer::Evals::Evaluator), score: Float, ?reason: String?, ?metadata: Hash[Symbol, untyped], ?higher_is_better: bool) -> void
24 25 26 27 28 29 30 31 |
# File 'lib/riffer/evals/result.rb', line 24 def initialize(evaluator:, score:, reason: nil, metadata: {}, higher_is_better: true) @evaluator = evaluator @score = score.to_f validate_score! @reason = reason @metadata = @higher_is_better = higher_is_better end |
Instance Attribute Details
#evaluator ⇒ Object (readonly)
The evaluator class that produced this result.
7 8 9 |
# File 'lib/riffer/evals/result.rb', line 7 def evaluator @evaluator end |
#higher_is_better ⇒ Object (readonly)
Whether higher scores are better for this evaluator.
19 20 21 |
# File 'lib/riffer/evals/result.rb', line 19 def higher_is_better @higher_is_better end |
#metadata ⇒ Object (readonly)
Additional metadata from the evaluation.
16 17 18 |
# File 'lib/riffer/evals/result.rb', line 16 def @metadata end |
#reason ⇒ Object (readonly)
Human-readable explanation of the score.
13 14 15 |
# File 'lib/riffer/evals/result.rb', line 13 def reason @reason end |
#score ⇒ Object (readonly)
The evaluation score (0.0 to 1.0).
10 11 12 |
# File 'lib/riffer/evals/result.rb', line 10 def score @score end |
Instance Method Details
#to_h ⇒ Object
Returns a hash representation of the result.
– : () -> Hash[Symbol, untyped]
37 38 39 40 41 42 43 44 45 |
# File 'lib/riffer/evals/result.rb', line 37 def to_h { evaluator: evaluator.name, score: score, reason: reason, metadata: , higher_is_better: higher_is_better } end |