Learn R Programming

arulesCBA (version 1.2.7)

predict.CBA: Model Prediction for Classifiers Based on Association Rules

Description

Predicts classes for new data using a CBA classifier.

Usage

# S3 method for CBA
predict(object, newdata, type = c("class", "score"), ...)

accuracy(pred, true)

Value

A factor vector with the classification result.

Arguments

object

An object of class CBA.

newdata

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

type

Predict "class" labels. Some classifiers can also return "scores".

...

Additional arguments are ignored.

pred, true

two factors with the same level representing the predictions and the ground truth (e.g., obtained with response()).

Author

Michael Hahsler

Examples

Run this code
data("iris")

train_id <- sample(seq_len(nrow(iris)), 130)
iris_train <- iris[train_id, ]
iris_test <- iris[-train_id, ]

cl <- CBA(Species ~., iris_train)
pr <- predict(cl, iris_test)
pr

accuracy(pr, response(Species ~., iris_test))

Run the code above in your browser using DataLab