From d49cdc01ee8a6a2ac01e305ec600f17895b76eab Mon Sep 17 00:00:00 2001 From: 01131304 <32574056+maksymiuks@users.noreply.github.com> Date: Sun, 9 Jun 2024 14:18:02 +0200 Subject: [PATCH 1/2] Fix wrong row order in the plot.model_performance --- DESCRIPTION | 2 +- NEWS.md | 4 ++++ R/plot_model_performance.R | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 2f4611518..9cac582fe 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: DALEX Title: moDel Agnostic Language for Exploration and eXplanation -Version: 2.5.1 +Version: 2.5.2 Authors@R: c(person("Przemyslaw", "Biecek", email = "przemyslaw.biecek@gmail.com", role = c("aut", "cre"), comment = c(ORCID = "0000-0001-8423-1823")), person("Szymon", "Maksymiuk", role = "aut", diff --git a/NEWS.md b/NEWS.md index f0cca4776..48a86f92f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +DALEX 2.5.2 +--------------------------------------------------------------- +* Fix wrong row order in the `plot.model_performance` ([#49](https://github.com/ModelOriented/DALEX/issues/49)) + DALEX 2.5.1 --------------------------------------------------------------- * adding the support for calculating kernel SHAP values via `predict_parts()` function diff --git a/R/plot_model_performance.R b/R/plot_model_performance.R index db82e078a..05433f912 100644 --- a/R/plot_model_performance.R +++ b/R/plot_model_performance.R @@ -80,6 +80,9 @@ plot.model_performance <- function(x, ..., geom = "ecdf", show_outliers = 0, ptl } df$label <- reorder(df$label, df$diff, loss_function) + # Sort df based on the label's levels to make sure downstream functions relying + # on the rows order work appropriately + df <- df[order(df$label), ] if (ptlabel == "name") { df$name <- NULL df$name <- rownames(df) From 752213150fa99cec45f8e1e588314377e31edd43 Mon Sep 17 00:00:00 2001 From: maksymiuks <32574056+maksymiuks@users.noreply.github.com> Date: Wed, 4 Sep 2024 10:56:53 +0200 Subject: [PATCH 2/2] Update documentation --- DESCRIPTION | 2 +- R/plot_model_performance.R | 3 +++ man/plot.model_performance.Rd | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 9cac582fe..69ed6e782 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -22,7 +22,7 @@ Description: Any unverified black box model is the path to failure. Opaqueness l License: GPL Encoding: UTF-8 LazyData: true -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.2 Depends: R (>= 3.5) Imports: ggplot2, diff --git a/R/plot_model_performance.R b/R/plot_model_performance.R index 05433f912..8286e6cba 100644 --- a/R/plot_model_performance.R +++ b/R/plot_model_performance.R @@ -8,6 +8,9 @@ #' @param show_outliers number of largest residuals to be presented (only when geom = boxplot). #' @param ptlabel either \code{"name"} or \code{"index"} determines the naming convention of the outliers #' +#' @details +#' Whenever multiple explainers are provided using ellipsis, they are sorted based on their labels levels. +#' #' @return An object of the class \code{model_performance}. #' #' @export diff --git a/man/plot.model_performance.Rd b/man/plot.model_performance.Rd index f6e063a22..820e9c372 100644 --- a/man/plot.model_performance.Rd +++ b/man/plot.model_performance.Rd @@ -35,6 +35,9 @@ An object of the class \code{model_performance}. \description{ Plot Dataset Level Model Performance Explanations } +\details{ +Whenever multiple explainers are provided using ellipsis, they are sorted based on their labels levels. +} \examples{ \donttest{ library("ranger")