I am attempting to make an association rules set using apriori - I am using a different dataset but the starwars dataset contains similar issues. Using arules I was attempting to list the rules and apply an arulesViz plot. From my understanding all strings must be ran as factors, listed as transactions and then apriori should be functioning properly but I get the ouput below after running the following code and rules is not added to environment:
install.packages("arules")
install.packages("arulesViz")
library(arulesViz)
library(arules)
data <- starwars[,c(4:6,8:10)]
data <- data.frame(sapply(data,as.factor))
data <- as(data, "transactions")
rules <- apriori(data, parameter = list(supp = 0.15, conf = 0.80))
inspect(rules)
inspect(sort(rules))
subrules <- head(sort(rules, by="lift"), 10)
plot(subrules, method="graph")
The following is the output from running apriori
rules <- apriori(data, parameter = list(supp = 0.15, conf = 0.80))
Apriori
Parameter specification:
confidence minval smax arem aval originalSupport maxtime support minlen maxlen target ext
0.8 0.1 1 none FALSE TRUE 5 0.15 1 10 rules FALSE
Algorithmic control:
filter tree heap memopt load sort verbose
0.1 TRUE TRUE FALSE TRUE 2 TRUE
Absolute minimum support count: 78
set item appearances ...[0 item(s)] done [0.00s].
set transactions ...[131 item(s), 522 transaction(s)] done [0.00s].
sorting and recoding items ... [0 item(s)] done [0.00s].
creating transaction tree ... done [0.00s].
checking subsets of size 1 done [0.00s].
writing ... [0 rule(s)] done [0.00s].
creating S4 object ... done [0.02s].
Error in length(obj) : Method length not implemented for class rules
I have also ran this with the following argument changes
target = "rules"
And have attempted to run with using only null arguments
Any help is greatly appreciated!