Skip to main content

A package for loading, preprocessing, vizualising and synchronizing soccere event and tracking data.

Project description

Logo

Latest Version Python Version Documentation Status CI/CD Status Codecov

DataBallPy

A package for loading, synchronizing, and analyzing your soccer event- and tracking data.

This package is developed to create a standardized way to analyse soccer matches using both event- and tracking data. Other packages, like kloppy and floodlight, already standardize the import of data sources. The current package goes a step further in combining different data streams from the same match. In this case, the Match object combines information from the event and tracking data. The main current feature is the smart synchronization of the tracking and event data. We utilize the Needleman-Wunch algorithm, inspired by this article, to align the tracking and even data, while ensuring the order of the events, something that is not done when only using (different) cost functions.

Final goal for DataBallPy

Although reading in and synchronising data is already very helpfull to get started with your analysis, it's only the first step. Even after this first step, getting your first 'simple' metrics out of the data might be more difficult than anticipated. Therefore, the primary end goal for this package is to create a space where (scientific) soccer metrics are implemented and can be used in a few lines. We even plan to go further and show clear notebooks (to combine text and code) with visualizations for all the features we implement. This way, you will not only get easy access to the features/metrics, but also understand exactly how it is calculated. We hope this will inspire others (both developers and scientist) to further improve the current features, and come up with valuable new ones. If you are interested in some of the features we implemented, see our official documentation.

V0.5.2 (15/11/2024)

  • Added match.get_column_ids with filters for team, player positions and minimal minutes played filters.
  • Added parser for DFL/Sportec Solutions event data
  • Added parser for Tracab xml format, used by DFL and Sportec solutions
  • Added integration for open data from DFL (open sourced by Bassek et al.)

Breaking changes

  • From now on, match.home_players_column_ids() and match.away_players_column_ids() are depreciated and will be removed in V0.7.0. Please use match.get_column_ids() in future version.
  • get_open_match() will now, by default, load in match J03WMX (1. FC Köln vs. FC Bayern München) instead of the anonimysed match from Metrica. To load in the metrica match, please parse provider="metrica" in the key word arguments.

Installation

$ pip install databallpy

Usage

The package is centered around the Match object. A Match has tracking data, event data metadata about the match. For a more elaborate example, see the Getting Started.

from databallpy import get_match, get_open_match

match = get_match(
  tracking_data_loc="../data/tracking_data.dat",
  tracking_metadata_loc="../data/tracking_metadata.xml",
  tracking_data_provider="tracab"
  event_data_loc="../data/event_data_f24.xml",
  event_metadata_loc="../data/event_metadata_f7.xml",
  event_data_provider="opta",
)

# or get the open match provided by the DFL (Sportec Solutions)
match = get_open_match()

[!note] The current supported tracking data providers are:

  • Tracab (including Sportec Solutions from the DFL)
  • Metrica
  • Inmotio

The accepted variables for the tracking_data_provider are ["tracab", "metrica", "inmotio", "dfl", "sportec"]

The current supported event data provider are:

  • Opta
  • Metrica
  • Instat
  • SciSports
  • Sportec Solutions (from the DFL)

The accepted variables for the event_data_provider are ["opta", "metrica", "instat", "scisports", "dfl", "sportec"]

If you wish to use a different provider that is not listed here, please open an issue here

See the documentation of the Match object and the example usage for more options. Note that this package is developed to combine event and tracking data, for now both datastreams are necessary to create a Match object.

Features

Preprocessing

Synchronization of tracking and event data

See our elaborate synchronisation page in the documentation for more information!

Tracking and event data is often poorly synchronized. For instance, when taking the event data of Opta and tracking data of Tracab, you can sync the fist frame with the kick-off pass. Now you can sync the other events with the tracking data based on the time difference between the event and the kick off pass. If you do this, how get something like this:

Your browser does not support the video tag.

https://user-images.githubusercontent.com/49450063/224564808-fa71735f-5510-464d-8499-9044227a02e8.mp4

