In market basket analysis, many association rules can be drawn from the same transactions. Lift helps shortlist rules by measuring whether an antecedent and consequent occur together more often than expected if they were independent. section 4.11 section 4.3.1
For a rule A → B, lift is the observed joint occurrence of A and B divided by the joint occurrence expected under independence: support(A and B) / [support(A) × support(B)]. A value above 1 means the pair occurs together more often than that baseline; below 1 means less often. Read lift alongside support and confidence rather than as a replacement for them. section 4.3.1 section 4.11
Five invoices
Milk and eggs occur together in two of five invoices; bread appears in four. Both sides of {milk, eggs} → {bread} occur together in two invoices, so lift is (2/5) / [(2/5) × (4/5)] = 1.25. The pairing is more frequent than the independence baseline, although it occurs in only 40% of invoices. section 4.3.1
Table 4.2 Dataset to understand the concept of support, confidence, lift, and conviction
|
Invoice Number
|
Milk
|
Eggs
|
Bread
|
Cheese
|
|---|---|---|---|---|
|
1001
|
1
|
1
|
1
|
0
|
|
1002
|
0
|
1
|
1
|
1
|
|
1003
|
1
|
1
|
1
|
0
|
|
1004
|
0
|
1
|
0
|
1
|
|
1005
|
0
|
1
|
1
|
0
|
Check the five invoice rows and their 1/0 purchase indicators before calculating each side’s support and the joint support. section 4.3.1
In Python, `apyori.apriori` accepts `min_lift` alongside minimum support, confidence, and rule length. One workflow converts CSV transactions into a list of lists, tries lift 4 without obtaining rules, then uses lift 2 and reports 200 rules. Inspect the returned rules’ support, confidence, and lift before deciding which associations are useful. section 4.4.1
apriori_rules = apriori(all_records, min_support=0.25, min_confidence=0.25, min_lift=2, min_length=2) apriori_rules = list(apriori_rules) print(len(apriori_rules))
Shows the Apriori call with `min_lift=2` and the other rule filters, making the selection settings reproducible. section 4.4.1
