socceraction.vaep.features#

Implements the feature tranformers of the VAEP framework.

socceraction.vaep.features.actiontype(actions)#

Get the type of each action.

Parameters

actions (Actions) – The actions of a game.

Returns

The ‘type_id’ of each action.

Return type

Features

socceraction.vaep.features.actiontype_onehot(actions)#

Get the one-hot-encoded type of each action.

Parameters

actions (SPADLActions) – The actions of a game.

Returns

A one-hot encoding of each action’s type.

Return type

Features

socceraction.vaep.features.actiontype_result_onehot(actions)#

Get a one-hot encoding of the combination between the type and result of each action.

Parameters

actions (SPADLActions) – The actions of a game.

Returns

The one-hot encoding of each action’s type and result.

Return type

Features

socceraction.vaep.features.bodypart(actions)#

Get the body part used to perform each action.

Parameters

actions (Actions) – The actions of a game.

Returns

The ‘bodypart_id’ of each action.

Return type

Features

socceraction.vaep.features.bodypart_onehot(actions)#

Get the one-hot-encoded bodypart of each action.

Parameters

actions (Actions) – The actions of a game.

Returns

The one-hot encoding of each action’s bodypart.

Return type

Features

socceraction.vaep.features.endlocation(actions)#

Get the location where each action ended.

Parameters

actions (SPADLActions) – The actions of a game.

Returns

The ‘end_x’ and ‘end_y’ location of each action.

Return type

Features

socceraction.vaep.features.endpolar(actions)#

Get the polar coordinates of each action’s end location.

The center of the opponent’s goal is used as the origin.

Parameters

actions (SPADLActions) – The actions of a game.

Returns

The ‘start_dist_to_goal’ and ‘start_angle_to_goal’ of each action.

Return type

Features

socceraction.vaep.features.feature_column_names(fs, nb_prev_actions=3)#

Return the names of the features generated by a list of transformers.

Parameters
  • fs (list(callable)) – A list of feature transformers.

  • nb_prev_actions (int, default=3 # noqa: DAR103) – The number of previous actions included in the game state.

Returns

The name of each generated feature.

Return type

list(str)

socceraction.vaep.features.gamestates(actions, nb_prev_actions=3)#

Convert a dataframe of actions to gamestates.

Each gamestate is represented as the <nb_prev_actions> previous actions.

The list of gamestates is internally represented as a list of actions dataframes \([a_0,a_1,\ldots]\) where each row in the a_i dataframe contains the previous action of the action in the same row in the \(a_{i-1}\) dataframe.

Parameters
  • actions (Actions) – A DataFrame with the actions of a game.

  • nb_prev_actions (int, default=3 # noqa: DAR103) – The number of previous actions included in the game state.

Returns

The <nb_prev_actions> previous actions for each action.

Return type

GameStates

socceraction.vaep.features.goalscore(gamestates)#

Get the number of goals scored by each team after the action.

Parameters

gamestates (GameStates) – The gamestates of a game.

Returns

The number of goals scored by the team performing the last action of the game state (‘goalscore_team’), by the opponent (‘goalscore_opponent’), and the goal difference between both teams (‘goalscore_diff’).

Return type

Features

socceraction.vaep.features.movement(actions)#

Get the distance covered by each action.

Parameters

actions (SPADLActions) – The actions of a game.

Returns

The horizontal (‘dx’), vertical (‘dy’) and total (‘movement’) distance covered by each action.

Return type

Features

socceraction.vaep.features.play_left_to_right(gamestates, home_team_id)#

Perform all action in the same playing direction.

This changes the start and end location of each action, such that all actions are performed as if the team plays from left to right.

Parameters
  • gamestates (GameStates) – The game states of a game.

  • home_team_id (int) – The ID of the home team.

Returns

The game states with all actions performed left to right.

Return type

GameStates

socceraction.vaep.features.result(actions)#

Get the result of each action.

Parameters

actions (SPADLActions) – The actions of a game.

Returns

The ‘result_id’ of each action.

Return type

Features

socceraction.vaep.features.result_onehot(actions)#

Get the one-hot-encode result of each action.

Parameters

actions (SPADLActions) – The actions of a game.

Returns

The one-hot encoding of each action’s result.

Return type

Features

socceraction.vaep.features.simple(actionfn)#

Make a function decorator to apply actionfeatures to game states.

Parameters

actionfn (callable) – A feature transformer that operates on actions.

Returns

A feature transformer that operates on game states.

Return type

FeatureTransfomer

socceraction.vaep.features.space_delta(gamestates)#

Get the distance covered between the last and previous actions.

Parameters

gamestates (GameStates) – The gamestates of a game.

Returns

A dataframe with a column for the horizontal (‘dx_a0i’), vertical (‘dy_a0i’) and total (‘mov_a0i’) distance covered between each <nb_prev_actions> action ai and action a0.

Return type

Features

socceraction.vaep.features.startlocation(actions)#

Get the location where each action started.

Parameters

actions (SPADLActions) – The actions of a game.

Returns

The ‘start_x’ and ‘start_y’ location of each action.

Return type

Features

socceraction.vaep.features.startpolar(actions)#

Get the polar coordinates of each action’s start location.

The center of the opponent’s goal is used as the origin.

Parameters

actions (SPADLActions) – The actions of a game.

Returns

The ‘start_dist_to_goal’ and ‘start_angle_to_goal’ of each action.

Return type

Features

socceraction.vaep.features.team(gamestates)#

Check whether the possession changed during the game state.

For each action in the game state, True if the team that performed the action is the same team that performed the last action of the game state; otherwise False.

Parameters

gamestates (GameStates) – The game states of a game.

Returns

A dataframe with a column ‘team_ai’ for each <nb_prev_actions> indicating whether the team that performed action a0 is in possession.

Return type

Features

socceraction.vaep.features.time(actions)#

Get the time when each action was performed.

This generates the following features:
period_id

The ID of the period.

time_seconds

Seconds since the start of the period.

time_seconds_overall

Seconds since the start of the game. Stoppage time during previous periods is ignored.

Parameters

actions (Actions) – The actions of a game.

Returns

The ‘period_id’, ‘time_seconds’ and ‘time_seconds_overall’ when each action was performed.

Return type

Features

socceraction.vaep.features.time_delta(gamestates)#

Get the number of seconds between the last and previous actions.

Parameters

gamestates (GameStates) – The game states of a game.

Returns

A dataframe with a column ‘time_delta_i’ for each <nb_prev_actions> containing the number of seconds between action ai and action a0.

Return type

Features