Discovering patterns in store data
Problem description
Analysing shopping baskets to discover the products bought together with association rules (Market Basket Analysis). The data is synthetic.
Objectives
- Understanding support, confidence and lift
- Extracting meaningful rules
- Turning rules into practical decisions
Problem type
Association Rules
Dataset
Tools used
Algorithms
Implementation steps
- In KNIME: File → Import KNIME Workflow… and choose store-patterns.knwf, then Execute all.
- Open store-patterns.ows in Orange after installing the Associate extension (Options → Add-ons).
- In WEKA: open store-baskets-synthetic.arff → Associate → Apriori, and set lowerBoundMinSupport = 0.1 and minMetric = 0.5.
- In KNIME: CSV Reader → turn the binary columns into an item set → Association Rule Learner.
- In Orange: you need the Associate extension (Frequent Itemsets, then Association Rules).
- Sort the rules by Lift and exclude those with a lift below 1.
Workflow diagram
Orange
DataAssociate
↔ Drag the diagram sideways to see all of it.
Connections as text (2)
- File → Frequent Itemsets (Data)
- File → Association Rules (Data)
KNIME
SourceManipulatorLearnerData portModel port
↔ Drag the diagram sideways to see all of it.
Connections as text (3)
- CSV Reader → Create Bit Vector
- Create Bit Vector → Association Rule Learner
- Association Rule Learner → Sorter
Project files
- CSV datasetCSV21.5 KB
- WEKA ARFF fileWEKA ARFF33.6 KB
- Orange workflow (.ows)Orange3.6 KB
- Data in Orange format (.tab) for the workflowOrange TAB21.6 KB
- Computed reference results (CSV)Results359.0 B
- KNIME workflow (.knwf): ran successfully in the KNIME 5.12 engine (not opened in the interface)KNIME55.9 KB
- Step-by-step implementation guide (PDF)PDF484.8 KB
- Full project package (ZIP)ZIP488.2 KB
The KNIME file (.knwf) was built on KNIME 5.12 and all its nodes ran successfully in the KNIME engine without opening the interface; open it from File → Import KNIME Workflow.
Results
Actual results computed on the attached files
• If cheese → eggs: support 0.177, confidence 0.922, lift 2.779
• If eggs → cheese: support 0.177, confidence 0.533, lift 2.779
• If butter → milk: support 0.117, confidence 0.897, lift 2.679
• If sugar → tea: support 0.232, confidence 0.927, lift 2.673
• If tea → sugar: support 0.232, confidence 0.668, lift 2.673
• If bread → milk: support 0.325, confidence 0.593, lift 1.769
Evaluation metrics
- Support
- Confidence
- Lift
Interpreting the results
The rule “cheese → eggs” has a high confidence and a lift of 2.78, meaning that the probability of buying eggs with cheese is much higher than usual. Rules with a lift below 1, however, have a misleadingly high confidence because the second product is common anyway.
Discussion questions
- Why might a rule with a confidence of 0.5 be useless?
- How would you use these rules for shelf arrangement or promotions?
- What is the effect of lowering the minimum support to 0.02?
