RepositoryPythonNLNetherlands
UnravelSports

UnravelSports/unravelsports

The unravelsports package aims to aid researchers, analysts and enthusiasts by providing intermediary steps in the complex process of turning raw sports data into meaningful information and actionable insights.

251stars
34forks
7issues
0views

Featured achievements

The project's latest awards

1
TINIX TRENDING·Topic: graph-neural-networks

#1 Repository of the month

1
TINIX TRENDING·Topic: gnn

#1 Repository of the month

1
TINIX TRENDING·Topic: spektral

#1 Repository of the month

unravelsports logo

UnravelSports tl;dr legal

🌀 pip install unravelsports

🌀 Documentation

Finally, we have documentation! Check out:

👉 unravelsports.readthedocs.io

🌀 What is it?

The unravelsports package aims to aid researchers, analysts and enthusiasts by providing intermediary steps in the complex process of converting raw sports data into meaningful information and actionable insights.

This package currently supports:

🌀 Features

Polars DataFrames

⚽🏈 Convert Tracking Data into Polars DataFrames for rapid data conversion and data processing.

⚽ For soccer we rely on Kloppy and as such we support Sportec, SkillCorner, PFF / GradientSports, Metrica, StatsPerform, Tracab (CyronHego), SecondSpectrum, HawkEye and Signality tracking data.

from unravel.soccer import KloppyPolarsDataset

from kloppy import sportec

kloppy_dataset = sportec.load_open_tracking_data()
kloppy_polars_dataset = KloppyPolarsDataset(
    kloppy_dataset=kloppy_dataset
)
period_idtimestampframe_idball_stateidxyzteam_idposition_namegame_idvxvyvzvaxayazaball_owning_team_idis_ball_carrier
010 days 00:00:0010000aliveDFL-OBJ-00008F-20.67-4.560DFL-CLU-000005RCBDFL-MAT-J03WPY0.393-0.21400.4470000DFL-CLU-00000PFalse
110 days 00:00:0010000aliveDFL-OBJ-0000EJ-8.86-0.940DFL-CLU-000005UNKDFL-MAT-J03WPY-0.0090.01800.020000DFL-CLU-00000PFalse
210 days 00:00:0010000aliveDFL-OBJ-0000F8-2.129.850DFL-CLU-00000PRMDFL-MAT-J03WPY00000000DFL-CLU-00000PFalse
310 days 00:00:0010000aliveDFL-OBJ-0000NZ0.5723.230DFL-CLU-00000PRBDFL-MAT-J03WPY0.179-0.13400.2230000DFL-CLU-00000PFalse
410 days 00:00:0010000aliveDFL-OBJ-0001HW-46.260.080DFL-CLU-000005GKDFL-MAT-J03WPY0.3570.07100.3640000DFL-CLU-00000PFalse

🏈 For American Football we use BigDataBowl Data directly.

from unravel.american_football import BigDataBowlDataset

bdb = BigDataBowlDataset(
    tracking_file_path="week1.csv",
    players_file_path="players.csv",
    plays_file_path="plays.csv",
)

Graph Neural Networks

⚽🏈 Convert Polars Dataframes into Graphs to train graph neural networks. These Graphs can be used with PyTorch Geometric or Spektral. unravelsports allows you to randomize and split data into train, test and validation sets along matches, sequences or possessions to avoid leakage and improve model quality. And finally, train, validate and test your (custom) Graph model(s) and easily predict on new data.

from unravel.soccer import SoccerGraphConverter

converter = SoccerGraphConverter(
    dataset=kloppy_polars_dataset,
    self_loop_ball=True,
    adjacency_matrix_connect_type="ball",
    adjacency_matrix_type="split_by_team",
    label_type="binary",
    defending_team_node_value=0.1,
    non_potential_receiver_node_value=0.1,
    random_seed=False,
    pad=False,
    verbose=False,
)

Pressing Intensity

Compute Pressing Intensity for a whole game (or segment) of Soccer tracking data.

See Pressing Intensity Jupyter Notebook for an example how to create mp4 videos.

from unravel.soccer import PressingIntensity

import polars as pl

model = PressingIntensity(
    dataset=kloppy_polars_dataset
)
model.fit(
    start_time = pl.duration(minutes=1, seconds=53),
    end_time = pl.duration(minutes=2, seconds=32),
    period_id = 1,
    method="teams",
    ball_method="max",
    orient="home_away",
    speed_threshold=2.0,
) 

1. FC Köln vs. FC Bayern München (May 27th 2023)


Formation and Position Identification

Compute Elastic Formation and Position Identification, EFPI for individual frames, possessions, periods or specific time intervals for Soccer.

For more information on all possibilities for "every" check out Polars Documentation.

from unravel.soccer import EFPI

model = EFPI(dataset=kloppy_polars_dataset)
model.fit(
    # Default 65 formations , or specify a subset (e.g. ["442" , "433"])
    formations=None,
    # specific time intervals (e.g. 1m, 1m14s, 2m30s etc.), or specify "possession", "period" or "frame".
    every="5m",
    substitutions="drop",
    change_threshold=0.1,
    change_after_possession=True,
)

