Answer architecture round 1: delete question-bench, keep its run's results in item 77 citing the commit that held it, and correct item 85's mention of item 78
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from typing import Callable, Sequence
|
||||
from typing import Callable
|
||||
import collections
|
||||
import dataclasses
|
||||
import statistics
|
||||
@@ -62,16 +62,16 @@ def bench(units: list[Unit], places: list[Place], unresolved: int, spread: dict[
|
||||
return RunScores(len(units), len(named), unmeasured, scores)
|
||||
|
||||
|
||||
def auc(named: Sequence[float], rest: Sequence[float]) -> float:
|
||||
def auc(named: list[int], rest: list[int]) -> float:
|
||||
"""The chance a named unit outranks one not named, a tie counting half: 0.5 is a coin toss, 1.0 a perfect ranking."""
|
||||
wins = sum((a > b) + 0.5 * (a == b) for a in named for b in rest)
|
||||
return wins / (len(named) * len(rest))
|
||||
|
||||
|
||||
def top_k(named: Sequence[float], rest: Sequence[float]) -> float:
|
||||
def top_k(named: list[int], rest: list[int]) -> float:
|
||||
"""The share of the metric's k highest units the seats named, k being how many they named. Units tied at the cut share its remaining slots evenly, as a random order of them would."""
|
||||
k = len(named)
|
||||
cut = sorted([*named, *rest], reverse=True)[k - 1]
|
||||
cut = sorted(named + rest, reverse=True)[k - 1]
|
||||
above = sum(value > cut for value in named)
|
||||
slots = k - above - sum(value > cut for value in rest)
|
||||
tied_named = sum(value == cut for value in named)
|
||||
|
||||
@@ -22,29 +22,17 @@ class ScoringRun:
|
||||
heading: str
|
||||
commit: str
|
||||
places: list[Place]
|
||||
overall: float | None
|
||||
|
||||
|
||||
def scoring_runs(history: str) -> list[ScoringRun]:
|
||||
"""Each scoring run in a comprehension history, with the places its seats named, as they wrote them, and the seats' mean overall score; paired rulings name what changed, not what is hard, and are left out."""
|
||||
"""Each scoring run in a comprehension history, with the places its seats named, as they wrote them; paired rulings name what changed, not what is hard, and are left out."""
|
||||
runs = []
|
||||
for heading, bodies in sections(history).items():
|
||||
if (named := RUN.match(heading)) and ", against " not in heading:
|
||||
runs.append(ScoringRun(heading, named.group(3), [place for body in bodies for place in seat_places(body)], mean_overall("\n".join(bodies))))
|
||||
runs.append(ScoringRun(heading, named.group(3), [place for body in bodies for place in seat_places(body)]))
|
||||
return runs
|
||||
|
||||
|
||||
def mean_overall(body: str) -> float | None:
|
||||
"""The last cell of the table's `Mean` row."""
|
||||
for line in body.splitlines():
|
||||
if line.startswith("| Mean |"):
|
||||
try:
|
||||
return float(line.strip().strip("|").split("|")[-1])
|
||||
except ValueError:
|
||||
return None
|
||||
return None
|
||||
|
||||
|
||||
def seat_places(body: str) -> list[Place]:
|
||||
places = []
|
||||
listing = False
|
||||
|
||||
Reference in New Issue
Block a user