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 += "
| {nSimulations} | " + sol += f"n={nSimulations} | " sol += "Pot A | " sol += "Pot B | " sol += "||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| {nSimulations} | " + sol += f"n={nSimulations} | " sol += "Pot A | " sol += "Pot B | " sol += "Pot C | " @@ -226,7 +229,7 @@ for sg in supergroups: sol += "|||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| {t1.shortname} - {t.pot} | " 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 += "|||||||||||||
| {val['violations']} ({percentage(val['violations'])}) | " + sol += f"{percentage(val['violations'])} | " sol += "||||||||||||
| "
for c,n in val['comments'].items():
- sol += f"{c} " + sol += f"{percentage(n)} " sol += f" | "
sol += f""
for c,n in val['comments'].items():
- sol += f"{n} ({percentage(n)}) " + sol += f"{c} " sol += f" | "
sol += "||||||||||||
| {val['violations']} ({percentage(val['violations'])}) | " + sol += f"{percentage(val['violations'])} | " sol += "||||||||||||
| " + sol += f" | "
for c,n in elementary_violations[key].items():
- sol += f"{c} - {n} ({percentage(n)}) " + sol += f"({percentage(n)}) {c} " sol += f" | "
sol += "||||||||||||