将规则包从常规格式转换为稀疏格式 [英] Converting from regular format to sparse format for arules package

查看:81
本文介绍了将规则包从常规格式转换为稀疏格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将常规数据集转换为稀疏格式.所有文档都有带有稀疏格式"的示例.您能帮我吗?

I am trying to convert my regular data set to sparse format. All documentations have examples with 'sparse format' Can you help me please?

我的样本数据集:

ID  Item
1   Avas
2    Alo
2   Erbi
8   Abra
8    Ali
9    Inj
10  Avas
11  Avas

推荐答案

转换为事务类:

trans1 <- as(split(df1[,"Item"], df1[,"ID"]), "transactions")

结果:

summary(trans1)
# transactions as itemMatrix in sparse format with
# 6 rows (elements/itemsets/transactions) and
# 6 columns (items) and a density of 0.2222222 
# 
# most frequent items:
#   Avas    Abra     Ali     Alo    Erbi (Other) 
#      3       1       1       1       1       1 

这篇关于将规则包从常规格式转换为稀疏格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