classFrequency: Extracting the Response and Class Frequency for Transactions...

Description Usage Arguments Value Author(s) See Also Examples

View source: R/classFrequency.R

Description

Converts the class items in transactions/CARs back to a class label. Class frequency can be used to check transactions for class imbalance or the proportion of rules for each class label in a set of CARs.

Usage

1
2
3
response(formula, x)
classFrequency(formula, x, type = "relative")
majorityClass(formula, transactions)

Arguments

formula

A symbolic description of the model to be fitted.

x, transactions

An object of class transactions or rules.

type

"relative" or "absolute" to return proportions or absolute counts.

Value

response returns the response label as a factor.

classFrequency returns the item frequency for each class label as a vector.

majorityClass returns the most frequent class label in the transactions.

Author(s)

Michael Hahsler

See Also

itemFrequency, rules, transactions.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
data("iris")

iris.disc <- discretizeDF.supervised(Species ~ ., iris)
iris.trans <- as(iris.disc, "transactions")
inspect(head(iris.trans, n = 2))

# convert the class items back to a class label
response(Species ~ ., head(iris.trans, n = 2))

# Class distribution. The iris dataset is perfectly balanced.
classFrequency(Species ~ ., iris.trans)

# Majority Class
# (Note: since all class frequencies for iris are the same, the first one is returned)
majorityClass(Species ~ ., iris.trans)

# Use for CARs
cars <- mineCARs(Species ~ ., iris.trans, parameter = list(support = 0.3))

# Number of rules for each class
classFrequency(Species ~ ., cars, type = "absolute")

# conclusion (item in the RHS) of the rule as a class label
response(Species ~ ., head(iris.trans, n = 2))

arulesCBA documentation built on April 20, 2020, 5:06 p.m.