Skip to content

Commit

Permalink
fix outdated URLs and rm old Rd file
Browse files Browse the repository at this point in the history
  • Loading branch information
bgreenwell committed Feb 22, 2024
1 parent eb73166 commit a9894c6
Show file tree
Hide file tree
Showing 15 changed files with 28 additions and 36 deletions.
5 changes: 5 additions & 0 deletions .Rproj.user/shared/notebooks/paths
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,14 @@
/Users/bgreenwell/Dropbox/devel/fastshap/inst/tinytest/test-fastshap-vs-other-pkgs.R="F70E1DED"
/Users/bgreenwell/Dropbox/devel/fastshap/inst/tinytest/test-genOMat.R="54612D12"
/Users/bgreenwell/Dropbox/devel/fastshap/inst/tinytest/test-shapviz.R="29D8DEE8"
/Users/bgreenwell/Dropbox/devel/fastshap/man/bin.Rd="869889FE"
/Users/bgreenwell/Dropbox/devel/fastshap/revdep/cran.md="FA0CBEF5"
/Users/bgreenwell/Dropbox/devel/fastshap/revdep/failures.md="54C2BBDB"
/Users/bgreenwell/Dropbox/devel/fastshap/revdep/problems.md="EC41BDD2"
/Users/bgreenwell/Dropbox/devel/fastshap/slowtests/fastshap-genOMat.cpp="99FEC81E"
/Users/bgreenwell/Dropbox/devel/fastshap/slowtests/slowtest-benchmark.R="29ADFB84"
/Users/bgreenwell/Dropbox/devel/fastshap/slowtests/slowtest-parallel.R="7B058F98"
/Users/bgreenwell/Dropbox/devel/fastshap/src/Makevars="2B6CF773"
/Users/bgreenwell/Dropbox/devel/fastshap/src/Makevars.win="0A0149DE"
/Users/bgreenwell/Dropbox/devel/fastshap/src/RcppExports.cpp="394C142D"
/Users/bgreenwell/Dropbox/devel/fastshap/vignettes/fastshap.Rmd="536A2979"
Expand Down
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: fastshap
Type: Package
Title: Fast Approximate Shapley Values
Version: 0.1.0
Version: 0.1.1
Authors@R: person("Brandon", "Greenwell", email = "[email protected]", role =
c("aut", "cre"), comment = c(ORCID = "0000-0002-8120-0084"))
Description: Computes fast (relative to other implementations) approximate
Expand All @@ -23,6 +23,7 @@ Enhances:
Suggests:
AmesHousing,
covr,
earth,
knitr,
ranger,
rmarkdown,
Expand Down
16 changes: 14 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
# fastshap 0.1.1

## Changed

* This NEWS file now follows the [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) format.

## Fixed

