惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

U
Unit 42
The Cloudflare Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Y
Y Combinator Blog
G
Google Developers Blog
Vercel News
Vercel News
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Jina AI
Jina AI
Blog — PlanetScale
Blog — PlanetScale
H
Help Net Security
博客园 - 三生石上(FineUI控件)
MongoDB | Blog
MongoDB | Blog
S
SegmentFault 最新的问题
阮一峰的网络日志
阮一峰的网络日志
H
Hackread – Cybersecurity News, Data Breaches, AI and More
aimingoo的专栏
aimingoo的专栏
T
Tailwind CSS Blog
博客园 - 叶小钗
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
月光博客
月光博客
Microsoft Security Blog
Microsoft Security Blog
P
Proofpoint News Feed
The GitHub Blog
The GitHub Blog
云风的 BLOG
云风的 BLOG

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
I Built a World Cup 2026 Prediction Pipeline with Sportmi...
Vesna · 2026-06-21 · via DEV Community

Vesna

I wanted a football prediction project that felt closer to a real data product than a one-off notebook.

So I built a pipeline that:

  • pulls World Cup and national-team data from Sportmicro
  • engineers match and team-form features
  • trains a hybrid prediction model
  • generates upcoming fixture predictions and provisional title odds
  • exports machine-readable outputs
  • can refresh itself on a schedule through GitHub Actions

The repo is here:

world-cup-2026-prediction-sportmicro-api

What problem I was trying to solve

A lot of sports prediction demos stop at one model and one CSV. That is fine for experimentation, but it breaks down quickly if you want something you can rerun, automate, or publish.

For this project, I wanted a workflow that could:

  1. discover the relevant World Cup league data dynamically
  2. combine tournament history with recent national-team form
  3. train models from cached data
  4. generate fresh outputs without manual cleanup
  5. fit naturally into CI/CD

The result is a small but production-style sports analytics pipeline.

The stack

  • Python for data fetching, feature engineering, training, and reporting
  • scikit-learn for classification and score expectation models
  • pandas and numpy for the data layer
  • Node.js only where it adds value: generating Sportmicro endpoint paths through the official @sportmicro/endpoint package
  • GitHub Actions for scheduled refreshes

That Python + Node split is deliberate. The modeling and orchestration live in Python, while the API query construction stays aligned with Sportmicro's official endpoint builder.

Why the Sportmicro integration is interesting

Instead of hardcoding raw query strings, the repo sends a JSON request spec from Python to a Node helper script, and the helper builds the final endpoint path using @sportmicro/endpoint.

That means filters like eq, gte, in(...), pagination, and ordering are all constructed in a consistent way.

This is the part I like most architecturally: Python stays clean, and the final URL generation still uses the official tooling intended for the API.

Example shape of the workflow:

python -m wc2026_predictor run-all

Under the hood, that flow:

  1. discovers the World Cup league id
  2. downloads seasons and historical World Cup matches
  3. pulls recent national-team matches
  4. trains the models
  5. predicts future World Cup fixtures
  6. writes reports and CSV/JSON outputs

How the model works

This is not a single-model predictor.

The repo uses a layered approach:

  • Elo-style team strength updates
  • rolling form features from recent matches
  • a RandomForestClassifier for match outcome classification
  • two PoissonRegressor models for expected home and away goals
  • a hybrid ensemble that blends ML probabilities, Elo expectation, and Poisson-derived outcome probabilities

I used this design because football is noisy. A pure classifier can miss score dynamics, and a pure Poisson model can miss richer recent-form patterns. Combining them gives a more balanced prediction layer.

What the pipeline outputs

Each run produces artifacts that are useful both for people and for downstream systems:

  • predictions/latest_match_predictions.csv
  • predictions/latest_match_predictions.json
  • predictions/title_odds.csv
  • predictions/title_odds.json
  • predictions/report.md

The match predictions include:

  • predicted result
  • home/draw/away probabilities
  • expected goals
  • most likely scoreline

The title odds are intentionally labeled as provisional when the full tournament structure is not yet available from the API.

A small detail that matters: automation

I also wired the repo to run through GitHub Actions on a schedule and by manual dispatch.

The workflow:

  • installs Python and Node
  • installs dependencies
  • runs the full prediction pipeline
  • commits refreshed outputs back into the repository

That turns the project from "interesting code" into something that can act like a living forecast feed.

Project structure

world-cup-2026-prediction-sportmicro-api/
├─ .github/workflows/automation.yml
├─ scripts/build_endpoint.mjs
├─ scripts/run_pipeline.ps1
├─ src/wc2026_predictor/
│  ├─ cli.py
│  ├─ endpoint_builder.py
│  ├─ features.py
│  ├─ modeling.py
│  ├─ pipeline.py
│  ├─ reporting.py
│  └─ sportmicro.py
├─ data/
├─ artifacts/
└─ predictions/

I tried to keep the boundaries clean:

  • sportmicro.py handles API access and normalization
  • features.py builds the training and fixture frames
  • modeling.py owns training and prediction logic
  • pipeline.py orchestrates the end-to-end flow
  • reporting.py turns outputs into a readable Markdown report

Running it locally

Setup is straightforward:

npm install
python -m pip install --upgrade pip
python -m pip install .[dev]

Then create .env from .env.example and set your API key:

SPORTMICRO_API_KEY=your_sportmicro_api_key_here
SPORTMICRO_BASE_URL=https://football.sportmicro.com
WC2026_PREDICTION_START_DATE=2026-01-01
WC2026_RECENT_MATCH_START_DATE=2021-01-01

Run the full workflow:

python -m wc2026_predictor run-all

Or use the PowerShell wrapper:

./scripts/run_pipeline.ps1

What I would improve next

There is still plenty of room to push this further:

  • add probability calibration analysis
  • bring in more match-statistics features
  • simulate bracket progression once full 2026 structure is available
  • publish a small dashboard on top of the generated outputs

Those are the kinds of upgrades that would move the project from "useful forecasting repo" to "full sports analytics product."

Final thought

The part I care about most in projects like this is not just prediction accuracy. It is whether the system is structured well enough to rerun, inspect, automate, and extend.

That was the goal here: build a World Cup 2026 prediction repo that is practical, composable, and easy to evolve.

If you are building in sports analytics, APIs, or ML pipelines, I think this pattern is more useful than another isolated notebook.

If you want, I can also turn this into:

  • a shorter dev.to version with a more punchy hook
  • a more SEO-focused version
  • a version written in a more personal "build in public"