arulesCBA (version 1.1.2)

predict: Classification with CBA classifier

Description

Uses a classifier based on association rules to classify a new set of data entries.

Usage

# S3 method for CBA
predict(object, newdata, …)

Arguments

object

A CBA classifier object with a default class and a sorted list of association rules

newdata

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

Additional arguments not used.

Value

Returns a vector of class labels, one for rows in newdata.

Details

Runs a linear pass through newdata and uses the CBA classifier to assign it a class.

Examples

Run this code
# NOT RUN {
data(iris)
irisDisc <- as.data.frame(lapply(iris[1:4], discretize, categories=9))
irisDisc$Species <- iris$Species
irisDisc <- irisDisc[sample(1:nrow(irisDisc)),]


# train classifier on the first 100 examples
classifier <- CBA(Species ~ ., irisDisc[1:100,], supp = 0.05, conf=0.8)
classifier

# predict the class for the remaining 50 examples
results <- predict(classifier, irisDisc[101:150,])
table(results, irisDisc$Species[101:150])

# use caret to get more statistics
library("caret")
confusionMatrix(results, irisDisc$Species[101:150])
# }

Run the code above in your browser using DataCamp Workspace