Skip to content

Commit

Permalink
candidate fix for #94
Browse files Browse the repository at this point in the history
  • Loading branch information
pbiecek committed Jan 3, 2020
1 parent a642104 commit 43e0d7b
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 4 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: ingredients
Title: Effects and Importances of Model Ingredients
Version: 0.5.0
Version: 0.5.1
Authors@R: c(person("Przemyslaw", "Biecek", email = "przemyslaw.biecek@gmail.com",
role = c("aut", "cre"),
comment = c(ORCID = "0000-0001-8423-1823")),
Expand Down
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
ingredients 0.5.1
---------------------------------------------------------------
* synchronisation with changes in DALEX 0.5
* new argument `desc_sorting` in `plot.variable_importance_explainer` [#94](https://github.com/ModelOriented/ingredients/issues/94)

ingredients 0.5.0
---------------------------------------------------------------
* `feature_importance` now does `15` permutations on each variable by default. Use the `B` argument to change this number
Expand Down
9 changes: 7 additions & 2 deletions R/plot_feature_importance.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#' By default \code{NULL} what means all variables
#' @param show_boxplots logical if \code{TRUE} (default) boxplot will be plotted to show permutation data.
#' @param bar_width width of bars. By default \code{10}
#' @param desc_sorting logical. Should the bars be sorted descending? By default TRUE
#'
#' @importFrom stats model.frame reorder
#' @importFrom utils head tail
Expand Down Expand Up @@ -89,7 +90,11 @@
#' }
#'
#' @export
plot.feature_importance_explainer <- function(x, ..., max_vars = NULL, show_boxplots = TRUE, bar_width = 10) {
plot.feature_importance_explainer <- function(x, ..., max_vars = NULL, show_boxplots = TRUE, bar_width = 10, desc_sorting = TRUE) {

if (!is.logical(desc_sorting)){
stop("desc_sorting is not logical")
}

dfl <- c(list(x), list(...))

Expand Down Expand Up @@ -127,7 +132,7 @@ plot.feature_importance_explainer <- function(x, ..., max_vars = NULL, show_boxp

# set the order of variables depending on their contribution
ext_expl_df$variable <- reorder(ext_expl_df$variable,
ext_expl_df$dropout_loss.x - ext_expl_df$dropout_loss.y,
(ext_expl_df$dropout_loss.x - ext_expl_df$dropout_loss.y) * ifelse(desc_sorting, 1, -1),
mean)

# remove rows that starts with _
Expand Down
2 changes: 2 additions & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,5 @@ reference:
contents:
- select_neighbours
- select_sample
- calculate_variable_profile
- calculate_variable_split
11 changes: 10 additions & 1 deletion man/plot.feature_importance_explainer.Rd

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

0 comments on commit 43e0d7b

Please sign in to comment.