Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt to XGBoost 3 #167

Merged
merged 2 commits into from
Jan 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

### Compatibility

- Adapt for upcoming {xgboost} version.
- Adapt for upcoming {shapr} version, thanks @martinju for the fix [#162](https://github.com/ModelOriented/shapviz/pull/162).

# shapviz 0.9.6
Expand Down
8 changes: 4 additions & 4 deletions R/shapviz.R
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ shapviz.matrix = function(
#' # XGBoost models
#' X_pred <- data.matrix(iris[, -1])
#' dtrain <- xgboost::xgb.DMatrix(X_pred, label = iris[, 1], nthread = 1)
#' fit <- xgboost::xgb.train(data = dtrain, nrounds = 10, nthread = 1)
#' fit <- xgboost::xgb.train(list(nthread = 1), data = dtrain, nrounds = 10)
#'
#' # Will use numeric matrix "X_pred" as feature matrix
#' x <- shapviz(fit, X_pred = X_pred)
Expand All @@ -131,12 +131,12 @@ shapviz.matrix = function(
#' x <- shapviz(fit, X_pred = dtrain, X = iris)
#'
#' # Multiclass setting
#' params <- list(objective = "multi:softprob", num_class = 3)
#' params <- list(objective = "multi:softprob", num_class = 3, nthread = 1)
#' X_pred <- data.matrix(iris[, -5])
#' dtrain <- xgboost::xgb.DMatrix(
#' X_pred, label = as.integer(iris[, 5]) - 1, nthread = 1
#' )
#' fit <- xgboost::xgb.train(params = params, data = dtrain, nrounds = 10, nthread = 1)
#' fit <- xgboost::xgb.train(params = params, data = dtrain, nrounds = 10)
#'
#' # Select specific class
#' x <- shapviz(fit, X_pred = X_pred, which_class = 3)
Expand All @@ -149,7 +149,7 @@ shapviz.matrix = function(
#' # What if we would have one-hot-encoded values and want to explain the original column?
#' X_pred <- stats::model.matrix(~ . -1, iris[, -1])
#' dtrain <- xgboost::xgb.DMatrix(X_pred, label = as.integer(iris[, 1]), nthread = 1)
#' fit <- xgboost::xgb.train(data = dtrain, nrounds = 10, nthread = 1)
#' fit <- xgboost::xgb.train(list(nthread = 1), data = dtrain, nrounds = 10)
#' x <- shapviz(
#' fit,
#' X_pred = X_pred,
Expand Down
7 changes: 4 additions & 3 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# shapviz 0.9.6 (Fix CRAN errors)
# shapviz 0.9.7

One vignette points to a missing figure, leading errors or notes in different builds.
Slight adaptions to comply with upcoming XGBoost version.

### Local checks

Expand All @@ -12,4 +12,5 @@ Status: OK

## Reverse dependencies (2)

Not checked because the change affects only a vignette.
OK: 2
BROKEN: 0
8 changes: 4 additions & 4 deletions man/shapviz.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 25 additions & 32 deletions revdep/README.md
Original file line number Diff line number Diff line change
@@ -1,53 +1,53 @@
# Platform

|field |value |
|:--------|:----------------------------------------|
|version |R version 4.4.1 (2024-06-14 ucrt) |
|os |Windows 11 x64 (build 22631) |
|system |x86_64, mingw32 |
|ui |RStudio |
|language |(EN) |
|collate |English_Switzerland.utf8 |
|ctype |English_Switzerland.utf8 |
|tz |Europe/Zurich |
|date |2024-09-13 |
|rstudio |2024.04.2+764 Chocolate Cosmos (desktop) |
|pandoc |NA |
|field |value |
|:--------|:-------------------------------------|
|version |R version 4.4.1 (2024-06-14 ucrt) |
|os |Windows 11 x64 (build 22631) |
|system |x86_64, mingw32 |
|ui |RStudio |
|language |(EN) |
|collate |English_Switzerland.utf8 |
|ctype |English_Switzerland.utf8 |
|tz |Europe/Zurich |
|date |2025-01-19 |
|rstudio |2024.12.0+467 Kousa Dogwood (desktop) |
|pandoc |NA |

# Dependencies

|package |old |new |Δ |
|:------------|:-------|:-------|:--|
|shapviz |0.9.4 |0.9.5 |* |
|shapviz |0.9.6 |0.9.7 |* |
|cli |3.6.3 |3.6.3 | |
|colorspace |2.1-1 |2.1-1 | |
|commonmark |1.9.1 |1.9.1 | |
|curl |5.2.2 |5.2.2 | |
|data.table |1.16.0 |1.16.0 | |
|commonmark |1.9.2 |1.9.2 | |
|curl |6.1.0 |6.1.0 | |
|data.table |1.16.4 |1.16.4 | |
|fansi |1.0.6 |1.0.6 | |
|farver |2.1.2 |2.1.2 | |
|ggfittext |0.10.2 |0.10.2 | |
|gggenes |0.5.1 |0.5.1 | |
|ggplot2 |3.5.1 |3.5.1 | |
|ggrepel |0.9.6 |0.9.6 | |
|glue |1.7.0 |1.7.0 | |
|glue |1.8.0 |1.8.0 | |
|gridtext |0.1.5 |0.1.5 | |
|gtable |0.3.5 |0.3.5 | |
|gtable |0.3.6 |0.3.6 | |
|isoband |0.2.7 |0.2.7 | |
|jpeg |0.1-10 |0.1-10 | |
|jsonlite |1.8.8 |1.8.8 | |
|jsonlite |1.8.9 |1.8.9 | |
|labeling |0.4.3 |0.4.3 | |
|lifecycle |1.0.4 |1.0.4 | |
|magrittr |2.0.3 |2.0.3 | |
|markdown |1.13 |1.13 | |
|munsell |0.5.1 |0.5.1 | |
|patchwork |1.2.0 |1.2.0 | |
|pillar |1.9.0 |1.9.0 | |
|patchwork |1.3.0 |1.3.0 | |
|pillar |1.10.1 |1.10.1 | |
|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.13 |1.0.13 | |
|Rcpp |1.0.14 |1.0.14 | |
|rlang |1.1.4 |1.1.4 | |
|scales |1.3.0 |1.3.0 | |
|shades |1.4.0 |1.4.0 | |
Expand All @@ -57,17 +57,10 @@
|utf8 |1.2.4 |1.2.4 | |
|vctrs |0.6.5 |0.6.5 | |
|viridisLite |0.4.2 |0.4.2 | |
|withr |3.0.1 |3.0.1 | |
|xfun |0.47 |0.47 | |
|withr |3.0.2 |3.0.2 | |
|xfun |0.50 |0.50 | |
|xgboost |1.7.8.1 |1.7.8.1 | |
|xml2 |1.3.6 |1.3.6 | |

# Revdeps

## Failed to check (2)

|package |version |error |warning |note |
|:--------|:-------|:-----|:-------|:----|
|fastshap |0.1.1 |1 | |2 |
|flowml |? | | | |

9 changes: 2 additions & 7 deletions revdep/cran.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
## revdepcheck results

We checked 2 reverse dependencies (1 from CRAN + 1 from Bioconductor), comparing R CMD check results across CRAN and dev versions of this package.
We checked 2 reverse dependencies, comparing R CMD check results across CRAN and dev versions of this package.

* We saw 0 new problems
* We failed to check 1 packages
* We failed to check 0 packages

Issues with CRAN packages are summarised below.

### Failed to check

* fastshap (NA)
143 changes: 1 addition & 142 deletions revdep/failures.md
Original file line number Diff line number Diff line change
@@ -1,142 +1 @@
# fastshap

<details>

* Version: 0.1.1
* GitHub: https://github.com/bgreenwell/fastshap
* Source code: https://github.com/cran/fastshap
* Date/Publication: 2024-02-22 22:00:02 UTC
* Number of recursive dependencies: 90

Run `revdepcheck::revdep_details(, "fastshap")` for more info

</details>

## In both

* R CMD check timed out


* checking package dependencies ... NOTE
```
Package which this enhances but not available for checking: 'lightgbm'
```

* checking Rd cross-references ... NOTE
```
Package unavailable to check Rd xrefs: 'lightgbm'
```

# flowml

<details>

* Version:
* GitHub: https://github.com/ModelOriented/shapviz
* Source code: NA
* Number of recursive dependencies: 0

</details>

## Error before installation

### Devel

```

There are binary versions available but the source versions are later:
binary source needs_compilation
abind 1.4-5 1.4-8 FALSE
gam 1.22-4 1.22-5 TRUE
ps 1.7.7 1.8.0 TRUE
RcppArmadillo 14.0.0-1 14.0.2-1 TRUE

Binaries will be installed
package 'ABCanalysis' successfully unpacked and MD5 sums checked
...
package 'pls' successfully unpacked and MD5 sums checked
package 'plyr' successfully unpacked and MD5 sums checked
package 'png' successfully unpacked and MD5 sums checked
package 'prettyunits' successfully unpacked and MD5 sums checked
package 'pROC' successfully unpacked and MD5 sums checked
package 'processx' successfully unpacked and MD5 sums checked
package 'prodlim' successfully unpacked and MD5 sums checked
package 'progress' successfully unpacked and MD5 sums checked
package 'progressr' successfully unpacked and MD5 sums checked
package 'promises' successfully unpacked and MD5 sums checked


Warning: unable to access index for repository https://bioconductor.org/packages/3.18/bioc/bin/windows/contrib/4.4:
cannot open URL 'https://bioconductor.org/packages/3.18/bioc/bin/windows/contrib/4.4/PACKAGES'
Warning: unable to access index for repository https://bioconductor.org/packages/3.18/bioc/bin/windows/contrib/4.4:
cannot open URL 'https://bioconductor.org/packages/3.18/bioc/bin/windows/contrib/4.4/PACKAGES'
Warning: unable to access index for repository https://bioconductor.org/packages/3.18/data/annotation/bin/windows/contrib/4.4:
cannot open URL 'https://bioconductor.org/packages/3.18/data/annotation/bin/windows/contrib/4.4/PACKAGES'
Warning: unable to access index for repository https://bioconductor.org/packages/3.18/data/annotation/bin/windows/contrib/4.4:
cannot open URL 'https://bioconductor.org/packages/3.18/data/annotation/bin/windows/contrib/4.4/PACKAGES'
Warning: unable to access index for repository https://bioconductor.org/packages/3.18/data/experiment/bin/windows/contrib/4.4:
cannot open URL 'https://bioconductor.org/packages/3.18/data/experiment/bin/windows/contrib/4.4/PACKAGES'
...
2: In download.file(url, destfile, method, mode = "wb", ...) :
downloaded length 247004746 != reported length 266665380
3: In download.file(url, destfile, method, mode = "wb", ...) :
URL 'https://cran.rstudio.com/bin/windows/contrib/4.4/h2o_3.44.0.3.zip': Timeout of 60 seconds was reached
4: In download.file(url, destfile, method, mode = "wb", ...) :
URL 'https://cran.rstudio.com/bin/windows/contrib/4.4/h2o_3.44.0.3.zip': Timeout of 60 seconds was reached
Warning in download.packages(pkgs, destdir = tmpd, available = available, :
download of package 'h2o' failed
Warning in download.packages(pkgs, destdir = tmpd, available = available, :
download of package 'h2o' failed


```
### CRAN

```

There are binary versions available but the source versions are later:
binary source needs_compilation
abind 1.4-5 1.4-8 FALSE
gam 1.22-4 1.22-5 TRUE
ps 1.7.7 1.8.0 TRUE
RcppArmadillo 14.0.0-1 14.0.2-1 TRUE

Binaries will be installed
package 'ABCanalysis' successfully unpacked and MD5 sums checked
...
package 'pls' successfully unpacked and MD5 sums checked
package 'plyr' successfully unpacked and MD5 sums checked
package 'png' successfully unpacked and MD5 sums checked
package 'prettyunits' successfully unpacked and MD5 sums checked
package 'pROC' successfully unpacked and MD5 sums checked
package 'processx' successfully unpacked and MD5 sums checked
package 'prodlim' successfully unpacked and MD5 sums checked
package 'progress' successfully unpacked and MD5 sums checked
package 'progressr' successfully unpacked and MD5 sums checked
package 'promises' successfully unpacked and MD5 sums checked


Warning: unable to access index for repository https://bioconductor.org/packages/3.18/bioc/bin/windows/contrib/4.4:
cannot open URL 'https://bioconductor.org/packages/3.18/bioc/bin/windows/contrib/4.4/PACKAGES'
Warning: unable to access index for repository https://bioconductor.org/packages/3.18/bioc/bin/windows/contrib/4.4:
cannot open URL 'https://bioconductor.org/packages/3.18/bioc/bin/windows/contrib/4.4/PACKAGES'
Warning: unable to access index for repository https://bioconductor.org/packages/3.18/data/annotation/bin/windows/contrib/4.4:
cannot open URL 'https://bioconductor.org/packages/3.18/data/annotation/bin/windows/contrib/4.4/PACKAGES'
Warning: unable to access index for repository https://bioconductor.org/packages/3.18/data/annotation/bin/windows/contrib/4.4:
cannot open URL 'https://bioconductor.org/packages/3.18/data/annotation/bin/windows/contrib/4.4/PACKAGES'
Warning: unable to access index for repository https://bioconductor.org/packages/3.18/data/experiment/bin/windows/contrib/4.4:
cannot open URL 'https://bioconductor.org/packages/3.18/data/experiment/bin/windows/contrib/4.4/PACKAGES'
...
2: In download.file(url, destfile, method, mode = "wb", ...) :
downloaded length 247004746 != reported length 266665380
3: In download.file(url, destfile, method, mode = "wb", ...) :
URL 'https://cran.rstudio.com/bin/windows/contrib/4.4/h2o_3.44.0.3.zip': Timeout of 60 seconds was reached
4: In download.file(url, destfile, method, mode = "wb", ...) :
URL 'https://cran.rstudio.com/bin/windows/contrib/4.4/h2o_3.44.0.3.zip': Timeout of 60 seconds was reached
Warning in download.packages(pkgs, destdir = tmpd, available = available, :
download of package 'h2o' failed
Warning in download.packages(pkgs, destdir = tmpd, available = available, :
download of package 'h2o' failed


```
*Wow, no problems at all. :)*
1 change: 1 addition & 0 deletions shapviz.Rproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Version: 1.0
ProjectId: 53532cda-0245-4018-9318-405db5e4b62a

RestoreWorkspace: Default
SaveWorkspace: Default
Expand Down
6 changes: 2 additions & 4 deletions tests/testthat/test-interface.R
Original file line number Diff line number Diff line change
Expand Up @@ -261,11 +261,9 @@ test_that("combining incompatible shapviz objects fails", {
X_pred <- data.matrix(iris[, -5L])
dtrain <- xgboost::xgb.DMatrix(X_pred, label = as.integer(iris[, 5L]) - 1L, nthread = 1)
fit <- xgboost::xgb.train(
params = list(nthread = 1L),
params = list(nthread = 1L, num_class = 3L, objective = "multi:softprob"),
data = dtrain,
nrounds = 1L,
objective="multi:softprob",
num_class = 3L
nrounds = 1L
)
shp3 <- shapviz(fit, X_pred = X_pred, which_class = 3L, interactions = TRUE)
mshp <- shapviz(fit, X_pred = X_pred, interactions = TRUE)
Expand Down
Loading