Releases: ModelOriented/shapviz
Releases · ModelOriented/shapviz
CRAN release 0.5.0
shapviz 0.5.0
Major improvement: SHAP interaction values
- Introduced API for SHAP interaction values
S_inter
(3D array):- Matrix method:
shapviz(object, ..., S_inter = NULL)
- XGBoost method:
shapviz(object, ..., interactions = TRUE)
- treeshap method:
shapviz(object, ...)
- Matrix method:
sv_interaction(x)
shows matrix of beeswarm plots.sv_dependence(x, v = "x1", color_var = "x2", interactions = TRUE)
plots SHAP interaction values.sv_dependence(x, v = "x1", interactions = TRUE)
plots pure main effects of "x1".- If SHAP interaction values are available,
sv_dependence(..., color_var = "auto")
uses those to determine the most interacting color variable. collapse_shap()
also works for SHAP interaction arrays.- SHAP interaction values can be extracted by
get_shap_interactions()
.
User visible changes
sv_importance()
: In case of too many features,sv_importance()
used to collapse the remaining features into an additional bar/beeswarm. This logic has been removed, and theshow_other
argument has been deprecated.- By default,
sv_dependence()
automatically adds horizontal jitter for discretev
. This now also works ifv
is numeric with at most seven unique values, not only for logicals, factors, and characterv
.
Compatibility with "ggplot2"
- "ggplot2" 3.4 has replaced the "size" aesthetic in line-based geoms by "linewidth". This has been adapted. "shapviz" now depends on ggplot2 >= 3.4.
Technical changes
sv_importance()
does not use a flipped coordinate system anymore.
CRAN release 0.4.1
New functionality
- Hide "other":
sv_importance()
has received a new argumentshow_others = TRUE
. Set toFALSE
to hide the "other" bar/beeswarm.
CRAN release 0.4.0
shapviz 0.4.0
Removed dependencies
The following dependencies have been removed:
- "ggbeeswarm"
- "vipor"
- "beeswarm"
Changes in sv_importance()
- New argument
bee_width
: Relative width of the beeswarms. The default is 0.4. It replaces thewidth
argument passed via...
. - New argument
bee_adjust
: Relative adjustment factor of the bandwidth used in estimating the density of the beeswarms. Default is 0.5. - In case a beeswarm is shown: the
...
arguments are now passed togeom_point()
.
Improvement with Plotly
plotly::ggplotly()
now works for most functionalities ofsv_importance()
, including beeswarms.
CRAN release 0.3.0
shapviz 0.3.0
Less picky interface
- The argument
X
of the constructor ofshapviz()
is now less picky. If it contains columns not present in the SHAP matrix, they are silently dropped. Furthermore, the column order of the SHAP matrix andX
is now determined by the SHAP matrix.
Removed (according to depreciation cycle)
- Functions
shapviz_from_lgb_predict()
andshapviz_from_xgb_predict()
format_fun
argument insv_force()
andsv_waterfall()
sort_fun
argument insv_waterfall()
Minor changes
collapse_shap()
is not anymore an S3 method. It is just a normal function that can be applied to a matrix.
CRAN release 0.2.2
shapviz 0.2.2
Bug fix
- For R versions < 4.1,
sv_importance()
would return an error.
Minor improvements
- kernelshap wrapper now also can deal with multioutput models.
CRAN release 0.2.1
shapviz 0.2.1
Major improvements
- Added kernelshap wrapper.
Minor changes
- Removed unnecessary conversion of
X_pred
frommatrix
toxgb.DMatrix
inshapviz.xgb.Booster()
. - Vignette: Added a CatBoost wrapper to the vignette and changed the
treeshap()
example to aranger()
model.
Maintainance
- Fixed CRAN notes on html5.
CRAN release 0.2.0
Major improvements
- Added H2O wrapper.
- Added shapr wrapper.
- Added an optional
collapse
argument inshapviz()
. This is named list specifying which columns in the SHAP matrix are to be collapsed by rowwise summation. A typical application will be to combine the SHAP values of one-hot-encoded dummies and explain them by the corrsponding factor variable. - Major rework of
sv_importance()
, see next section.
Major rework of sv_importance()
The calculations behind sv_importance()
are unchanged, but defaults and some plot aspects have been reworked.
- Instead of a beeswarm plot,
sv_importance()
now shows a bar plot by default. Usekind = "beeswarm"
to get a beeswarm plot. - The bar plot of
sv_importance()
does not show SHAP feature importances as text anymore. Useshow_numbers = TRUE
to get them back. Furthermore, the numbers are now printed on top of the bars instead on their bottom. - The new argument
show_numbers
can be used to to add SHAP feature importance values for all plot types. - The default of
max_display
has been increased from 10 to 15. - The bar width has been reduced from 0.9 to 2/3 relative width. It can be controlled by the new argument
bar_width
. - The color bar title of the beeswarm plot can now be manually chosen by the new argument
color_bar_title
. Set toNULL
to remove the color bar altogether. - The argument
format_fun
now uses a right-aligned number formatter with aligned decimal separator by default.
Minor changes
- Added
dim()
method for "shapviz" object, implyingnrow()
andncol()
. - To allow more flexible formatting, the
format_fun
argument ofsv_waterfall()
andsv_force()
has been replaced byformat_shap
to format SHAP values andformat_feat
to format numeric feature values. By default, they use the new global options "shapviz.format_shap" and "shapviz.format_feat", both with defaultfunction(z) prettyNum(z, digits = 3, scientific = FALSE)
. sv_waterfall()
now uses the more consistent argumentorder_fun = function(s) order(abs(s))
instead of the originalsort_fun = function(shap) abs(shap)
that was then passed toorder()
.- Added argument
viridis_args = getOption("shapviz.viridis_args")
tosv_dependence()
andsv_importance()
to control the viridis color scale options. The default global option equalslist(begin = 0.25, end = 0.85, option = "inferno")
. For example, to switch to a standard viridis scale, you can either change the default withoptions(shapviz.viridis_args = NULL)
or setviridis_args = NULL
. - Deprecated helper functions
shapviz_from_lgb_predict()
andshapviz_from_xgb_predict
in favour of the collapsing logic (see above). The functions will be removed in version 0.3.0. - Added 'lightgbm' as "Enhances" dependency.
- Added 'h2o' as "Enhances" dependency.
- Anticipated changes in
predict()
arguments of LightGBM (data -> newdata, predcontrib = TRUE -> type = "contrib"). - More unit tests.
- Improved documentation.
- Fixed github installation instruction in README and vignette.
CRAN release 0.1.0
This is the initial release.