Market Basket Analysis is a data mining technique used to study customer purchasing patterns. It analyzes transaction data to identify products that are frequently bought together. The main purpose is to understand the relationship between items in a shopping basket. Businesses use this technique to improve product placement, cross selling and promotional strategies. It is based on association rule mining and uses measures like support, confidence and lift. For example, customers who buy rice may also buy pulses. Retail stores and online platforms use this method to increase sales and customer satisfaction. It helps businesses make data based marketing decisions and improve overall profitability.
Purpose of Market Basket Analysis:
1. Identify Product Relationships
The main purpose of market basket analysis is to identify relationships between products. It studies transaction data to find items that are frequently purchased together. For example, customers who buy coffee may also buy sugar. These relationships help businesses understand customer buying patterns. By identifying such combinations, retailers can make better marketing decisions. It also helps in designing combo offers. Understanding product relationships improves sales strategies and customer convenience. This purpose forms the foundation for effective merchandising and promotional planning in retail and online businesses.
2. Improve Product Placement
Market basket analysis helps in arranging products strategically in stores. When businesses know which items are often bought together, they can place them near each other. This increases impulse buying and improves customer experience. For example, snacks and soft drinks can be displayed in the same section. In supermarkets and malls, proper placement increases sales volume. Online platforms also show related products on the same page. This purpose enhances visibility of products and encourages additional purchases, leading to higher revenue and improved store performance.
3. Support Cross Selling
Another important purpose is to support cross selling strategies. Cross selling means suggesting related products to customers. Market basket analysis provides data based recommendations. For example, if a customer buys a laptop, the system may suggest a mouse or bag. These suggestions increase the value of each transaction. It improves average order size and overall profit. In Indian e commerce platforms, cross selling is widely used. This purpose helps businesses maximize revenue from existing customers without increasing marketing cost.
4. Enhance Promotional Planning
Market basket analysis supports effective promotional planning. Businesses can create discounts and combo offers based on frequently purchased items. For example, offering a discount on both tea and biscuits together can attract more customers. Promotions based on real data are more successful than random offers. During festival seasons in India, such strategies increase sales significantly. This purpose helps companies design targeted marketing campaigns. It improves customer engagement and ensures better utilization of promotional budgets.
5. Improve Inventory Management
Market basket analysis helps businesses manage inventory efficiently. By understanding product demand and common purchase combinations, companies can maintain proper stock levels. If certain items are frequently sold together, both products should be adequately stocked. This reduces stock shortages and excess inventory. Efficient inventory management lowers storage cost and improves supply chain performance. In large retail chains, accurate stock planning is very important. This purpose ensures product availability and smooth operations, leading to better customer satisfaction and business profitability.
Steps of Market Basket Analysis:
1. Define Business Objectives
The market basket analysis process begins with defining business objectives, establishing what the organization hopes to achieve through the analysis. Clear objectives guide all subsequent decisions about data selection, parameter settings, and pattern interpretation. Common objectives include increasing average transaction value through cross-selling, optimizing store layouts to encourage additional purchases, designing effective promotions and bundles, improving inventory management based on product relationships, or enhancing recommendation engines for e-commerce. For example, a retailer might aim to identify product combinations that could be featured together in a Diwali promotional display. Objectives should be specific, measurable, and aligned with broader business strategies. Well-defined objectives ensure that analysis efforts focus on discovering actionable patterns rather than generating interesting but unused insights.
2. Data Collection and Selection
Data collection and selection gathers the transactional data needed for analysis. Market basket analysis requires point-of-sale or e-commerce transaction data where each purchase is recorded with items bought together. Data sources may include POS systems, e-commerce platforms, loyalty card databases, or any system capturing customer purchases. This step involves selecting relevant time periods, filtering out incomplete or erroneous transactions, and deciding on the level of granularity (SKU level, product category, or brand). For example, a retailer might collect one year of transaction data from all stores, excluding returns and employee purchases. Data selection also considers whether to analyze all transactions or focus on specific customer segments, store types, or time periods. Quality data selection ensures that analysis reflects genuine customer behavior patterns relevant to business objectives.
3. Data Preparation and Cleaning
Data preparation and cleaning transforms raw transaction data into a format suitable for analysis. This critical step addresses numerous data quality issues that would otherwise distort results. Tasks include removing duplicate transactions, handling returns and cancellations, standardizing product descriptions and codes, grouping similar items (e.g., different package sizes of the same product), and filtering out infrequent items that would generate too many rules. For example, preparation might consolidate “Bread White 400g” and “Bread White 800g” into a single “Bread” category for meaningful pattern discovery. Missing or invalid data must be addressed. This step often consumes significant effort but is essential because analysis quality directly depends on input data quality. Well-prepared data ensures that discovered patterns reflect genuine customer behavior rather than data artifacts.
4. Transaction Encoding
Transaction encoding converts prepared transaction data into the binary matrix format required by association mining algorithms. Each transaction becomes a row, each distinct item becomes a column, with 1 indicating presence and 0 indicating absence of that item in the transaction. For example, a transaction containing bread, milk, and eggs would be encoded as [1,1,0,1,0,…] across all item columns. This binary representation enables efficient support counting and rule generation. For large item sets, sparse matrix representations save memory by storing only the 1s. Some implementations also encode quantity or monetary value for weighted analysis, though basic market basket analysis uses simple presence-absence. Proper encoding ensures that algorithms can efficiently process the data and discover meaningful patterns without computational bottlenecks or memory constraints.
5. Set Minimum Support Threshold
Setting minimum support threshold defines the frequency baseline for considering patterns as interesting. Support is the proportion of transactions containing a particular item set. The threshold determines which patterns survive the mining process too high eliminates potentially interesting patterns for less frequent items, too low generates overwhelming numbers of rules. For example, in a store with 100,000 monthly transactions, setting minimum support at 0.5 percent means patterns must appear in at least 500 transactions to be considered. Threshold selection balances statistical significance with business relevance, often guided by business objectives, computational constraints, or exploratory analysis. Some retailers use multiple thresholds or category-specific thresholds. Proper threshold setting is critical because it directly controls the number and quality of patterns discovered, shaping all subsequent analysis.
6. Set Minimum Confidence Threshold
Setting minimum confidence threshold defines the strength requirement for generated rules. Confidence measures how often the rule holds true the proportion of transactions containing the antecedent that also contain the consequent. For rule X → Y, confidence = support(X∪Y) / support(X). Higher confidence indicates stronger association. Threshold selection depends on business context and risk tolerance for acting on rules. For example, a retailer might require 70 percent confidence before placing items together on a promotional display, but accept 50 percent confidence for online recommendations with low implementation cost. Confidence thresholds balance rule reliability with coverage higher thresholds yield fewer but stronger rules. This step, combined with support threshold, controls the final rule set size and quality, ensuring that deployed rules have sufficient predictive power to drive business value.
7. Generate Frequent Item Sets
Generate frequent item sets identifies all combinations of items that meet the minimum support threshold. Using algorithms like Apriori or FP-Growth, this step systematically discovers which item groups appear together frequently. The process starts with single items meeting support, then generates pairs, then triples, and so on, pruning candidates that cannot be frequent based on the downward closure property. For example, if bread, milk, and butter each meet support individually, the algorithm evaluates all pairs (bread-milk, bread-butter, milk-butter) and retains those meeting support. Only frequent pairs generate triples for evaluation. This step is computationally intensive but essential, producing the foundation from which all association rules will be derived. The result is a complete set of frequent item sets representing patterns occurring often enough in the data to warrant consideration.
8. Generate Association Rules
Generate association rules creates if-then rules from the frequent item sets discovered. For each frequent item set, all possible non-empty subsets are considered as antecedents, with the remaining items as consequents. For example, from frequent item set {bread, milk, eggs}, possible rules include bread → milk, eggs; milk → bread, eggs; bread, milk → eggs; and so on. Each rule is evaluated for confidence, and only those meeting the minimum confidence threshold are retained. The number of possible rules grows rapidly, requiring efficient generation strategies. Typically, only rules with single-item consequents are generated for interpretability, though multi-item consequents are possible. Rule generation transforms frequent patterns into actionable if-then statements describing customer behavior and cross-selling opportunities, ready for business application.
9. Evaluate Rules with Lift and Other Metrics
Evaluate rules with lift and other metrics assesses rule quality beyond support and confidence to identify truly interesting associations. Lift measures how much more likely the consequent is given the antecedent compared to its baseline probability. Lift > 1 indicates positive association, lift = 1 indicates independence, lift < 1 indicates negative association. Other metrics include conviction, leverage, and statistical significance. For example, a rule with 80 percent confidence might seem strong, but if the consequent appears in 75 percent of all transactions, lift of 1.07 indicates only modest improvement over random. Evaluation filters out trivial rules and highlights unexpected, actionable patterns. This step ensures that business attention focuses on rules representing genuine, non-obvious relationships rather than statistically trivial co-occurrences of common items. It transforms raw rules into prioritized insights aligned with discovery objectives.
10. Interpret and Deploy Results
Interpret and deploy results translates discovered rules into business actions and measures their impact. Domain experts review rules to confirm business meaning, identify actionable insights, and understand context. For example, discovering that diapers and beer are frequently purchased together might be interpreted as young fathers shopping on Friday evenings, leading to strategic placement near each other with complementary promotions. Deployment may involve changing store layouts, creating product bundles, designing targeted promotions, implementing recommendation engines, or adjusting inventory policies. Results should be measured against original business objectives through A/B testing, sales tracking, or basket size analysis. Feedback loops capture which rules delivered value, guiding future analysis refinement. This final step transforms statistical patterns into business value, completing the journey from data to decisions through market basket analysis.
Example of Market Basket Analysis:
Consider a small retail store with five transactions. Each transaction contains items purchased together by a customer. The goal is to discover association rules that reveal which products are frequently bought together, enabling cross-selling opportunities and optimized store layouts.
Transaction Data:
-
T1: Bread, Milk, Eggs
-
T2: Bread, Butter, Eggs
-
T3: Milk, Butter, Eggs
-
T4: Bread, Milk, Butter
-
T5: Bread, Milk, Butter, Eggs
This small dataset will demonstrate the complete market basket analysis process from data preparation to rule evaluation.
1. Business Objective Definition
The retailer defines clear business objectives before analysis begins. The primary goal is to increase average transaction value by identifying cross-selling opportunities. Secondary objectives include optimizing store layouts to place associated items near each other and designing promotional bundles for upcoming festive seasons. The retailer specifically wants to know which products should be featured together in Diwali promotional displays and which combinations could be recommended to customers at checkout. Success will be measured by increased basket size and higher conversion rates on recommendations. These objectives guide all subsequent decisions about data selection, parameter settings, and rule interpretation. Well-defined objectives ensure that analysis focuses on discovering actionable patterns that directly contribute to business goals rather than generating interesting but unused insights.
2. Data Collection
The retailer collects transaction data from the point-of-sale system for the past month. Five sample transactions are extracted for analysis, though real-world analysis would involve thousands or millions of transactions. Each transaction record includes a unique transaction ID, date and time, items purchased with quantities, and payment method. The sample data shows:
T1: Bread (1), Milk (1), Eggs (12)
T2: Bread (1), Butter (1), Eggs (6)
T3: Milk (1), Butter (1), Eggs (12)
T4: Bread (1), Milk (1), Butter (1)
T5: Bread (1), Milk (1), Butter (1), Eggs (6)
Data collection ensures that transactions represent genuine customer purchases, excluding returns, employee purchases, or test transactions that would distort patterns.
3. Data Preparation
Data preparation transforms raw transactions into a clean format suitable for analysis. The retailer consolidates different package sizes of the same product (eggs sold in 6-count and 12-count packages are both coded as “Eggs” for analysis). Returns and voided transactions are removed. Products are assigned consistent identifiers and descriptions. The prepared transaction data now shows:
T1: Bread, Milk, Eggs
T2: Bread, Butter, Eggs
T3: Milk, Butter, Eggs
T4: Bread, Milk, Butter
T5: Bread, Milk, Butter, Eggs
This preparation ensures that analysis focuses on product relationships rather than package size variations, and that only genuine customer transactions contribute to pattern discovery.
4. Transaction Encoding
Transaction encoding converts the prepared data into a binary matrix format required by association mining algorithms. Each row represents a transaction, each column represents a product, with 1 indicating presence and 0 indicating absence.
| Transaction | Bread | Milk | Butter | Eggs |
|---|---|---|---|---|
| T1 | 1 | 1 | 0 | 1 |
| T2 | 1 | 0 | 1 | 1 |
| T3 | 0 | 1 | 1 | 1 |
| T4 | 1 | 1 | 1 | 0 |
| T5 | 1 | 1 | 1 | 1 |
This binary encoding enables efficient counting of item combinations. For example, counting transactions with Bread and Milk together involves finding rows where both columns have value 1 (T1, T4, T5). The matrix format is essential for support calculation and frequent item set generation.
5. Support Calculation for Single Items
Support is calculated as the proportion of transactions containing an item. With 5 total transactions, support for each item is:
-
Bread: Appears in T1, T2, T4, T5 → 4 transactions → Support = 4/5 = 0.8 or 80%
-
Milk: Appears in T1, T3, T4, T5 → 4 transactions → Support = 4/5 = 0.8 or 80%
-
Butter: Appears in T2, T3, T4, T5 → 4 transactions → Support = 4/5 = 0.8 or 80%
-
Eggs: Appears in T1, T2, T3, T5 → 4 transactions → Support = 4/5 = 0.8 or 80%
All single items have 80% support. If minimum support is set at 60%, all items qualify as frequent. This high frequency is typical in small examples; real datasets would have many items with lower support. Support calculation identifies which items appear often enough to warrant further analysis.
6. Minimum Support Threshold Setting
The retailer sets minimum support at 60% based on business objectives. With only 5 transactions in this example, 60% means patterns must appear in at least 3 transactions. In real-world analysis with thousands of transactions, minimum support might be set much lower, perhaps 0.5% to 5%, depending on business goals. Lower thresholds capture more patterns including those involving less common items but generate more rules to evaluate. Higher thresholds focus only on very common patterns. The 60% threshold here ensures that only patterns appearing in at least 3 of 5 transactions will be considered. This balances pattern significance with practical usefulness for this small dataset, though real applications require careful threshold selection based on transaction volume and business objectives.
7. Frequent Item Set Generation
With minimum support at 60%, frequent item sets are generated starting from single items and progressing to larger combinations:
Single items (support 80%): All four items are frequent.
Two-item sets (support calculation):
-
Bread, Milk: T1, T4, T5 → 3 transactions → Support = 60% → Frequent
-
Bread, Butter: T2, T4, T5 → 3 transactions → Support = 60% → Frequent
-
Bread, Eggs: T1, T2, T5 → 3 transactions → Support = 60% → Frequent
-
Milk, Butter: T3, T4, T5 → 3 transactions → Support = 60% → Frequent
-
Milk, Eggs: T1, T3, T5 → 3 transactions → Support = 60% → Frequent
-
Butter, Eggs: T2, T3, T5 → 3 transactions → Support = 60% → Frequent
All six pairs meet minimum support and are frequent.
Three-item sets:
-
Bread, Milk, Butter: T4, T5 → 2 transactions → Support = 40% → Not frequent
-
All other triples also have 40% support → Not frequent
Generation stops here as no three-item sets meet support. The result is 4 single items and 6 pairs as frequent item sets.
8. Minimum Confidence Threshold Setting
The retailer sets minimum confidence at 70% based on business requirements for acting on rules. Confidence measures how often the rule holds true when the antecedent is present. For promotional decisions with physical implementation costs (like changing store layouts), higher confidence reduces risk of wasted effort. For lower-cost applications like online recommendations, lower confidence might be acceptable. The 70% threshold in this example means that for a rule X → Y to be actionable, at least 70% of transactions containing X must also contain Y. This threshold balances rule reliability with coverage, ensuring that deployed recommendations have strong predictive power while maintaining enough rules for business application.
9. Rule Generation
Rules are generated from the frequent two-item sets. For each pair {X, Y}, two rules are considered: X → Y and Y → X. Confidence is calculated as support(X,Y) divided by support(X).
For {Bread, Milk}:
-
Bread → Milk: Confidence = support(Bread,Milk)/support(Bread) = 0.6/0.8 = 0.75 or 75%
-
Milk → Bread: Confidence = support(Milk,Bread)/support(Milk) = 0.6/0.8 = 0.75 or 75%
For {Bread, Butter}:
-
Bread → Butter: Confidence = 0.6/0.8 = 75%
-
Butter → Bread: Confidence = 0.6/0.8 = 75%
Similar calculations for all six pairs yield 12 rules, each with 75% confidence. All meet the 70% minimum confidence threshold, so all 12 rules are initially retained. Rule generation transforms frequent patterns into actionable if-then statements ready for evaluation.
10. Rule Evaluation with Lift
Lift measures rule strength beyond random co-occurrence. Lift = confidence / support(consequent). For Bread → Milk:
-
support(Milk) = 0.8
-
confidence = 0.75
-
Lift = 0.75 / 0.8 = 0.9375
Calculate for all rules:
| Rule | Confidence | Consequent Support | Lift |
|---|---|---|---|
| Bread → Milk | 75% | 80% | 0.94 |
| Milk → Bread | 75% | 80% | 0.94 |
| Bread → Butter | 75% | 80% | 0.94 |
| Butter → Bread | 75% | 80% | 0.94 |
| Bread → Eggs | 75% | 80% | 0.94 |
| Eggs → Bread | 75% | 80% | 0.94 |
| Milk → Butter | 75% | 80% | 0.94 |
| Butter → Milk | 75% | 80% | 0.94 |
| Milk → Eggs | 75% | 80% | 0.94 |
| Eggs → Milk | 75% | 80% | 0.94 |
| Butter → Eggs | 75% | 80% | 0.94 |
| Eggs → Butter | 75% | 80% | 0.94 |
All lifts are below 1, indicating negative association despite high confidence. This reveals that these common items actually occur together slightly less than expected by chance.
11. Interpretation of Results
The retailer interprets the results with business context. Despite high confidence (75%) for all rules, negative lift (<1) indicates that these items are bought together less often than expected given their individual popularity. This is because each item is extremely common (80% support), so random chance would predict co-occurrence of 64% (0.8 × 0.8). Actual co-occurrence at 60% is slightly below random expectation. Therefore, no true positive association exists among these items. The retailer realizes that cross-promoting these particular items may not increase basket size beyond current levels. However, this insight is valuable it prevents wasted effort on promotions that would not drive incremental sales. The analysis suggests focusing on less common items where positive associations might exist.
12. Business Actions and Deployment
Based on the analysis, the retailer decides on appropriate actions. Since all popular items show negative lift, cross-promoting among them would not drive incremental sales. Instead, the retailer will:
-
Focus future analysis on medium-frequency items where positive associations are more likely
-
Investigate three-item combinations that might show positive lift despite pairs being negative
-
Consider time-based analysis to see if associations vary by day of week or season
-
Use insights to avoid inefficient promotions rather than to create new ones
For deployment, the retailer integrates these findings into merchandising strategy, ensuring that promotional efforts target genuinely associated products rather than common items that happen to co-occur. Results are documented and shared with category managers, and feedback loops track the impact of any implemented changes. This final step transforms analysis insights into business value, even when the insight is “don’t waste effort on these combinations.”
One thought on “Market Basket Analysis, Purpose, Steps, Example”