Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

classFrequency

Extracting the Response and Class Frequency for Transactions or CAR Sets


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

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

Examples

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

Classification Based on Association Rules

v1.2.0
GPL-3
Authors
Michael Hahsler [aut, cre, cph], Ian Johnson [aut, cph], Tyler Giallanza [ctb]
Initial release
2020-4-17

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.