Set-piece added value

wa_setpieces.core.value blends two things into one number per delivery: the xT added by the delivery itself, and – if it produced a shot, whether straight off the ball or via a second-phase loose ball – how good a chance that shot was. added_value = delivery_xt_added + shot_value.

The shot link comes from Opta’s own assist-chain qualifier (wa_setpieces.core.chains.link_set_piece_shots()), scoped to the shooting team’s own event stream – eventId is only unique within one team’s event stream in this feed (both teams number their events 1, 2, 3, … independently), so resolving it without that scoping can silently attribute a shot to the wrong team’s delivery.

from pathlib import Path

from wa_setpieces import load_matches
from wa_setpieces.core.value import set_piece_added_value, set_piece_value_summary
from wa_setpieces.viz.plots import plot_xt_added_bars
from wa_setpieces.core.xt import XTModel

try:
    _here = Path(__file__).resolve().parent
except NameError:
    _here = Path.cwd()
DATA = _here.parent / "tests" / "data" / "sample_match.json"

events = load_matches(DATA)
model = XTModel.fit(events, x_bins=8, y_bins=6)

Per-delivery breakdown for free kicks:

set_piece_added_value(events, "free_kick", model)
matchId eventId contestantId playerId playerName outcome delivery_xt_added shot_value added_value is_goal
0 sample_match 6 cxb4hqite921i36gwrezdts7c ecaofku4htx8if4kk2teq1rrp R. Adé 1 0.000100 0.0 0.000100 False
1 sample_match 67 f2yd0yzt0om6qhks9gbowu1d6 77t9kl34rhnesp7qz8uqdcga2 S. Callegari 1 -0.000630 0.0 -0.000630 False
2 sample_match 85 f2yd0yzt0om6qhks9gbowu1d6 9g05j8p6gyul0zlnx70rffkve S. Mina 1 0.001337 0.0 0.001337 False
3 sample_match 87 cxb4hqite921i36gwrezdts7c dll3x4ua7q15dcb7gbm61jso9 L. Segovia 1 0.000000 0.0 0.000000 False
4 sample_match 108 cxb4hqite921i36gwrezdts7c cebzrizhi195acmaw8c4cku09 A. Tobar 1 0.002644 0.0 0.002644 False
5 sample_match 121 f2yd0yzt0om6qhks9gbowu1d6 7ww4nc2olcox6pyggzepjth0q R. Silva 0 0.000000 0.0 0.000000 False
6 sample_match 141 f2yd0yzt0om6qhks9gbowu1d6 77t9kl34rhnesp7qz8uqdcga2 S. Callegari 0 0.000000 0.0 0.000000 False
7 sample_match 171 f2yd0yzt0om6qhks9gbowu1d6 9k61c9b8xjgh6jy6tziw11905 P. Velasco 0 0.000000 0.0 0.000000 False
8 sample_match 208 cxb4hqite921i36gwrezdts7c dll3x4ua7q15dcb7gbm61jso9 L. Segovia 1 -0.001122 0.0 -0.001122 False
9 sample_match 220 cxb4hqite921i36gwrezdts7c ecaofku4htx8if4kk2teq1rrp R. Adé 1 0.000566 0.0 0.000566 False
10 sample_match 305 f2yd0yzt0om6qhks9gbowu1d6 c9htznfxd2gjo5s3klq2tvlqt D. Armas 0 0.000000 0.0 0.000000 False
11 sample_match 307 cxb4hqite921i36gwrezdts7c ecaofku4htx8if4kk2teq1rrp R. Adé 1 -0.001222 0.0 -0.001222 False
12 sample_match 455 f2yd0yzt0om6qhks9gbowu1d6 9g05j8p6gyul0zlnx70rffkve S. Mina 1 -0.000255 0.0 -0.000255 False
13 sample_match 488 f2yd0yzt0om6qhks9gbowu1d6 d6gphu89283pngbaenacu1cr9 R. Jaramillo 1 0.010445 0.0 0.010445 False
14 sample_match 473 cxb4hqite921i36gwrezdts7c dll3x4ua7q15dcb7gbm61jso9 L. Segovia 0 0.000000 0.0 0.000000 False
15 sample_match 526 f2yd0yzt0om6qhks9gbowu1d6 czrsu9ep8tzghq0klucpfv6c5 B. Caicedo 1 -0.003492 0.0 -0.003492 False
16 sample_match 572 f2yd0yzt0om6qhks9gbowu1d6 4t4oc5mv6gujh932jz6scuulm N. Molina 1 -0.000008 0.0 -0.000008 False
17 sample_match 543 cxb4hqite921i36gwrezdts7c 6w4sdzr4l7g9efzx6paxvadat J. Quintero 1 0.009179 0.0 0.009179 False
18 sample_match 588 cxb4hqite921i36gwrezdts7c d7d208zfvkuvjaba38rlcjxl G. Valle 0 0.000000 0.0 0.000000 False
19 sample_match 595 cxb4hqite921i36gwrezdts7c 7dr2jx3u755avbchwnycsq0h5 K. Minda 1 -0.001591 0.0 -0.001591 False
20 sample_match 705 f2yd0yzt0om6qhks9gbowu1d6 d6gphu89283pngbaenacu1cr9 R. Jaramillo 1 -0.001397 0.0 -0.001397 False
21 sample_match 712 f2yd0yzt0om6qhks9gbowu1d6 9mrxht9j08y9w07w3877o2gwk Ó. Quiñónez 1 -0.000712 0.0 -0.000712 False
22 sample_match 671 cxb4hqite921i36gwrezdts7c 3oyfdo7dnp4taew78zalpjp0q G. Villamíl 1 -0.008039 0.0 -0.008039 False
23 sample_match 715 cxb4hqite921i36gwrezdts7c d7d208zfvkuvjaba38rlcjxl G. Valle 0 0.000000 0.0 0.000000 False
24 sample_match 844 f2yd0yzt0om6qhks9gbowu1d6 7ww4nc2olcox6pyggzepjth0q R. Silva 1 0.000657 0.0 0.000657 False


Ranked, as a diverging bar chart (green = created value, red = cost it):

free_kick_value = set_piece_added_value(events, "free_kick", model)
fig, ax = plot_xt_added_bars(
    free_kick_value, value_col="added_value", title="Free-kick added value"
)
plot 11 set piece value

Rolled up per team:

set_piece_value_summary(events, "corner", model)
contestantId deliveries total_added_value avg_added_value goals
0 cxb4hqite921i36gwrezdts7c 2 -0.0192 -0.0096 0
1 f2yd0yzt0om6qhks9gbowu1d6 7 0.0000 0.0000 0


Gallery generated by Sphinx-Gallery