Event
Dataset
kloppy.domain.models.event.EventDataset (Dataset)
dataclass
EventDataset
Attributes:
Name | Type | Description |
---|---|---|
metadata |
Metadata |
See |
records |
List[Event] |
See |
dataset_type |
DatasetType |
|
events |
alias for |
add_state(self, *builder_keys)
See [add_state][kloppy.domain.services.state_builder.add_state]
filter(self, filter_)
inherited
Filter all records used filter_
Parameters:
Name | Type | Description | Default |
---|---|---|---|
- |
filter_ |
required |
Examples:
>>> from kloppy.domain import EventType
>>> dataset = dataset.filter(lambda event: event.event_type == EventType.PASS)
>>> dataset = dataset.filter('pass')
Source code in kloppy/domain/models/event.py
def filter(self, filter_):
"""
Filter all records used `filter_`
Arguments:
- filter_:
Examples:
>>> from kloppy.domain import EventType
>>> dataset = dataset.filter(lambda event: event.event_type == EventType.PASS)
>>> dataset = dataset.filter('pass')
"""
return replace(
self,
records=self.find_all(filter_),
)
Events
Event base class
kloppy.domain.models.event.Event (DataRecord, ABC)
dataclass
Abstract event baseclass. All other event classes inherit from this class.
Attributes:
Name | Type | Description |
---|---|---|
period |
Period |
See |
timestamp |
float |
Timestamp of occurrence |
ball_owning_team |
Optional[kloppy.domain.models.common.Team] |
See |
ball_state |
Optional[kloppy.domain.models.common.BallState] |
See |
event_id |
str |
identifier given by provider |
team |
Team |
See |
player |
Player |
See |
coordinates |
Point |
Coordinates where event happened. See |
raw_event |
Dict |
Dict |
state |
Dict[str, Any] |
Dict[str, Any] |
qualifiers |
List[kloppy.domain.models.event.Qualifier] |
See |
__repr__(self)
special
get_qualifier_value(self, qualifier_type)
Returns the Qualifier of a certain type, or None if qualifier is not present.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
qualifier_type |
Type[kloppy.domain.models.event.Qualifier] |
one of the following QualifierTypes: |
required |
Examples:
>>> from kloppy.domain import SetPieceQualifier
>>> pass_event.get_qualifier_value(SetPieceQualifier)
<SetPieceType.GOAL_KICK: 'GOAL_KICK'>
Source code in kloppy/domain/models/event.py
def get_qualifier_value(self, qualifier_type: Type[Qualifier]):
"""
Returns the Qualifier of a certain type, or None if qualifier is not present.
Arguments:
qualifier_type: one of the following QualifierTypes: [`SetPieceQualifier`][kloppy.domain.models.event.SetPieceQualifier]
[`BodyPartQualifier`][kloppy.domain.models.event.BodyPartQualifier] [`PassQualifier`][kloppy.domain.models.event.PassQualifier]
Examples:
>>> from kloppy.domain import SetPieceQualifier
>>> pass_event.get_qualifier_value(SetPieceQualifier)
<SetPieceType.GOAL_KICK: 'GOAL_KICK'>
"""
if self.qualifiers:
for qualifier in self.qualifiers:
if isinstance(qualifier, qualifier_type):
return qualifier.value
return None
kloppy.domain.models.event.ShotEvent (Event)
dataclass
ShotEvent
Attributes:
Name | Type | Description |
---|---|---|
period |
Period |
See |
timestamp |
float |
Timestamp of occurrence |
ball_owning_team |
Optional[kloppy.domain.models.common.Team] |
See |
ball_state |
Optional[kloppy.domain.models.common.BallState] |
See |
event_id |
str |
identifier given by provider |
team |
Team |
See |
player |
Player |
See |
coordinates |
Point |
Coordinates where event happened. See |
raw_event |
Dict |
Dict |
state |
Dict[str, Any] |
Dict[str, Any] |
qualifiers |
List[kloppy.domain.models.event.Qualifier] |
See |
event_type |
EventType |
|
event_name |
str |
|
result_coordinates |
Point |
See |
result |
ShotResult |
See |
kloppy.domain.models.event.PassEvent (Event)
dataclass
PassEvent
Attributes:
Name | Type | Description |
---|---|---|
period |
Period |
See |
timestamp |
float |
Timestamp of occurrence |
ball_owning_team |
Optional[kloppy.domain.models.common.Team] |
See |
ball_state |
Optional[kloppy.domain.models.common.BallState] |
See |
event_id |
str |
identifier given by provider |
team |
Team |
See |
player |
Player |
See |
coordinates |
Point |
Coordinates where event happened. See |
raw_event |
Dict |
Dict |
state |
Dict[str, Any] |
Dict[str, Any] |
qualifiers |
List[kloppy.domain.models.event.Qualifier] |
See |
event_type |
EventType |
|
event_name |
str |
|
receive_timestamp |
float |
|
receiver_coordinates |
Point |
See |
receiver_player |
Player |
See |
result |
PassResult |
See |
kloppy.domain.models.event.TakeOnEvent (Event)
dataclass
TakeOnEvent
Attributes:
Name | Type | Description |
---|---|---|
period |
Period |
See |
timestamp |
float |
Timestamp of occurrence |
ball_owning_team |
Optional[kloppy.domain.models.common.Team] |
See |
ball_state |
Optional[kloppy.domain.models.common.BallState] |
See |
event_id |
str |
identifier given by provider |
team |
Team |
See |
player |
Player |
See |
coordinates |
Point |
Coordinates where event happened. See |
raw_event |
Dict |
Dict |
state |
Dict[str, Any] |
Dict[str, Any] |
qualifiers |
List[kloppy.domain.models.event.Qualifier] |
See |
event_type |
EventType |
|
event_name |
str |
|
result |
TakeOnResult |
See |
kloppy.domain.models.event.CarryEvent (Event)
dataclass
CarryEvent
Attributes:
Name | Type | Description |
---|---|---|
period |
Period |
See |
timestamp |
float |
Timestamp of occurrence |
ball_owning_team |
Optional[kloppy.domain.models.common.Team] |
See |
ball_state |
Optional[kloppy.domain.models.common.BallState] |
See |
event_id |
str |
identifier given by provider |
team |
Team |
See |
player |
Player |
See |
coordinates |
Point |
Coordinates where event happened. See |
raw_event |
Dict |
Dict |
state |
Dict[str, Any] |
Dict[str, Any] |
qualifiers |
List[kloppy.domain.models.event.Qualifier] |
See |
event_type |
EventType |
|
event_name |
str |
|
end_timestamp |
float |
|
end_coordinates |
Point |
See |
result |
CarryResult |
See |
kloppy.domain.models.event.RecoveryEvent (Event)
dataclass
RecoveryEvent
Attributes:
Name | Type | Description |
---|---|---|
period |
Period |
See |
timestamp |
float |
Timestamp of occurrence |
ball_owning_team |
Optional[kloppy.domain.models.common.Team] |
See |
ball_state |
Optional[kloppy.domain.models.common.BallState] |
See |
event_id |
str |
identifier given by provider |
team |
Team |
See |
player |
Player |
See |
coordinates |
Point |
Coordinates where event happened. See |
raw_event |
Dict |
Dict |
state |
Dict[str, Any] |
Dict[str, Any] |
qualifiers |
List[kloppy.domain.models.event.Qualifier] |
See |
event_type |
EventType |
|
event_name |
str |
"recovery" |
kloppy.domain.models.event.SubstitutionEvent (Event)
dataclass
SubstitutionEvent
Attributes:
Name | Type | Description |
---|---|---|
period |
Period |
See |
timestamp |
float |
Timestamp of occurrence |
ball_owning_team |
Optional[kloppy.domain.models.common.Team] |
See |
ball_state |
Optional[kloppy.domain.models.common.BallState] |
See |
event_id |
str |
identifier given by provider |
team |
Team |
See |
player |
Player |
See |
coordinates |
Point |
Coordinates where event happened. See |
raw_event |
Dict |
Dict |
state |
Dict[str, Any] |
Dict[str, Any] |
qualifiers |
List[kloppy.domain.models.event.Qualifier] |
See |
event_type |
EventType |
|
event_name |
str |
|
replacement_player |
Player |
See |
kloppy.domain.models.event.PlayerOnEvent (Event)
dataclass
PlayerOnEvent
Attributes:
Name | Type | Description |
---|---|---|
period |
Period |
See |
timestamp |
float |
Timestamp of occurrence |
ball_owning_team |
Optional[kloppy.domain.models.common.Team] |
See |
ball_state |
Optional[kloppy.domain.models.common.BallState] |
See |
event_id |
str |
identifier given by provider |
team |
Team |
See |
player |
Player |
See |
coordinates |
Point |
Coordinates where event happened. See |
raw_event |
Dict |
Dict |
state |
Dict[str, Any] |
Dict[str, Any] |
qualifiers |
List[kloppy.domain.models.event.Qualifier] |
See |
event_type |
EventType |
|
event_name |
str |
|
kloppy.domain.models.event.PlayerOffEvent (Event)
dataclass
PlayerOffEvent
Attributes:
Name | Type | Description |
---|---|---|
period |
Period |
See |
timestamp |
float |
Timestamp of occurrence |
ball_owning_team |
Optional[kloppy.domain.models.common.Team] |
See |
ball_state |
Optional[kloppy.domain.models.common.BallState] |
See |
event_id |
str |
identifier given by provider |
team |
Team |
See |
player |
Player |
See |
coordinates |
Point |
Coordinates where event happened. See |
raw_event |
Dict |
Dict |
state |
Dict[str, Any] |
Dict[str, Any] |
qualifiers |
List[kloppy.domain.models.event.Qualifier] |
See |
event_type |
EventType |
|
event_name |
str |
|
kloppy.domain.models.event.CardEvent (Event)
dataclass
CardEvent
Attributes:
Name | Type | Description |
---|---|---|
period |
Period |
See |
timestamp |
float |
Timestamp of occurrence |
ball_owning_team |
Optional[kloppy.domain.models.common.Team] |
See |
ball_state |
Optional[kloppy.domain.models.common.BallState] |
See |
event_id |
str |
identifier given by provider |
team |
Team |
See |
player |
Player |
See |
coordinates |
Point |
Coordinates where event happened. See |
raw_event |
Dict |
Dict |
state |
Dict[str, Any] |
Dict[str, Any] |
qualifiers |
List[kloppy.domain.models.event.Qualifier] |
See |
event_type |
EventType |
|
event_name |
str |
|
card_type |
CardType |
See |
kloppy.domain.models.event.FoulCommittedEvent (Event)
dataclass
FoulCommittedEvent
Attributes:
Name | Type | Description |
---|---|---|
period |
Period |
See |
timestamp |
float |
Timestamp of occurrence |
ball_owning_team |
Optional[kloppy.domain.models.common.Team] |
See |
ball_state |
Optional[kloppy.domain.models.common.BallState] |
See |
event_id |
str |
identifier given by provider |
team |
Team |
See |
player |
Player |
See |
coordinates |
Point |
Coordinates where event happened. See |
raw_event |
Dict |
Dict |
state |
Dict[str, Any] |
Dict[str, Any] |
qualifiers |
List[kloppy.domain.models.event.Qualifier] |
See |
event_type |
EventType |
|
event_name |
str |
"foul_committed" |
kloppy.domain.models.event.BallOutEvent (Event)
dataclass
BallOutEvent
Attributes:
Name | Type | Description |
---|---|---|
period |
Period |
See |
timestamp |
float |
Timestamp of occurrence |
ball_owning_team |
Optional[kloppy.domain.models.common.Team] |
See |
ball_state |
Optional[kloppy.domain.models.common.BallState] |
See |
event_id |
str |
identifier given by provider |
team |
Team |
See |
player |
Player |
See |
coordinates |
Point |
Coordinates where event happened. See |
raw_event |
Dict |
Dict |
state |
Dict[str, Any] |
Dict[str, Any] |
qualifiers |
List[kloppy.domain.models.event.Qualifier] |
See |
event_type |
EventType |
|
event_name |
str |
"ball_out" |
kloppy.domain.models.event.GenericEvent (Event)
dataclass
GenericEvent
Attributes:
Name | Type | Description |
---|---|---|
period |
Period |
See |
timestamp |
float |
Timestamp of occurrence |
ball_owning_team |
Optional[kloppy.domain.models.common.Team] |
See |
ball_state |
Optional[kloppy.domain.models.common.BallState] |
See |
event_id |
str |
identifier given by provider |
team |
Team |
See |
player |
Player |
See |
coordinates |
Point |
Coordinates where event happened. See |
raw_event |
Dict |
Dict |
state |
Dict[str, Any] |
Dict[str, Any] |
qualifiers |
List[kloppy.domain.models.event.Qualifier] |
See |
event_type |
EventType |
|
event_name |
str |
|
Results
kloppy.domain.models.event.ShotResult (ResultType)
ShotResult
Attributes:
Name | Type | Description |
---|---|---|
GOAL |
ShotResult |
Shot resulted in a goal |
OFF_TARGET |
ShotResult |
Shot was off target |
POST |
ShotResult |
Shot hit the post |
BLOCKED |
ShotResult |
Shot was blocked by another player |
SAVED |
ShotResult |
Shot was saved by the keeper |
kloppy.domain.models.event.PassResult (ResultType)
PassResult
Attributes:
Name | Type | Description |
---|---|---|
COMPLETE |
PassResult |
Complete pass |
INCOMPLETE |
PassResult |
Incomplete pass (intercepted) |
OUT |
PassResult |
Ball went out |
OFFSIDE |
PassResult |
Offside |
kloppy.domain.models.event.CarryResult (ResultType)
CarryResult
Attributes:
Name | Type | Description |
---|---|---|
COMPLETE |
CarryResult |
Complete carry |
INCOMPLETE |
CarryResult |
Incomplete carry |
kloppy.domain.models.event.TakeOnResult (ResultType)
TakeOnResult
Attributes:
Name | Type | Description |
---|---|---|
COMPLETE |
TakeOnResult |
Complete take-on |
INCOMPLETE |
TakeOnResult |
Incomplete take-on |
OUT |
TakeOnResult |
Ball went out |
Types
kloppy.domain.models.event.EventType (Enum)
Attributes:
Name | Type | Description |
---|---|---|
GENERIC |
EventType |
Unrecognised event type |
PASS |
EventType |
|
SHOT |
EventType |
|
TAKE_ON |
EventType |
|
CARRY |
EventType |
|
SUBSTITUTION |
EventType |
|
CARD |
EventType |
|
PLAYER_ON |
EventType |
|
PLAYER_OFF |
EventType |
|
RECOVERY |
EventType |
|
BALL_OUT |
EventType |
|
FOUL_COMMITTED |
EventType |
|
FORMATION_CHANGE |
EventType |
kloppy.domain.models.event.CardType (Enum)
CardType
Attributes:
Name | Type | Description |
---|---|---|
FIRST_YELLOW |
CardType |
First yellow card |
SECOND_YELLOW |
CardType |
Second yellow card |
RED |
CardType |
Red card |
Qualifiers
Qualifier specify additional information about certain events. See get_qualifier_value
for usage.
kloppy.domain.models.event.Qualifier (ABC)
dataclass
kloppy.domain.models.event.SetPieceQualifier (EnumQualifier)
dataclass
SetPieceQualifier
Attributes:
Name | Type | Description |
---|---|---|
value |
SetPieceType |
Specifies the type of set piece |
kloppy.domain.models.event.SetPieceType (Enum)
SetPieceType
Attributes:
Name | Type | Description |
---|---|---|
GOAL_KICK |
SetPieceType |
|
FREE_KICK |
SetPieceType |
|
THROW_IN |
SetPieceType |
|
CORNER_KICK |
SetPieceType |
|
PENALTY |
SetPieceType |
|
KICK_OFF |
SetPieceType |
kloppy.domain.models.event.BodyPartQualifier (EnumQualifier)
dataclass
BodyPartQualifier(value: kloppy.domain.models.event.BodyPart)
kloppy.domain.models.event.BodyPart (Enum)
BodyPart
Attributes:
Name | Type | Description |
---|---|---|
RIGHT_FOOT |
BodyPart |
Pass or Shot with right foot, save with right foot (for goalkeepers). |
LEFT_FOOT |
BodyPart |
Pass or Shot with leftt foot, save with left foot (for goalkeepers). |
HEAD |
BodyPart |
Pass or Shot with head, save with head (for goalkeepers). |
BOTH_HANDS |
BodyPart |
Goalkeeper only. Save with both hands. |
CHEST |
BodyPart |
Goalkeeper only. Save with chest. |
LEFT_HAND |
BodyPart |
Goalkeeper only. Save with left hand. |
RIGHT_HAND |
BodyPart |
Goalkeeper only. Save with right hand. |
DROP_KICK |
BodyPart |
Pass is a keeper drop kick. |
KEEPER_ARM |
BodyPart |
Pass thrown from keepers hands. |
OTHER |
BodyPart |
Other body part (chest, back, etc.), for Pass and Shot. |
NO_TOUCH |
BodyPart |
Pass only. A player deliberately let the pass go past him instead of receiving it to deliver to a teammate behind him. (Also known as a "dummy"). |
kloppy.domain.models.event.PassQualifier (EnumQualifier)
dataclass
PassQualifier(value: kloppy.domain.models.event.PassType)
kloppy.domain.models.event.PassType (Enum)
PassType
Attributes:
Name | Type | Description |
---|---|---|
CROSS |
PassType |
|
HAND_PASS |
PassType |
|
HEAD_PASS |
PassType |
|
HIGH_PASS |
PassType |
|
LAUNCH |
PassType |
|
SIMPLE_PASS |
PassType |
|
SMART_PASS |
PassType |