From ce9f82569d62799e314abf83113a85230cd146f0 Mon Sep 17 00:00:00 2001 From: martin Date: Thu, 1 Feb 2024 15:08:26 +0100 Subject: [PATCH] UEFA NL --- uefa/nations_league/analytics.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/uefa/nations_league/analytics.py b/uefa/nations_league/analytics.py index 9f6f3a8..821598c 100644 --- a/uefa/nations_league/analytics.py +++ b/uefa/nations_league/analytics.py @@ -59,6 +59,7 @@ import random import time import json import csv +import numpy as np import networkx as nx import matplotlib.pyplot as plt from datetime import timedelta @@ -147,6 +148,8 @@ for key, val in teams_in_group_together.items(): maxVal = val +mean = np.mean([val for val in teams_in_group_together.values() if val > 0]) + # %% @@ -201,7 +204,7 @@ for sg in supergroups: sol += "\n" sol += "\n" sol += "" - sol += f"" + sol += f"" sol += "" sol += "" sol += "" @@ -209,7 +212,7 @@ for sg in supergroups: sol += "
{nSimulations}n={nSimulations}Pot APot B
\n" sol += "\n" sol += "" - sol += f"" + sol += f"" sol += "" sol += "" sol += "" @@ -226,7 +229,7 @@ for sg in supergroups: sol += "\n" sol += f"" for t2 in sg.teams.order_by('pot'): - color = heatmap_color_for((abs(teams_in_group_together[(t1,t2)]-(maxVal+minVal)/2))/((maxVal-minVal)/2 or 1)) + color = heatmap_color_for((abs(teams_in_group_together[(t1,t2)]-mean))/((maxVal-minVal)/2 or 1)) opacity = "1" if teams_in_group_together[(t1,t2)] == 0: color = 'lightgrey' @@ -255,17 +258,17 @@ sol += "\n" sol += "\n" sol += "\n" for val in violated_blockings.values(): - sol += f"" + sol += f"" sol += "\n" sol += "\n" for val in violated_blockings.values(): sol += f"" sol += f"" sol += "\n" sol += "\n" @@ -290,13 +293,13 @@ sol += "\n" sol += "\n" for key in elementary_violations.keys(): val = violated_wishes[key] - sol += f"" + sol += f"" sol += "\n" sol += "\n" for key,val in elementary_violations.items(): - sol += f"" sol += "\n" sol += "\n"
{nSimulations}n={nSimulations}Pot APot BPot C
{t1.shortname} - {t.pot}
{val['violations']} ({percentage(val['violations'])}){percentage(val['violations'])}
" for c,n in val['comments'].items(): - sol += f"{c}
" + sol += f"{percentage(n)}
" sol += f"
" for c,n in val['comments'].items(): - sol += f"{n} ({percentage(n)})
" + sol += f"{c}
" sol += f"
{val['violations']} ({percentage(val['violations'])}){percentage(val['violations'])}
" + sol += f"" for c,n in elementary_violations[key].items(): - sol += f"{c} - {n} ({percentage(n)})
" + sol += f"({percentage(n)}) {c}
" sol += f"