| ruleInduction | R Documentation |
Induces association rules that can be generated from supplied itemsets, optionally using a transactions data set to recount support.
ruleInduction(x, ...)
## S4 method for signature 'itemsets'
ruleInduction(
x,
transactions = NULL,
confidence = 0.8,
method = c("ptree", "apriori"),
reduce = FALSE,
verbose = FALSE,
...
)
x |
the set of itemsets from which rules will be induced. |
... |
unused; unknown arguments produce a warning. |
transactions |
the transactions used to mine |
confidence |
numeric value in |
method |
induction method: |
reduce |
logical; remove unused items before counting to reduce memory use and potentially improve speed? |
verbose |
logical; report progress and timing information? |
All rules that can be created using the supplied itemsets and that surpass the
specified minimum confidence threshold are returned.
ruleInduction() can be used to produce
closed association rules defined by Pei
et al. (2000) as rules X => Y where both X and Y are
closed frequent itemsets. See the code example in the Example section.
Rule induction implements two methods. The default is "ptree".
"ptree" method without transactions:
No transactions need to be specified if
x contains a complete set of frequent
itemsets. The itemsets' support counts are stored in a ptree and then retrieved to
create rules and calculate confidence. This is very fast, but fails if
support values are missing or x is not a complete set of frequent itemsets.
"ptree" method with transactions:
If transactions are specified then all transactions are counted into a prefix
tree and
later retrieved to create rules from the itemsets and calculate confidence values.
This is slower, but necessary if x is not a complete set of frequent itemsets.
To improve speed, unused items are removed from the transaction
data before creating the prefix tree (this behavior can be changed using the
argument reduce). This might be slower for large transaction
data sets. However, this is highly recommended as the items are also
reordered to reduce the counting time.
"apriori" method (always needs transactions):
All association rules are mined from the transactions data set using apriori()
with the
smallest support found in the itemsets. In a second step, all rules which cannot
be generated from one of the itemsets are removed. This procedure is very slow,
especially for itemsets with many elements or very low support.
A rules object containing all induced rules meeting the confidence
threshold. Its quality data includes support, confidence, and lift; methods
that recount transactions can include an itemset index identifying the
source itemset.
Christian Buchta and Michael Hahsler
Michael Hahsler, Christian Buchta, and Kurt Hornik. Selective association rule generation. Computational Statistics, 23(2):303-315, April 2008.
Jian Pei, Jiawei Han, Runying Mao. CLOSET: An Efficient Algorithm for Mining Frequent Closed Itemsets. ACM SIGMOD Workshop on Research Issues in Data Mining and Knowledge Discovery (DMKD 2000).
Other mining algorithms:
APappearance-class,
AScontrol-classes,
ASparameter-classes,
apriori(),
eclat(),
fim4r(),
weclat()
Other postprocessing:
is.closed(),
is.generator(),
is.maximal(),
is.redundant(),
is.significant(),
is.superset()
data("Adult")
## find all closed frequent itemsets
closed_is <- apriori(Adult, target = "closed frequent itemsets", support = 0.4)
closed_is
## use rule induction to produce all closed association rules
closed_rules <- ruleInduction(closed_is, transactions = Adult, verbose = TRUE)
## inspect the resulting closed rules
summary(closed_rules)
inspect(head(closed_rules, by = "lift"))
## get rules from frequent itemsets. Here, transactions does not need to be
## specified for rule induction.
frequent_is <- eclat(Adult, support = 0.4)
assoc_rules <- ruleInduction(frequent_is)
assoc_rules
inspect(head(assoc_rules))
## for itemsets that are not a complete set of frequent itemsets,
## transactions need to be specified.
some_is <- sample(frequent_is, 10)
some_rules <- ruleInduction(some_is, transactions = Adult)
some_rules
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.