Note: For changes to the Python wrapper
pyshapr, see the pyshapr
CHANGELOG.
"arf" approach for conditional sampling with
adversarial random forests via the arf package (#497)extra_computation_args$max_batch_cube_size
argument, which caps the dense per-batch array of the
gaussian, copula and empirical
approaches by automatically using more batches in high-dimensional
settings, avoiding the RcppArmadillo
Cube::init(): requested size is too large failure and often
reducing runtime. For gaussian/copula the
array has
n_MC_samples * n_explain * coalitions_per_batch * n_features
elements, and for empirical it is the distance array with
n_train * n_explain * coalitions_per_batch elements.
Defaults to 1e6 elements. (#504)scope and y_explain arguments to
explain(). Set scope = "global" to explain the
model’s global loss (using
extra_computation_args$global_loss_func, defaulting to
log-loss for binary 0/1 responses and MSE otherwise) instead of
individual predictions, and plot the result with plot()
using plot_type = "bar" or "waterfall".
scope = "global" also works together with grouping
(group), causal Shapley values
(causal_ordering/confounding), and asymmetric
Shapley values (asymmetric). (#503)explain() now errors early when the vaeac
approach uses future batching with a serializing parallelization backend
(a future multisession or cluster
plan) with more than one worker, since torch objects are
external pointers that cannot be exported to separate R processes. Use a
forking plan (future::plan(future::multicore)) or set
extra_computation_args$vS_batching_method = "forloop". (#507, #517)vaeac approach where an
all-categorical data set whose features all have the same number of
levels was encoded incorrectly, causing a torch
index ... is out of bounds error.
vaeac_preprocess_data() used
sapply(data, levels), which simplifies to a matrix (instead
of a per-feature list) when every feature is a factor with the same
number of levels, corrupting one_hot_max_sizes. (#506)iterative = FALSE) with a moderate number of features
could ignore max_n_coalitions and enumerate all
2^n_features coalitions (an incorrect exact-computation
threshold of n_shapley_values^2 instead of
2^n_shapley_values), causing severe slowdowns and
RcppArmadillo Cube::init() failures in high
dimensions. (#505)cli::cli_progress_step() reporting artificially
short timings for the v(S) computation step by passing
.envir = parent.frame() to bind the progress bar’s lifetime
to the correct calling environment. (#496)dev/prepare-pr,
dev/check-pr, dev/publish-pr) with
dev/pr-workflow.md for automated and agent-assisted PR
readiness checks; consolidated development scripts under
dev/. (#494)vdiffr plot snapshot tests on R < 4.5.0 to
avoid spurious failures caused by formatting changes in older R
versions. (#494)"arf" and
"vaeac" approaches that verify explain() runs
without errors and that the returned Shapley values satisfy the
efficiency property, providing platform coverage for the snapshot tests
skipped on macOS. (#497)uv with Python
3.14 (#493).explain() rather than fresh-process
runtime, while retaining harness timings as diagnostics, and refreshed
the retained results so all published peak RAM values use cgroup-v2
memory.peak. (#511)shaprpy to
pyshapr. R console output from
summary()/print() on Python-initiated
explanations now references
pyshapr.explain()/pyshapr.explain_forecast().
A thin shaprpy compatibility package remains available on
PyPI for a transition period. (#500)plot.shapr() with smarter defaults for
index_x_explain: now defaults to 1:10 for bar
and waterfall plots, and all observations for scatter and beeswarm
plots. Informative messages are shown if more than 10 observations are
available for bar/waterfall plots (#487).forecast_ARIMA to
fc_model in S3 method registrations and implementations
after class name change in the forecast package (to align
with fable package conventions). This affects both
get_model_specs and predict_model methods.
CRAN tests added to catch such up front in the future (#487).plot_MSEv_eval_crit() and related documentation
to use “coalition” instead of “comb” for plot types, improving clarity
and consistency (#487).summary.shapr() to return a
summary.shapr class object (rather than just printing) for
improved reusability and consistency with R conventions (#482).plot.shapr() with default
index_x_explain = 1:10 for more convenient plotting of
first observations (and printing info about this) (#482).xgboost after their breaking
change class update (version >= 3.1.2.1). We now support both the
previous and the new xgboost versions (#481).summary.shapr() method (#482)summary.shapr() and the xgboost class (#483).what argument in
get_results() to extract the programming language used (R
or Python) (#477), to
ease reuse of the R methods in the shaprpy
Python wrapper.print_ggplot argument to
plot.shapr() (default TRUE) to ensure ggplots
are displayed when sourced, in functions, loops etc. Applied the same
fix to plot_SV_several_approaches(). (#478)get_results() for extracting key components from
a shapr object, including Shapley values, model parameters,
and iterative computation details (#460).summary.shapr() method, which builds on
get_results() and internal format_xyz()
functions to provide a concise overview of explanation objects (#460).print.shapr() to support printing of specific
components, with customizable control over digits and decimal precision
(#460).cli-based output functions for improved
reuse across multiple methods (#460).as.integer() coercion in the computation of coalitions per
coalition size (#462).shaprpy on PyPI. See the shaprpy
CHANGELOG for details.Implement semi-deterministic sampling of coalitions similar to
the default in the shap python library and described and
discussed as the PySHAP* strategy in Olsen & Jullum (2024).
It is disabled by default, but can be set via
extra_computation_args = list(semi_deterministic_sampling = TRUE)
in explain(). The functionality is available when paired
coalition sampling (the default) is enabled. See #449 for
details.
Deletes the regression-surrogate parsnip object when testing to avoid future conflicts with model object changes. (Second last commit in #447).
Improve and update the logic and print for setting the number of
coalitions in the next iteration for iterative = TRUE (#452)
Allow passing vS_batching_method to
explain()/explain_forecast() to specify the batch
computation method (default is "future" for both,
"forloop" available mainly for dev purposes) (#452)
Transform to use the cli and rlang
packages to provide all messages/warnings/stops with nicer formatting
and layout. The messages (via cli_inform()) now also obey
the verbose argument and are displayed only if
'basic' %in% verbose is TRUE. The header printout also
differs between explain()/explain_forecast()
and whether called from Python. This also adds cli and
rlang to imports. (#453)
Now using testthat::skip_if_not_installed for all
tests requiring suggested packages to ensure they are skipped gracefully
when dependencies are unavailable (#451)
KernelSHAP_reweighing() (#448)seed argument, and only pass to
torch if not NULL (#452)explain_forecast() use future for
batch computation as well (by default) (#452)approach = 'empirical' occurring when
n_features < n_explain (#453)Fix documentation issues detected during shapr 1.0.2 release (#442)
print() by warning() on
two occasionsFix issue with
Expected <nn_module> but got object of type <NULL>
for approach='vaeac' after recent torch update
broke it (#444)
Changes default seed in explain() and
explain_forecast() from 1 to NULL to avoid set.seed() to
conflict with later called code (#445)
Other minor fixes
expect_snapshot_rds() to reduce false positive
roundoff-errors between platforms (#444)explain_forecast() (#433)by=.I (#434)paired_shap_sampling and
kernelSHAP_reweighting into
extra_computation_args (#428)iterative = TRUE for
explain_forecast() which was not using coalitions from
previous iterations (#426)verbose
argument for explain_forecast() (#425)party package returns a
constparty object (#423)keep_samp_for_vS with iterative approach (#417)explain() in R
(#416)shapr() for initial setup + explain() for
explanation for specific observations), to a single function
call (also named explain()). The data used for training and
to be explained have gotten explicit names (x_train and
x_explain). The order of the input arguments has also been
slightly changed (model is now the first argument).explain() instead of being defined
as functions of a specific class in the global env.make_dummies used to
explain xgboost models with categorical data, is removed to
simplify the code base. This is rather handled with a custom prediction
model.explain.ctree_comb_mincrit, which allowed
combining models with approch=ctree with different
mincrit parameters, has been removed to simplify the code
base. It may return in a completely general manner in later version of
shapr.shaprpyr, #325) for
explaining predictions from Python models (from Python) utilizing almost
all functionality of shapr. The wrapper moves back and
forth back and forth between Python and R, doing the prediction in
Python, and almost everything else in R. This simplifies maintenance of
shaprpy significantly. The wrapper is available here.progressr
package. Must be activated by the user with
progressr::handlers(global = TRUE) or wrapping the call to
explain() around
progressr::with_progress({})approach = 'categorical' (#256,
#307)
used to explain models with solely categorical features by directly
using/estimating the joint distribution of all feature
combinations.approch='timeseries' (#314) for
explaining classifications based on time series data/models with the
method described in Sec 4.3 of the groupShapley
paper.explain_forecast to explain
forecasts from time series models, at various prediction horizons (#328).
Uses a different set of input argument which is more appropriate for
these models.approach = 'independence' method
providing significantly faster computation (no longer as a special case
of the empirical method). Also allow the method to be used
on models with categorical data (#315).explain, also using vdiffr for plot tests. Test
functions are only written for exported core functions. Internal
functions are only tested through the exported ones.datasets::airquality dataset. This avoids including a new
package just for the dataset (#248).shapr(data[,1:5],model...)attach(): Fixed by changing how we simulate adding a
function to .GlobalEnv in the failing test. Actual package not
affected.