ramseshk 8e759b0d0f Project Al-Cihred: ML auction strategy with exact 500cr spend
- LightGBM trained on 11,300 per-matchday votes (R²=0.147, RMSE=1.19)
- MILP with exact 499-500cr budget: 3GK+8DEF+8MID+6FWD
- Practical constraints: 2 starting GKs, 21/25 reliable (>15g)
- Realistic prices: Lautaro 229cr, Malen 220cr, Douvikas 56cr
- Squad: Svilar(21)+Carnesecchi(18)+Christensen(1)=40GK · 8DEF 128cr · 8MID 152cr · 6FWD 180cr
- Every player has 2-3 alternatives
- Updated dashboard auction page to load the plan
2026-08-11 16:20:45 +08:00
2023-09-30 09:24:58 +02:00
2023-10-05 19:41:20 +02:00
2023-10-05 19:41:20 +02:00
2023-10-05 19:41:20 +02:00
2022-11-12 11:29:20 +01:00
2023-10-05 19:41:20 +02:00
2023-10-05 19:41:20 +02:00
2023-09-30 09:24:58 +02:00
2023-09-30 09:24:58 +02:00
2023-09-30 09:24:58 +02:00
2022-11-12 11:29:20 +01:00

Fantabeto 26/27

Fantacalcio Bayesian Estimated Team's Outcome

SOTA Machine Learning for Serie A Fantasy Football Dominance

Python 3.11 License: MIT


Architecture Overview

Fantabeto 26/27 is a complete rewrite of the original 2023/24 codebase, upgraded with production-grade data engineering, state-of-the-art ML models, and advanced optimization algorithms. It predicts Fantacalcio Modified Scores (voto + bonus/malus), probabilistic card distributions, goal probabilities, and penalty chances — then generates optimal lineups via Monte Carlo Tree Search.

                         ┌──────────────────────────────┐
                         │      Data Ingestion           │
                         │  FBref │ Fantacalcio │ API   │
                         └──────────────┬───────────────┘
                                        │
                         ┌──────────────▼───────────────┐
                         │      Feature Engineering       │
                         │  Fatigue │ Pitch Tilt │ RAG   │
                         │  Weather │ Name Matching      │
                         └──────────────┬───────────────┘
                                        │
              ┌─────────────────────────┼─────────────────────────┐
              │                         │                         │
    ┌─────────▼──────────┐  ┌───────────▼───────────┐  ┌─────────▼──────────┐
    │   GBM Ensemble      │  │   Card Classifiers    │  │    T-GNN            │
    │ LightGBM + CatBoost │  │ Yellow/Red/Penalty    │  │ Player Interactions │
    │    + XGBoost        │  │ + Goal Probability    │  │                     │
    └─────────┬──────────┘  └───────────┬───────────┘  └─────────┬──────────┘
              │                         │                         │
              └─────────────────────────┼─────────────────────────┘
                                        │
                         ┌──────────────▼───────────────┐
                         │     Optimization Engine       │
                         │  Auction (MILP) │ Lineup (MCTS)│
                         │  Transfers │ Opponent Model  │
                         └──────────────┬───────────────┘
                                        │
                         ┌──────────────▼───────────────┐
                         │     Telegram Bot + CI/CD      │
                         │  Fri/Sun briefings │ Actions  │
                         └──────────────────────────────┘

Key Features

Data Pipeline

  • FBref Scraper: Rotating proxies + Playwright Cloudflare bypass
  • Fantacalcio.it Integration: API → Excel votes/stats with HTML fallback
  • api-football: Real-time xG, injuries, fixtures (via RapidAPI)
  • News RAG Pipeline: Italian sports news (Gazzetta, Sky Sport, Di Marzio) → injuries, suspensions, tactical shifts via LLM extraction

SOTA ML Architecture

  • GBM Ensemble (LightGBM + CatBoost + XGBoost): Stacked blending with Ridge meta-learner, bootstrap uncertainty
  • Temporal GNN: Player-to-player interaction modeling (winger crosses → striker goals)
  • Card Classifiers: Yellow/red card probability with SMOTE class imbalance handling
  • Penalty Model: Team-specific penalty taker heuristics
  • Goal Probability: Poisson regression for goal count prediction
  • Optuna: Hyperparameter tuning with time-series cross-validation

