The whole pipeline in one call

Extraction, team/player counts, second-phase detection, retention, added value, the report, and the rating are normally five-plus function calls chained together. wa_setpieces.run_workflow() runs that whole chain for one set-piece type and hands back every table at once – this example runs it, then plots straight off the result.

from pathlib import Path

from wa_setpieces import load_matches, run_workflow
from wa_setpieces.core.xt import XTModel
from wa_setpieces.viz.plots import plot_dashboard, plot_rating_benchmark

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)

One call gets everything – summary through rating:

result = run_workflow(events, "corner", model=model, min_deliveries=1, min_shots=1)
result.report
contestantId attempts successful success_rate second_phases second_phase_goals second_phase_rate retention_rate total_added_value avg_added_value goals
0 cxb4hqite921i36gwrezdts7c 2 1 0.500 0 0 0.000 0.500 -0.0192 -0.0096 0
1 f2yd0yzt0om6qhks9gbowu1d6 7 1 0.143 2 0 0.286 0.429 0.0000 0.0000 0


Straight into a plot, no intermediate wiring:

team_id = result.report["contestantId"].iloc[0]
fig = plot_dashboard(events, team_id, set_piece_type="corner")
cxb4hqit… — corner deliveries, cxb4hqit… — corner end zones, Attempts by set-piece type, Success rate by set-piece type
fig, ax = plot_rating_benchmark(result.team_rating, title="Corner rating — by team")
plot 17 full workflow

Gallery generated by Sphinx-Gallery