Reputation: 473
I have created set of association rules in Julia language, and saved them as csv. Now I would like to use R to make visualizations of them, but when I read csv it is a data frame, not a arules class (which is kind of obvious!).
How to convert data frame into rules-class (https://www.rdocumentation.org/packages/arules/versions/1.6-6/topics/rules-class) to use visualizations from arulesViz
library (https://cran.r-project.org/web/packages/arulesViz/vignettes/arulesViz.pdf)?
# reproduce some data
dat <- data.frame(
lhs_ids = c("{}", "{B}"),
rhs_id = c("{A}", "{A}"),
confidence = c(0.25, 0.2),
support = c(0.25, 0.03),
lift = c(1, 0.5),
)
# convert
a_rules <- as(dat, "rules")
Error in as(., "rules") :
no method or default for coercing “data.frame” to “rules”
Upvotes: 0
Views: 116
Reputation: 3075
You should use PMML, the standard way to transfer rules between tools. See: https://rdrr.io/cran/arules/man/pmml.html
Upvotes: 0