agents.common.models.grade.binary¶
Binary grading model for pass/fail evaluations.
This module implements a binary grading system suitable for pass/fail, yes/no, correct/incorrect, and similar binary evaluations.
Classes¶
Binary grading model for pass/fail evaluations. |
Module Contents¶
- class agents.common.models.grade.binary.BinaryGrade(/, **data)¶
Bases:
haive.agents.common.models.grade.base.Grade
Binary grading model for pass/fail evaluations.
This grade model represents simple binary outcomes such as pass/fail, yes/no, correct/incorrect, acceptable/unacceptable, etc.
- Parameters:
data (Any)
- value¶
The binary grade value (True for pass/yes, False for fail/no)
- grade_type¶
Always GradeType.BINARY
Example
# Passing grade grade = BinaryGrade( value=True, justification="Response correctly identifies all key concepts", confidence=0.95 ) # Failing grade grade = BinaryGrade( value=False, justification="Response contains factual errors and misses main points", confidence=0.88 ) # Using string values (automatically converted) grade = BinaryGrade( value="pass", # Converted to True justification="Meets minimum requirements" )
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- classmethod convert_value_to_bool(v)¶
Convert various representations to boolean.
Accepts boolean values, strings, and numbers and converts them to appropriate boolean values for grading.
- Parameters:
v (Any) – Value to convert to boolean
- Returns:
Boolean representation of the value
- Raises:
ValueError – If the value cannot be converted to a meaningful boolean
- Return type:
- classmethod create_fail(justification, confidence=1.0, **kwargs)¶
Convenience method to create a failing grade.
- Parameters:
- Returns:
BinaryGrade instance with value=False
- Return type:
- classmethod create_pass(justification, confidence=1.0, **kwargs)¶
Convenience method to create a passing grade.
- Parameters:
- Returns:
BinaryGrade instance with value=True
- Return type:
- flip()¶
Create a new BinaryGrade with the opposite value.
Useful for creating inverse grades or testing scenarios.
- Returns:
New BinaryGrade instance with flipped value
- Return type:
- get_display_value()¶
Get a human-readable display value.
- Returns:
“Pass” for True, “Fail” for False
- Return type:
- get_emoji_representation()¶
Get an emoji representation of the grade.
- Returns:
✅ for pass, ❌ for fail
- Return type:
- get_normalized_score()¶
Get the grade as a normalized score between 0.0 and 1.0.
- Returns:
1.0 for True (pass), 0.0 for False (fail)
- Return type:
- is_passing(threshold=None)¶
Determine if the grade represents a passing score.
For binary grades, this simply returns the boolean value. The threshold parameter is ignored for binary grades.
- to_display_string()¶
Convert grade to a human-readable display string.
- Returns:
Formatted string representation of the binary grade
- Return type: