PySport/kloppy

Add pressure event

DriesDeprest opened this issue · 1 comments

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?

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.