关于「条件参数化编译:把决策表压成决策列表与有序决策图」,《条件参数化规则蒸馏与在线校准》给出的定量结论是什么?
结论:第二章把 72 格决策表编译成决策列表与有序决策图,变量次序不同,节点数从 6 个到 23 个不等。
数据口径:书中参数为示意,全部计算由书中程序生成。 本书是非个人化经营分析,不构成投资、法律或医疗意见,不对应任何真实客户或成交。
对照数据表
下表数字由本章 Python 程序原样打印,可重新运行复现。 程序只用 Python 标准库与结论吻合的打印值: 23, 72
| orders 120; internal nodes min 6 median 12.0 max 23 | |
| best three orders (nodes, mean tests): | |
| visit>src>dev>slot>tier | 6 2.702 |
| visit>src>slot>tier>dev | 6 2.702 |
| visit>src>slot>dev>tier | 6 2.702 |
| worst three orders: | |
| tier>dev>slot>visit>src | 23 4.052 |
| tier>slot>dev>visit>src | 23 4.052 |
| slot>tier>dev>visit>src | 23 4.552 |
| fewest mean tests: visit>src>dev>slot>tier with 6 nodes, 2.702 tests | |
| flat table rows 72; every diagram answers in < | 5 tests |
查看完整验算程序
# Chapter 2. p22: the same conditioned table as a reduced ordered
# decision diagram (Bryant 1986, generalised to multi-valued tests).
# For each of the 5! = 120 attribute orders we build the reduced diagram
# (merge identical sub-diagrams, skip tests whose branches all agree)
# and count internal nodes and the traffic-weighted number of tests per
# query. Table and weights are the illustrative ones of p21.
import itertools
import math
import statistics
ATTRS = [("tier", ("low", "mid", "high"), (0.50, 0.35, 0.15)),
("src", ("search", "social", "direct"), (0.45, 0.35, 0.20)),
("dev", ("mobile", "desktop"), (0.70, 0.30)),
("visit", ("first", "return"), (0.65, 0.35)),
("slot", ("day", "night"), (0.60, 0.40))]
def label(c):
tier, src, dev, visit, slot = c
if visit == "return":
return "S" if tier == "high" else "B"
if src == "social":
return "B" if dev == "mobile" else "S"
if src == "search":
return "S" if tier == "low" else "D"
return "D" if (slot == "night" and tier != "low") else "S"
def build(order):
unique = {}
def node(level, partial):
if level == len(order):
c = tuple(partial[i] for i in range(len(ATTRS)))
return ("leaf", label(c))
a = order[level]
kids = []
for v in ATTRS[a][1]:
partial[a] = v
kids.append(node(level + 1, partial))
del partial[a]
if all(k == kids[0] for k in kids):
return kids[0]
key = (a, tuple(kids))
if key not in unique:
unique[key] = ("n", len(unique))
return unique[key]
root = node(0, {})
return root, unique
def tests(order, root, unique):
back = {v: k for k, v in unique.items()}
terms = []
for c in itertools.product(*[a[1] for a in ATTRS]):
w = 1.0
for (_, vals, ws), v in zip(ATTRS, c):
w *= ws[vals.index(v)]
n, steps = root, 0
while n[0] == "n":
a, kids = back[n]
n = kids[ATTRS[a][1].index(c[a])]
steps += 1
terms.append(w * steps)
return math.fsum(terms)
def main():
rows = []
for order in itertools.permutations(range(len(ATTRS))):
root, unique = build(list(order))
rows.append((len(unique), tests(order, root, unique), order))
sizes = [r[0] for r in rows]
print("orders 120; internal nodes min {} median {} max {}".format(
min(sizes), statistics.median(sizes), max(sizes)))
rows.sort(key=lambda r: (r[0], r[1], r[2]))
name = lambda o: ">".join(ATTRS[i][0] for i in o)
print("best three orders (nodes, mean tests):")
for n, t, o in rows[:3]:
print(" {:<30} {:>3} {:.3f}".format(name(o), n, t))
print("worst three orders:")
for n, t, o in rows[-3:]:
print(" {:<30} {:>3} {:.3f}".format(name(o), n, t))
fast = min(rows, key=lambda r: (r[1], r[0], r[2]))
print("fewest mean tests: {} with {} nodes, {:.3f} tests".format(
name(fast[2]), fast[0], fast[1]))
print("flat table rows 72; every diagram answers in <= 5 tests")
if __name__ == "__main__":
main()唯一数据源与引用
范雅福(Fan, Y.). (2026). 《高阶知识蒸馏进化、条件参数化编译与实盘转化反馈校准母典》第 2 章「条件参数化编译:把决策表压成决策列表与有序决策图」(版本 1.0.0). 5D Library. DOI 待发布
DOI 待发布 · 专著页正式发布后上线(本站暂无专著页) · 5DL-B-377 · v1.0.0 · CC-BY-NC-ND-4.0
BibTeX
@book{fan2026377,
author = {Fan, Yafu},
title = {Next-Generation Knowledge Distillation, Context-Parametric Compilation and Live-Conversion Feedback Calibration},
year = {2026},
publisher = {5D Library},
edition = {1.0.0},
note = {DOI pending}
}