-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
240 changed files
with
41,435 additions
and
7,885 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#' Helper function for package development | ||
#' | ||
#' This is a manual extension of [testthat::snapshot_review()] which works for the \code{.rds} files used in | ||
#' this package. | ||
#' | ||
#' @param path Character | ||
#' @param ... Additional arguments passed to [waldo::compare()] | ||
#' Gives the relative path to the test files to review | ||
#' | ||
snapshot_review_man <- function(path, ...) { | ||
changed <- testthat:::snapshot_meta(path) | ||
these_rds <- (tools::file_ext(changed$name) == "rds") | ||
if (any(these_rds)) { | ||
for (i in which(these_rds)) { | ||
old <- readRDS(changed[i, "cur"]) | ||
new <- readRDS(changed[i, "new"]) | ||
|
||
cat(paste0("Difference for check ", changed[i, "name"], " in test ", changed[i, "test"], "\n")) | ||
print(waldo::compare(old, new, max_diffs = 50, ...)) | ||
browser() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,4 +29,4 @@ jobs: | |
run: lintr::lint_package() | ||
shell: Rscript {0} | ||
env: | ||
LINTR_ERROR_ON_LINT: true | ||
LINTR_ERROR_ON_LINT: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,3 +31,6 @@ docs/* | |
doc | ||
Meta | ||
docs | ||
/doc/ | ||
/Meta/ | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
Package: shapr | ||
Version: 0.2.3 | ||
Version: 0.2.3.9000 | ||
Title: Prediction Explanation with Dependence-Aware Shapley Values | ||
Description: Complex machine learning models are often hard to interpret. However, in | ||
many situations it is crucial to understand and explain why a model made a specific | ||
|
@@ -12,6 +12,7 @@ Authors@R: c( | |
person("Nikolai", "Sellereite", email = "[email protected]", role = "aut", comment = c(ORCID = "0000-0002-4671-0337")), | ||
person("Martin", "Jullum", email = "[email protected]", role = c("cre", "aut"), comment = c(ORCID = "0000-0003-3908-5155")), | ||
person("Annabelle", "Redelmeier", email = "[email protected]", role = "aut"), | ||
person("Jon", "Lachmann", email = "[email protected]", role = "aut"), | ||
person("Anders", "Løland", email = "[email protected]", role = "ctb"), | ||
person("Jens Christian", "Wahl", email = "[email protected]", role = "ctb"), | ||
person("Camilla", "Lingjærde", role = "ctb"), | ||
|
@@ -32,22 +33,29 @@ Imports: | |
Rcpp (>= 0.12.15), | ||
condMVNorm, | ||
mvnfast, | ||
Matrix | ||
Matrix, | ||
future.apply | ||
Suggests: | ||
ranger, | ||
xgboost, | ||
mgcv, | ||
testthat, | ||
testthat (>= 3.0.0), | ||
knitr, | ||
rmarkdown, | ||
roxygen2, | ||
MASS, | ||
ggplot2, | ||
caret, | ||
gbm, | ||
party, | ||
partykit | ||
partykit, | ||
waldo, | ||
progressr, | ||
future, | ||
ggbeeswarm, | ||
vdiffr, | ||
forecast | ||
LinkingTo: | ||
RcppArmadillo, | ||
Rcpp | ||
VignetteBuilder: knitr | ||
Config/testthat/edition: 3 | ||
Roxygen: list(markdown = TRUE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#' Set up the framework chosen approach | ||
#' | ||
#' The different choices of `approach` takes different (optional) parameters, which are forwarded from [explain()]. | ||
#' | ||
#' @param ... `approach`-specific arguments. See below. | ||
#' | ||
#' @inheritParams default_doc_explain | ||
#' | ||
#' @export | ||
setup_approach <- function(internal, ...) { | ||
approach <- internal$parameters$approach | ||
|
||
this_class <- "" | ||
|
||
if (length(approach) > 1) { | ||
class(this_class) <- "combined" | ||
} else { | ||
class(this_class) <- approach | ||
} | ||
|
||
UseMethod("setup_approach", this_class) | ||
} | ||
|
||
#' @inheritParams default_doc | ||
#' @export | ||
setup_approach.combined <- function(internal, ...) { | ||
org_approach <- internal$parameters$approach | ||
unique_approaches <- unique(org_approach) | ||
|
||
for (i in unique_approaches) { | ||
internal$parameters$approach <- i | ||
internal <- setup_approach(internal, ...) | ||
} | ||
internal$parameters$approach <- org_approach | ||
|
||
return(internal) | ||
} | ||
|
||
#' Generate data used for predictions | ||
#' | ||
#' @param x Explainer object. See [explain()] for more information. | ||
#' | ||
#' @param seed Positive integer. If `NULL` the seed will be inherited from the calling environment. | ||
#' | ||
#' @param index_features Positive integer vector. Specifies the indices of combinations to apply to the present method. | ||
#' `NULL` means all combinations. Only used internally. | ||
#' | ||
#' @param ... Currently not used. | ||
#' | ||
#' @return A data.table containing simulated data passed to prediction(). | ||
#' | ||
#' @export | ||
#' @keywords internal | ||
prepare_data <- function(internal, ...) { | ||
this_class <- "" | ||
class(this_class) <- internal$parameters$approach | ||
UseMethod("prepare_data", this_class) | ||
} | ||
|
||
#' @keywords internal | ||
insert_defaults <- function(internal, defaults) { | ||
par_names <- names(defaults) | ||
|
||
overwrite_names <- par_names[!(par_names %in% names(internal$parameters))] | ||
|
||
internal$parameters <- append(internal$parameters, defaults[overwrite_names]) | ||
|
||
return(internal) | ||
} | ||
|
||
#' @keywords internal | ||
get_factor_approaches <- function() { | ||
c("'independence' (not recommended)", "'ctree'", "'categorical'") | ||
} |
Oops, something went wrong.