rules-class {arules}R Documentation

Class rules — A Set of Rules

Description

Defines the rules class to represent a set of association rules and methods to work with rules.

Usage

rules(rhs, lhs, itemLabels = NULL, quality = data.frame())

## S4 method for signature 'rules'
summary(object, ...)

## S4 method for signature 'rules'
length(x)

## S4 method for signature 'rules'
nitems(x)

## S4 method for signature 'rules'
labels(object, ruleSep = " => ", ...)

## S4 method for signature 'rules'
itemLabels(object)

## S4 replacement method for signature 'rules'
itemLabels(object) <- value

## S4 method for signature 'rules'
itemInfo(object)

lhs(x)

## S4 method for signature 'rules'
lhs(x)

lhs(x) <- value

## S4 replacement method for signature 'rules'
lhs(x) <- value

rhs(x)

rhs(x) <- value

## S4 replacement method for signature 'rules'
rhs(x) <- value

## S4 method for signature 'rules'
rhs(x)

## S4 method for signature 'rules'
items(x)

generatingItemsets(x)

## S4 method for signature 'rules'
generatingItemsets(x)

Arguments

rhs, lhs

itemMatrix objects or objects that can be converted using encode().

itemLabels

a vector of all possible item labels (character) or a transactions object to copy the item coding used for encode() (see itemCoding for details).

quality

a data.frame with quality information (one row per rule).

object, x

the object

...

further arguments

ruleSep

rule separation symbol

value

replacement value

Details

Mined rule sets typically contain several interest measures accessible with the quality() method. Additional measures can be calculated via interestMeasure().

To create rules manually, the itemMatrix for the LHS and the RHS of the rules need to be compatible. See itemCoding for details.

Functions

Slots

lhs,rhs

itemMatrix representing the left-hand-side and right-hand-side of the rules.

quality

the quality data.frame

info

a list with mining information.

Objects from the Class

Objects are the result of calling the function apriori(). Objects can also be created by calls of the form new("rules", ...) or by using the constructor function rules().

Coercions

Author(s)

Michael Hahsler

See Also

Superclass: associations

Other associations functions: abbreviate(), associations-class, c(), duplicated(), extract, inspect(), is.closed(), is.generator(), is.maximal(), is.redundant(), is.significant(), is.superset(), itemsets-class, match(), sample(), sets, size(), sort(), unique()

Examples

data("Adult")

## Mine rules
rules <- apriori(Adult, parameter = list(support = 0.3))
rules

## Select a subset of rules using partial matching on the items
## in the right-hand-side and a quality measure
rules.sub <- subset(rules, subset = rhs %pin% "sex" & lift > 1.3)

## Display the top 3 support rules
inspect(head(rules.sub, n = 3, by = "support"))

## Display the first 3 rules
inspect(rules.sub[1:3])

## Get labels for the first 3 rules
labels(rules.sub[1:3])
labels(rules.sub[1:3], itemSep = " + ", setStart = "", setEnd="",
  ruleSep = " ---> ")

## Manually create rules using the item coding in Adult and calculate some interest measures
twoRules <- rules(
  lhs = list(
    c("age=Young", "relationship=Unmarried"),
    c("age=Old")
  ),
  rhs = list(
    c("income=small"),
    c("income=large")
  ),
  itemLabels = Adult
)

quality(twoRules) <- interestMeasure(twoRules,
  measure = c("support", "confidence", "lift"), transactions = Adult)

inspect(twoRules)


[Package arules version 1.7-7 Index]