Skip to content

Commit a9456f4

Browse files
authored
Merge pull request #110 from ModelOriented/CRAN-update
Preparation of CRAN release
2 parents a690ff6 + 4478f17 commit a9456f4

18 files changed

+137
-106
lines changed

CRAN-SUBMISSION

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
Version: 0.3.8
2-
Date: 2023-09-23 12:06:38 UTC
3-
SHA: 7ca4f7e46e925abd8cf0155227d126ebd9ea2364
1+
Version: 0.4.0
2+
Date: 2023-11-10 18:24:23 UTC
3+
SHA: 4b25bb0b9f2223185eac1fe01a19d6014d01eb12

NAMESPACE

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ S3method(permshap,ranger)
99
S3method(print,kernelshap)
1010
S3method(print,permshap)
1111
S3method(summary,kernelshap)
12+
S3method(summary,permshap)
1213
export(is.kernelshap)
1314
export(is.permshap)
1415
export(kernelshap)

R/kernelshap.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@
117117
#' see README for an example. Parallelization automatically disables the progress bar.
118118
#' @param parallel_args Named list of arguments passed to [foreach::foreach()].
119119
#' Ideally, this is `NULL` (default). Only relevant if `parallel = TRUE`.
120-
#' Example on Windows: if `object` is a GAM fitted with package {mgcv},
120+
#' Example on Windows: if `object` is a GAM fitted with package 'mgcv',
121121
#' then one might need to set `parallel_args = list(.packages = "mgcv")`.
122122
#' @param verbose Set to `FALSE` to suppress messages and the progress bar.
123123
#' @param ... Additional arguments passed to `pred_fun(object, X, ...)`.
@@ -165,7 +165,7 @@
165165
#' s
166166
#'
167167
#' # MODEL TWO: Multi-response linear regression
168-
#' fit <- lm(as.matrix(iris[1:2]) ~ Petal.Length + Petal.Width + Species, data = iris)
168+
#' fit <- lm(as.matrix(iris[, 1:2]) ~ Petal.Length + Petal.Width + Species, data = iris)
169169
#' s <- kernelshap(fit, iris[1:4, 3:5], bg_X = bg_X)
170170
#' summary(s)
171171
#'

R/methods.R

