題組內容
五、假設某一家店中有以下的六次交易(transactions) : (每小題 8 分,共 24 分)
A: {bread, milk, diapers, juice}
B: {bread, milk, diapers, eggs}
C: {milk, diapers, beer, eggs}
D: {bread, beer}
E: {milk, diapers, eggs, juice}
F: {milk, diapers, beer}
A: {bread, milk, diapers, juice}
B: {bread, milk, diapers, eggs}
C: {milk, diapers, beer, eggs}
D: {bread, beer}
E: {milk, diapers, eggs, juice}
F: {milk, diapers, beer}
(二)假設我們設定 support threshold 為 0.6,請找出所有的 frequent itemsets。 也就是說,U={bread, milk, diapers, juice, eggs, beer}這六樣產品的集合, 有那些子集合在 A-F 的六個交易中,被採購的機率超過 0.6。
詳解 (共 1 筆)
詳解
為了找出所有的 frequent itemsets,我們需要計算每個可能的子集合的 support 值,然後確定其是否超過設定的 support 閾值(0.6)。
支持度計算
首先,我們需要計算每個單一產品和多重產品組合的支持度(support)。給定的交易如下:
- A:{bread, milk, diapers, juice}
- B:{bread, milk, diapers, eggs}
- C:{milk, diapers, beer, eggs}
- D:{bread, beer}
- E:{milk, diapers, eggs, juice}
- F:{milk, diapers, beer}
計算每個項目及其組合的支持度
我們首先計算每個單項產品的支持度:
- 單項產品支持度計算
- bread:出現在 A, B, D 中,共 3 次。支持度 = 3/6 = 0.5
- milk:出現在 A, B, C, E, F 中,共 5 次。支持度 = 5/6 ≈ 0.833
- diapers:出現在 A, B, C, E, F 中,共 5 次。支持度 = 5/6 ≈ 0.833
- juice:出現在 A, E 中,共 2 次。支持度 = 2/6 ≈ 0.333
- eggs:出現在 B, C, E 中,共 3 次。支持度 = 3/6 = 0.5
- beer:出現在 C, D, F 中,共 3 次。支持度 = 3/6 = 0.5
由於 support threshold 為 0.6,支持度超過 0.6 的單項產品有:
- milk (0.833)
- diapers (0.833)
- 雙項產品組合支持度計算
- {bread, milk}:出現在 A, B 中,共 2 次。支持度 = 2/6 ≈ 0.333
- {bread, diapers}:出現在 A, B 中,共 2 次。支持度 = 2/6 ≈ 0.333
- {bread, juice}:出現在 A 中,共 1 次。支持度 = 1/6 ≈ 0.167
- {bread, eggs}:出現在 B 中,共 1 次。支持度 = 1/6 ≈ 0.167
- {bread, beer}:出現在 D 中,共 1 次。支持度 = 1/6 ≈ 0.167
- {milk, diapers}:出現在 A, B, C, E, F 中,共 5 次。支持度 = 5/6 ≈ 0.833
- {milk, juice}:出現在 A, E 中,共 2 次。支持度 = 2/6 ≈ 0.333
- {milk, eggs}:出現在 B, C, E 中,共 3 次。支持度 = 3/6 = 0.5
- {milk, beer}:出現在 C, F 中,共 2 次。支持度 = 2/6 ≈ 0.333
- {diapers, juice}:出現在 A, E 中,共 2 次。支持度 = 2/6 ≈ 0.333
- {diapers, eggs}:出現在 B, C, E 中,共 3 次。支持度 = 3/6 = 0.5
- {diapers, beer}:出現在 C, F 中,共 2 次。支持度 = 2/6 ≈ 0.333
- {juice, eggs}:出現在 E 中,共 1 次。支持度 = 1/6 ≈ 0.167
- {juice, beer}:出現 0 次。支持度 = 0/6 = 0
- {eggs, beer}:出現在 C 中,共 1 次。支持度 = 1/6 ≈ 0.167
支持度超過 0.6 的雙項產品組合有:
- {milk, diapers} (0.833)
- 三項產品組合支持度計算
- {milk, diapers, juice}:出現在 A, E 中,共 2 次。支持度 = 2/6 ≈ 0.333
- {milk, diapers, eggs}:出現在 B, C, E 中,共 3 次。支持度 = 3/6 = 0.5
- {milk, diapers, beer}:出現在 C, F 中,共 2 次。支持度 = 2/6 ≈ 0.333
支持度超過 0.6 的三項產品組合:
- 沒有
總結
所有支持度超過 0.6 的 frequent itemsets 如下:
- {milk} (0.833)
- {diapers} (0.833)
- {milk, diapers} (0.833)