CBA_ruleset | R Documentation |
Objects for classifiers based on association rules have class "CBA"
.
A creator function CBA_ruleset()
and several methods are provided.
CBA_ruleset( formula, rules, default = NA, method = "first", weights = NULL, bias = NULL, model = NULL, discretization = NULL, description = "Custom rule set", ... ) rules(x) ## S3 method for class 'CBA' rules(x) ## S3 method for class 'CBA' predict(object, newdata, type = c("class", "score"), ...)
formula |
A symbolic description of the model to be fitted. Has to be
of form |
rules |
A set of class association rules mined with |
default |
Default class. If not
specified then objects that are not matched by rules are classified as |
method |
Classification method |
weights |
Rule weights for method majority. Either a quality measure
available in |
bias |
Class bias vector. |
model |
An optional list with model information (e.g., parameters). |
discretization |
A list with discretization information used by |
description |
Description field used when the classifier is printed. |
... |
Additional arguments added as list elements to the CBA object. |
x, object |
An object of class |
newdata |
A data.frame or transactions containing rows of new entries to be classified. |
type |
Predict |
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.
CBA_ruleset()
returns an object of class CBA
representing the trained classifier with fields:
formula |
used formula. |
rules |
the classifier rule base. |
default |
default class label or |
method |
classification method. |
weights |
rule weights. |
bias |
class bias vector if available. |
model |
list with model description. |
discretization |
discretization information. |
description |
description in human readable form. |
predict
returns predicted labels for newdata
.
rules
returns the rule base.
Michael Hahsler
CBA
, mineCARs
,
apriori
, rules
,
transactions
.
data("iris") # discretize and create transactions iris.disc <- discretizeDF.supervised(Species ~., iris) trans <- as(iris.disc, "transactions") # 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 and use the majority class as the default if no rule matches. cl <- CBA_ruleset(Species ~ ., cars, method = "first", default = uncoveredMajorityClass(Species ~ ., trans, cars)) cl # look at the rule base rules(cl) # make predictions prediction <- predict(cl, trans) table(prediction, response(Species ~ ., trans)) # use weighted majority cl <- CBA_ruleset(Species ~ ., cars, method = "majority", weights = "lift", default = uncoveredMajorityClass(Species ~ ., trans, cars)) cl prediction <- predict(cl, trans) table(prediction, response(Species ~ ., trans))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.