First exams 2027 · HL only 2027 年首次开考 · 仅 HL

A4.3.5 · Machine learning approaches (HL only)

A4.3.5 · 机器学习方法(仅 HL)

Association Rule Learning

关联规则学习

A hardware store notices that customers who buy paint very often buy a roller in the same visit. Nobody programmed that rule in; association rule learning found it by counting what actually turns up together across thousands of transactions.

一家五金店注意到,买油漆的顾客常常在同一次购物中也买了滚筒刷。没有人把这条规则写进程序;关联规则学习是通过统计成千上万笔交易中实际一起出现的东西发现它的。

Like clustering, this is unsupervised: the transaction data carries no label saying which items "belong" together. The algorithm only counts co-occurrence.

和聚类一样,这也是无监督的:交易数据里没有标签说明哪些商品"应该"放在一起。算法只是统计它们同时出现的次数。

HL only 仅 HL Typically 3–4 marks · AO2 通常 3–4 分 · AO2 Command term: describe 命令词:describe(描述)

Explainer

讲解

Finding what goes together

找出哪些东西常在一起

Df

Association rule learning finds rules of the form "if a transaction contains itemset A, it is also likely to contain itemset B", by counting how often items co-occur across a large set of transactions. It is not limited to shopping baskets: the same idea uncovers patterns in fraud data or website clicks.

关联规则学习通过统计大量交易中商品共同出现的频率,找出形如"如果一笔交易包含商品集 A,那它也很可能包含商品集 B"这样的规则。它不局限于购物篮:同样的思路也能在欺诈数据或网站点击中发现规律。

Explainer

讲解

Support, confidence, lift

支持度、置信度、提升度

MetricWhat it measuresFormula
SupportHow often an itemset appears at all, across every transactiontransactions containing the itemset ÷ all transactions
ConfidenceFor a rule A → B, how reliably B appears when A doessupport(A and B) ÷ support(A)
LiftWhether A and B occur together more than chance alone would predictconfidence(A → B) ÷ support(B)
指标它衡量什么公式
支持度一个商品集在所有交易中出现的频率包含该商品集的交易数 ÷ 全部交易数
置信度对规则 A → B,当 A 出现时 B 出现的可靠程度support(A 和 B) ÷ support(A)
提升度A 和 B 一起出现的频率是否高于纯属巧合的预期confidence(A → B) ÷ support(B)
Reading lift 如何解读提升度

A lift above 1 means the two items appear together more than random chance would suggest, so the rule is worth acting on. A lift of exactly 1 means they are statistically independent; buying A tells you nothing about B.

提升度大于 1 表示这两件商品一起出现的频率高于随机巧合所预期的,所以这条规则值得采纳。提升度恰好等于 1 表示两者在统计上相互独立;买了 A 完全不能说明关于 B 的任何事。

Explore

探索

Rules from a hardware store

五金店的规则

20 transactions from a hardware store, simplified to just four items. Click a rule to see its support, confidence and lift worked out from the basket counts below.

来自一家五金店的 20 笔交易,简化到只有四种商品。点击一条规则,看看它的支持度、置信度和提升度是如何从下面的购物篮计数中算出来的。

Paint bought in 10 of 20 transactions
Roller bought in 8 of 20 transactions
Masking tape bought in 6 of 20 transactions
Paint AND roller bought together in 7 of 20 transactions
Paint AND masking tape bought together in 3 of 20 transactions
油漆:20 笔交易中的 10 笔
滚筒刷:20 笔交易中的 8 笔
遮蔽胶带:20 笔交易中的 6 笔
油漆和滚筒刷一起购买:20 笔交易中的 7 笔
油漆和遮蔽胶带一起购买:20 笔交易中的 3 笔

Check your understanding

检验你的理解

Support(paint) = 0.50 and support(paint and roller) = 0.35. What is confidence(paint → roller)?

Support(油漆) = 0.50,support(油漆和滚筒刷) = 0.35。confidence(油漆 → 滚筒刷)是多少?

Common mistake

常见错误

Recurring confusion between the three metrics 这三个指标之间反复出现的混淆

RecurringTreating confidence as if it already accounts for how common the recommended item is on its own. A rule can have high confidence purely because item B is popular with everyone, paint-buyer or not, not because A and B are genuinely linked. That is exactly what lift checks: a lift near 1 means the "association" is really just B's general popularity showing through.

反复出现把置信度当成已经考虑了被推荐商品本身有多常见。一条规则可能置信度很高,纯粹是因为商品 B 本来就很受欢迎,不管顾客买没买油漆,而不是因为 A 和 B 之间真的有关联。这正是提升度要检查的:提升度接近 1 就说明这个"关联"其实只是 B 本身的高人气在起作用。

✕

Wrong: "The rule {paint} → {roller} has 70% confidence, so paint strongly causes people to buy a roller."

错误: "规则 {油漆} → {滚筒刷} 的置信度是 70%,所以油漆强烈地导致人们购买滚筒刷。"

✓

Right: "The rule has 70% confidence, but confidence alone does not rule out that rollers are just generally popular. Checking the lift confirms whether paint buyers choose a roller more often than a random customer would, which is what actually supports stocking them together."

正确: "这条规则的置信度是 70%,但仅凭置信度无法排除滚筒刷本身就很受欢迎这种可能。检查提升度能确认买油漆的顾客选择滚筒刷的频率是否真的高于随机顾客,而这才是把两者摆在一起销售的真正依据。"

Revision questions

复习题

Specimen-paper style. Write an answer, then reveal the marking points and mark yourself.

采用样卷风格。写下答案,然后展开评分要点给自己打分。

Question 1 · 2 marks 第 1 题 · 2 分

[2]Define the term support as used in association rule learning.

[2]在关联规则学习的语境下定义支持度。

Question 2 · 4 marks 第 2 题 · 4 分

[4]Support(paint) = 0.50, support(masking tape) = 0.30, support(paint and masking tape) = 0.15. Calculate confidence(paint → masking tape) and lift(paint → masking tape).

[4]support(油漆) = 0.50,support(遮蔽胶带) = 0.30,support(油漆和遮蔽胶带) = 0.15。计算 confidence(油漆 → 遮蔽胶带) 和 lift(油漆 → 遮蔽胶带)。

Question 3 · 3 marks 第 3 题 · 3 分

[3]Describe one real-world application of association rule learning other than a shopping basket.

[3]描述除购物篮以外,关联规则学习的一个现实应用。

Question 4 · 3 marks 第 4 题 · 3 分

[3]Explain why a rule can have high confidence without being a genuinely useful association.

[3]解释为什么一条规则可能置信度很高,却不是一个真正有用的关联。

Flashcards

记忆卡片

Active recall for this statement’s key terms.

针对本条考纲陈述关键术语的主动回忆练习。

Prototype render · grounded in the IB CS 2027 subject guide and the Hodder and Oxford IB CS 2027 texts for A4.3.5 · not yet wired to live routes