在R中使用规则创建特定规则

编程入门 行业动态 更新时间:2024-10-27 20:26:59
本文介绍了在R中使用规则创建特定规则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个大数据集(0和1的矩阵),具有200个变量(每个变量是一个项目)和近1M行(每行是一个事务).我在R中使用"arules"包进行关联规则挖掘.我考虑了 2个项目,并且我想创建在规则的左侧至少具有其中一项的所有规则.我写的代码是:

I have a large data set (matrix of 0s and 1s) with 200 variables(each variable is an item) and almost 1M rows (each row is a transaction). I use "arules" package in R for association rule mining. I considered 2 items and I want to create all the rules that have at least one of them at the left hand side of the rule. The code that I wrote is:

rules <- apriori(data, parameter = list(support = 0.1, confidence = 0.1, minlen =2),appearance = list(lhs=c("itemA=1","itemB=1"),default="rhs"))

但是此代码创建的规则在规则的左侧仅包含itemA,仅itemB或仅包含这两个规则.如果您能帮助我,我非常感谢.

But this code creates the rules that have only itemA, only itemB, or only both of them at the left hand side of the rules. I really appreciate if you could help me.

推荐答案

我猜这段代码对您有用:

I guess this code works for you:

rules <- apriori(data, parameter = list(support = 0.1, confidence = 0.1,minlen =2)) subrules <- subset(rules, subset = lhs %in% c("itemA=1","itemB=1"))

更多推荐

在R中使用规则创建特定规则

本文发布于:2023-08-04 17:44:47,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1298333.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:规则

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!