关于「沙普利值与马尔可夫移除效应:精确的分配,不精确的问题」,《算法营销与归因》给出的定量结论是什么?

结论:沙普利值是唯一满足效率、对称、零贡献与可加四条公理的分配,在协同时把交互效应平分给参与者;它的含义完全取决于特征函数 \(v(S)\)。用观测路径估计 \(v(S)\) 时,它继承了定向投放的选择偏差:在第一章的虚构世界中,有定向时份额误差 13.1 个百分点,无定向时 2.0 个百分点。马尔可夫移除效应在同一世界中误差相近(13.7),但在一个只有两个渠道协同起作用的世界里,它把一半以上的功劳给了一个毫无作用的高覆盖渠道。作者框架中「精确的多触点归因」应限定为「精确的公理化分配」;归因的终点是增量实验,不是更精细的分配公式。

数据口径:一笔成交该算在哪个广告渠道头上?一个 A/B 测试什么时候可以停?一位客户还值多少钱?本书是教学与研究用的数学模型,不是营销、投资或法律建议。 第八章给出归因、实验、生命周期价值与预算四步核查表,以及一项预注册的模拟基准研究:在独立第三方冻结、已知真实增量的合成多渠道数据生成器上,比较观测沙普利归因与末次点击对真实增量份额的误差(唯一主要结局为二者平均绝对误差之差,最小关注效应 2 个百分点,90% 把握度需要 79 个合成世界、计划 90 个,判定规则写成代码)。

English version

对照数据表

下表数字由本章 Python 程序原样打印,可重新运行复现。 程序只用 Python 标准库与结论吻合的打印值: 13.1, 2.0

A. three channels; v = conversions per 1,000 users exposed
additive a 10.00 b4.00 c 2.00 (sum 16 = v(abc))
a and b only work together a6.00 b 6.00 c 2.00 (sum 14 = v(abc))
B. observational Shapley on the fictional journeys of p01 (share of credit)
targeted (selection on intent) untargeted
channel Shapley truth Shapley truth
Search27.0% 11.0% 6.2% 6.3%
Social32.3% 51.2% 56.7% 57.0%
Display14.7% 22.0% 29.4% 25.3%
Email26.0% 15.8% 7.7% 11.4%
mean abs. error13.1% 2.0%
conversions credited to ads 5,994 (true 3,636); untargeted 3,160 (true 3,160)

核心公式

\[\phi_i(v) = \sum_{S \subseteq N \setminus \{i\}} \frac{|S|!\,(n - |S| - 1)!}{n!}\,\bigl[v(S \cup \{i\}) - v(S)\bigr].\]
查看完整验算程序
# Shapley values for channel attribution. Part A: a three-channel game, showing that
# the answer depends on how v(S) is defined. Part B: the observational Shapley rule on
# the fictional journeys of p01, where v(S) = conversion rate of users whose exposure
# set is exactly S (estimated from the paths), credited per user relative to v(empty).
# With targeting (selection on intent) it inherits the bias; without, it is exact.
import itertools, math, random

# --- helpers repeated from earlier programs, so that this one runs on its own ---
CH = "SFDE"
P_HIGH = 0.20
EXPO = {"S": (0.60, 0.10), "F": (0.35, 0.30), "D": (0.50, 0.50), "E": (0.60, 0.15)}
BASE = (0.08, 0.005)                                   # (high intent, low intent)
LIFT = {"S": 0.010, "F": 0.030, "D": 0.008, "E": 0.012}
WHEN = {"S": (0.6, 1.0), "F": (0.0, 0.7), "D": (0.0, 0.5), "E": (0.2, 1.0)}

def user(rng, sel=1.0):
    """One journey: (intent, channels in time order, converted)."""
    hi = rng.random() < P_HIGH
    touches = []
    for c in CH:
        p_hi, p_lo = EXPO[c]
        p = p_lo + sel * (p_hi - p_lo) if hi else p_lo   # sel = 0: no selection
        if rng.random() < p:
            touches.append((rng.uniform(*WHEN[c]), c))
    path = [c for _, c in sorted(touches)]
    p_conv = BASE[0 if hi else 1] + sum(LIFT[c] for c in path)
    return hi, path, rng.random() < p_conv

