Skip to content

Commit

Permalink
Fix if transactions parameter does not contain transactions for rules.
Browse files Browse the repository at this point in the history
  • Loading branch information
mhahsler committed Apr 4, 2020
1 parent ad1e55f commit 78ee130
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions R/interestMeasures.R
Original file line number Diff line number Diff line change
Expand Up @@ -366,9 +366,10 @@ setMethod("interestMeasure", signature(x = "rules"),
.rhsSupport <- function(x, transactions, reuse = TRUE){
q <- quality(x)

if(reuse && !is.null(q$confidence) && !is.null(q$lift))
if(reuse && !is.null(q$confidence) && !is.null(q$lift)) {
rhsSupport <- q$confidence / q$lift
else {
rhsSupport[is.na(rhsSupport)] <- 0 ### in case lift was NaN (0/0)
} else {
if(is.null(transactions)) stop("transactions missing. Please specify the data used to mine the rules as transactions!")
if(all(diff(rhs(x)@data@p) == 1))
rhsSupport <- unname(itemFrequency(transactions)[rhs(x)@data@i+1L]) ### this is a lot faster for single items in the RHS
Expand Down

0 comments on commit 78ee130

Please sign in to comment.