diff --git a/CRAN-SUBMISSION b/CRAN-SUBMISSION index 00fdd20..c078dc8 100644 --- a/CRAN-SUBMISSION +++ b/CRAN-SUBMISSION @@ -1,3 +1,3 @@ -Version: 0.9.2 -Date: 2023-10-14 16:44:29 UTC -SHA: 1d239694c309c6b48168b2ca19b8fd5c8d6f1d2d +Version: 0.9.3 +Date: 2024-01-12 11:21:47 UTC +SHA: d2f329e540177df778e787a27dec50d34cb5ed5c diff --git a/R/shapviz.R b/R/shapviz.R index 39a9726..3d07af5 100644 --- a/R/shapviz.R +++ b/R/shapviz.R @@ -111,7 +111,6 @@ shapviz.matrix = function(object, X, baseline = 0, collapse = NULL, #' Creates a "shapviz" object from an XGBoost model. #' @export #' @examples -#' \dontrun{ #' # XGBoost models #' X_pred <- data.matrix(iris[, -1]) #' dtrain <- xgboost::xgb.DMatrix(X_pred, label = iris[, 1], nthread = 1) @@ -184,7 +183,6 @@ shapviz.matrix = function(object, X, baseline = 0, collapse = NULL, #' mx #' all.equal(mx[[3]], x) #' } -#' } shapviz.xgb.Booster = function(object, X_pred, X = X_pred, which_class = NULL, collapse = NULL, interactions = FALSE, ...) { stopifnot( diff --git a/R/sv_dependence.R b/R/sv_dependence.R index d5c944a..f5fc22f 100644 --- a/R/sv_dependence.R +++ b/R/sv_dependence.R @@ -39,7 +39,6 @@ #' @param ... Arguments passed to [ggplot2::geom_jitter()]. #' @returns An object of class "ggplot" (or "patchwork") representing a dependence plot. #' @examples -#' \dontrun{ #' dtrain <- xgboost::xgb.DMatrix( #' data.matrix(iris[, -1]), label = iris[, 1], nthread = 1 #' ) @@ -57,7 +56,6 @@ #' sv_dependence( #' x2, c("Petal.Length", "Species"), color_var = NULL, interactions = TRUE #' ) -#' } #' @export #' @seealso [potential_interactions()] sv_dependence <- function(object, ...) { diff --git a/R/sv_dependence2D.R b/R/sv_dependence2D.R index 2f3e41e..3b871ac 100644 --- a/R/sv_dependence2D.R +++ b/R/sv_dependence2D.R @@ -29,7 +29,6 @@ #' @param ... Arguments passed to [ggplot2::geom_jitter()]. #' @returns An object of class "ggplot" (or "patchwork") representing a dependence plot. #' @examples -#' \dontrun{ #' dtrain <- xgboost::xgb.DMatrix( #' data.matrix(iris[, -1]), label = iris[, 1], nthread = 1 #' ) @@ -48,7 +47,6 @@ #' # mshapviz object #' mx <- split(sv, f = iris$Species) #' sv_dependence2D(mx, x = "Petal.Length", y = "Sepal.Width") -#' } #' @export #' @seealso [sv_dependence()] sv_dependence2D <- function(object, ...) { diff --git a/R/sv_force.R b/R/sv_force.R index 3e3a305..f8e1cd7 100644 --- a/R/sv_force.R +++ b/R/sv_force.R @@ -11,7 +11,6 @@ #' (via [ggrepel::geom_text_repel()]). #' @returns An object of class "ggplot" (or "patchwork") representing a force plot. #' @examples -#' \dontrun{ #' dtrain <- xgboost::xgb.DMatrix( #' data.matrix(iris[, -1]), label = iris[, 1], nthread = 1 #' ) @@ -22,7 +21,6 @@ #' #' # Aggregate over all observations with Petal.Length == 1.4 #' sv_force(x, row_id = x$X$Petal.Length == 1.4) -#' } #' @export #' @seealso [sv_waterfall()] sv_force <- function(object, ...) { diff --git a/R/sv_importance.R b/R/sv_importance.R index 921a683..64a58f1 100644 --- a/R/sv_importance.R +++ b/R/sv_importance.R @@ -46,7 +46,6 @@ #' `kind = "no"` - a named numeric vector of sorted SHAP feature importances #' (or a matrix in case of an object of class "mshapviz"). #' @examples -#' \dontrun{ #' X_train <- data.matrix(iris[, -1]) #' dtrain <- xgboost::xgb.DMatrix(X_train, label = iris[, 1], nthread = 1) #' fit <- xgboost::xgb.train(data = dtrain, nrounds = 10, nthread = 1) @@ -54,8 +53,6 @@ #' sv_importance(x) #' sv_importance(x, kind = "no") #' sv_importance(x, kind = "beeswarm", show_numbers = TRUE) -#' } -#' #' @seealso \code{\link{sv_interaction}} #' @export sv_importance <- function(object, ...) { diff --git a/R/sv_interaction.R b/R/sv_interaction.R index be0707f..f205408 100644 --- a/R/sv_interaction.R +++ b/R/sv_interaction.R @@ -18,7 +18,6 @@ #' numeric matrix of average absolute SHAP interactions sorted by the average #' absolute SHAP values (or a list of such matrices in case of "mshapviz" object). #' @examples -#' \dontrun{ #' dtrain <- xgboost::xgb.DMatrix( #' data.matrix(iris[, -1]), label = iris[, 1], nthread = 1 #' ) @@ -26,7 +25,6 @@ #' x <- shapviz(fit, X_pred = dtrain, X = iris, interactions = TRUE) #' sv_interaction(x, kind = "no") #' sv_interaction(x, max_display = 2, size = 3) -#' } #' @seealso [sv_importance()] #' @export sv_interaction <- function(object, ...) { diff --git a/R/sv_waterfall.R b/R/sv_waterfall.R index c5b217e..41b7e23 100644 --- a/R/sv_waterfall.R +++ b/R/sv_waterfall.R @@ -35,7 +35,6 @@ #' will altogether suppress adding text to the bars. #' @returns An object of class "ggplot" (or "patchwork") representing a waterfall plot. #' @examples -#' \dontrun{ #' dtrain <- xgboost::xgb.DMatrix( #' data.matrix(iris[, -1]), label = iris[, 1], nthread = 1 #' ) @@ -51,7 +50,6 @@ #' #' # Aggregate over all observations with Petal.Length == 1.4 #' sv_waterfall(x, row_id = x$X$Petal.Length == 1.4) -#' } #' @export #' @seealso [sv_force()] sv_waterfall <- function(object, ...) { diff --git a/cran-comments.md b/cran-comments.md index c040929..0c2f94f 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,52 +1,14 @@ -# shapviz 0.9.2 +# shapviz 0.9.3 -## Resubmission 7 +Hi CRAN team -No effect of setDTthreads(2). Commenting out now all tests with xgboost. - -## Resubmission 6 - -Test timing not fixed, still. Now testing to import {data.table} and setDTthreads(2) pre checks. - -## Resubmission 5 - -Now trying - -Sys.setenv(DT_NUM_THREADS = 1) -Sys.setenv("TESTTHAT_CPUS" = 1) -options(Ncpus = 1) - - -## Resubmission 4 - -Trying to set Sys.setenv(DT_NUM_THREADS = 2) in the unit tests to fix the crazy Debian behaviour. - -## Resubmission 3 - -Moving one single nthread = 1 into param = list(). Setting nrounds = 1 in all tests. If this does not help, I will need to delete most unit tests. - -## Resubmission 2 - -Setting nthread = 1 in unit tests and vignettes. Hope this fixes the problems. - -## Resubmission 1 - -Fixing problems with curly braces in .rd files. - -### Original message - -Hello CRAN team - -{shapviz} already got 2 reverse dependencies, which look okay. - -The update has mainly added more flexibility of the importance plots for multi-output models. +This is a relatively small update, but offers much more flexibility in the interaction heuristic. ## Checks look good ### check(manual = TRUE, cran = TRUE) -- checking HTML version of manual ... NOTE - Skipping checking HTML validation: no command 'tidy' found +Ok ### RHub (usual notes) @@ -54,8 +16,14 @@ The update has mainly added more flexibility of the importance plots for multi-o Packages which this enhances but not available for checking: 'fastshap', 'h2o', 'lightgbm' * checking HTML version of manual ... NOTE -Skipping checking HTML validation: no command 'tidy' found Skipping checking math rendering: package 'V8' unavailable +* checking for non-standard things in the check directory ... NOTE +Found the following files/directories: + ''NULL'' +* checking for detritus in the temp directory ... NOTE +Found the following files/directories: + 'lastMiKTeXException' + ### Winbuilder() diff --git a/man/shapviz.Rd b/man/shapviz.Rd index a408183..adc08cb 100644 --- a/man/shapviz.Rd +++ b/man/shapviz.Rd @@ -174,7 +174,6 @@ return a "mshapviz" object, containing a "shapviz" object per output. S <- matrix(c(1, -1, -1, 1), ncol = 2, dimnames = list(NULL, c("x", "y"))) X <- data.frame(x = c("a", "b"), y = c(100, 10)) shapviz(S, X, baseline = 4) -\dontrun{ # XGBoost models X_pred <- data.matrix(iris[, -1]) dtrain <- xgboost::xgb.DMatrix(X_pred, label = iris[, 1], nthread = 1) @@ -248,7 +247,6 @@ if (requireNamespace("lightgbm", quietly = TRUE)) { all.equal(mx[[3]], x) } } -} \seealso{ \code{\link[=sv_importance]{sv_importance()}}, \code{\link[=sv_dependence]{sv_dependence()}}, \code{\link[=sv_dependence2D]{sv_dependence2D()}}, \code{\link[=sv_interaction]{sv_interaction()}}, \code{\link[=sv_waterfall]{sv_waterfall()}}, \code{\link[=sv_force]{sv_force()}}, \code{\link[=collapse_shap]{collapse_shap()}} diff --git a/man/sv_dependence.Rd b/man/sv_dependence.Rd index 2d2493f..50b2fc2 100644 --- a/man/sv_dependence.Rd +++ b/man/sv_dependence.Rd @@ -100,7 +100,6 @@ By default, the feature on the color scale is selected via SHAP interactions }} \examples{ -\dontrun{ dtrain <- xgboost::xgb.DMatrix( data.matrix(iris[, -1]), label = iris[, 1], nthread = 1 ) @@ -119,7 +118,6 @@ sv_dependence( x2, c("Petal.Length", "Species"), color_var = NULL, interactions = TRUE ) } -} \seealso{ \code{\link[=potential_interactions]{potential_interactions()}} } diff --git a/man/sv_dependence2D.Rd b/man/sv_dependence2D.Rd index 5248e4b..46473d9 100644 --- a/man/sv_dependence2D.Rd +++ b/man/sv_dependence2D.Rd @@ -94,7 +94,6 @@ has no effect. }} \examples{ -\dontrun{ dtrain <- xgboost::xgb.DMatrix( data.matrix(iris[, -1]), label = iris[, 1], nthread = 1 ) @@ -114,7 +113,6 @@ sv_dependence2D( mx <- split(sv, f = iris$Species) sv_dependence2D(mx, x = "Petal.Length", y = "Sepal.Width") } -} \seealso{ \code{\link[=sv_dependence]{sv_dependence()}} } diff --git a/man/sv_force.Rd b/man/sv_force.Rd index 2eeddc9..d0a420f 100644 --- a/man/sv_force.Rd +++ b/man/sv_force.Rd @@ -96,7 +96,6 @@ baseline SHAP value. }} \examples{ -\dontrun{ dtrain <- xgboost::xgb.DMatrix( data.matrix(iris[, -1]), label = iris[, 1], nthread = 1 ) @@ -108,7 +107,6 @@ sv_force(x, row_id = 65, max_display = 3, size = 9, fill_colors = 4:5) # Aggregate over all observations with Petal.Length == 1.4 sv_force(x, row_id = x$X$Petal.Length == 1.4) } -} \seealso{ \code{\link[=sv_waterfall]{sv_waterfall()}} } diff --git a/man/sv_importance.Rd b/man/sv_importance.Rd index 59f6f8d..5c8617f 100644 --- a/man/sv_importance.Rd +++ b/man/sv_importance.Rd @@ -117,7 +117,6 @@ are sorted in decreasing order of importance. }} \examples{ -\dontrun{ X_train <- data.matrix(iris[, -1]) dtrain <- xgboost::xgb.DMatrix(X_train, label = iris[, 1], nthread = 1) fit <- xgboost::xgb.train(data = dtrain, nrounds = 10, nthread = 1) @@ -125,8 +124,6 @@ x <- shapviz(fit, X_pred = X_train) sv_importance(x) sv_importance(x, kind = "no") sv_importance(x, kind = "beeswarm", show_numbers = TRUE) -} - } \seealso{ \code{\link{sv_interaction}} diff --git a/man/sv_interaction.Rd b/man/sv_interaction.Rd index c24cba0..a72d0c7 100644 --- a/man/sv_interaction.Rd +++ b/man/sv_interaction.Rd @@ -87,7 +87,6 @@ The features are sorted in decreasing order of usual SHAP importance. }} \examples{ -\dontrun{ dtrain <- xgboost::xgb.DMatrix( data.matrix(iris[, -1]), label = iris[, 1], nthread = 1 ) @@ -96,7 +95,6 @@ x <- shapviz(fit, X_pred = dtrain, X = iris, interactions = TRUE) sv_interaction(x, kind = "no") sv_interaction(x, max_display = 2, size = 3) } -} \seealso{ \code{\link[=sv_importance]{sv_importance()}} } diff --git a/man/sv_waterfall.Rd b/man/sv_waterfall.Rd index 8c3f689..cbafd93 100644 --- a/man/sv_waterfall.Rd +++ b/man/sv_waterfall.Rd @@ -102,7 +102,6 @@ baseline SHAP value. }} \examples{ -\dontrun{ dtrain <- xgboost::xgb.DMatrix( data.matrix(iris[, -1]), label = iris[, 1], nthread = 1 ) @@ -119,7 +118,6 @@ sv_waterfall( # Aggregate over all observations with Petal.Length == 1.4 sv_waterfall(x, row_id = x$X$Petal.Length == 1.4) } -} \seealso{ \code{\link[=sv_force]{sv_force()}} } diff --git a/revdep/README.md b/revdep/README.md index 0ff6b19..de06d8c 100644 --- a/revdep/README.md +++ b/revdep/README.md @@ -10,7 +10,7 @@ |collate |German_Switzerland.utf8 | |ctype |German_Switzerland.utf8 | |tz |Europe/Zurich | -|date |2023-10-13 | +|date |2024-01-12 | |rstudio |2023.06.1+524 Mountain Hydrangea (desktop) | |pandoc |3.1.6 @ C:\Users\Michael\AppData\Local\Pandoc\pandoc.exe | @@ -18,49 +18,49 @@ |package |old |new |Δ | |:------------|:-------|:-------|:--| -|shapviz |0.9.1 |0.9.2 |* | -|cli |3.6.1 |3.6.1 | | +|shapviz |0.9.2 |0.9.3 |* | +|cli |3.6.2 |3.6.2 | | |colorspace |2.1-0 |2.1-0 | | |commonmark |1.9.0 |1.9.0 | | -|curl |5.1.0 |5.1.0 | | -|data.table |1.14.8 |1.14.8 | | -|fansi |1.0.5 |1.0.5 | | +|curl |5.2.0 |5.2.0 | | +|data.table |1.14.10 |1.14.10 | | +|fansi |1.0.6 |1.0.6 | | |farver |2.1.1 |2.1.1 | | |ggfittext |0.10.1 |0.10.1 | | |gggenes |0.5.1 |0.5.1 | | |ggplot2 |3.4.4 |3.4.4 | | -|ggrepel |0.9.3 |0.9.3 | | -|glue |1.6.2 |1.6.2 | | +|ggrepel |0.9.5 |0.9.5 | | +|glue |1.7.0 |1.7.0 | | |gridtext |0.1.5 |0.1.5 | | |gtable |0.3.4 |0.3.4 | | |isoband |0.2.7 |0.2.7 | | |jpeg |0.1-10 |0.1-10 | | -|jsonlite |1.8.7 |1.8.7 | | +|jsonlite |1.8.8 |1.8.8 | | |labeling |0.4.3 |0.4.3 | | -|lifecycle |1.0.3 |1.0.3 | | +|lifecycle |1.0.4 |1.0.4 | | |magrittr |2.0.3 |2.0.3 | | -|markdown |1.10 |1.10 | | +|markdown |1.12 |1.12 | | |munsell |0.5.0 |0.5.0 | | -|patchwork |1.1.3 |1.1.3 | | +|patchwork |1.2.0 |1.2.0 | | |pillar |1.9.0 |1.9.0 | | |pkgconfig |2.0.3 |2.0.3 | | |png |0.1-8 |0.1-8 | | |R6 |2.5.1 |2.5.1 | | |RColorBrewer |1.1-3 |1.1-3 | | -|Rcpp |1.0.11 |1.0.11 | | -|rlang |1.1.1 |1.1.1 | | -|scales |1.2.1 |1.2.1 | | +|Rcpp |1.0.12 |1.0.12 | | +|rlang |1.1.3 |1.1.3 | | +|scales |1.3.0 |1.3.0 | | |shades |1.4.0 |1.4.0 | | -|stringi |1.7.12 |1.7.12 | | -|stringr |1.5.0 |1.5.0 | | +|stringi |1.8.3 |1.8.3 | | +|stringr |1.5.1 |1.5.1 | | |tibble |3.2.1 |3.2.1 | | -|utf8 |1.2.3 |1.2.3 | | -|vctrs |0.6.3 |0.6.3 | | +|utf8 |1.2.4 |1.2.4 | | +|vctrs |0.6.5 |0.6.5 | | |viridisLite |0.4.2 |0.4.2 | | -|withr |2.5.1 |2.5.1 | | -|xfun |0.40 |0.40 | | -|xgboost |1.7.5.1 |1.7.5.1 | | -|xml2 |1.3.5 |1.3.5 | | +|withr |2.5.2 |2.5.2 | | +|xfun |0.41 |0.41 | | +|xgboost |1.7.6.1 |1.7.6.1 | | +|xml2 |1.3.6 |1.3.6 | | # Revdeps diff --git a/vignettes/basic_use.Rmd b/vignettes/basic_use.Rmd index 45517a2..d3346af 100644 --- a/vignettes/basic_use.Rmd +++ b/vignettes/basic_use.Rmd @@ -68,8 +68,10 @@ set.seed(1) # Build model x <- c("carat", "cut", "color", "clarity") -dtrain <- xgb.DMatrix(data.matrix(diamonds[x]), label = diamonds$price) -fit <- xgb.train(params = list(learning_rate = 0.1), data = dtrain, nrounds = 65) +dtrain <- xgb.DMatrix(data.matrix(diamonds[x]), label = diamonds$price, nthread = 1) +fit <- xgb.train( + params = list(learning_rate = 0.1, nthread = 1), data = dtrain, nrounds = 65 +) # SHAP analysis: X can even contain factors dia_2000 <- diamonds[sample(nrow(diamonds), 2000), x]