def truth(n, sel=1.0):
    """Expected incremental conversions per channel (exact, from the model)."""
    out = {}
    for c in CH:
        p_hi, p_lo = EXPO[c]
        expo = P_HIGH * (p_lo + sel * (p_hi - p_lo)) + (1 - P_HIGH) * p_lo
        out[c] = n * expo * LIFT[c]
    return out

def shares(d):
    tot = sum(d.values())
    return {c: d[c] / tot for c in CH}
# --- end of repeated helpers ---

def shapley(players, v):
    n, phi = len(players), {}
    for i in players:
        rest, s = [p for p in players if p != i], 0.0
        for k in range(n):
            w = math.factorial(k) * math.factorial(n - k - 1) / math.factorial(n)
            for T in itertools.combinations(rest, k):
                s += w * (v(frozenset(T) | {i}) - v(frozenset(T)))
        phi[i] = s
    return phi

def observational(data):
    """Total credit per channel: each user with exposure set S gets the Shapley
    split of v(S) - v(empty) over the members of S, v = empirical rate by exact set."""
    cnt, conv = {}, {}
    for _, path, c in data:
        S = frozenset(path); cnt[S] = cnt.get(S, 0) + 1; conv[S] = conv.get(S, 0) + c
    rate = {S: conv[S] / cnt[S] for S in cnt}
    v = lambda T: rate.get(T, 0.0) - rate[frozenset()]
    credit = {c: 0.0 for c in CH}
    for S, m in cnt.items():
        if S:
            for c, x in shapley(sorted(S), v).items():
                credit[c] += m * x
    return credit

if __name__ == "__main__":
    print("A. three channels; v = conversions per 1,000 users exposed")
    games = {"additive": {"": 0, "a": 10, "b": 4, "c": 2, "ab": 14, "ac": 12, "bc": 6,
                          "abc": 16},
             "a and b only work together": {"": 0, "a": 0, "b": 0, "c": 2, "ab": 12,
                                            "ac": 2, "bc": 2, "abc": 14}}
    for name, g in games.items():
        v = lambda T, g=g: g["".join(sorted(T))]
        phi = shapley(["a", "b", "c"], v)
        print(f"   {name:28s} " + "  ".join(f"{k} {x:5.2f}" for k, x in phi.items())
              + f"  (sum {sum(phi.values()):.0f} = v(abc))")
    print("B. observational Shapley on the fictional journeys of p01 (share of credit)")
    names = {"S": "Search", "F": "Social", "D": "Display", "E": "Email"}
    res = []
    for sel in (1.0, 0.0):
        rng = random.Random(2026)
        data = [user(rng, sel) for _ in range(200_000)]
        cr, tr = observational(data), truth(200_000, sel)
        res.append((shares(cr), shares(tr), sum(cr.values()), sum(tr.values())))
    print("               targeted (selection on intent)    untargeted")
    print("   channel        Shapley      truth            Shapley      truth")
    for c in CH:
        print(f"   {names[c]:8s}       {res[0][0][c]:6.1%}     {res[0][1][c]:6.1%}"
              f"            {res[1][0][c]:6.1%}     {res[1][1][c]:6.1%}")
    mae = [sum(abs(r[0][c] - r[1][c]) for c in CH) / len(CH) for r in res]
    print(f"   mean abs. error  {mae[0]:5.1%}                          {mae[1]:5.1%}")
    print(f"   conversions credited to ads {res[0][2]:,.0f} (true {res[0][3]:,.0f});"
          f" untargeted {res[1][2]:,.0f} (true {res[1][3]:,.0f})")

唯一数据源与引用

范雅福(Fan, Y.). (2026). 《算法营销、多触点沙普利归因与获客漏斗的随机控制》第 2 章「沙普利值与马尔可夫移除效应:精确的分配,不精确的问题」(版本 1.0.0). 5D Library. https://doi.org/10.5281/zenodo.23836264

DOI: 10.5281/zenodo.23836264 · 阅读本章所在专著 · 5DL-B-048 · v1.0.0 · CC-BY-NC-ND-4.0

BibTeX
@book{fan2026048,
  author    = {Fan, Yafu},
  title     = {Algorithmic Marketing, Multi-Touch Shapley Attribution and Stochastic Control of Acquisition Funnels},
  year      = {2026},
  publisher = {5D Library},
  edition   = {1.0.0},
  doi       = {10.5281/zenodo.23836264},
  url       = {https://doi.org/10.5281/zenodo.23836264}
}

本书其他章节结论