What does Context-Parametric Rule Distillation and Online Calibration conclude, in numbers, about “Context-Parametric Compilation: Squeezing a Decision Table into Decision Lists and Ordered Decision Diagrams”?

Answer: Chapter 2 compiles the 72-cell table into a decision list and an ordered decision diagram whose size ranges from 6 to 23 nodes depending on variable order.

Scope of the numbers: Parameters are illustrative and all calculations are generated by the book's programs. This is general business analysis, not investment, legal or medical advice, and it describes no real customer or sale.

中文版

Data table

The numbers below are printed verbatim by the chapter's Python program and can be reproduced by running it. standard-library Python onlyprinted values that match the answer: 23, 72

orders 120; internal nodes min 6 median 12.0 max 23
best three orders (nodes, mean tests):
visit>src>dev>slot>tier6 2.702
visit>src>slot>tier>dev6 2.702
visit>src>slot>dev>tier6 2.702
worst three orders:
tier>dev>slot>visit>src23 4.052
tier>slot>dev>visit>src23 4.052
slot>tier>dev>visit>src23 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
Show the full program
# 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()

Single source and citation

Fan, Y. (2026). Next-Generation Knowledge Distillation, Context-Parametric Compilation and Live-Conversion Feedback Calibration (Version 1.0.0), Chapter 2: Context-Parametric Compilation: Squeezing a Decision Table into Decision Lists and Ordered Decision Diagrams. 5D Library. DOI pending

DOI pending · monograph page goes live after publication · 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}
}

Other chapter answers in this book