|
42 | 42 | #' @param B Number of permutation rounds used for calculation of SV. Default is \code{10}. |
43 | 43 | #' See \href{https://modelstudio.drwhy.ai/articles/ms-perks-features.html#more-calculations-means-more-time}{\bold{vignette}} |
44 | 44 | #' @param B_fi Number of permutation rounds used for calculation of FI. Default is \code{B}. |
| 45 | +#' @param open_plots A vector listing plots to be initially opened (and on which positions). Default is \code{c("fi")}. |
45 | 46 | #' @param eda Compute EDA plots and Residuals vs Feature plot, which adds the data to the dashboard. Default is \code{TRUE}. |
46 | 47 | #' @param show_info Verbose a progress on the console. Default is \code{TRUE}. |
47 | 48 | #' @param verbose An alias for \code{show_info}. If provided, it will override the value. |
@@ -186,6 +187,7 @@ modelStudio.explainer <- function(explainer, |
186 | 187 | B = 10, |
187 | 188 | B_fi = B, |
188 | 189 | eda = TRUE, |
| 190 | + open_plots = c("fi"), |
189 | 191 | show_info = TRUE, |
190 | 192 | parallel = FALSE, |
191 | 193 | options = ms_options(), |
@@ -213,6 +215,14 @@ modelStudio.explainer <- function(explainer, |
213 | 215 | if (is.null(max_features_fi)) max_features_fi <- max_features |
214 | 216 | if (!is.null(verbose)) show_info <- verbose |
215 | 217 | if (is.null(N)) stop("`N` argument must be an integer") |
| 218 | + if (length(open_plots) > prod(facet_dim)) |
| 219 | + stop(paste0("`open_plots` is of length larger than defined by `facet_dim` dimensions.", |
| 220 | + "Increase `facet_dim` or shorten `open_plots`.")) |
| 221 | + available_plots <- c('bd', 'sv', 'cp', 'fi', 'pd', 'ad', 'rv', 'fd', 'tv', 'at') |
| 222 | + if (!all(open_plots %in% c(available_plots, toupper(available_plots)))) |
| 223 | + stop(paste0("`open_plots` must be a vector with the following values: 'bd',", |
| 224 | + " 'sv', 'cp', 'fi', 'pd', 'ad', 'rv', 'fd', 'tv', 'at'.")) |
| 225 | + open_plots <- toupper(open_plots) |
216 | 226 | #if (identical(N_fi, numeric(0))) N_fi <- NULL |
217 | 227 |
|
218 | 228 | if (is.null(new_observation)) { |
@@ -250,7 +260,11 @@ modelStudio.explainer <- function(explainer, |
250 | 260 | loss_function <- DALEX::loss_root_mean_square |
251 | 261 | } |
252 | 262 | } else { |
253 | | - loss_function <- DALEX::loss_default(explainer$model_info$type) |
| 263 | + if (package_version(packageVersion("DALEX")) < package_version("2.5.0")) { |
| 264 | + loss_function <- DALEX::loss_default(explainer$model_info$type) |
| 265 | + } else { |
| 266 | + loss_function <- DALEX::get_loss_default(explainer$model_info$type) |
| 267 | + } |
254 | 268 | } |
255 | 269 |
|
256 | 270 | variable_splits_type <- ifelse('variable_splits_type' %in% kwargs_names, |
@@ -504,6 +518,7 @@ modelStudio.explainer <- function(explainer, |
504 | 518 | version_text = version_text, |
505 | 519 | measure_text = measure_text, |
506 | 520 | drop_down_data = jsonlite::toJSON(drop_down_data), |
| 521 | + open_plots = as.list(open_plots), |
507 | 522 | eda = eda, |
508 | 523 | widget_id = widget_id, |
509 | 524 | is_target_binary = is_binary(y) |
|
0 commit comments