October 2017
Intermediate to advanced
1159 pages
26h 10m
English
To discover shopping patterns, we will use the two algorithms that we have looked into before, Apriori and FP-growth.
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:
import java.io.BufferedReader; import java.io.FileReader; import weka.core.Instances; import weka.associations.Apriori;
First, we will load the supermarket dataset:
Instances data = new Instances(
new BufferedReader(
new FileReader("datasets/chap5/supermarket.arff")));Next, we will initialize an Apriori instance and call the buildAssociations(Instances) function to start frequent pattern mining, as follows:
Apriori model = new Apriori(); ...