实用脚本统计门前抢点射门次数对比?

wen 实用脚本 15

门前抢点射门统计脚本

下面提供一个实用的 Python 脚本,用于统计并对比不同球员/球队的门前抢点射门次数(基于事件数据),适用于 StatsBomb、Wyscout 或自定义 CSV 数据。

实用脚本统计门前抢点射门次数对比?

核心思路

"门前抢点"通常指:在六码区(6-yard box)内、无控球调整的快速射门,判定条件:

  • 射门位置在禁区内(尤其是小禁区附近,x ≥ 0.83 或距球门 < 8 米)
  • 触球类型为"一脚出球"或"首次触球即射"(first-time shot)
  • 前一次事件为传球/传中(非个人盘带后射门)

脚本实现

import pandas as pd
import numpy as np
def load_events(path):
    """加载事件数据,需包含: match_id, team, player, event_type, 
       x, y, sub_type, touch_type, timestamp"""
    df = pd.read_csv(path)
    return df
def tag_poacher_shots(df, x_thresh=0.83, y_center=0.5, y_width=0.25):
    """
    标记门前抢点射门
    x_thresh: 射门位置x阈值(标准化0-1,越大越靠球门)
    y_center/y_width: 中路区域范围(标准化y坐标)
    """
    shots = df[df['event_type'] == 'Shot'].copy()
    # 1. 位置条件:小禁区附近中路
    in_box = shots['x'] >= x_thresh
    in_center = shots['y'].between(y_center - y_width, y_center + y_width)
    # 2. 触球条件:一脚出球/首次触球即射
    first_time = shots['touch_type'].isin(['first_time', 'one_touch'])
    # 3. 前置事件:来自传球/传中
    from_pass = shots['sub_type'].isin(['pass', 'cross', 'through_ball'])
    shots['is_poacher'] = in_box & in_center & (first_time | from_pass)
    return shots
def compare_poacher_shots(shots):
    """按球队和球员统计对比"""
    poacher = shots[shots['is_poacher']]
    # 按球队统计
    by_team = shots.groupby('team').agg(
        总射门=('event_type', 'count'),
        抢点射门=('is_poacher', 'sum')
    )
    by_team['抢点占比%'] = (by_team['抢点射门'] / by_team['总射门'] * 100).round(1)
    # 按球员统计
    by_player = shots.groupby(['team', 'player']).agg(
        总射门=('event_type', 'count'),
        抢点射门=('is_poacher', 'sum')
    )
    by_player['抢点占比%'] = (by_player['抢点射门'] / by_player['总射门'] * 100).round(1)
    return by_team.sort_values('抢点射门', ascending=False), \
           by_player.sort_values('抢点射门', ascending=False)
if __name__ == '__main__':
    df = load_events('events.csv')
    shots = tag_poacher_shots(df)
    team_stats, player_stats = compare_poacher_shots(shots)
    print("=== 球队门前抢点射门对比 ===")
    print(team_stats.to_string())
    print("\n=== 球员门前抢点射门对比 (Top 20) ===")
    print(player_stats.head(20).to_string())
    team_stats.to_csv('team_poacher_stats.csv', encoding='utf-8-sig')
    player_stats.to_csv('player_poacher_stats.csv', encoding='utf-8-sig')

数据格式要求

CSV 至少需包含以下列:

列名 说明 示例
match_id 比赛ID 3788741
team 球队 曼城
player 球员 哈兰德
event_type 事件类型 Shot
x, y 标准化坐标(0-1) 89, 0.48
sub_type 子类型 cross
touch_type 触球方式 first_time
timestamp 时间戳 00:23:15

进阶优化建议

  1. 坐标换算:若使用 StatsBomb 原始坐标(0-120 × 0-80),需先归一化:

    df['x'] = df['x'] / 120
    df['y'] = df['y'] / 80
  2. 区分抢点类型:可细分"前点抢点/后点抢点/中路抢点",加一个 y 区间判断。

  3. 转化率对比:加入 shot_outcome 列,统计抢点射门的进球转化率,更有实战价值。

  4. 可视化:用 matplotlib 画出各队抢点射门次数柱状图对比。

  5. 对抗干扰:加入 under_pressure 字段,可过滤出"高压下抢点"这一更硬核指标。

示例输出

=== 球队门前抢点射门对比 ===
          总射门  抢点射门  抢点占比%
曼城        18      7      38.9
利物浦      15      5      33.3
阿森纳      12      3      25.0
=== 球员门前抢点射门对比 (Top 20) ===
             总射门  抢点射门  抢点占比%
哈兰德(曼城)   6      4      66.7
努涅斯(利物浦) 5      3      60.0

如果你告诉我具体的数据来源(StatsBomb / Opta / 自建表)和字段结构,我可以把脚本调整为直接可跑的版本。

抱歉,评论功能暂时关闭!

友情链接攻略窝 · 礼包窝 · 配置窝 · 换算窝 · 算法窝 · 查文窝 · 手册窝 · 问答窝 · 全文搜 · 手册库
相关站点礼包窝 · 查文窝