PySport / kloppy

kloppy: standardizing soccer tracking- and event data
https://kloppy.pysport.org
BSD 3-Clause "New" or "Revised" License
326 stars 55 forks source link

Add pressure event #283

Closed DriesDeprest closed 3 months ago

DriesDeprest commented 5 months ago

I want to add support for pressure events in our data model, by adding a PressureEvent class

@dataclass(repr=False)
@docstring_inherit_attributes(Event)
class PressureEvent(Event):
    """
    PressureEvent

    Attributes:
        event_type (EventType): `EventType.Pressure` (See [`EventType`][kloppy.domain.models.event.EventType])
        event_name (str): `"pressure"`,
        end_timestamp (float):
    """

    end_timestamp: float

    event_type: EventType = EventType.Pressure
    event_name: str = "pressure"

In a first phase, this event would only be created when deserializing StatsBomb data, for which I will add support. But in a later, I envision that for a given game we could generate PressureEvents out of the TrackingDataset and feed it back to the EventDataset.

Thoughts?

probberechts commented 5 months ago

This looks good to me. I like that you added the end_timestamp.

I guess you could also consider deriving an outcome (I am thinking of "ball retention" and "forced loss") and whether or not it is a counter-pressing event. But these features are not essential and could be added later too.