diff --git a/R/orsf_vint.R b/R/orsf_vint.R index 388a5715..b8c6c4e0 100644 --- a/R/orsf_vint.R +++ b/R/orsf_vint.R @@ -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_")] } @@ -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 + + }) } diff --git a/cran-comments.md b/cran-comments.md index aba8c749..50c2d321 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -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. diff --git a/tests/testthat/test-orsf_vint.R b/tests/testthat/test-orsf_vint.R index 9676808d..d17ace90 100644 --- a/tests/testthat/test-orsf_vint.R +++ b/tests/testthat/test-orsf_vint.R @@ -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)) + + } +)