2017-02-06 74 views
1

我正嘗試使用以下代碼來使用「arules」包關聯規則。關聯規則中的錯誤

數據鏈路(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") 

刪除

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

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)) 

錯誤

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

但是,我收到以下錯誤。我也嘗試了一些其他的「方法」,但同樣的錯誤。我會很感激任何類型的建議。

.local(x,transactions,...)中的錯誤: 交易缺失。請指定用於挖掘項目集的事務! 另外:警告信息: interestMeasure(rules,method =「cosine」,adult2,reuse = FALSE): interestMeasure:現在不推薦使用參數方法!改用措施!

回答

0

不知道任何關於包arules,使用「措施」,而不是「法」在下面的行應努力(基於幫助頁)

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