What does Live Locks, Bank Matching and Styling CRM conclude, in numbers, about “A Hybrid Recommender: Taste in Shapes and Colours People Name”?

Answer: Chapter 5's hybrid recommender reaches 0.1897 against 0.1620 for collaborative filtering alone; a colour label helps only when it predicts choices and costs 0.0260 when it does not.

Scope of the numbers: Its customers, delays, rates and parameters are illustrative models; all calculations are generated by its programs; the book is not legal, financial, banking or data-protection advice. Marked boxes separate published evidence, runnable Python calculations (16 programs), classical sources and the author's hypotheses.

中文版

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: 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
Show the full program
# 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))

Single source and citation

Fan, Y. (2026). Live-Shopping Flash Inventory Locks, Bayesian Bank-Feed Reconciliation and Personalized Styling CRM (Version 1.0.0), Chapter 5: A Hybrid Recommender: Taste in Shapes and Colours People Name. 5D Library. DOI pending

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

Other chapter answers in this book