Skip to content

ubtuna/transfermarkt-analytics

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⚽ Transfermarkt Analytics

End-to-end football analytics project combining exploratory analysis, machine learning, and business intelligence to study European football performance using the Transfermarkt dataset.

Python Pandas Scikit-learn BigQuery Power BI License


📖 About

Final capstone project of the Workintech Data Scientist & AI Program, developed by a team of four. The project analyzes European football data from Transfermarkt across 14 leagues and 389 teams, delivering two interconnected analytical tracks plus a machine-learning prediction layer on top.


👥 Team & My Contribution

This was a 4-person team project. I personally led two of the analytical tracks:

Track Lead Notebook Dashboard Score
💰 Squad Value vs. Team Success Uğur Batuhan Tuna (me) 01_eda_squad_value/KadroDegeri_vs_Basari.ipynb 9.3 / 10
Match Result Prediction Uğur Batuhan Tuna (me) 02_eda_match_prediction/ + 03_ml_match_predictor/ 10 / 10
📊 [Track 3 name] [Teammate name / @github]
🎯 [Track 4 name] [Teammate name / @github]

This repository contains the tracks I led. The data was sourced from Transfermarkt.


🏗️ Project Structure

transfermarkt-analytics/
│
├── 📁 notebooks/
│   ├── 01_eda_squad_value/
│   │   └── KadroDegeri_vs_Basari.ipynb          # EDA + squad value vs success analysis
│   ├── 02_eda_match_prediction/
│   │   └── eda_match_prediction.ipynb           # Data prep for the ML model
│   └── 03_ml_match_predictor/
│       └── MacTahminiwithPredictor_Model.ipynb  # ML training + predict_match() demo
│
├── 📁 data/
│   ├── raw/                                      # Raw Transfermarkt data
│   ├── processed/                                # Cleaned dataset for the ML model
│   └── README.md
│
├── 📁 dashboards/
│   ├── KadroDegeriVsBasariFinalVersionDone.pbix
│   ├── Match_Prediction.pbix
│   └── *.png                                     # Dashboard screenshots
│
├── 📁 docs/
│   ├── sunum_rehberi.md                          # Presentation guide
│   └── mac_tahmini_ozet.md                       # Match prediction technical summary
│
├── 📄 requirements.txt
├── 📄 .gitignore
├── 📄 LICENSE
└── 📄 README.md

🛠️ Tech Stack

Data & Cloud

  • Google BigQuery — backup of the raw Transfermarkt dataset
  • Google Colab — notebook environment

Python

  • pandas, numpy — data manipulation
  • scikit-learn — ML models (Logistic Regression, Random Forest)
  • matplotlib, seaborn — plots inside notebooks

Visualization

  • Power BI Desktop — interactive dashboards

Collaboration

  • GitHub, Trello

🏗️ Pipeline

           ┌─────────────────────────────┐
           │  Raw Transfermarkt Data     │
           └──────────┬──────────────────┘
                      │
        ┌─────────────┴──────────────┐
        │                            │
        ▼                            ▼
┌───────────────────┐       ┌────────────────────┐
│ 01 EDA            │       │ 02 EDA             │
│ Squad Value vs    │       │ Match Prediction   │
│ Success           │       │ (data prep)        │
└─────────┬─────────┘       └──────────┬─────────┘
          │                            │
          ▼                            ▼
┌───────────────────┐       ┌────────────────────┐
│ Power BI          │       │ Processed dataset  │
│ Kadro Değeri      │       └──────────┬─────────┘
│ Dashboard         │                  │
└───────────────────┘                  ▼
                             ┌────────────────────┐
                             │ 03 ML Model        │
                             │ MacTahmini with    │
                             │ Predictor          │
                             └──────────┬─────────┘
                                        │
                                        ▼
                             ┌────────────────────┐
                             │ Power BI           │
                             │ Match Prediction   │
                             │ Dashboard          │
                             └────────────────────┘

💰 Track 1 — Squad Value vs. Team Success

Question: Do teams with higher squad market values actually win more? Who punches above their weight?

Notebook: notebooks/01_eda_squad_value/KadroDegeri_vs_Basari.ipynb

