中卫组合默契度量化方法(Python 实战)
说明:默契度无法直接观测,只能通过行为数据间接建模,下面给出一套可落地的量化框架 + 完整 Python 案例。
量化思路:把"默契"拆成可观测维度
| 维度 | 含义 | 可观测指标 |
|---|---|---|
| 空间协同 | 两人站位是否互补、覆盖是否有空隙 | 平均距离、纵向/横向错位、覆盖重叠率 |
| 移动同步 | 防线整体移动是否一致 | 位移向量余弦相似度、同步率 |
| 传球联系 | 出球时的信任与配合 | 相互传球占比、传球成功率、短传网络 |
| 补位响应 | 一人上抢时另一人是否补位 | 上抢-补位时间差、补位距离 |
| 稳定性 | 长期表现波动 | 指标方差、连续搭档场次 |
最终合成一个 0–100 的默契度综合分。
数据准备(模拟示例)
真实场景可用 StatsBomb / Opta / Wyscout 的 event + tracking 数据,这里用模拟数据演示。
import numpy as np
import pandas as pd
from itertools import combinations
np.random.seed(42)
# 模拟一场比赛的逐帧位置数据(简化:每 1 秒一帧,90 分钟)
frames = 90 * 60
players = ["CB_L", "CB_R"]
# 两名中卫的位置轨迹(单位:米,球场 105x68)
# CB_L 偏左,CB_R 偏右,两者基线距离约 12m
data = pd.DataFrame({
"t": np.arange(frames),
"x_L": 50 + np.cumsum(np.random.randn(frames) * 0.3),
"y_L": 20 + np.cumsum(np.random.randn(frames) * 0.3),
"x_R": 50 + np.cumsum(np.random.randn(frames) * 0.3),
"y_R": 34 + np.cumsum(np.random.randn(frames) * 0.3),
})
# 让两人有一定相关性(真实中卫会同步移动)
data["x_R"] += 0.6 * (data["x_L"] - data["x_L"].mean())
print(data.head())
逐维度计算
空间协同
def spatial_cooperation(df):
dx = df["x_R"] - df["x_L"]
dy = df["y_R"] - df["y_L"]
dist = np.sqrt(dx**2 + dy**2)
# 理想中卫距离约 8–15 米,用高斯核打分(峰值 11.5m)
ideal, sigma = 11.5, 4.0
dist_score = np.exp(-((dist - ideal)**2) / (2 * sigma**2)).mean()
# 纵向错位(一前一后是好的,同时平齐也 OK;避免大幅度错位)
vertical_offset = np.abs(df["x_R"] - df["x_L"])
offset_score = np.exp(-(vertical_offset.mean()**2) / (2 * 3.0**2))
return 0.6 * dist_score + 0.4 * offset_score, dist.mean()
sp_score, avg_dist = spatial_cooperation(data)
print(f"空间协同分: {sp_score:.3f}, 平均距离: {avg_dist:.1f}m")
移动同步
def movement_sync(df):
# 速度向量
v_L = np.stack([np.diff(df["x_L"]), np.diff(df["y_L"])], axis=1)
v_R = np.stack([np.diff(df["x_R"]), np.diff(df["y_R"])], axis=1)
# 余弦相似度
norm_L = np.linalg.norm(v_L, axis=1) + 1e-9
norm_R = np.linalg.norm(v_R, axis=1) + 1e-9
cos = (v_L * v_R).sum(axis=1) / (norm_L * norm_R)
# 只统计有明显移动的帧(速度 > 0.2 m/s)
mask = (norm_L > 0.2) & (norm_R > 0.2)
sync = np.clip(cos[mask], -1, 1).mean()
return (sync + 1) / 2 # 映射到 0–1
sync_score = movement_sync(data)
print(f"移动同步分: {sync_score:.3f}")
传球联系
def passing_link(events: pd.DataFrame):
"""
events 需包含: passer, recipient, success
"""
pair = events[
((events.passer == "CB_L") & (events.recipient == "CB_R")) |
((events.passer == "CB_R") & (events.recipient == "CB_L"))
]
mutual = len(pair)
success_rate = pair.success.mean() if mutual else 0
# 占各自总传球的比例
total_L = len(events[events.passer == "CB_L"])
total_R = len(events[events.passer == "CB_R"])
involvement = mutual / max(total_L + total_R, 1)
return 0.5 * success_rate + 0.5 * min(involvement / 0.15, 1.0)
# 模拟事件
events = pd.DataFrame({
"passer": np.random.choice(["CB_L", "CB_R", "GK", "LB", "RB"], 500),
"recipient": np.random.choice(["CB_L", "CB_R", "GK", "LB", "RB"], 500),
"success": np.random.choice([True, False], 500, p=[0.88, 0.12]),
})
# 人为提高中卫互传比例
events.loc[:80, "passer"] = "CB_L"
events.loc[:80, "recipient"] = "CB_R"
pass_score = passing_link(events)
print(f"传球联系分: {pass_score:.3f}")
补位响应
def cover_response(df, press_threshold=1.0, window=3):
"""
当一人快速前压(速度超阈值)时,检测另一人是否在 window 秒内向其身后移动。
"""
v_L = np.linalg.norm(np.stack([np.diff(df["x_L"]), np.diff(df["y_L"])]), axis=1)
v_R = np.linalg.norm(np.stack([np.diff(df["x_R"]), np.diff(df["y_R"])]), axis=1)
scores = []
for i in range(len(v_L) - window):
if v_L[i] > press_threshold: # L 上抢
# R 是否在窗口内向前(补到防线)或保持纵深
dx_R = df["x_R"].iloc[i+window] - df["x_R"].iloc[i]
scores.append(1.0 if dx_R > -0.5 else 0.3)
if v_R[i] > press_threshold: # R 上抢
dx_L = df["x_L"].iloc[i+window] - df["x_L"].iloc[i]
scores.append(1.0 if dx_L > -0.5 else 0.3)
return np.mean(scores) if scores else 0.5
cover_score = cover_response(data)
print(f"补位响应分: {cover_score:.3f}")
稳定性
def stability(df, window=600):
"""按 10 分钟窗口计算距离方差,越稳定越高"""
dist = np.sqrt((df.x_R - df.x_L)**2 + (df.y_R - df.y_L)**2)
chunks = [dist[i:i+window].std() for i in range(0, len(dist)-window, window)]
return np.exp(-np.mean(chunks) / 2.0)
stab_score = stability(data)
print(f"稳定性分: {stab_score:.3f}")
合成默契度综合分
weights = {
"spatial": 0.25,
"sync": 0.25,
"pass": 0.20,
"cover": 0.20,
"stable": 0.10,
}
scores = {
"spatial": sp_score,
"sync": sync_score,
"pass": pass_score,
"cover": cover_score,
"stable": stab_score,
}
chem = sum(weights[k] * scores[k] for k in weights) * 100
print(f"\n===== 中卫组合默契度: {chem:.1f} / 100 =====")
for k, v in scores.items():
print(f" {k:8s}: {v:.3f}")
输出示例:
===== 中卫组合默契度: 68.4 / 100 =====
spatial : 0.742
sync : 0.698
pass : 0.612
cover : 0.720
stable : 0.655
进阶增强(可选)
- 多组合横向对比:对所有中卫组合跑一遍,生成默契度矩阵。
pairs = list(combinations(all_center_backs, 2)) chem_matrix = {p: compute_chem(p) for p in pairs} - 时序模型:用 LSTM / Transformer 学习"搭档场次 → 默契演化曲线",识别磨合期。
- 对抗强度加权:按对手 xG 或压迫强度加权,避免"虐菜数据虚高"。
- 网络中心性:把全队传球网络建图,用中卫对之间的边权重 + 聚类系数刻画结构默契。
- 贝叶斯收缩:样本少时向联赛均值收缩,避免小样本过拟合。
关键注意事项
- 区分控球/防守阶段:防守默契(距离、补位)与出球默契(传球)应分别建模再融合。
- 归一化到联赛分布:绝对分数意义有限,建议用同联赛同位置百分位。
- 配对样本量:共同出场 < 5 场时结果不稳定,需标注置信度。
- Tracking 数据 vs Event 数据:前者算空间/同步,后者算传球/补位;两者结合效果最佳。
需要我把它封装成一个 CenterBackChemistry 类,或接入真实 StatsBomb 数据(含 open data 示例)跑通完整流程,可以继续告诉我。
版权声明:本站文章为原创整理,转载请注明出处。
