socceraction.xthreat.ExpectedThreat#

class socceraction.xthreat.ExpectedThreat(l=16, w=12, eps=1e-05)#

An implementation of the Expected Threat (xT) model.

The xT model 1 can be used to value actions that successfully move the ball between two locations on the pitch by computing the difference between the long-term probability of scoring on the start and end location of an action.

Parameters
  • l (int) – Amount of grid cells in the x-dimension of the grid.

  • w (int) – Amount of grid cells in the y-dimension of the grid.

  • eps (float) – The desired precision to calculate the xT value of a cell. Default is 5 decimal places of precision (1e-5).

l#

Amount of grid cells in the x-dimension of the grid.

Type

int

w#

Amount of grid cells in the y-dimension of the grid.

Type

int

eps#

The desired precision to calculate the xT value of a cell. Default is 5 decimal places of precision (1e-5).

Type

float

heatmaps#

The i-th element corresponds to the xT value surface after i iterations.

Type

list(np.ndarray)

xT#

The final xT value surface.

Type

np.ndarray

scoring_prob_matrix#

The probability of scoring when taking a shot for each cell.

Type

np.ndarray, shape(M,N)

shot_prob_matrix#

The probability of choosing to shoot for each cell.

Type

np.ndarray, shape(M,N)

move_prob_matrix#

The probability of choosing to move for each cell.

Type

np.ndarray, shape(M,N)

transition_matrix#

When moving, the probability of moving to each of the other zones.

Type

np.ndarray, shape(M*N,M*N)

References

1

Singh, Karun. “Introducing Expected Threat (xT).” 15 February, 2019. https://karun.in/blog/expected-threat.html

Methods

__init__

fit

Fits the xT model with the given actions.

interpolator

Interpolate over the pitch.

predict

Compute the xT values for the given actions.

rate

Compute the xT values for the given actions.

save_model

Save the xT value surface in JSON format.