Skip to content

Commit

Permalink
Candidate fix for #118 (#119)
Browse files Browse the repository at this point in the history
* Fi rebuilded

* Update R-CMD-check.yaml

* Update plot_feature_importance.R

Co-authored-by: maksymiuks <sz.maksymiuk@gmail.com>
  • Loading branch information
maksymiuks and maksymiuks committed Jul 1, 2020
1 parent 8dcd429 commit f40aad8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
1 change: 0 additions & 1 deletion .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ jobs:
- {os: windows-latest, r: '3.6'}
- {os: ubuntu-16.04, r: '4.0', rspm: "https://demo.rstudiopm.com/all/__linux__/xenial/latest"}
- {os: ubuntu-16.04, r: '3.6', rspm: "https://demo.rstudiopm.com/all/__linux__/xenial/latest"}
- {os: ubuntu-16.04, r: '3.5', rspm: "https://demo.rstudiopm.com/all/__linux__/xenial/latest"}

env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
Expand Down
3 changes: 3 additions & 0 deletions R/feature_importance.R
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,9 @@ feature_importance.default <- function(x,

class(res) <- c("feature_importance_explainer", "data.frame")

if(!is.null(attr(loss_function, "loss_name"))) {
attr(res, "loss_name") <- attr(loss_function, "loss_name")
}
res
}

8 changes: 6 additions & 2 deletions R/plot_feature_importance.R
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,16 @@ plot.feature_importance_explainer <- function(x, ..., max_vars = NULL, show_boxp
stat = "identity", fill = "#371ea3", color = "#371ea3", width = 0.25)
}

if (!is.null(attr(x, "loss_name"))) {
y_lab <- paste(attr(x, "loss_name")[1], "loss after permutations")
} else {
y_lab <- "Loss function after variable's permutations"
}
# facets have fixed space, can be resolved with ggforce https://github.com/tidyverse/ggplot2/issues/2933

pl + coord_flip() +
scale_color_manual(values = DALEX::colors_discrete_drwhy(nlabels)) +
facet_wrap(~label, ncol = 1, scales = "free_y") + DALEX::theme_drwhy_vertical() +
ylab("Drop-out loss") + xlab("") +
ylab(y_lab) + xlab("") +
labs(title = title, subtitle = subtitle) +
theme(legend.position = "none")

Expand Down

0 comments on commit f40aad8

Please sign in to comment.