Arules 返回空的 LHS
Arules returning empty LHS
我有一个如下所示的数据集:
"user.get","search_restaurants","cuisines.get"
"user.get","search_restaurants","user.get","search_restaurants"
"order/address/get_user_addresses"
"search_restaurants","search_restaurantssearch_restaurants"
"restaurant.get","search_restaurants","order/menu","restaurant.get","restaurant.get","restaurant.get","order/menu","order/menu","restaurant.get","restaurant.getsearch_restaurantsrestaurant.get","user.get","order/menu","order/menu","get_user_reviews_filtered","order/menu","restaurant.get"
当我运行 apriori算法就可以了:
txn1 = read.transactions(file="path", rm.duplicates=TRUE)
basket_rules <- apriori(txn1, parameter = list(sup = 0.01, conf = 0.01,target="rules"))
inspect(basket_rules)
我得到空白的 lhs。它们是:
{} => {cuisines.get}
,等等
知道为什么会这样吗?如何解决这个问题?
来自 help("apriori")
:
The default value in APparameter
for minlen
is 1
. This means that
rules with only one item (i.e., an empty antecedent/LHS) like
{} => {beer}
will be created. These rules mean that no matter what other items are
involved the item in the RHS will appear with the probability given by
the rule's confidence (which equals the support). If you want to avoid
these rules then use the argument parameter=list(minlen=2)
.
卢克的回答是正确的。
此外,我们可以说先验总是给我们关于结果的信息,即程序中的 RHS。这就是为什么如果没有使用 'minlen',那么对于具有等于最小置信度的最小支持度的单个项目集,也会在结果输出中给出。
例如。
> inspect(rules)
lhs rhs support confidence lift count
[1] {} => {Soup} 0.8 0.8 1.0 4
[2] {} => {Pasta} 0.8 0.8 1.0 4
[3] {Salad} => {Ham} 0.4 1.0 1.7 2
我希望这能解释输出(其他规则未在此示例中显示)。
上面给出的是这个table.
的部分输出
Customer ID Food
1 -Salad, Hamburger, Taco
2 -Soup, Hamburger, Pasta
3 -Salad, Soup, Hamburger, Pasta
4 -Soup, Pasta
5 -Taco, Pasta, Soup
我有一个如下所示的数据集:
"user.get","search_restaurants","cuisines.get"
"user.get","search_restaurants","user.get","search_restaurants"
"order/address/get_user_addresses"
"search_restaurants","search_restaurantssearch_restaurants"
"restaurant.get","search_restaurants","order/menu","restaurant.get","restaurant.get","restaurant.get","order/menu","order/menu","restaurant.get","restaurant.getsearch_restaurantsrestaurant.get","user.get","order/menu","order/menu","get_user_reviews_filtered","order/menu","restaurant.get"
当我运行 apriori算法就可以了:
txn1 = read.transactions(file="path", rm.duplicates=TRUE)
basket_rules <- apriori(txn1, parameter = list(sup = 0.01, conf = 0.01,target="rules"))
inspect(basket_rules)
我得到空白的 lhs。它们是:
{} => {cuisines.get}
,等等
知道为什么会这样吗?如何解决这个问题?
来自 help("apriori")
:
The default value in
APparameter
forminlen
is1
. This means that rules with only one item (i.e., an empty antecedent/LHS) like{} => {beer}
will be created. These rules mean that no matter what other items are involved the item in the RHS will appear with the probability given by the rule's confidence (which equals the support). If you want to avoid these rules then use the argument
parameter=list(minlen=2)
.
卢克的回答是正确的。 此外,我们可以说先验总是给我们关于结果的信息,即程序中的 RHS。这就是为什么如果没有使用 'minlen',那么对于具有等于最小置信度的最小支持度的单个项目集,也会在结果输出中给出。
例如。
> inspect(rules)
lhs rhs support confidence lift count
[1] {} => {Soup} 0.8 0.8 1.0 4
[2] {} => {Pasta} 0.8 0.8 1.0 4
[3] {Salad} => {Ham} 0.4 1.0 1.7 2
我希望这能解释输出(其他规则未在此示例中显示)。 上面给出的是这个table.
的部分输出Customer ID Food
1 -Salad, Hamburger, Taco
2 -Soup, Hamburger, Pasta
3 -Salad, Soup, Hamburger, Pasta
4 -Soup, Pasta
5 -Taco, Pasta, Soup