prepareTransactions: Prepare Data for Associative Classification

View source: R/prepareTransactions.R

prepareTransactionsR Documentation

Prepare Data for Associative Classification

Description

Data in a data.frame are discretized using class-based discretization and converted into transactions. For transaction data that was not created from a data.frame, a negative class item is added to create data for a binary classifier.

Usage

prepareTransactions(formula, data, disc.method = "mdlp", match = NULL)

Arguments

formula

the formula.

data

a data.frame with the data.

disc.method

Discretization method used to discretize continuous variables if data is a data.frame (default: "mdlp"). See discretizeDF.supervised for more supervised discretization methods.

match

typically NULL. Only used internally if data is a already a set of transactions.

Value

An object of class transactions from arules with an attribute called "disc_info" that contains information on the used discretization for each column.

Author(s)

Michael Hahsler

See Also

transactions, transactions2DF.

Examples


# Perform discretization and convert to transactions
data("iris")
iris_trans <- prepareTransactions(Species ~ ., iris)
inspect(head(iris_trans))

# A negative class item is added for regular transaction data (here "!canned beer")
# Note: backticks are needed in formulas with item labels that contain a space.
data("Groceries")
g2 <- prepareTransactions(`canned beer` ~ ., Groceries)
inspect(head(g2))


ianjjohnson/arulesCBA documentation built on June 13, 2022, 2:07 p.m.