我试图使用以下代码来使用" 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)
但是,我收到以下错误。我还尝试了其他一些&#34;方法&#34;但同样的错误。我很感激任何类型的建议。
.local(x,transactions,...)中的错误: 交易缺失。请指定用于挖掘项目集的交易! 另外:警告信息: 兴趣测量(规则,方法=&#34;余弦&#34;,成人2,重复=假): interestMeasure:参数方法现已弃用!改为使用措施!
答案 0 :(得分:0)
在不知道有关包arules
的任何内容的情况下,使用“measure”而不是“method”,如以下行所示(基于帮助页面)
IS = interestMeasure(rules, measure = "cosine", adult2, reuse = FALSE)