arulesCBA (version 1.1.3-1)

CBA.object: Objects for Classifiers Based on Association Rules

Description

Objects for classifiers based on association rules have class "CBA". A creator function CBA_ruleset() and several methods are provided.

Usage

CBA_ruleset(formula, rules, method = "first", weights = NULL, default = NULL,
  description = "Custom rule set")

# S3 method for CBA print(x, ...) # S3 method for CBA rules(x) # S3 method for CBA predict(object, newdata, …)

Arguments

formula

A symbolic description of the model to be fitted. Has to be of form class ~ .. The class is the variable name (part of the item label before =).

rules

A set of class association rules mined with mineCars or apriori (from arules).

method

Classification method "first" found rule or "majority".

weights

Rule weights for method majority. Either a quality measure available in rules or a numeric vector of the same length are rules can be specified. If missing, then equal weights are used

default

Default class of the form variable=level. If not specified then the most frequent RHS in rules is used.

description

Description field used when the classifier is printed.

x, object

An object of class CBA.

newdata

A data.frame or transactions containing rows of new entries to be classified.

Additional arguments currently not used.

Value

CBA_ruleset() returns an object of class CBA representing the trained classifier with fields:

rules

the classifier rule base.

class

class variable.

levels

levels of the class variable.

default

default class label.

method

classification method.

weights

rule weights.

predict retuns predicted labels for newdata.

rules returns the rule base.

Details

CBA_ruleset creates a new object of class CBA using the provides rules as the rule base. For method "first", the user needs to make sure that the rules are predictive and sorted from most to least predictive.

See Also

CBA, mineCARs, apriori, rules, transactions.

Examples

Run this code
# NOT RUN {
data("iris")
iris.disc <- discretizeDF.supervised(Species ~., iris)

# create transactions
trans <- as(iris.disc, "transactions")
truth <- iris.disc$Species

# create rule base with CARs
cars <- mineCARs(Species ~ ., trans, parameter = list(support = .01, confidence = .8))

cars <- cars[!is.redundant(cars)]
cars <- sort(cars, by = "conf")

# create classifier
cl <- CBA_ruleset(Species ~ ., cars)
cl

# look at the rule base
rules(cl)

# make predictions
prediction <- predict(cl, trans)
table(prediction, truth)

# use weighted majority
cl <- CBA_ruleset(Species ~ ., cars, method = "majority", weights = "lift")
cl

prediction <- predict(cl, trans)
table(prediction, truth)
# }

Run the code above in your browser using DataCamp Workspace