Season-long projections + 4-3-3 formation default
- 505 players projected across all 38 matchdays (opponent-adjusted, home/away, fatigue) - Season FV rankings: Douvikas 254, Paz N. 254, Dimarco 251, Martinez L. 245 - 4-3-3 Best XI (league): 2851 FV total with captain Douvikas - 4-3-3 from Al-Cihred squad: 2562 FV (90% efficiency) - Dashboard Matchday page: season projection rankings table + 4-3-3 XI - Dashboard Lineup page: default formation changed to 4-3-3 - Per-matchday granular projections saved - All 49 tests passing
This commit is contained in:
@@ -1,17 +1,24 @@
|
||||
import sys; from pathlib import Path; _p = Path(__file__).resolve().parent.parent.parent; str(_p) not in sys.path and sys.path.insert(0, str(_p))
|
||||
"""Page 1 — Matchday Control Room.
|
||||
|
||||
KPI row, fixture difficulty heatmap, start/sit table, bump chart.
|
||||
KPI row, fixture difficulty heatmap, start/sit table, season-long projections.
|
||||
"""
|
||||
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
import streamlit as st
|
||||
import plotly.graph_objects as go
|
||||
from plotly.subplots import make_subplots
|
||||
|
||||
from dashboard.warehouse import load_predictions, load_fixtures, load_players, load_lineups, load_votes
|
||||
from dashboard.viz.components import inject_css, kpi_card, section, insight, role_chip
|
||||
from dashboard.viz.charts import fixture_heatmap, kpi_sparkline, error_violins
|
||||
from dashboard.viz.template import PITCH_GREEN, GOLD, RED, SKY, VIOLET, WHITE, TEXT_SECONDARY, ROLE_COLORS, ROLE_ICONS, FANTABETO_TEMPLATE
|
||||
from dashboard.viz.template import (
|
||||
PITCH_GREEN, GOLD, RED, SKY, VIOLET, WHITE, TEXT_SECONDARY,
|
||||
ROLE_COLORS, ROLE_ICONS, FANTABETO_TEMPLATE
|
||||
)
|
||||
|
||||
SEASON_PROJECTIONS = Path(__file__).resolve().parent.parent.parent / "data" / "season_projections_26_27.xlsx"
|
||||
|
||||
|
||||
@st.cache_data(ttl=3600)
|
||||
@@ -168,6 +175,47 @@ def run():
|
||||
)
|
||||
st.plotly_chart(fig, width="stretch")
|
||||
|
||||
# ── Season Projections ─────────────────────────────────────────────
|
||||
st.divider()
|
||||
section("📅 Season-Long Projections", "4-3-3 starting XI + full season FV rankings.")
|
||||
|
||||
if SEASON_PROJECTIONS.exists():
|
||||
season = pd.read_excel(SEASON_PROJECTIONS)
|
||||
|
||||
# 4-3-3 Best XI
|
||||
s_gk = season[season['role'] == 'P'].nlargest(1, 'total_season_fv')
|
||||
s_def = season[season['role'] == 'D'].nlargest(4, 'total_season_fv')
|
||||
s_mid = season[season['role'] == 'C'].nlargest(3, 'total_season_fv')
|
||||
s_fwd = season[season['role'] == 'A'].nlargest(3, 'total_season_fv')
|
||||
stotal = s_gk['total_season_fv'].sum() + s_def['total_season_fv'].sum() + \
|
||||
s_mid['total_season_fv'].sum() + s_fwd['total_season_fv'].sum()
|
||||
captain_iron = s_fwd.iloc[0]
|
||||
|
||||
c_season, c_table = st.columns([1, 2])
|
||||
with c_season:
|
||||
st.markdown("**4-3-3 Projected XI (Season)**", unsafe_allow_html=False)
|
||||
st.markdown(f"🧤 {s_gk.iloc[0]['player']} ({s_gk.iloc[0]['team']}) — {s_gk.iloc[0]['total_season_fv']:.0f} FV")
|
||||
for _, d in s_def.iterrows():
|
||||
st.markdown(f"🛡 {d['player']} ({d['team']}) — {d['total_season_fv']:.0f} FV")
|
||||
for _, m in s_mid.iterrows():
|
||||
st.markdown(f"⚙ {m['player']} ({m['team']}) — {m['total_season_fv']:.0f} FV")
|
||||
for _, f in s_fwd.iterrows():
|
||||
st.markdown(f"⚡ {f['player']} ({f['team']}) — {f['total_season_fv']:.0f} FV")
|
||||
st.markdown(f"⭐ Captain: **{captain_iron['player']}** → {stotal + captain_iron['total_season_fv']:.0f} FV")
|
||||
insight(f"Projected season total: {stotal:.0f} FV ({stotal + captain_iron['total_season_fv']:.0f} with captain)")
|
||||
|
||||
with c_table:
|
||||
show = season.nlargest(25, 'total_season_fv')[
|
||||
['player', 'role', 'team', 'projected_games', 'avg_fv_per_game', 'total_season_fv']
|
||||
].copy()
|
||||
show.columns = ['Player', 'Role', 'Team', 'Games', 'Avg FV/g', 'Season FV']
|
||||
show['Season FV'] = show['Season FV'].astype(float).round(0).astype(int)
|
||||
show['Avg FV/g'] = show['Avg FV/g'].astype(float).round(2)
|
||||
st.dataframe(show, use_container_width=True, hide_index=True)
|
||||
insight("Season-long FV projections based on 25/26 performance, opponent difficulty, home/away, and fatigue.")
|
||||
else:
|
||||
st.info("Season projections not yet generated. Run the season projector to populate.")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
run()
|
||||
|
||||
Reference in New Issue
Block a user