As you can see, the timing (and placing) of the events do not correspond good with the tracking data locations, especially when events follow up quickly or around shots. Using the methodology of this article, this package is able to synchronize tracking and event data using the Needleman-Wunsch algorithm.

After running the following command, the events are better synchronized to the tracking data:

$ match.synchronise_tracking_and_event_data()
Your browser does not support the video tag.

https://user-images.githubusercontent.com/49450063/224564913-4091faf7-f6ef-4429-b132-7f93ce5e1d91.mp4

For a more elaborate example of how we synchronize the tracking and event data, see the Synchronisation Page in our documentation.

Visualizations

DataBallPy offers a variety of visualizations to help you understand the data better. For example, you can visualize the tracking data with synchronised event as shown above. Also, you can visualize events and tracking data separately. For more information, see the Visualizations Page in our documentation.

Soccer Specific Metrics

  • Covered Distance: Calculate the covered distance in different velocity and acceleration zones.
  • Pressure: Calculate the pressure any player in the match (Herold & Kempe, 2022).
  • Team Possession: Calculate the team possession based on the synchronised event data.
  • Individual Player Possession: Calculate the individual player possession based on the tracking data (Vidal-Codina et al., 2022).
  • Simple Expected Goals (xG) model: Calculate the simple expected goals model.
  • Expected Threat model: Calculate the expected threat model from Karun Singh to on ball events.
  • Voronoi Model: Calculate the Voronoi space occupation based on the tracking data.
  • Gaussian Model: Calculate the Gaussian space occupation based on the tracking data (Fernandez & Born, 2018).

Documentation

The official documentation can be found here.

Providers

For now we limited providers. We are planning on adding more providers later on.

Event data providers:

  • Opta
  • Metrica
  • Instat
  • SciSports
  • Sportec Solutions (for the DFL)

Tracking data providers:

  • Tracab (including Sportec Solutions format from the DFL)
  • Metrica
  • Inmotio

Contributing

Interested in contributing? Check out the contributing guidelines. Please note that this project is released with a Code of Conduct. By contributing to this project, you agree to abide by its terms.

Maintainers & owners

Contributors

License

databallpy was created by Alexander Oonk & Daan Grob. It is licensed under the terms of the MIT license.

Similar projects

Although we think this package helps when starting to analyse soccer data, other packages may be better suited for your specific needs. Make sure to check out the following packages as well:

And for a more specific toturials on how to get started with soccer data"

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

databallpy-0.5.2.tar.gz (865.1 kB view details)

Uploaded Source

Built Distribution

databallpy-0.5.2-py3-none-any.whl (887.6 kB view details)

Uploaded Python 3

File details

Details for the file databallpy-0.5.2.tar.gz.

File metadata

  • Download URL: databallpy-0.5.2.tar.gz
  • Upload date:
  • Size: 865.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.11.1 Darwin/24.0.0

File hashes

Hashes for databallpy-0.5.2.tar.gz
Algorithm Hash digest
SHA256 81f8e4a6b2ffc499229e48f1b824b2e093c3d8e6a22fcad4301ecc37cd2f60a6
MD5 1385f71d7ef991874f261f9c485e56fb
BLAKE2b-256 c004be4974faf385c1f24a8a55884a1defce371143dd7a533d338554a084b9b8

See more details on using hashes here.

File details

Details for the file databallpy-0.5.2-py3-none-any.whl.

File metadata

  • Download URL: databallpy-0.5.2-py3-none-any.whl
  • Upload date:
  • Size: 887.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.11.1 Darwin/24.0.0

File hashes

Hashes for databallpy-0.5.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9b78ded85f5cb0a7466238cc5149b9d191105b033b3c972f010288075b303205
MD5 8b276554bb19d8c028e547be253f3226
BLAKE2b-256 b96da4c50af2f42b49be9f3609c2fb3174e2d0c6871d5d0876c9b1fda2d413b9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page