kstat kstat - 4 years ago 98
R Question

Error in association Rules

Hi, I was trying to use the following code for association rules using "arules" package.



data link (http://archive.ics.uci.edu/ml/datasets/Adult)



library(Matrix)
library(arules)
adult<-read.table("adult.data.txt", sep = ",")
colnames(adult)<- c("age","workclass","fnlwgt","education","education-num","marital-status","occupation","relationship","race","sex","capital-gain","capital-loss","hours-per-week","native-country","Probability for the label")


Remove



adult[["fnlwgt"]] <- NULL
adult[["education-num"]] <- NULL


Group



adult[["age"]] <- ordered(cut(adult[["age"]], c(15,25,45,65,100)), labels = c("Young", "Middle", "Older", "Senior"))

adult[[ "hours-per-week"]] <- ordered(cut(adult[[ "hours-per-week"]], c(0,25,40,60,168)),labels = c("Part-time", "Full-time", "Over-time", "VeryHigh"))

adult[[ "capital-gain"]] <- ordered(cut(adult[[ "capital-gain"]], c(-Inf,0, median(adult[["capital-gain"]][adult[["capital-gain"]]>0]), Inf)), labels = c("None", "Low", "High"))
adult[[ "capital-loss"]] <- ordered(cut(adult[[ "capital-loss"]], c(-Inf,0, median(adult[["capital-loss"]][adult[["capital-loss"]]>0]), Inf)), labels = c("None", "Low", "High"))

adult2 <- as(adult, "transactions")
rules <- apriori(adult2, parameter = list(supp = .5, conf = .85, target = "rules", minlen=2))


Error



IS = interestMeasure(rules, method = "cosine", adult2, reuse = FALSE)


However, I am getting the following error. I also tried some other "methods" but same error. I would appreciate any type of suggestions.



Error in .local(x, transactions, ...) :
transactions missing. Please specify the transactions used to mine the itemsets!
In addition: Warning message:
In interestMeasure(rules, method = "cosine", adult2, reuse = FALSE) :
interestMeasure: parameter method is now deprecated! Use measure instead!

Answer Source

Without knowing anything about the package arules, using "measure" instead of "method" as in the following line should work (based on the help page)

IS = interestMeasure(rules, measure = "cosine", adult2, reuse = FALSE)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download