+35-15
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
1-
#' Print Method
2-
#'
3-
#' Prints the first two rows of the matrix (or matrices) of SHAP values.
1+
#' Prints "kernelshap" Object
42
#'
53
#' @param x An object of class "kernelshap".
64
#' @param n Maximum number of rows of SHAP values to print.
75
#' @param ... Further arguments passed from other methods.
86
#' @returns Invisibly, the input is returned.
97
#' @export
108
#' @examples
11-
#' fit <- stats::lm(Sepal.Length ~ ., data = iris)
12-
#' s <- kernelshap(fit, iris[1:3, -1], bg_X = iris[-1])
9+
#' fit <- lm(Sepal.Length ~ ., data = iris)
10+
#' s <- kernelshap(fit, iris[1:3, -1], bg_X = iris[, -1])
1311
#' s
1412
#' @seealso [kernelshap()]
1513
print.kernelshap <- function(x, n = 2L, ...) {
@@ -18,25 +16,32 @@ print.kernelshap <- function(x, n = 2L, ...) {
1816
invisible(x)
1917
}
2018

21-
#' @describeIn print.kernelshap Print method for "permshap" object
19+
#' Prints "permshap" Object
20+
#'
21+
#' @param x An object of class "permshap".
22+
#' @inheritParams print.kernelshap
23+
#' @inherit print.kernelshap return
2224
#' @export
25+
#' @examples
26+
#' fit <- lm(Sepal.Length ~ ., data = iris)
27+
#' s <- permshap(fit, iris[1:3, -1], bg_X = iris[, -1])
28+
#' s
29+
#' @seealso [permshap()]
2330
print.permshap <- function(x, n = 2L, ...) {
2431
print.kernelshap(x, n = n, ...)
2532
}
2633

27-
#' Summary Method
34+
#' Summarizes "kernelshap" Object
2835
#'
2936
#' @param object An object of class "kernelshap".
30-
#' @param compact Set to `TRUE` to hide printing the top n SHAP values,
31-
#' standard errors and feature values.
32-
#' @param n Maximum number of rows of SHAP values, standard errors and feature values
33-
#' to print.
37+
#' @param compact Set to `TRUE` for a more compact summary.
38+
#' @param n Maximum number of rows of SHAP values etc. to print.
3439
#' @param ... Further arguments passed from other methods.
3540
#' @returns Invisibly, the input is returned.
3641
#' @export
3742
#' @examples
38-
#' fit <- stats::lm(Sepal.Length ~ ., data = iris)
39-
#' s <- kernelshap(fit, iris[1:3, -1], bg_X = iris[-1])
43+
#' fit <- lm(Sepal.Length ~ ., data = iris)
44+
#' s <- kernelshap(fit, iris[1:3, -1], bg_X = iris[, -1])
4045
#' summary(s)
4146
#' @seealso [kernelshap()]
4247
summary.kernelshap <- function(object, compact = FALSE, n = 2L, ...) {
@@ -74,6 +79,21 @@ summary.kernelshap <- function(object, compact = FALSE, n = 2L, ...) {
7479
invisible(object)
7580
}
7681

82+
#' Summarizes "permshap" Object
83+
#'
84+
#' @param object An object of class "permshap".
85+
#' @inheritParams summary.kernelshap
86+
#' @inherit summary.kernelshap return
87+
#' @export
88+
#' @examples
89+
#' fit <- lm(Sepal.Length ~ ., data = iris)
90+
#' s <- permshap(fit, iris[1:3, -1], bg_X = iris[, -1])
91+
#' summary(s)
92+
#' @seealso [permshap()]
93+
summary.permshap <- function(object, compact = FALSE, n = 2L, ...) {
94+
summary.kernelshap(object, compact = compact, n = n, ...)
95+
}
96+
7797
#' Check for kernelshap
7898
#'
7999
#' Is object of class "kernelshap"?
@@ -83,7 +103,7 @@ summary.kernelshap <- function(object, compact = FALSE, n = 2L, ...) {
83103
#' @export
84104
#' @examples
85105
#' fit <- lm(Sepal.Length ~ ., data = iris)
86-
#' s <- kernelshap(fit, iris[1:2, -1], bg_X = iris[-1])
106+
#' s <- kernelshap(fit, iris[1:2, -1], bg_X = iris[, -1])
87107
#' is.kernelshap(s)
88108
#' is.kernelshap("a")
89109
#' @seealso [kernelshap()]
@@ -100,7 +120,7 @@ is.kernelshap <- function(object){
100120
#' @export
101121
#' @examples
102122
#' fit <- lm(Sepal.Length ~ ., data = iris)
103-
#' s <- permshap(fit, iris[1:2, -1], bg_X = iris[-1])
123+
#' s <- permshap(fit, iris[1:2, -1], bg_X = iris[, -1])
104124
#' is.permshap(s)
105125
#' is.permshap("a")
106126
#' @seealso [kernelshap()]

R/permshap.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
#' s
3434
#'
3535
#' # MODEL TWO: Multi-response linear regression
36-
#' fit <- lm(as.matrix(iris[1:2]) ~ Petal.Length + Petal.Width + Species, data = iris)
36+
#' fit <- lm(as.matrix(iris[, 1:2]) ~ Petal.Length + Petal.Width + Species, data = iris)
3737
#' s <- permshap(fit, iris[1:4, 3:5], bg_X = bg_X)
3838
#' s
3939
#'

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ The package contains two workhorses to calculate SHAP values for any model:
2020

2121
### Kernel SHAP or permutation SHAP?
2222

23-
- Exact Kernel SHAP and exact permutation SHAP values agree for additive models, and differ for models with interactions.
23+
- Exact Kernel SHAP and exact permutation SHAP values (usually) agree for additive models.
2424
- If the number of features is sufficiently small, we recommend `permshap()` over `kernelshap()`.
2525

2626
### Typical workflow to explain any model

cran-comments.md

+9-51
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,33 @@
1-
# Resubmission II
1+
# kernelshap 0.4.0
22

3-
I have now removed the non-registered DOI from the description file.
3+
Dear CRAN-team
44

5-
This was Uwe's comment:
5+
I have added exact permutation SHAP values, and the possibility to use factor-valued predictions.
66

7-
Found the following (possibly) invalid DOIs:
8-
DOI: 10.5555/3295222.3295230
9-
From: DESCRIPTION
10-
Status: 404
11-
Message: Not Found
12-
13-
and looking for the DOI shows it is not registered.
14-
Even when going to
15-
https://dl.acm.org/doi/10.5555/3295222.3295230
16-
and clicking on the "Publisher Site" link leads us into nirvana.
17-
18-
So I guess the is ill registered and you have to revert the change. My
19-
apologoies, I had not checked whether the DOI given is registreed or not.
20-
21-
Best,
22-
23-
24-
# Resubmission I
25-
26-
I stumbled over a DOI: Uwe gently pointed this out:
27-
28-
"
29-
The Description field contains
30-
<https://dl.acm.org/doi/10.5555/3295222.3295230>, and Covert and Lee
31-
Please use permanent DOI markup for linking to publications as in
32-
<doi:prefix/suffix>.
33-
"
34-
35-
This resubmission fixes this.
36-
37-
# Original message
38-
39-
Hello CRAN
40-
41-
This is a small maintenance release only.
42-
43-
Thanks a lot
7+
Thanks a lot for running CRAN.
448

459
Michael
4610

4711
## Checks
4812

4913
### Revdep
5014

51-
survex 1.1.3
15+
survex 1.2.0
5216
- OK: 1
5317
- BROKEN: 0
5418

55-
### Local check with innocent NOTE
19+
### Local check with usual NOTE
5620

57-
checking HTML version of manual ... NOTE
21+
checking HTML version of manual ... NOTE
5822
Skipping checking HTML validation: no command 'tidy' found
5923

6024
### `check_win_devel()` NOTE
6125

62-
- R Under development (unstable) (2023-09-11 r85126 ucrt)
26+
- R Under development (unstable) (2023-11-09 r85497 ucrt)
6327

6428
### `check_rhub()` NOTES
6529

66-
-> Note sure where the 403 problem comes from. Is it relevant?
67-
68-
Found the following (possibly) invalid URLs:
69-
URL: https://dl.acm.org/doi/10.5555/3295222.3295230
70-
From: DESCRIPTION
71-
Status: 403
72-
Message: Forbidden
7330
* checking HTML version of manual ... NOTE
7431
Skipping checking HTML validation: no command 'tidy' found
7532
Skipping checking math rendering: package 'V8' unavailable
33+

man/is.kernelshap.Rd

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/is.permshap.Rd

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/kernelshap.Rd

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/permshap.Rd

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/print.kernelshap.Rd

+4-12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/print.permshap.Rd

+29
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/summary.kernelshap.Rd

+6-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)