Report L by the share of chunks with a 🔴 in score-outcomes where most hold none
This commit is contained in:
@@ -104,9 +104,12 @@ def report(results: list[Result]) -> list[str]:
|
||||
lines.append(opening + too_few(len(rows), name, "both outcomes"))
|
||||
continue
|
||||
guesses, rounds, red = ([row[column] for row in rows] for column in range(3))
|
||||
found = [rank_correlation(guesses, rounds), rank_correlation(guesses, red)]
|
||||
undefined = ", since every chunk held one value" if None in found else ""
|
||||
lines.append(opening + f"rank correlation {listed(['none' if value is None else f'{value:+.2f}' for value in found], 'and')}{undefined} ({plural(len(rows), 'chunk')})")
|
||||
if name == "L" and red.count(0) * 2 > len(red):
|
||||
# Where most chunks hold no 🔴 every median reads 0 and the rank rests on the few that have one, so L is read by how often a chunk has one.
|
||||
lines.append(f"- {name}, by review rounds past each pass's first: rank correlation {correlations([rank_correlation(guesses, rounds)])} ({plural(len(rows), 'chunk')})")
|
||||
lines.append(f"- {name}, by the share of chunks with a 🔴, since most of the {len(rows)} chunks hold none: " + ", ".join(f"{guess} → {sum(1 for at, count in zip(guesses, red) if at == guess and count)} of {plural(guesses.count(guess), 'chunk')}" for guess in sorted(set(guesses))))
|
||||
continue
|
||||
lines.append(opening + f"rank correlation {correlations([rank_correlation(guesses, rounds), rank_correlation(guesses, red)])} ({plural(len(rows), 'chunk')})")
|
||||
return lines
|
||||
|
||||
|
||||
@@ -137,6 +140,12 @@ def too_few(held: int, name: str, what: str) -> str:
|
||||
return f"{held} {chunks} {name} and {what}; the report needs {ENOUGH}."
|
||||
|
||||
|
||||
def correlations(found: list[float | None]) -> str:
|
||||
"""Each rank correlation signed to two places, `none` where it is undefined, with the reason once after them."""
|
||||
undefined = ", since every chunk held one value" if None in found else ""
|
||||
return listed(["none" if value is None else f"{value:+.2f}" for value in found], "and") + undefined
|
||||
|
||||
|
||||
def rank_correlation(guesses: list[int], results: list[int]) -> float | None:
|
||||
"""Spearman's rank correlation, tied values sharing their mean rank; None where either side holds one value, which no order can rank."""
|
||||
if len(set(guesses)) < 2 or len(set(results)) < 2:
|
||||
|
||||
Reference in New Issue
Block a user