Learn R Programming

arules (version 1.7.15)

support: Support Counting for Itemsets

Description

Counts support for itemsets represented by an itemMatrix or an associations object in a transactions data set.

Usage

support(x, transactions, ...)

# S4 method for itemMatrix support( x, transactions, type = c("relative", "absolute"), method = c("ptree", "tidlists"), reduce = FALSE, weighted = FALSE, verbose = FALSE, ... )

# S4 method for associations support( x, transactions, type = c("relative", "absolute"), method = c("ptree", "tidlists"), reduce = FALSE, weighted = FALSE, verbose = FALSE, ... )

Value

An unnamed numeric vector of length length(x). Values are relative supports when type = "relative" and counts or weight sums when type = "absolute".

Arguments

x

an itemMatrix or associations object containing the itemsets for which support is counted.

transactions

the transactions data set in which support is counted.

...

further arguments passed from the generic to a method.

type

return "relative" support or "absolute" counts (or summed weights when weighted = TRUE).

method

support-counting method: "ptree" or "tidlists".

reduce

logical; remove unused items before prefix-tree counting?

weighted

logical; use transaction weights stored in the weight column of transactionInfo()?

verbose

logical; report progress and timing information?

Author

Michael Hahsler and Christian Buchta

Details

Normally, the support of frequent itemsets is counted efficiently during the mining process using a minimum support threshold. However, if only the support for specific itemsets (maybe itemsets with very low support) is needed, or the support of a set of itemsets needs to be recalculated on different transactions than they were mined on, then support() can be used.

Several methods for support counting are available:

  • "ptree" (default method): The counters for the itemsets are organized in a prefix tree. The transactions are sequentially processed and the corresponding counters in the prefix tree are incremented (see Hahsler et al, 2008). This method is used by default since it is typically significantly faster than transaction ID list intersection.

  • "tidlists": Support is counted using transaction ID list intersection which is used by several fast mining algorithms (e.g., by Eclat). However, support is determined for each itemset individually which is slow for a large number of long itemsets in dense data.

The item coding of x and transactions is reconciled using item labels. Items that occur only in transactions do not affect the count. With reduce = TRUE, unused items are removed before prefix-tree counting.

Weighted support uses the numeric weight column in transactionInfo(transactions). Absolute weighted support is the sum of the weights of supporting transactions; relative weighted support divides this value by the sum of all transaction weights.

References

Michael Hahsler, Christian Buchta, and Kurt Hornik. Selective association rule generation. Computational Statistics, 23(2):303-315, April 2008.

See Also

Other interest measures: confint, coverage(), interestMeasure(), is.redundant(), is.significant()

Examples

Run this code
data("Income")

## find and some frequent itemsets
itemsets <- eclat(Income)[1:5]

## inspect the support returned by eclat
inspect(itemsets)

## count support in the database
support(items(itemsets), Income)
support(itemsets, Income, type = "absolute")

Run the code above in your browser using DataLab