简体   繁体   English

在RHS和RHS中为R中的关联规则挖掘指定多个参数

[英]Specifying multiple parameters in LHS and RHS for Association Rule Mining in R

I am mining some rules using the arules and arulesviz packages in R. I was able to specify the LHS and RHS for the rule mining. 我正在使用R中的arulesarulesviz包挖掘一些规则。我能够为规则挖掘指定LHS和RHS。 However, I want to specify multiple parameters in the LHS and RHS and then check the support and confidence on these rules. 但是,我想在LHS和RHS中指定多个参数,然后检查对这些规则的支持和信心。

I have tried mining the rules specifying the LHS but the results I am getting include both, rules for each parameter as well as rules for both parameters combined. 我已经尝试挖掘指定LHS的规则,但我得到的结果包括每个参数的规则以及两个参数组合的规则。

rules_sales <- apriori(sales, 
                        parameter=list(support =0.001, confidence =0.001, minlen=2, maxlen=4), 
                        appearance = list(lhs=c("warehouse=Antwerp", "cargo=Drones"), 
                                          rhs=paste0("importCountries=", unique(sales$importCountries)), default="none"))
 inspect(rules_sales)

Expected Result should only include 预期结果应仅包括

{warehouse=Antwerp,cargo=Drones} => {importCountries=***} 0.030937427 0.54508197  4.1074625 266 

and not 

{warehouse=Antwerp} => {importCountries=***}  0.030937427 0.54508197  4.1074625 266 

From the documentation ( ? APappearance ): 从文档( ? APappearance ):

lhs, rhs, both, items, none: character vectors giving the labels of the items which can appear in the specified place (rhs, lhs or both for rules and items for itemsets) lhs,rhs,both,items,none:给出可以出现在指定位置的项目标签的字符向量(项目集的规则和项目的rhs,lhs或两者)

This means that either of the items specified in LHS can appear there. 这意味着LHS中指定的任一项都可以出现在那里。 If you specify two items and only want rules with both in the LHS then set minlen = 3 (2 for LHS + 1 for RHS). 如果您指定两个项目并且只想在LHS中同时使用两个规则,则设置minlen = 3 (LHS为2,RHS为1)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM