关于「混合推荐:轮廓品味与客户自己说的颜色」,《直播锁单、流水核销与买手推荐》给出的定量结论是什么?

结论:第五章的混合推荐达到 0.1897,单用协同过滤是 0.1620;颜色标签只有能预测选择时才有帮助,没有信息时损失 0.0260。

数据口径:书中的客户、延迟、比率与参数均为示意模型;全部计算由书中程序生成;本书不是法律、财务、银行或个人资料保护方面的建议。 书中以标注框区分已发表的证据、可运行的 Python 计算(16 段程序)、原典与作者的假说。

English version

对照数据表

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

tag strength 0.8, 3000 buyers, 60 bags; hit rate in top 3:
popularity0.1267
item CF0.1620
content0.1603
hybrid0.1897
random 3 of the unbought bags: about 0.0526
查看完整验算程序
# Chapter 5. p09: A hybrid recommender for a private customer pool. 60
# bags, each with one of 6 silhouettes and one of 5 colour families
# (labelled by the five-element names wood, fire, earth, metal and
# water, as customers in Taiwan often describe their own colours). 3000
# past buyers have a taste over silhouettes, a dominant colour family
# and a declared colour tag that equals it with chance s. Each bought
# 2 to 5 bags by a softmax of taste plus popularity; the last purchase
# is held out. Recommenders show 3 bags not yet bought: popularity,
# item-to-item collaborative filtering (cosine on co-purchases),
# content (silhouette history plus declared tag), and a hybrid. We
# report the share of held-out purchases among the 3. Seed 112.
import math
import random

NI, NS, NC = 60, 6, 5

def world(rng, s, n=3000):
    items = [(rng.randrange(NS), rng.randrange(NC), rng.gauss(0, 0.5))
             for _ in range(NI)]
    users = []
    for _ in range(n):
        g = [rng.gammavariate(0.6, 1.0) for _ in range(NS)]
        tot = math.fsum(g)
        sil = [x / tot for x in g]
        col = rng.randrange(NC)
        tag = col if rng.random() < s else rng.randrange(NC)
        util = [4.0 * sil[si] + (1.5 if ci == col else 0.0) + pop
                for si, ci, pop in items]
        hist = []
        for _ in range(rng.randint(2, 5)):
            w = [math.exp(u) if i not in hist else 0.0
                 for i, u in enumerate(util)]
            r, acc = rng.random() * math.fsum(w), 0.0
            for i, x in enumerate(w):
                acc += x
                if acc >= r:
                    hist.append(i)
                    break
        users.append((hist[:-1], hist[-1], tag))
    return items, users

def cosine(users):
    co = [[0] * NI for _ in range(NI)]
    cnt = [0] * NI
    for h, _, _ in users:
        for i in h:
            cnt[i] += 1
            for j in h:
                if i != j:
                    co[i][j] += 1
    return [[co[i][j] / math.sqrt(cnt[i] * cnt[j]) if cnt[i] and cnt[j]
             else 0.0 for j in range(NI)] for i in range(NI)]

def scores(kind, h, tag, items, sim, pop, a=0.5):
    out = []
    for j in range(NI):
        cf = math.fsum(sim[i][j] for i in h)
        sil = sum(1 for i in h if items[i][0] == items[j][0]) / len(h)
        ct = sil + (0.5 if items[j][1] == tag else 0.0)
        val = {"popularity": pop[j], "item CF": cf, "content": ct,
               "hybrid": a * cf / (1 + cf) + (1 - a) * ct / 1.5}[kind]
        out.append(val)
    return out

def evaluate(items, users, kinds=("popularity", "item CF", "content",
                                  "hybrid")):
    sim = cosine(users)
    pop = [0] * NI
    for h, _, _ in users:
        for i in h:
            pop[i] += 1
    hit = {k: 0 for k in kinds}
    for h, test, tag in users:
        for k in kinds:
            sc = scores(k, h, tag, items, sim, pop)
            top = sorted((j for j in range(NI) if j not in h),
                         key=lambda j: -sc[j])[:3]
            hit[k] += test in top
    return {k: v / len(users) for k, v in hit.items()}

if __name__ == "__main__":
    items, users = world(random.Random(112), 0.8)
    print("   tag strength 0.8, 3000 buyers, 60 bags; hit rate in top 3:")
    for k, v in evaluate(items, users).items():
        print("     {:10s}  {:.4f}".format(k, v))
    print("   random 3 of the unbought bags: about {:.4f}".format(3 / 57))

唯一数据源与引用

范雅福(Fan, Y.). (2026). 《海外连线脉冲库存锁、银行流水贝叶斯核销与个性化买手推荐系统》第 5 章「混合推荐:轮廓品味与客户自己说的颜色」(版本 1.0.0). 5D Library. DOI 待发布

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

BibTeX
@book{fan2026112,
  author    = {Fan, Yafu},
  title     = {Live-Shopping Flash Inventory Locks, Bayesian Bank-Feed Reconciliation and Personalized Styling CRM},
  year      = {2026},
  publisher = {5D Library},
  edition   = {1.0.0},
  note      = {DOI pending}
}

本书其他章节结论