Association Rule Mining Cheat Sheet
Explains support, confidence, and lift metrics along with the Apriori and FP-Growth algorithms for discovering frequent itemsets and association rules.
2 PagesIntermediateFeb 25, 2026
Key Metrics
The three numbers every association rule is judged on.
- Support- P(A and B): fraction of all transactions containing both items
- Confidence- P(B|A): fraction of transactions with A that also contain B
- Lift- confidence(A->B) / support(B); lift > 1 means A and B co-occur more than chance
- Antecedent / consequent- "If A (antecedent) then B (consequent)" -- the left- and right-hand sides of a rule
- Frequent itemset- A set of items whose support meets a minimum threshold
Apriori Algorithm
Mine frequent itemsets and rules from one-hot encoded transactions with mlxtend.
python
from mlxtend.frequent_patterns import apriori, association_rules# df: one-hot encoded, rows = transactions, cols = items (True/False)frequent_itemsets = apriori(df, min_support=0.02, use_colnames=True)rules = association_rules(frequent_itemsets, metric='lift', min_threshold=1.0)rules = rules.sort_values('lift', ascending=False)print(rules[['antecedents', 'consequents', 'support', 'confidence', 'lift']].head())
FP-Growth Algorithm
Faster alternative to Apriori that avoids repeated database scans via an FP-tree.
python
from mlxtend.frequent_patterns import fpgrowthfrequent_itemsets = fpgrowth(df, min_support=0.02, use_colnames=True)print(frequent_itemsets.sort_values('support', ascending=False).head(10))
Common Use Cases
Where market-basket analysis shows up in practice.
- Market basket analysis- "Customers who bought X also bought Y" recommendations in retail
- Cross-selling- Bundling frequently co-purchased products in promotions
- Web usage mining- Finding sequences of pages frequently visited together
- Fraud detection- Discovering unusual co-occurring transaction patterns
Pro Tip
A high-lift rule with very low support is often just noise from a handful of transactions -- always check support alongside lift before acting on a rule.
Was this cheat sheet helpful?
Explore Topics
#AssociationRuleMining#AssociationRuleMiningCheatSheet#DataScience#Intermediate#KeyMetrics#AprioriAlgorithm#FPGrowthAlgorithm#CommonUseCases#Algorithms#MachineLearning#CheatSheet#SkillVeris
Advertisement
Sri Hayavadhana Info-Tech
Professional Web Designing Services
- Responsive Websites
- E-commerce Solutions
- SEO Friendly Design
- Fast & Secure
- Support & Maintenance