Skip to content

Commit

Permalink
Merge pull request #57 from dexonsmith/cap-expected-win-rate-to-1-in-…
Browse files Browse the repository at this point in the history
…a-million

When tallying, cap the expected win rate at 1:1M
  • Loading branch information
anoek authored Jan 13, 2024
2 parents aae46f5 + 4b43369 commit 64bf1de
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion analysis/util/TallyGameAnalytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ def add_glicko2_analytics(self, result: Glicko2Analytics) -> None:
if result.expected_win_rate > 0.5
else (not black_won if result.expected_win_rate < 0.5 else 0.5)
)
self.prediction_cost[size][speed][rank][handicap] += - math.log(result.expected_win_rate if black_won else 1 - result.expected_win_rate)
# Cap the expected win rate at 1 in 1M to avoid MathDomain errors.
capped_win_rate = max(min(result.expected_win_rate, 0.999999), 0.000001)
self.prediction_cost[size][speed][rank][handicap] += - math.log(capped_win_rate if black_won else 1 - capped_win_rate)
self.count[size][speed][rank][handicap] += 1

def add_gor_analytics(self, result: GorAnalytics) -> None:
Expand Down

0 comments on commit 64bf1de

Please sign in to comment.