Elastic Formation and Position Identification Example

⌛ More to come soon...!

🌀 Quick Start

📖 ⚽ The Quick Start Jupyter Notebook explains how to convert any positional tracking data from Kloppy to Spektral GNN in a few easy steps while walking you through the most important features and documentation.

📖 ⚽ The Graph Converter Tutorial Jupyter Notebook gives an in-depth walkthrough.

📖 🏈 The BigDataBowl Converter Tutorial Jupyter Notebook gives an guide on how to convert the BigDataBowl data into Graphs.

📖 ⚽ The Pressing Intensity Tutorial Jupyter Notebook gives a description on how to create Pressing Intensity videos.

🌀 Additional Reading

📖 A Graph Neural Network Deep-dive into Successful Counterattacks {A. Sahasrabudhe J. Bekkers, 2023}

🎤 Cutting Edge Football Analytics: using polars, keras and spektral (PyData London, 2025)

🌀 Installation

The easiest way to get started is:

pip install unravelsports

🌀 Licenses

This project is licensed under the Mozilla Public License Version 2.0 (MPL), which requires that you include a copy of the license and provide attribution to the original authors. Any modifications you make to the MPL-licensed files must be documented, and the source code for those modifications must be made open-source under the same license.

🌀 Citation

If you use this repository for any educational purposes, research, project etc., please reference both:

📎 The unravelsports package.

BibTex
@software{unravelsports2024repository,
  author = {Bekkers, Joris},
  title = {unravelsports},
  version = {2.0.0},
  year = {2024},
  publisher = {GitHub},
  url = {https://github.com/unravelsports/unravelsports}
}

📎 Bekkers, J., & Sahasrabudhe, A. (2024). A Graph Neural Network deep-dive into successful counterattacks. arXiv preprint arXiv:2411.17450.

BibTex
@inproceedings{sahasrabudhe2023graph,
  title={A Graph Neural Network deep-dive into successful counterattacks},
  author={Sahasrabudhe, Amod and Bekkers, Joris},
  booktitle={17th Annual MIT Sloan Sports Analytics Conference. Boston, MA, USA: MIT},
  pages={15},
  year={2023}
}

📎 Bekkers, J. (2024). Pressing Intensity: An Intuitive Measure for Pressing in Soccer. arXiv preprint arXiv:2501.04712.

BibTex
@article{bekkers2024pressing,
  title={Pressing Intensity: An Intuitive Measure for Pressing in Soccer},
  author={Bekkers, Joris},
  journal={arXiv preprint arXiv:2501.04712},
  year={2024}
}

📎 Bekkers, J. (2025). EFPI: Elastic Formation and Position Identification in Football (Soccer) using Template Matching and Linear Assignment. arXiv preprint arXiv:2506.23843.

BibTex
@article{bekkers2025efpi,
  title={EFPI: Elastic Formation and Position Identification in Football (Soccer) using Template Matching and Linear Assignment},
  author={Bekkers, Joris},
  journal={arXiv preprint arXiv:2506.23843},
  year={2025}
}

🌀 Social Media

<img alt="LinkedIn" width="40px" src="https://upload.wikimedia.org/wikipedia/commons/c/ca/LinkedIn_logo_initials.png"/> <img alt="Bluesky" width="40px" src="https://upload.wikimedia.org/wikipedia/commons/thumb/7/7a/Bluesky_Logo.svg/2319px-Bluesky_Logo.svg.png"/>

Similar Projects

Discover other similar projects and AI models.

RepositoryPython
ML-KULeuven/socceraction

Convert soccer event stream data to SPADL and value player actions using VAEP or xT

832
Oct 18, 2026
Repository
matiasmascioto/awesome-soccer-analytics

:soccer::chart_with_upwards_trend: A curated list of awesome resources related to Soccer Analytics.

633
Nov 17, 2020
RepositoryTypeScript
langfuse/langfuse

🪢 Open source AI engineering platform: AI Gateway, agent observability, evals, and prompt/skill management, built on OpenTelemetry. One open platform for every AI call and every agent. Self-host or use Langfuse Cloud.

38.1k
Dec 1, 2026
RepositoryC++
tensorflow/tensorflow

An Open Source Machine Learning Framework for Everyone

201.9k
Dec 1, 2026
RepositoryGo
grafana/grafana

The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.

78.4k
Nov 30, 2026
RepositoryPython
roboflow/sports

computer vision and sports

5.5k
Nov 27, 2026
RepositoryPython
probberechts/soccerdata

⛏⚽ Scrape soccer data from Club Elo, ESPN, FBref, Football-Data.co.uk, Sofascore, SoFIFA, Understat and WhoScored.

2.1k
Nov 21, 2026
RepositoryPython
kyleskom/NBA-Machine-Learning-Sports-Betting

NBA sports betting using machine learning

1.8k
Nov 11, 2026
RepositoryPython
TorchSpatiotemporal/tsl

tsl: a PyTorch library for processing spatiotemporal data.

394
Nov 23, 2026