Skip to content

Commit

Permalink
Merge pull request #45 from ropensci/issue39
Browse files Browse the repository at this point in the history
fixing recycling error with vint
  • Loading branch information
bcjaeger authored Mar 9, 2024
2 parents ed7aa17 + 79e134e commit 74ffa7b
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 2 deletions.
15 changes: 14 additions & 1 deletion R/orsf_vint.R
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ orsf_vint <- function(object,
pd$id_intr <- paste(pd$var_1_name, pd$var_2_name, sep = sep)

if(object$tree_type == 'classification'){
# better to compute interaction scores on the mean scale if
# partial dependence is computed using probabilities
pd[, mean := log(mean+0.01)]
pd[, class := paste0(class, "._aorsf.split_")]
}
Expand Down Expand Up @@ -141,7 +143,18 @@ orsf_vint <- function(object,
"\\.\\_aorsf\\.split\\_\\.",
keep = 2L)]

out <- out[, .(score = mean(score)), by = c('interaction')]
pd_split <- lapply(pd_split, function(dt){

dt[, class := gsub(pattern = "\\._aorsf\\.split_",
replacement = '',
x = class)]

# inverse transform from log taken above
dt[, mean := exp(mean) - 0.01]

dt

})

}

Expand Down
7 changes: 6 additions & 1 deletion cran-comments.md
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
I am sorry that my previous attempts did not fix the clang-UBSAN issue and led to. With the help of a colleague, I was able to reproduce the undefined behavior error and resolve it for this submission. I understand you are taking an extended break from reviewing this package and I'm comfortable waiting until the break is concluded.

With the help of a colleague, I was able to reproduce the undefined behavior error. I am confident that it is now resolved.

I understand you are taking an extended break from reviewing this package and I'm comfortable waiting until the break is concluded. Thank you for everything you do.

I saw that it took a long time to run tests on my last submission. I added rules to skip tests on CRAN that require longer run times. I hope this is helpful.
26 changes: 26 additions & 0 deletions tests/testthat/test-orsf_vint.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,29 @@ test_that(

}
)

test_that(
desc = "vint succeeds on categorical forests",
code = {

skip_on_cran()

fit <- orsf(species ~ ., data = penguins_orsf)

vints <- orsf_vint(fit)

expect_true(all(levels(penguins_orsf$species) %in% vints$class))

penguins_bnry <- penguins_orsf
penguins_bnry$species <- factor(penguins_bnry$species == "Adelie",
levels = c(FALSE, TRUE),
labels = c("Other", "adelie"))

fit <- orsf(species ~ ., data = penguins_bnry)

vints <- orsf_vint(fit)

expect_true(all(levels(penguins_bnry$species) %in% vints$class))

}
)

0 comments on commit 74ffa7b

Please sign in to comment.