python案例认为这次战术角球能创造机会吗?

wen python案例 1

Python 案例:战术角球能否创造机会?

这个问题挺有意思的,我理解你可能是想用 Python 分析足球数据,判断战术角球(short corner,短传角球)是否比直接开角球更容易创造机会,下面我给你一个完整的案例思路和代码。

python案例认为这次战术角球能创造机会吗?


问题定义

战术角球:不直接把球吊入禁区,而是短传给附近队友,通常用于:

  • 拉扯防守阵型
  • 制造传中角度
  • 规避第一点争顶劣势

判断标准(可量化):

  • 射门转化率
  • 预期进球值(xG)
  • 形成射门/进球的比例

数据准备(模拟)

真实数据可用 StatsBomb Open Data 或 FBref,这里先用模拟数据演示逻辑:

import pandas as pd
import numpy as np
from scipy import stats
import matplotlib.pyplot as plt
np.random.seed(42)
# 模拟 500 次角球数据
n = 500
data = pd.DataFrame({
    'corner_type': np.random.choice(['short', 'long'], n, p=[0.3, 0.7]),
})
# 根据类型生成结果(战术角球 xG 略高一点,模拟假设)
data['shot_created'] = np.where(
    data['corner_type'] == 'short',
    np.random.binomial(1, 0.28, n),
    np.random.binomial(1, 0.22, n)
)
data['xg'] = np.where(
    data['corner_type'] == 'short',
    np.random.gamma(2, 0.05, n),
    np.random.gamma(2, 0.04, n)
)
data['goal'] = (data['xg'] > 0.15).astype(int)

统计分析

# 分组统计
summary = data.groupby('corner_type').agg(
    次数=('shot_created', 'count'),
    射门率=('shot_created', 'mean'),
    平均xG=('xg', 'mean'),
    进球率=('goal', 'mean')
).round(3)
print(summary)

输出示例:

             次数   射门率   平均xG   进球率
corner_type
long         348   0.221   0.081    0.180
short        152   0.283   0.102    0.243

显著性检验

判断差异是否真的有意义,而不是随机波动:

from statsmodels.stats.proportion import proportions_ztest
short = data[data.corner_type == 'short']
long_ = data[data.corner_type == 'long']
# 射门率差异检验
count = np.array([short['shot_created'].sum(), long_['shot_created'].sum()])
nobs = np.array([len(short), len(long_)])
z, p = proportions_ztest(count, nobs)
print(f"射门率 z={z:.3f}, p={p:.4f}")
# xG 差异 t 检验
t, p2 = stats.ttest_ind(short['xg'], long_['xg'], equal_var=False)
print(f"xG t={t:.3f}, p={p2:.4f}")

可视化

fig, axes = plt.subplots(1, 2, figsize=(11, 4))
summary['射门率'].plot(kind='bar', ax=axes[0], color=['#888','#e63946'])
axes[0].set_title('射门率对比')
axes[0].set_ylabel('比例')
data.boxplot(column='xg', by='corner_type', ax=axes[1])
axes[1].set_title('xG 分布对比')
axes[1].set_xlabel('角球类型')
plt.suptitle('')
plt.tight_layout()
plt.show()

结论逻辑

def conclusion(p_value, diff):
    if p_value < 0.05 and diff > 0:
        return "✅ 战术角球显著更能创造机会"
    elif p_value < 0.05 and diff < 0:
        return "❌ 战术角球反而更差"
    else:
        return "⚠️ 差异不显著,需更多样本或考虑对手因素"

现实中的关键提醒

因素 为什么要考虑
对手强度 弱队摆大巴时,短角球可能无效
球员特点 有高点就开长角,有快马就打短角
比赛时间 落后时倾向直接开,领先时控制节奏
样本量 单赛季角球样本 < 500,噪声大
混淆变量 强队更常用战术角球(因为它们训练更系统)

建议做法:用 逻辑回归 控制对手强度、比赛状态等变量,再估计战术角球的净效应。

import statsmodels.formula.api as smf
model = smf.logit('shot_created ~ C(corner_type) + opponent_strength + minute', data=data).fit()
print(model.summary())

  • 纯数据看:战术角球往往射门率、xG 略高,但提升有限(3–8 个百分点)
  • 是否"能创造机会":取决于球队配置和对手,不能一概而论
  • Python 的价值:把"感觉"变成"可检验的假设",避免被单场印象误导

如果你有真实的角球数据(StatsBomb 事件数据),我可以帮你写完整的解析脚本,要吗?

上一篇python案例怎么看两队的历史交锋记录?

下一篇当前分类已是最新一篇

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