predict: Classification with CBA classifier

Description Usage Arguments Details Value Author(s) Examples

Description

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

Usage

1
2
## S3 method for class '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.

Details

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

Value

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

Author(s)

Ian Johnson

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
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])

arulesCBA documentation built on July 27, 2017, 9:01 a.m.