Association Rule Mining discovers the relationship between two or more items in a dataset. Association rules are if-then statements that support to show the probability of interactions between data items.
Association analysis uses a set of transactions to discover rules that indicate the likely occurrence of an item based on the occurrences of other items in the transaction. Association rule is represented as an expression of the form, A --> B, which means that A implies B, where A and B are item sets.
For example,
{Milk, Diaper} -> {Beer}
A is {Milk, Diaper] -> B which is {Beer}
Evaluation Metrics
Support (s) = Fraction of transactions that contain both X and Y i.e. how often Milk, Diaper and Beer occur together in the transactions.
Confidence (c) = Measures how often each item in Y appears in transactions that contain X. Confidence can be computed using the following formula:
C= Support (X + Y)/Support (X)
Is the example, how often beer occurs in the transactions which contain milk and diaper.
Association Rule Mining in Java
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import weka.core.Instances;
import weka.associations.Apriori;
public class _6_Association {
public static void main(String args[]) throws Exception {
Instances data = new Instances(
new BufferedReader(
new FileReader("\\data\\supermarket.arff")));
Apriori model = new Apriori();
model.buildAssociations(data);
System.out.println(model);
}
}
Comments