The R package arulesCBA (Hahsler et al. 2019) is an extension of the package arules (Hahsler, Grün, and Hornik 2005) to perform association rule-based classification. The package provides the infrastructure for class association rules and implements associative classifiers based on 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.). Some algorithms are interfaced by the R package R/Weka (Hornik, Buchta, and Zeileis 2009) and the LUCS-KDD Software Library (Coenen 2013).
The following R packages use arulesCBA:
arules,
qCBA,
tidybins
To cite package ‘arulesCBA’ in publications use:
Hahsler M, Johnson I, Kliegr T, Kuchař J (2019). “Associative Classification in R: arc, arulesCBA, and rCBA.” The R Journal, 11, 254-267. ISSN 2073-4859, https://doi.org/10.32614/RJ-2019-048.
@Article{,
title = {{Associative Classification in R: arc, arulesCBA, and rCBA}},
author = {Michael Hahsler and Ian Johnson and Tom{\'{a}}\v{s} Kliegr and Jaroslav Kucha\v{r}},
year = {2019},
journal = {{The R Journal}},
volume = {11},
issue = {2},
pages = {254-267},
issn = {2073-4859},
doi = {10.32614/RJ-2019-048},
}
Stable CRAN version: Install from within R with
install.packages("arulesCBA")
Current development version: Install from r-universe.
install.packages("arulesCBA",
repos = c("https://mhahsler.r-universe.dev",
"https://cloud.r-project.org/"))
library("arulesCBA")
data("iris")
Learn a classifier.
classifier <- CBA(Species ~ ., data = iris)
classifier
## CBA Classifier Object
## Formula: Species ~ .
## Number of rules: 6
## Default Class: versicolor
## Classification method: first
## Description: CBA algorithm (Liu et al., 1998)
Inspect the rulebase.
inspect(classifier$rules, linebreak = TRUE)
## Warning in seq.default(length = NCOL(quality)): partial argument match of
## 'length' to 'length.out'
## lhs rhs support confidence coverage lift count size coveredTransactions totalErrors
## [1] {Petal.Length=[-Inf,2.45)} => {Species=setosa} 0.33 1.00 0.33 3.0 50 2 50 50
## [2] {Sepal.Length=[6.15, Inf],
## Petal.Width=[1.75, Inf]} => {Species=virginica} 0.25 1.00 0.25 3.0 37 3 37 13
## [3] {Sepal.Length=[5.55,6.15),
## Petal.Length=[2.45,4.75)} => {Species=versicolor} 0.14 1.00 0.14 3.0 21 3 21 13
## [4] {Sepal.Width=[-Inf,2.95),
## Petal.Width=[1.75, Inf]} => {Species=virginica} 0.11 1.00 0.11 3.0 17 3 5 8
## [5] {Petal.Width=[1.75, Inf]} => {Species=virginica} 0.30 0.98 0.31 2.9 45 2 4 6
## [6] {} => {Species=versicolor} 0.33 0.33 1.00 1.0 150 1 33 6
Make predictions for the first few instances of iris.
predict(classifier, head(iris))
## [1] setosa setosa setosa setosa setosa setosa
## Levels: setosa versicolor virginica
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.