Optimization Engine

  • Auction (MILP): Multi-period stochastic knapsack via PuLP/Gurobi
    • Budget allocation per role (GK, DEF, MID, FWD)
    • Grid Auction (Asta a Griglia) game theory
  • Weekly Lineup (MCTS): Win-probability maximization vs opponent projection
    • Modificatore Difesa (defense modifier)
    • Captain selection optimization
    • Opposition weakness exploitation
  • Transfer Market (Svincolati): Buy-low/sell-high via xG divergence + regression to the mean

Agentic Workflow

  • Sunday Morning Bot: Telegram/Discord → auto briefing with start/sit recommendations
  • GitHub Actions: Automated Friday + Sunday pipeline (scrape → predict → notify)
  • Tactical Briefing: Narrated decision rationale (e.g., "Start X over Y — opponent left-back injured")

Quick Start

Prerequisites

  • Python 3.11+
  • Playwright: playwright install chromium
  • [Optional] RapidAPI key for api-football
  • [Optional] Fantacalcio.it account for vote API access
  • [Optional] Telegram Bot Token for notifications

Installation

git clone https://github.com/uPeppe/fantabeto.git
cd fantabeto
make install

Environment Variables

Copy .env.example and fill in:

FANTACALCIO_TOKEN=your_fc_access_token
RAPIDAPI_KEY=your_rapidapi_key
TELEGRAM_BOT_TOKEN=your_telegram_bot_token
TELEGRAM_CHAT_ID=your_chat_id
OPENAI_API_KEY=your_openai_key   # for LLM-enhanced news extraction

Usage

# Full pipeline: scrape → features → train
make pipeline

# Generate matchday predictions
make predict

# Run tests
make test

# Send Telegram briefing
make bot

Python API

from src.pipeline import Pipeline

pipeline = Pipeline()

# Scrape historical seasons
pipeline.scrape_fbref(["2024-2025", "2025-2026"], current=True)

# Build feature dataset
dataset = pipeline.build_features()

# Train models
model = pipeline.train_models(
    X=dataset.drop(columns=["fantavote"]),
    y=dataset["fantavote"],
)

# Run lineup optimization
result = pipeline.optimize_lineup("data/predictions.xlsx", "my_squad.xlsx")

Package Structure

src/
├── scraper/
│   ├── fbref_scraper.py         # FBref.com Serie A scraper
│   ├── fantacalcio_scraper.py   # Fantacalcio.it votes/rosters
│   ├── api_football.py          # api-football RapidAPI client
│   ├── proxy_manager.py         # Rotating proxy pool
│   └── browser_fallback.py      # Playwright Cloudflare bypass
├── features/
│   ├── vote_processor.py        # Vote → unified database
│   ├── player_features.py       # Player-level feature builder
│   ├── match_features.py        # Per-match feature matrix
│   ├── advanced_metrics.py      # Fatigue, Tilt, Weather
│   └── news_rag.py              # News ingestion + entity extraction
├── models/
│   ├── gbm_model.py             # LightGBM/CatBoost/XGBoost ensemble
│   ├── tgcn_model.py            # Temporal GNN interactions
│   ├── distribution_head.py     # SinhArcsinh + Bernoulli
│   ├── card_model.py            # Cards + Penalties + Goals
│   └── train.py                 # Optuna tuning + pipeline
├── optimization/
│   ├── auction_solver.py        # MILP auction strategy
│   ├── lineup_solver.py         # MCTS lineup selection
│   ├── transfer_analyzer.py     # Buy-low/Sell-high analysis
│   └── opponent_model.py        # Opponent behavior modeling
├── bot/
│   ├── telegram_bot.py          # Telegram bot client
│   └── briefing.py              # Tactical briefing generator
└── pipeline.py                  # Full pipeline orchestrator

2026/27 Season Configuration

Key season data in config/:

  • 26_27_teams.yaml — Teams, promoted/relegated, API season IDs
  • fantasy_scoring.yaml — FVM scoring rules, Modificatore, role quotas
  • news_sources.yaml — RSS feeds for Italian sports news
  • name_fix.yaml — FBref ↔ Fantacalcio name mappings

Testing

# Full test suite
make test

# With coverage
pytest tests/ --cov=src --cov-report=term

Credits

License

MIT — See LICENSE

S
Description
Fantabeto 26/27 — SOTA ML for Serie A Fantasy Football
Readme MIT 139 MiB
Languages
Jupyter Notebook 85.7%
Python 13.6%
JavaScript 0.3%
CSS 0.2%