标签:http ima default 绘制 col list size nbsp one
对数据menu_orders.txt文件数据进行关联分析
(1)使支持度为0.4、频繁项集元素个数大于等于2,查看关联规则数量的变化,输出与a相关的规则
#导入arules包 install.packages("arules") library ( arules ) setwd(‘D:\\data‘) Gary<- read.transactions("menu_orders.txt", format = "basket", sep=",") #设置频繁项集元素个数大于等于2 GarySize<-size(Gary) Gary_u<-Gary[GarySize>1] #查看部分规则 inspect(Gary_u) #支持度0.4,置信度0.5,输出与a相关的规则 Gary_u=apriori(Gary_u,parameter=list(support=0.4,confidence=0.5)) #Gary_u=apriori(Gary_u,parameter=list(support=0.4,confidence=0.5),appearance=list(rhs=c("a"),default="lhs")) #输出与a相关的规则 Gary_u=subset(Gary_u,items%pin%c("a")) #求所需要的关联规则子集 #查看部分规则 inspect(Gary_u)
(2)过滤掉lhs为空的规则
#导入arules包 install.packages("arules") library ( arules ) setwd(‘D:\\data‘) Gary<- read.transactions("menu_orders.txt", format = "basket", sep=",") #设置频繁项集元素个数大于等于2 GarySize<-size(Gary) Gary_u<-Gary[GarySize>1] #查看部分规则 inspect(Gary_u) #支持度0.4,置信度0.5,过滤掉lhs为空的规则 Gary_u=apriori(Gary_u,parameter=list(support=0.4,confidence=0.5,minlen=2)) #Gary_u=apriori(Gary_u,parameter=list(support=0.4,confidence=0.5),appearance=list(rhs=c("a"),default="lhs")) #查看部分规则 inspect(Gary_u)
(3)过滤掉提升度小于1的规则
#导入arules包 install.packages("arules") library ( arules ) setwd(‘D:\\data‘) Gary<- read.transactions("menu_orders.txt", format = "basket", sep=",") #设置频繁项集元素个数大于等于2 GarySize<-size(Gary) Gary_u<-Gary[GarySize>1] #查看部分规则 inspect(Gary_u) #支持度0.4,置信度0.5 Gary_u=apriori(Gary_u,parameter=list(support=0.4,confidence=0.5)) #Gary_u=apriori(Gary_u,parameter=list(support=0.4,confidence=0.5),appearance=list(rhs=c("a"),default="lhs")) #过滤掉提升度小于1的规则。 Gary_u<- subset(Gary_u,lift > 1) #查看部分规则 inspect(Gary_u)
(4)绘制支持度、置信度和提升度的关系图
(后续补上。。。)
(5)绘制出关联规则图
(后续补上。。。)
标签:http ima default 绘制 col list size nbsp one
原文地址:https://www.cnblogs.com/1138720556Gary/p/9898410.html