0

我正在尝试进行子集化,以使 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
4

1 回答 1

0

由于您没有提供您的数据,因此有点难以确认,但我相信您几乎就在那里。您的第一个子集语句给出了 lhs 仅包含=1's 的规则(对 rhs 没有限制)。您的第二个子集语句给出了 rhs 仅包含=1's 的规则(对 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"));
于 2018-09-09T17:31:40.020 回答