在"Zero frequent items" when using the eclat to mine frequent itemsets中,OP对分组/聚类感兴趣,其基础是分组/聚类在一起的频率。arules::inspect函数可以检查此分组。
library(arules)
dataset <- read.transactions("8GbjnHK2.txt", sep = ";", rm.duplicates = TRUE)
f <- eclat(dataset,
parameter = list(
supp = 0.001,
maxlen = 17,
tidLists = TRUE))
inspect(head(sort(f, by = "support"), 10))数据集可以从https://pastebin.com/8GbjnHK2下载。
但是,输出不能作为数据帧轻松地保存到另一个对象。
out <- inspect(f)那么,我们如何捕获inspect(f)的输出作为数据帧呢?
发布于 2018-05-27 16:45:06
我们可以使用方法labels提取关联/分组,使用quality提取质量度量(支持和计数)。然后,我们可以使用cbind将它们存储到数据帧中。
out <- cbind(labels = labels(f), quality(f))
head(out)
# labels support count
# 1 {3031093,3059242} 0.001010 16
# 2 {3031096,3059242} 0.001073 17
# 3 {3060614,3060615} 0.001010 16
# 4 {3022540,3072091} 0.001010 16
# 5 {3061698,3061700} 0.001073 17
# 6 {3031087,3059242} 0.002778 44发布于 2019-01-02 22:37:43
强制将项目集强制到data.frame也会创建所需的输出。
> head(as(f, "data.frame"))
items support count
1 {3031093,3059242} 0.001010101 16
2 {3031096,3059242} 0.001073232 17
3 {3060614,3060615} 0.001010101 16
4 {3022540,3072091} 0.001010101 16
5 {3061698,3061700} 0.001073232 17
6 {3031087,3059242} 0.002777778 44https://stackoverflow.com/questions/50554355
复制相似问题