To discover shopping patterns, we will use the two algorithms that we have looked into before: Apriori and FP-Growth.
Discover patterns
Apriori
We will use the Apriori algorithm as implemented in Weka. It iteratively reduces the minimum support until it finds the required number of rules with the given minimum confidence. We'll implement the algorithm using the following steps:
- We'll import the required libraries using the following lines of code:
import java.io.BufferedReader; import java.io.FileReader; import weka.core.Instances; import weka.associations.Apriori;
- First, we'll load the supermarket.arff dataset:
Instances data = new Instances(new BufferedReader(new FileReader("data/supermarket.arff...