Description Usage Arguments Value Examples
View source: R/classification.R
A classification function
1 | classification(test, rules, verbose = TRUE)
|
test |
|
rules |
|
verbose |
verbose indicator |
vector with classifications
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | library("arules")
library("rCBA")
data("iris")
train <- sapply(iris, as.factor)
train <- data.frame(train, check.names=FALSE)
txns <- as(train,"transactions")
rules = apriori(txns, parameter=list(support=0.03, confidence=0.03, minlen=2),
appearance = list(rhs=c("Species=setosa", "Species=versicolor", "Species=virginica"),default="lhs"))
predictions <- rCBA::classification(train,rules)
table(predictions)
sum(as.character(train$Species)==as.character(predictions),na.rm=TRUE)/length(predictions)
|
Loading required package: rJava
Loading required package: arules
Loading required package: Matrix
Attaching package: ‘arules’
The following objects are masked from ‘package:base’:
abbreviate, write
OpenJDK 64-Bit Server VM warning: Can't detect primordial thread stack location - find_vma failed
Warning message:
Column(s) 1, 2, 3, 4, 5 not logical or factor. Applying default discretization (see '? discretizeDF').
Apriori
Parameter specification:
confidence minval smax arem aval originalSupport maxtime support minlen
0.03 0.1 1 none FALSE TRUE 5 0.03 2
maxlen target ext
10 rules TRUE
Algorithmic control:
filter tree heap memopt load sort verbose
0.1 TRUE TRUE FALSE TRUE 2 TRUE
Absolute minimum support count: 4
set item appearances ...[3 item(s)] done [0.00s].
set transactions ...[126 item(s), 150 transaction(s)] done [0.00s].
sorting and recoding items ... [54 item(s)] done [0.00s].
creating transaction tree ... done [0.00s].
checking subsets of size 1 2 3 done [0.00s].
writing ... [52 rule(s)] done [0.00s].
creating S4 object ... done [0.00s].
2020-12-22 04:33:09 rCBA: initialized
2020-12-22 04:33:09 rCBA: data 150x5
took: 0.1 s
2020-12-22 04:33:09 rCBA: rules 52
took: 0.05 s
2020-12-22 04:33:09 rCBA: classification completed
took: 0.1 s
predictions
setosa versicolor virginica
51 48 49
[1] 0.9466667
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.