apriori(data, parameter = NULL, appearance = NULL, control = NULL)
transactions
or any data structure
which can be coerced into
transactions
(e.g., a binary
matrix or data.frame).APparameter
or named list.
The default behavior is to mine rules with minimum support of 0.1,
minimum confidence of 0.8, maximum of 10 items (maxlen), and
a maximal time for subset checking of 5 seconds (maxtime).APappearance
or named list.
With this argument item appearance can be restricted
(implements rule templates).
By default all items can appear unrestricted.APcontrol
or named list.
Controls the algorithmic performance of the mining
algorithm (item sorting, report progress (verbose), etc.)rules
or
itemsets
.
Note: Apriori only creates rules with one item in the RHS (Consequent)! The default value in APparameter
for minlen
is 1. This
means that rules with only one item (i.e., an empty antecedent/LHS) like
$$\{\} => \{beer\}$$
will be created.
These rules mean that no matter what other items are involved the
item in the RHS will appear with the probability given by the rule's
confidence (which equals the support).
If you want to avoid these rules then use
the argument parameter=list(minlen=2)
.
Notes on run time and memory usage:
If the minimum support
is chosen
too low for the dataset, then the algorithm will try to
create an extremely large set of itemsets/rules. This will result in very
long run time and eventually the process will run out of memory.
To prevent this, the default maximal
length of itemsets/rules is restricted to 10 items
(via the parameter element maxlen=10
) and
the time for checking subsets is limited to 5 seconds
(via maxtime=5
). The output will show if you
hit these limits in the "checking subsets" line of the output. The
time limit is only checked when the subset size increases, so
it may run significantly longer than what you specify in maxtime.
Interrupting execution with Control-C/Esc is not recommended.
Memory cleanup will be prevented resulting in a memory leak. Also,
interrupts are only checked when the subset size increases, so it may take
some time till the execution actually stops.
Christian Borgelt (2003) Efficient Implementations of Apriori and Eclat. Workshop of Frequent Item Set Mining Implementations (FIMI 2003, Melbourne, FL, USA).
APRIORI Implementation: www.borgelt.net/apriori.html
APparameter-class
,
APcontrol-class
,
APappearance-class
,
transactions-class
,
itemsets-class
,
rules-class
data("Adult")
## Mine association rules.
rules <- apriori(Adult,
parameter = list(supp = 0.5, conf = 0.9, target = "rules"))
summary(rules)
Run the code above in your browser using DataLab