Skip to content

Commit

Permalink
Merge pull request #152 from koalaverse/devel
Browse files Browse the repository at this point in the history
update vignette examples
  • Loading branch information
bgreenwell committed Aug 18, 2023
2 parents 33cc92e + c851d82 commit 954c822
Show file tree
Hide file tree
Showing 11 changed files with 81 additions and 76 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: vip
Type: Package
Title: Variable Importance Plots
Version: 0.4.0
Version: 0.4.1
Authors@R: c(
person(c("Brandon", "M."), family = "Greenwell",
email = "greenwell.brandon@gmail.com",
Expand Down
13 changes: 11 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
# vip 0.4.1

## Changed

* Minor tweaks to URLs and tests to pass CRAN checks.


# vip 0.4.0

## Changed

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

* The training data has to be explicitly passed in more cases.
* Removed lifecycle badge from `README` file.

* The training data has to be explicitly passed in more cases when using `vi_permute()`, `vi_shap()`, and `vi_firm()`.

* Raised R version dependency to >= 4.1.0 (the introduction of the native piper operator `|>`).

* The `vi_permute` function now uses [yardstick](https://cran.r-project.org/package=yardstick); consequently, metric functions now conform to [yardstick](https://cran.r-project.org/package=yardstick) metric argument names.
* The `vi_permute` function now relies on the [yardstick](https://cran.r-project.org/package=yardstick) package for compouting performance measures (e.g., RMSE and log loss); consequently, user-supplied metric functions now nned to conform to [yardstick](https://cran.r-project.org/package=yardstick) metric argument names.

* The `var_fun` argument in `vi_firm()` has been deprecated; use the new `var_continuous` and `var_categorical` instead.

Expand Down
2 changes: 1 addition & 1 deletion R/vi_shap.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#'
#' @details This approach to computing VI scores is based on the mean absolute
#' value of the SHAP values for each feature; see, for example,
#' <https://github.com/slundberg/shap> and the references therein.
#' <https://github.com/shap/shap> and the references therein.
#'
#' Strumbelj, E., and Kononenko, I. Explaining prediction models and individual
#' predictions with feature contributions. Knowledge and information systems
Expand Down
18 changes: 12 additions & 6 deletions R/vip.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@
#' only for the permutation-based importance method with \code{nsim > 1} and
#' `keep = TRUE`; see [vi_permute][vip::vi_permute] for details.
#'
#' @param mapping Set of aesthetic mappings created by [aes][ggplot2::aes]
#' or [aes_][ggplot2::aes_]. See example usage below.
#' @param mapping Set of aesthetic mappings created by
#' [aes][ggplot2::aes]-related functions and/or tidy eval helpers. See example
#' usage below.
#'
#' @param aesthetics List specifying additional arguments passed on to
#' [layer][ggplot2::layer]. These are often aesthetics, used to set an aesthetic
Expand Down Expand Up @@ -79,9 +80,10 @@
#' vip(vis, geom = "point", horiz = FALSE, aesthetics = list(size = 3))
#'
#' # Plot unaggregated permutation scores (boxplot colored by feature)
#' library(ggplot2) # for `aes_string()` function
#' library(ggplot2) # for `aes()`-related functions and tidy eval helpers
#' vip(vis, geom = "boxplot", all_permutations = TRUE, jitter = TRUE,
#' mapping = aes_string(fill = "Variable"),
#' #mapping = aes_string(fill = "Variable"), # for ggplot2 (< 3.0.0)
#' mapping = aes(fill = .data[["Variable"]]), # for ggplot2 (>= 3.0.0)
#' aesthetics = list(color = "grey35", size = 0.8))
#'
#' #
Expand Down Expand Up @@ -161,7 +163,7 @@ vip.default <- function(
}
imp <- sort_importance_scores(imp, decreasing = TRUE) # make sure these are sorted first!
imp <- imp[seq_len(num_features), ] # only retain num_features variable importance scores
x.string <- "reorder(Variable, Importance)"
# x.string <- "reorder(Variable, Importance)"

# Clean up raw scores for permutation-based VI scores
if (!is.null(attr(imp, which = "raw_scores"))) {
Expand All @@ -178,7 +180,11 @@ vip.default <- function(
}

# Initialize plot
p <- ggplot2::ggplot(imp, ggplot2::aes_string(x = x.string, y = "Importance"))
# p <- ggplot2::ggplot(imp, ggplot2::aes_string(x = x.string, y = "Importance"))
p <- ggplot2::ggplot(imp, ggplot2::aes(
x = reorder(Variable, Importance),
y = Importance
))

# Construct a barplot
if (geom == "col") {
Expand Down
1 change: 0 additions & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ knitr::opts_chunk$set(
[![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/vip)](https://cran.r-project.org/package=vip)
[![R-CMD-check](https://github.com/koalaverse/vip/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/koalaverse/vip/actions/workflows/R-CMD-check.yaml)
[![Coverage Status](https://codecov.io/gh/koalaverse/vip/graph/badge.svg)](https://app.codecov.io/github/koalaverse/vip?branch=master)
[![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable)
[![Downloads](https://cranlogs.r-pkg.org/badges/vip)](https://cran.r-project.org/package=vip/)
[![The R Journal](https://img.shields.io/badge/The%20R%20Journal-10.32614%2FRJ--2020--013-brightgreen)](https://doi.org/10.32614/RJ-2020-013)
<!-- badges: end -->
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
[![R-CMD-check](https://github.com/koalaverse/vip/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/koalaverse/vip/actions/workflows/R-CMD-check.yaml)
[![Coverage
Status](https://codecov.io/gh/koalaverse/vip/graph/badge.svg)](https://app.codecov.io/github/koalaverse/vip?branch=master)
[![Lifecycle:
stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable)
[![Downloads](https://cranlogs.r-pkg.org/badges/vip)](https://cran.r-project.org/package=vip/)
[![The R
Journal](https://img.shields.io/badge/The%20R%20Journal-10.32614%2FRJ--2020--013-brightgreen)](https://doi.org/10.32614/RJ-2020-013)
Expand Down
12 changes: 0 additions & 12 deletions inst/tinytest/test_pkg_partykit.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,6 @@ expect_identical(
target = unname(vis4)
)

# Expectations for `get_training_data()`
expect_equal(
current = vip:::get_training_data.default(fit1),
target = friedman1,
check.attributes = FALSE
)
expect_equal(
current = vip:::get_training_data.default(fit2),
target = friedman1,
check.attributes = FALSE
)

# Expectations for `get_feature_names()`
expect_identical(
current = vip:::get_feature_names.constparty(fit1),
Expand Down
6 changes: 0 additions & 6 deletions inst/tinytest/test_pkg_pls.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,6 @@ expect_identical(
target = caret::varImp(fit)$Overall
)

# Expectations for `get_training_data()`
expect_identical(
current = vip:::get_training_data.default(fit),
target = friedman1
)

# Expectations for `get_feature_names()`
expect_identical(
current = vip:::get_feature_names.mvr(fit),
Expand Down
2 changes: 1 addition & 1 deletion man/vi_shap.Rd

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

Loading

0 comments on commit 954c822

Please sign in to comment.