将规则的先验输出从二元交易矩阵限制为指定值为1的项目

问题描述 投票:0回答:1

我试图将rhs和lhs上的所有项目设置为1,但这不起作用。还有其他方法可以确保LHS和规则的RHS上的项目都只是'1'吗?我使用了以下代码。

rules = apriori(cosdat1, parameter=list(support=0.28, confidence=0.3, minlen=2, target="rules"))
summary(rules)

    rules.sub <- subset(rules, subset = lhs %in% c("Bag=1","Blush=1","Nail.Polish=1","Brushes=1","Concealer=1","Eyebrow.Pencils=1","Bronzer=1","Lip.liner=1","Mascara=1","Eye.shadow=1","Foundation=1","Lip.Gloss=1","Lipstick=1","Eyeliner=1"));
    rules.sub

    rules.sub1 <- subset(rules, subset = rhs %in% c("Bag=1","Blush=1","Nail.Polish=1","Brushes=1","Concealer=1","Eyebrow.Pencils=1","Bronzer=1","Lip.liner=1","Mascara=1","Eye.shadow=1","Foundation=1","Lip.Gloss=1","Lipstick=1","Eyeliner=1"));
    rules.sub1
r transactions rules apriori binary-matrix
1个回答
0
投票

由于您没有提供数据,因此有点难以确认,但我相信您几乎就在那里。你的第一个子集语句给出的规则只包含=1的lhs(对rhs没有限制)。你的第二个子集语句给出的规则是rhs只包含=1(对lhs没有限制)。要使限制适用于双方,请将第二个语句应用于第一个语句的结果。

rules.sub1 <- subset(rules.sub, subset = rhs %in% c("Bag=1","Blush=1",
      "Nail.Polish=1","Brushes=1","Concealer=1","Eyebrow.Pencils=1","Bronzer=1",
      "Lip.liner=1","Mascara=1","Eye.shadow=1","Foundation=1",
      "Lip.Gloss=1","Lipstick=1","Eyeliner=1"));
© www.soinside.com 2019 - 2024. All rights reserved.