agents.common.models.grade.composite¶
Composite grading model for combining multiple grade types.
This module implements a composite grading system that combines multiple different grade types into a single comprehensive evaluation.
Classes¶
Composite grading model for combining multiple grade types. |
Module Contents¶
- class agents.common.models.grade.composite.CompositeGrade(/, **data)¶
Bases:
haive.agents.common.models.grade.base.Grade
Composite grading model for combining multiple grade types.
This grade model combines multiple individual grades of different types into a single comprehensive assessment. It supports weighted averaging, statistical analysis, and consensus building across different grading approaches.
- Parameters:
data (Any)
- grades¶
List of individual grades to combine
- weights¶
Optional weights for each grade (auto-normalized)
- combination_method¶
Method for combining grades
- primary_grade_index¶
Index of the primary/most important grade
- consensus_threshold¶
Threshold for consensus analysis
Example
# Individual grades binary_grade = BinaryGrade(value=True, justification="Meets requirements") numeric_grade = NumericGrade(value=8.5, max_value=10, justification="High quality work") letter_grade = LetterGrade(value="B+", justification="Good performance overall") # Composite grade composite = CompositeGrade( grades=[binary_grade, numeric_grade, letter_grade], weights=[0.2, 0.5, 0.3], # Different importance levels combination_method="weighted_average", justification="Combined assessment across multiple criteria" ) # Equal weight composite composite_equal = CompositeGrade( grades=[binary_grade, numeric_grade, letter_grade], combination_method="simple_average", justification="Balanced multi-perspective evaluation" )
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 create_consensus_grade(grades, justification, consensus_threshold=0.8, **kwargs)¶
Create a CompositeGrade focused on consensus building.
- Parameters:
- Returns:
CompositeGrade configured for consensus analysis
- Return type:
- classmethod create_from_grades(grades, justification, weights=None, method='weighted_average', **kwargs)¶
Create a CompositeGrade from a list of existing grades.
- Parameters:
- Returns:
CompositeGrade instance
- Return type:
- get_consensus_analysis()¶
Get detailed consensus analysis.
- get_grade_breakdown()¶
Get detailed breakdown of individual grades.
- get_grade_statistics()¶
Get statistical analysis of the individual grades.
- get_normalized_score()¶
Get the composite grade as a normalized score between 0.0 and 1.0.
Uses the specified combination method to compute the final score.
- Returns:
Combined normalized score across all grades
- Return type:
- get_normalized_score_using_method(method)¶
Get normalized score using a specific combination method.
- get_normalized_weights()¶
Get normalized weights that sum to 1.0.
- get_outlier_grades(threshold=0.3)¶
Identify grades that are outliers compared to the group.
- has_consensus()¶
Check if there’s consensus among the individual grades.
- Returns:
True if the variance in normalized scores is below consensus threshold
- Return type:
- is_passing(threshold=None)¶
Determine if the composite grade represents a passing score.
- to_display_string()¶
Convert grade to a human-readable display string.
- Returns:
Formatted string representation of the composite grade
- Return type:
- classmethod validate_combination_method(v)¶
Validate that combination method is supported.
- Parameters:
v (str) – Combination method string
- Returns:
Validated combination method
- Raises:
ValueError – If combination method is not supported
- Return type:
- validate_grade_value(value)¶
Validate that a value represents valid composite grade data.
- Parameters:
value (Any) – The value to validate (should be list of grades)
- Returns:
True if the value can be converted to valid grades, False otherwise
- Return type:
- validate_weights_and_indices()¶
Validate weights match grades count and indices are valid.
- Returns:
Self if validation passes
- Raises:
ValueError – If weights or indices are invalid
- Return type: