I am working on association problem using Apriori algorithm . Although I'm getting the output but there is self-relation or so as to say autocorrelation problem getting into it . The carmodels should show relations with other carmodels but it is showing the relation with the same carmodels . The input columns have repeatation . I've just put a chunk of input from a large dataset . Is there anyway to remove the autocorrelation problem from the output .
The source code is provided below:-
mydata <- read.table(header=TRUE, text="
cookieid pageinfo
l8nqwetygUoySgkFHTG datsuncarsgtyoplus
Deniju1uufQfOLQSZszdOdLok marutisuzukicarwiftdzire
l8nofddggreerweUoySgkFHTG hondacarsmobiliom
qrtyftg1z7UoySgkFHTG fordcarsfigosd
")
carmodels<-data.frame(mydata)
head(carmodels)
#Exporting the new copy of webVisitors(copywebVisitors) into excel file named as "done.csv"
write.csv(carmodels, "C:\\Users\\Desktop\\done.csv")
df_cars <- read.csv("done.csv")
library(plyr)
df_itemcars <- ddply(df_cars,c("cookieid"), function(df1){paste(df1$pageinfo,collapse = ",")})
View(df_itemcars)
df_itemcars$cookieid <- NULL
colnames(df_itemcars) <- c("carmodels")
head(df_itemcars)
write.csv(df_itemcars,"Itemcars.csv", row.names = TRUE)
library(Matrix)
library(arules)
txn = read.transactions(file="Itemcars.csv", rm.duplicates= TRUE, format="basket",sep=",",cols=NULL)
df_basket0 <- as(txn,"data.frame")
View(df_basket0)
basket_rules <- apriori(txn,parameter = list(sup = 0.01, conf = 0.5,target="rules"))
inspect(basket_rules)
df_basket <- as(basket_rules,"data.frame")
View(df_basket)
And in the output I'm getting autocorrelation problem i.e its showing relation with itself only . Need some help . Any changes that can be made to remove this autocorrelation? The output looks like:- enter image description here
One can only guess from your screenshot that you should remove trailing quotes and whitespaces from the items:
Now, we substitute quotes and whitespaces at the start and end: