Classification Based on Association Rules

CRAN version Rdoc CRAN RStudio mirror downloads Travis-CI Build Status CRAN RStudio mirror downloads

The R package arulesCBA (Hahsler et al, 2020) is an extension of the package arules to perform association rule-based classification. The package implements the following algorithms:

The package also provides the infrastructure for associative classification (supervised discetization, mining class association rules (CARs)), and implements various association rule-based classification strategies (first match, majority voting, weighted voting, etc.).

Installation

Stable CRAN version: install from within R with

install.packages("arulesCBA")

Current development version:

library("devtools")
install_github("ianjjohnson/arulesCBA")

Usage

library("arulesCBA")
data("iris")
 
# learn a classifier
classifier <- CBA(Species ~ ., data = iris)
classifier

    CBA Classifier Object
    Class: Species=setosa, Species=versicolor, Species=virginica
    Default Class: Species=versicolor
    Number of rules: 6
    Classification method: first  
    Description: CBA algorithm (Liu et al., 1998)

# inspect the rulebase
inspect(rules(classifier), linebreak = TRUE)
     lhs                           rhs                  support conf lift count 
 [1] {Petal.Length=[-Inf,2.45)} => {Species=setosa}        0.33 1.00  3.0    50 
 [2] {Sepal.Length=[6.15, Inf],       
      Petal.Width=[1.75, Inf]}  => {Species=virginica}     0.25 1.00  3.0    37 
 [3] {Sepal.Length=[5.55,6.15),   
      Petal.Length=[2.45,4.75)} => {Species=versicolor}    0.14 1.00  3.0    21 
 [4] {Sepal.Width=[-Inf,2.95),
      Petal.Width=[1.75, Inf]}  => {Species=virginica}     0.11 1.00  3.0    17
 [5] {Petal.Width=[1.75, Inf]}  => {Species=virginica}     0.30 0.98  2.9    45 
 [6] {}                         => {Species=versicolor}    0.33 0.33  1.0   150

# make predictions for the first few instances of iris
predict(classifier, head(iris))

   [1] setosa setosa setosa setosa setosa setosa
   Levels: setosa versicolor virginica

References