Approach

  • Cleaned and joined Transfermarkt squad-value data with league standings across 14 leagues.
  • Computed correlation between total squad value and sporting outcomes (points, wins, goal difference).
  • Identified outlier clubs — over-performers and under-performers relative to their market value.
  • Exported aggregated metrics for the Power BI dashboard.

📊 Dashboard

Overview — Squad Value vs. Points Correlation

Overall correlation across 1,353 club-seasons: r = 0.56. Money buys a baseline, but not a ceiling.

Squad Value Overview

League Comparison — Cost per Point

How much do teams pay (in €M squad value) for each league point? Premier League is the most expensive at €6.8M/point, Süper Lig the cheapest at €1.4M.

League Comparison

Efficiency Analysis — Over- and Under-Performers (2025)

Who delivers value for money, and who spends big for little return?

Efficiency 2025

Project Review Score: 9.3 / 10


⚽ Track 2 — Match Result Prediction

Question: Can we predict home-win / draw / away-win from squad value, form, and head-to-head history?

This track is split across two notebooks: one for data preparation, one for the ML model.

🧪 Step 1 — EDA & Data Preparation

Notebook: notebooks/02_eda_match_prediction/eda_match_prediction.ipynb

  • Loaded raw match and club data.
  • Cleaned, joined, and engineered features:
    • Squad market value differential (home vs. away)
    • Recent form (rolling points over the last N matches)
    • Head-to-head historical record
    • Home advantage indicator
    • League-level context features
  • Wrote the processed dataset to data/processed/ for the ML notebook.

🤖 Step 2 — ML Model & Live Predictor

Notebook: notebooks/03_ml_match_predictor/MacTahminiwithPredictor_Model.ipynb

  • Loaded the processed dataset.
  • Trained and compared Logistic Regression and Random Forest classifiers.
  • Evaluated with accuracy, precision/recall, and confusion matrices.
  • Exposed a predict_match(home_team, away_team) function returning probabilities for each outcome.

📊 Dashboard

Overview — Match Outcome Distribution

Across 54,890 matches: 44.4% home wins, 30.5% away wins, 25.1% draws. Home advantage is real and remarkably consistent across seasons.

Match Prediction Overview

Home Advantage & League Comparison

Which leagues show the strongest home advantage? Süper Lig and La Liga top the list, while Eredivisie sees more away wins than most.

Home Advantage

Squad Value Impact on Match Outcome

When one team's squad value dominates the other's, the goal difference distribution shifts sharply. A "crushing advantage" (Ezici Üstünlük) predicts a home win 66% of the time.

Value Impact

Project Review Score: 10 / 10


🚀 Getting Started

Prerequisites

  • Python 3.10+
  • Power BI Desktop (to open the .pbix files) — download here

Install dependencies

git clone https://github.com/ubtuna/transfermarkt-analytics.git
cd transfermarkt-analytics

python -m venv venv
source venv/bin/activate          # Linux/Mac/WSL
# venv\Scripts\activate           # Windows PowerShell

pip install -r requirements.txt

Running the notebooks

The notebooks are designed to run in order:

  1. Track 1 (standalone):

    • Open notebooks/01_eda_squad_value/KadroDegeri_vs_Basari.ipynb
    • Make sure data/raw/ is populated (see data/README.md)
    • Run all cells
  2. Track 2 (two-step):

    • First run notebooks/02_eda_match_prediction/eda_match_prediction.ipynb → produces a cleaned dataset in data/processed/
    • Then run notebooks/03_ml_match_predictor/MacTahminiwithPredictor_Model.ipynb → trains the model and exposes predict_match()

📚 Documentation


🔭 Next Steps

Ideas I'd like to explore in a future version:

  • Add a dbt layer for modular data transformations
  • Benchmark Random Forest against XGBoost and LightGBM
  • Wrap predict_match() in a simple Streamlit app
  • Schedule BigQuery refreshes for a live demo

📜 License

MIT License — see LICENSE for details.


👤 Author

Uğur Batuhan Tuna Data Scientist / Data Analyst | Workintech Graduate | Ex-Capgemini


Built with ☕ and an unreasonable amount of football statistics.

About

End-to-end football analytics using Python, SQL, BigQuery, and Power BI — capstone project of Workintech Data Scientist & AI Program.

Topics

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors