apriori算法尝试 r语言
a<-matrix(0,7,4,dimnames=list(c("basket1","basket2","basket3","basket4","basket5","basket6","basket7"),c("item1","item2","item3","item4"))) a[1,]<-c(1,0,1,0) a[2,]<-c(0,0,1,1) a[3,]<-c(1,1,1,1) a[4,]<-c(1,1,0,0) a[5,]<-c(0,0,1,0) a[6,]<-c(1,0,1,1) a[7,]<-c(0,1,1,1) #### # item1 item2 item3 item4 #basket1 1 0 1 0 #basket2 0 0 1 1 #basket3 1 1 1 1 #basket4 1 1 0 0 #basket5 0 0 1 0 #basket6 1 0 1 1 #basket7 0 1 1 1 #### a.class<-as(a,"transactions") rules<-apriori(a.class,parameter=list(supp=0.01,conf=0.5,target="rules")) if(!is.na(((([email protected])@data)@i[1]))){ WRITE(rules,file="apriori_rules.txt",sep = "|",col.names=NA) }
apriori算法尝试 r语言.pdf
本文转自:http://www.bassary.com/?p=1147