Classification with CBA classifier

Share:

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

An S3 object (a CBA classifier) with a default class and a sorted list of association rules

newdata

A data.frame or arules transaction set 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
18
19
20
# prepare data
data(iris)
irisDisc <- as.data.frame(lapply(iris[1:4], function(x) discretize(x, categories=9)))
irisDisc$Species <- iris$Species
irisDisc <- irisDisc[sample(1:nrow(irisDisc)),]


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

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

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

## End(Not run)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.