MCPcopy Create free account
hub / github.com/Dizzy-K/AutoPT / build_metric_matrix

Function build_metric_matrix

analysis/summary.py:152–177  ·  view source on GitHub ↗
(
    results: Iterable[NormalizedResult],
    *,
    rows_field: str,
    cols_field: str,
    metric: str = "success_rate",
)

Source from the content-addressed store, hash-verified

150
151
152def build_metric_matrix(
153 results: Iterable[NormalizedResult],
154 *,
155 rows_field: str,
156 cols_field: str,
157 metric: str = "success_rate",
158) -> dict[str, Any]:
159 result_list = list(results)
160 row_names = sorted({group_key(item, rows_field) for item in result_list})
161 col_names = sorted({group_key(item, cols_field) for item in result_list})
162 matrix: dict[str, dict[str, float | int | None]] = {}
163 for row_name in row_names:
164 matrix[row_name] = {}
165 for col_name in col_names:
166 cell_items = [
167 item
168 for item in result_list
169 if group_key(item, rows_field) == row_name and group_key(item, cols_field) == col_name
170 ]
171 matrix[row_name][col_name] = metric_value(cell_items, metric)
172 return {
173 "rows": row_names,
174 "cols": col_names,
175 "metric": metric,
176 "values": matrix,
177 }
178
179
180def metric_value(results: Iterable[NormalizedResult], metric: str) -> float | int | None:

Callers 1

handle_analysis_commandFunction · 0.85

Calls 2

group_keyFunction · 0.85
metric_valueFunction · 0.85

Tested by

no test coverage detected