APappearance-class {arules}R Documentation

Class “APappearance” — Specifying the ‘appearance’ Argument of apriori()

Description

Specifies the restrictions on the associations mined by apriori. Note that appearance is not supported by the implementation of eclat.

Objects from the Class

If appearance restrictions are used, an appearance object will be created automatically within the apriori function using the information in the named list of the function's appearance argument. In this case, the item labels used in the list will be automatically matched against the items in the used transaction database. The list can contain the following elements:

lhs, rhs, both, items, none:

character vectors giving the labels of the items which can appear in the specified place (rhs, lhs or both for rules and items for itemsets). The special place none specifies, that the items mentioned there cannot appear in the rule/itemset.

default:

one of "both", "lhs", "rhs", "none" (the default is "both"). Specified the default appearance for all items not explicitly mentioned in the other elements of the list.

Objects can also be created by calls of the form new("APappearance", ...). In this case, item IDs (column numbers of the transactions incidence matrix) have to be used instead of labels.

Slots

set:

an integer scalar indicating how many items are specified for each of lhs, rhs, items, both and none

items:

an integer vector of item IDs (column numbers)

labels:

a character vector of item labels

default:

a character scalar indicating the value for default appearance

Author(s)

Michael Hahsler and Bettina Gruen

References

Christian Borgelt (2004) Apriori — Finding Association Rules/Hyperedges with the Apriori Algorithm. www.borgelt.net/apriori.html

See Also

apriori

Examples

data("Adult")

## find only frequent itemsets which do not contain  small or large income
is <- apriori(Adult, parameter = list(support= 0.1, target="frequent"), 
  appearance = list(none = c("income=small", "income=large"),
  default="both"))
itemFrequency(items(is))["income=small"]
itemFrequency(items(is))["income=large"]

## find itemsets that only contain small or large income and young age
is <- apriori(Adult, parameter = list(support= 0.1, target="frequent"), 
  appearance = list(items = c("income=small", "income=large", "age=Young"),
  default="none"))
inspect(head(is))
  
## find only rules with small or large income in the right-hand-side.
rules <- apriori(Adult, parameter = list(support=0.2, confidence = 0.5), 
  appearance = list(rhs = c("income=small", "income=large"),
  default="lhs"))
inspect(head(rules))

## for more complicated restrictions you have to mine all rules/itemsets and
## then filter the results afterwards

[Package arules version 1.1-7 Index]