Scoring Utilities
scoring
Utility functions for score calculations.
This module provides helper functions for score normalization and weighted averaging.
Functions
clamp_score
Clamp a score value to a specified range.
Ensures the score stays within valid bounds by applying min/max constraints.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
float
|
The score value to clamp. |
required |
min_value
|
float
|
Minimum allowed value (default: 0.0). |
0.0
|
max_value
|
float
|
Maximum allowed value (default: 100.0). |
100.0
|
Returns:
| Type | Description |
|---|---|
float
|
Clamped value between min_value and max_value (inclusive). |
Example
Source code in at_scorer/utils/scoring.py
weighted_score
Calculate a weighted average score from multiple category scores.
Computes a weighted average of scores where each score is multiplied by its corresponding weight, then normalized by the total weight. The result is scaled to 0-100 range.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scores
|
dict[str, float]
|
Dictionary mapping category names to their scores (0.0-1.0 range). |
required |
weights
|
dict[str, float]
|
Dictionary mapping category names to their weights. Weights are normalized automatically, so they don't need to sum to 1.0. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Weighted average score scaled to 0-100 range. |