APappearance-class: Class APappearance - Specifying the appearance Argument of...

Description Objects from the Class Slots Author(s) References See Also Examples

Description

Specifies the restrictions on the associations mined by apriori. These restrictions can implement certain aspects of rule templates described by Klemettinen (1994).

Note that appearance is only supported by the implementation of apriori.

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). none specifies, that the items mentioned there cannot appear anywhere in the rule/itemset. Note that items cannot be specified in more than one place (i.e., you cannot specify an item in lhs and rhs, but have to specify it as both).

default:

one of "both", "lhs", "rhs", "none". Specified the default appearance for all items not explicitly mentioned in the other elements of the list. Leave unspecified and the code will guess the correct setting.

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

M. Klemettinen, H. Mannila, P. Ronkainen, H. Toivonen and A. I. Verkamo (1994). Finding Interesting Rules from Large Sets of Discovered Association Rules. In Proceedings of the Third International Conference on Information and Knowledge Management, 401–407.

See Also

apriori

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
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")))
itemFrequency(items(is))["income=small"]
itemFrequency(items(is))["income=large"]

## find itemsets that only contain small or large income, or young age
is <- apriori(Adult, parameter = list(support= 0.1, target="frequent"), 
  appearance = list(items = c("income=small", "income=large", "age=Young")))
inspect(head(is))
  
## find only rules with income-related variables in the right-hand-side.
incomeItems <- grep("^income=", itemLabels(Adult), value = TRUE)
incomeItems
rules <- apriori(Adult, parameter = list(support=0.2, confidence = 0.5), 
  appearance = list(rhs = incomeItems))
inspect(head(rules))

## Note: For more complicated restrictions you have to mine all rules/itemsets and
## then filter the results afterwards.

Example output

Loading required package: Matrix

Attaching package: 'arules'

The following objects are masked from 'package:base':

    abbreviate, write

Apriori

Parameter specification:
 confidence minval smax arem  aval originalSupport maxtime support minlen
         NA    0.1    1 none FALSE            TRUE       5     0.1      1
 maxlen            target   ext
     10 frequent itemsets FALSE

Algorithmic control:
 filter tree heap memopt load sort verbose
    0.1 TRUE TRUE  FALSE TRUE    2    TRUE

Absolute minimum support count: 4884 

set item appearances ...[2 item(s)] done [0.00s].
set transactions ...[115 item(s), 48842 transaction(s)] done [0.03s].
sorting and recoding items ... [29 item(s)] done [0.01s].
creating transaction tree ... done [0.03s].
checking subsets of size 1 2 3 4 5 6 7 8 9 done [0.06s].
writing ... [2066 set(s)] done [0.00s].
creating S4 object  ... done [0.01s].
income=small 
           0 
income=large 
           0 
Apriori

Parameter specification:
 confidence minval smax arem  aval originalSupport maxtime support minlen
         NA    0.1    1 none FALSE            TRUE       5     0.1      1
 maxlen            target   ext
     10 frequent itemsets FALSE

Algorithmic control:
 filter tree heap memopt load sort verbose
    0.1 TRUE TRUE  FALSE TRUE    2    TRUE

Absolute minimum support count: 4884 

set item appearances ...[3 item(s)] done [0.00s].
set transactions ...[115 item(s), 48842 transaction(s)] done [0.03s].
sorting and recoding items ... [31 item(s)] done [0.01s].
creating transaction tree ... done [0.03s].
checking subsets of size 1 2 3 4 5 6 7 8 9 done [0.12s].
writing ... [2616 set(s)] done [0.00s].
creating S4 object  ... done [0.01s].
    items                        support   count
[1] {occupation=Other-service}   0.1007944 4923 
[2] {relationship=Unmarried}     0.1049302 5125 
[3] {occupation=Sales}           0.1126899 5504 
[4] {occupation=Adm-clerical}    0.1148806 5611 
[5] {hours-per-week=Part-time}   0.1210638 5913 
[6] {occupation=Exec-managerial} 0.1246059 6086 
[1] "income=small" "income=large"
Apriori

Parameter specification:
 confidence minval smax arem  aval originalSupport maxtime support minlen
        0.5    0.1    1 none FALSE            TRUE       5     0.2      1
 maxlen target   ext
     10  rules FALSE

Algorithmic control:
 filter tree heap memopt load sort verbose
    0.1 TRUE TRUE  FALSE TRUE    2    TRUE

Absolute minimum support count: 9768 

set item appearances ...[2 item(s)] done [0.00s].
set transactions ...[115 item(s), 48842 transaction(s)] done [0.03s].
sorting and recoding items ... [18 item(s)] done [0.01s].
creating transaction tree ... done [0.03s].
checking subsets of size 1 2 3 4 5 6 7 done [0.01s].
writing ... [1753 rule(s)] done [0.00s].
creating S4 object  ... done [0.01s].
    lhs    rhs                        support   confidence lift count
[1] {}  => {age=Middle-aged}          0.5051185 0.5051185  1    24671
[2] {}  => {income=small}             0.5061218 0.5061218  1    24720
[3] {}  => {hours-per-week=Full-time} 0.5850907 0.5850907  1    28577
[4] {}  => {sex=Male}                 0.6684820 0.6684820  1    32650
[5] {}  => {workclass=Private}        0.6941976 0.6941976  1    33906
[6] {}  => {race=White}               0.8550428 0.8550428  1    41762

arules documentation built on April 7, 2018, 9:03 a.m.