文章预览
教程首页及目录 教程地址:https://www.kirenz.com/blog/posts/2020-05-14-r-association-rule-mining/ R实现 为了在R中执行关联分析,我们使用rules和arulesViz包。具体请查阅Hornik et al.(2005)对包的详细描述。 install.packages( "arules" ) install.packages( "arulesViz" ) library(arules) library(arulesViz) library(tidyverse) library(knitr) # create a list of baskets market_basket < - list( c( "apple" , "beer" , "rice" , "meat" ), c( "apple" , "beer" , "rice" ), c( "apple" , "beer" ), c( "apple" , "pear" ), c( "milk" , "beer" , "rice" , "meat" ), c( "milk" , "beer" , "rice" ), c( "milk" , "beer" ), c( "milk" , "pear" ) ) # set transaction names (T1 to T8) names(market_basket) < - paste( "T" , c(1:8), sep = "" ) 构建的测试数据 市场篮子示例 数据转换 首先,必须将交易数据加载到“事交易类”
………………………………