* Removed an unnecessary `.Rd` file to satisfy CRAN policies.
* Fixed a couple of outdated URLs.
* Added [earth](https://CRAN.R-project.org/package=earth) to the list of suggested packages since it's referenced a couple of times in the package documentation.

# fastshap 0.1.0

## Breaking changes
Expand Down Expand Up @@ -70,9 +82,9 @@ features.
## New features

* The default method of `explain()` gained a new logical argument called `adjust`. When `adjust = TRUE` (and `nsim > 1`), the algorithm will adjust the sum of the estimated Shapley values to satisfy the *efficiency property*; that is, to equal the difference between the model's prediction for that sample and the average prediction over all the training data. This option is experimental and we follow the same approach as in
[shap](https://github.com/slundberg/shap) [(#6)](https://github.com/bgreenwell/fastshap/issues/6).
[shap](https://github.com/shap/shap) [(#6)](https://github.com/bgreenwell/fastshap/issues/6).

* New (experimental) function for constructing [force plots](https://github.com/slundberg/shap) [(#7)](https://github.com/bgreenwell/fastshap/issues/7) to help visualize prediction explanations. The function is also a generic which means additional methods can be added.
* New (experimental) function for constructing [force plots](https://github.com/shap/shap) [(#7)](https://github.com/bgreenwell/fastshap/issues/7) to help visualize prediction explanations. The function is also a generic which means additional methods can be added.

* Function `explain()` became a generic and gained a new logical argument, `exact`, for computing exact Shapley contributions for linear models (Linear SHAP, which assumes independent features) and boosted decision trees (Tree SHAP). Currently, only `"lm"`, `"glm"`, and `"xgb.Booster"` objects are supported [(#2)](https://github.com/bgreenwell/fastshap/issues/2)[(#3)](https://github.com/bgreenwell/fastshap/issues/3).

Expand Down
4 changes: 2 additions & 2 deletions R/explain.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#' @importFrom foreach foreach %do% %dopar%
#' @importFrom stats var
explain_column <- function(object, X, column, pred_wrapper, newdata = NULL) {

# Check types
if (!is.null(newdata) && !identical(class(X), class(newdata))) {
stop("Arguments `X` and `newdata` do not inherit from the same class: ",
Expand Down Expand Up @@ -191,7 +191,7 @@ explain_column <- function(object, X, column, pred_wrapper, newdata = NULL) {
#' [stats::lm()] or [stats::glm()] object) assumes that the
#' input features are independent. Also, setting `adjust = TRUE` is
#' experimental and we follow the same approach as in
#' [shap](https://github.com/slundberg/shap).
#' [shap](https://github.com/shap/shap).
#'
#' @references
#' Strumbelj, E., and Igor K. (2014). Explaining prediction models and
Expand Down
2 changes: 2 additions & 0 deletions R/gen_friedman.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#' @param Integer specifying the number of bins to split `x` into.
#'
#' @keywords internal
#'
#' @noRd
bin <- function(x, n_bins) {
quantiles <- stats::quantile(x, probs = seq(from = 0, to = 1,
length = n_bins + 1))
Expand Down
10 changes: 0 additions & 10 deletions R/print.R

This file was deleted.

17 changes: 0 additions & 17 deletions man/bin.Rd

This file was deleted.

2 changes: 1 addition & 1 deletion man/explain.Rd

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

Empty file.
Empty file.
Empty file.
Empty file.
1 change: 0 additions & 1 deletion src/Makevars
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
CXX_STD = CXX11
## PKG_CXXFLAGS = $(SHLIB_OPENMP_CXXFLAGS)
## PKG_LIBS = $(SHLIB_OPENMP_CXXFLAGS) $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)

Expand Down
2 changes: 1 addition & 1 deletion vignettes/fastshap.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ set.seed(2129) # for reproducibility
## [1] "explain" "matrix" "array"
```

Note that the MC approach used by [fastshap](https://cran.r-project.org/package=fastshap) (and other packages) will not produce Shapley-based feature contributions that satisfy the [efficiency property](https://christophm.github.io/interpretable-ml-book/shapley.html#the-shapley-value-in-detail); that is, they won't add up to the difference between the corresponding prediction and baseline (i.e., average training prediction). However, borrowing a trick from the popular Python [shap](https://github.com/slundberg/shap) library, we can use a regression-based adjustment to correct the sum. To do this, simply set `adjust = TRUE` in the call to `explain()`^[Note that `nsim` has to be larger than one whenever setting `adjust = TRUE`.]:
Note that the MC approach used by [fastshap](https://cran.r-project.org/package=fastshap) (and other packages) will not produce Shapley-based feature contributions that satisfy the [efficiency property](https://christophm.github.io/interpretable-ml-book/shapley.html#the-shapley-value-in-detail); that is, they won't add up to the difference between the corresponding prediction and baseline (i.e., average training prediction). However, borrowing a trick from the popular Python [shap](https://github.com/shap/shap) library, we can use a regression-based adjustment to correct the sum. To do this, simply set `adjust = TRUE` in the call to `explain()`^[Note that `nsim` has to be larger than one whenever setting `adjust = TRUE`.]:


```r
Expand Down
2 changes: 1 addition & 1 deletion vignettes/fastshap.Rmd.orig
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ set.seed(2129) # for reproducibility
nsim = 1000))
```

Note that the MC approach used by [fastshap](https://cran.r-project.org/package=fastshap) (and other packages) will not produce Shapley-based feature contributions that satisfy the [efficiency property](https://christophm.github.io/interpretable-ml-book/shapley.html#the-shapley-value-in-detail); that is, they won't add up to the difference between the corresponding prediction and baseline (i.e., average training prediction). However, borrowing a trick from the popular Python [shap](https://github.com/slundberg/shap) library, we can use a regression-based adjustment to correct the sum. To do this, simply set `adjust = TRUE` in the call to `explain()`^[Note that `nsim` has to be larger than one whenever setting `adjust = TRUE`.]:
Note that the MC approach used by [fastshap](https://cran.r-project.org/package=fastshap) (and other packages) will not produce Shapley-based feature contributions that satisfy the [efficiency property](https://christophm.github.io/interpretable-ml-book/shapley.html#the-shapley-value-in-detail); that is, they won't add up to the difference between the corresponding prediction and baseline (i.e., average training prediction). However, borrowing a trick from the popular Python [shap](https://github.com/shap/shap) library, we can use a regression-based adjustment to correct the sum. To do this, simply set `adjust = TRUE` in the call to `explain()`^[Note that `nsim` has to be larger than one whenever setting `adjust = TRUE`.]:

```{r titanic-explain-jack-adjust}
set.seed(2133) # for reproducibility
Expand Down

0 comments on commit a9894c6

Please sign in to comment.