关于「前向后向:后验边际、最优路径与「再等两次点击」」,《隐马尔可夫与客户决策阶段》给出的定量结论是什么?

结论:第三章讲前向后向与两种最优准则,晚两次点击判断可多得 0.0413 的准确率。

数据口径:书中阶段、页面类型与全部概率均为示意;全部计算由书中程序生成;本书是非个人化经营建议,只使用站内匿名化与客户同意的数据,不跨站追踪,不推断敏感属性,阶段解码不用于施压、差别定价或主动联系客户,紧迫感只来自真实库存与真实截止。 第一章在示意参数下量出:前向滤波的四分类准确率比最后一次点击高 0.0410,就绪判别从 0.6990 提高到 0.7630;增益随阶段黏性与页面区分力在 0.0307 到 0.1187 之间变化,维特比最后一格在页面模糊时反而低 0.1007。

English version

对照数据表

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

stage at clicks 1-6 of 3000 visits, judged with L later clicks
lag L4-stage accready accgain over L=0
00.55960.7832+0.0000
10.58730.8062+0.0277
20.60090.8146+0.0413
30.60150.8169+0.0419
40.60260.8167+0.0429
80.60570.8186+0.0461

核心公式

\[\gamma_t(j) = P(s_t = j \mid o_1, \dots, o_T).\]
查看完整验算程序
# Chapter 3. p33: what waiting a few clicks buys, fixed-lag smoothing.
# Model: the four-stage HMM of p11 (illustrative). 3,000 visits of 10
# to 16 clicks, fixed seed. The stage at click t is judged from clicks
# 1 to t + L. L = 0 is the real-time filter, the only rule a live reply
# can use; larger L means answering L clicks later. Reported: 4-stage
# accuracy and ready-or-not accuracy (ready = compare or decide) at
# each lag, over clicks 1 to 6 of every visit so all lags are defined.
import math
import random

PI = [0.70, 0.20, 0.08, 0.02]
A = [[0.70, 0.22, 0.06, 0.02],
     [0.08, 0.64, 0.23, 0.05],
     [0.02, 0.10, 0.66, 0.22],
     [0.01, 0.03, 0.16, 0.80]]
B = [[0.45, 0.30, 0.08, 0.07, 0.06, 0.04],
     [0.15, 0.35, 0.25, 0.12, 0.08, 0.05],
     [0.08, 0.22, 0.15, 0.30, 0.17, 0.08],
     [0.05, 0.12, 0.08, 0.15, 0.30, 0.30]]
K = 4
la = [[math.log(x) for x in r] for r in A]
lb = [[math.log(x) for x in r] for r in B]
LAGS = (0, 1, 2, 3, 4, 8)


def lse(xs):
    top = max(xs)
    return top + math.log(math.fsum(math.exp(x - top) for x in xs))


def draw(rng, probs):
    u, acc = rng.random(), 0.0
    for k, p in enumerate(probs):
        acc += p  # step
        if u < acc:
            return k
    return len(probs) - 1


def smoothed(obs, t):
    # 用前 len(obs) 次点击判断第 t 次点击时的阶段
    al = [math.log(PI[k]) + lb[k][obs[0]] for k in range(K)]
    for u in range(1, t + 1):
        al = [lse([al[i] + la[i][j] for i in range(K)]) + lb[j][obs[u]]
              for j in range(K)]
    be = [0.0] * K
    for u in range(len(obs) - 2, t - 1, -1):
        be = [lse([la[i][j] + lb[j][obs[u + 1]] + be[j]
                   for j in range(K)]) for i in range(K)]
    return max(range(K), key=lambda k: al[k] + be[k])


rng = random.Random(20261113)
N = 3000
acc = {L: [] for L in LAGS}
rdy = {L: [] for L in LAGS}
for _ in range(N):
    t_len = rng.randint(10, 16)
    s = [draw(rng, PI)]
    for _ in range(t_len - 1):
        s.append(draw(rng, A[s[-1]]))
    o = [draw(rng, B[k]) for k in s]
    for t in range(6):
        for L in LAGS:
            g = smoothed(o[:t + L + 1], t)
            acc[L].append(1.0 if g == s[t] else 0.0)
            rdy[L].append(1.0 if (g >= 2) == (s[t] >= 2) else 0.0)

print("stage at clicks 1-6 of %d visits, judged with L later clicks" % N)
print("lag L   4-stage acc   ready acc   gain over L=0")
base = math.fsum(acc[0]) / len(acc[0])
for L in LAGS:
    a = math.fsum(acc[L]) / len(acc[L])
    r = math.fsum(rdy[L]) / len(rdy[L])
    print("%5d   %11.4f   %9.4f   %+12.4f" % (L, a, r, a - base))

唯一数据源与引用

范雅福(Fan, Y.). (2026). 《隐马尔可夫维特比解码、浏览点击序列反推客户隐藏决策阶段与出手时机母典》第 3 章「前向后向:后验边际、最优路径与「再等两次点击」」(版本 1.0.0). 5D Library. DOI 待发布

DOI 待发布 · 专著页正式发布后上线(本站暂无专著页) · 5DL-B-300 · v1.0.0 · CC-BY-NC-ND-4.0

BibTeX
@book{fan2026300,
  author    = {Fan, Yafu},
  title     = {Hidden Markov Models and Viterbi Decoding: Inferring a Customer's Hidden Decision Stage from Click Sequences and Timing the Offer},
  year      = {2026},
  publisher = {5D Library},
  edition   = {1.0.0},
  note      = {DOI pending}
}

本书其他章节结论