Skip to content

Commit

Permalink
v3.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
hbaniecki committed Feb 24, 2022
1 parent a909856 commit 91da18c
Show file tree
Hide file tree
Showing 9 changed files with 90 additions and 59 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: modelStudio
Title: Interactive Studio for Explanatory Model Analysis
Version: 3.0.0.9000
Version: 3.1.0
Authors@R:
c(person("Hubert", "Baniecki", role = c("aut", "cre"),
email = "[email protected]",
Expand Down
4 changes: 3 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# modelStudio (development)
# modelStudio 3.1.0
* changed y-axis variable labels in `SV` to the same as in `BD`
* added new parameter to `modelStudio()`: `max_features_fi = max_features`, which allows displaying a distinctive number of features in `FI` plot (other than in `BD` and `SV`)
* added new options to `ms_options()`: `**_axis_title`, which allow changing plot-specific axis title (default varies)

# modelStudio 3.0.0
* **BREAKING CHANGES**:
Expand Down
7 changes: 4 additions & 3 deletions R/modelStudio.R
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,8 @@ modelStudio.explainer <- function(explainer,
variable_splits_type=variable_splits_type),
"ingredients::accumulated_dependence (categorical)", show_info, pb, N/30)
}

fi_data <- prepare_feature_importance(fi, max_features_fi, options$show_boxplot,
attr(loss_function, "loss_name"), ...)

fi_data <- prepare_feature_importance(fi, max_features_fi, options$show_boxplot, ...)
pd_data <- prepare_partial_dependence(pd_n, pd_c, variables = variable_names)
ad_data <- prepare_accumulated_dependence(ad_n, ad_c, variables = variable_names)
mp_ret <- calculate(
Expand Down Expand Up @@ -495,6 +494,8 @@ modelStudio.explainer <- function(explainer,
if (is.null(options$ms_title)) options$ms_title <- paste0("Interactive Studio for ", label, " Model")
if (!is.null(options$ms_subtitle)) options$ms_margin_top <- options$ms_margin_top + 40
if (is.null(options$margin_left)) options$margin_left <- max(105, 7*max(nchar(variable_names)))
if (is.null(options$fi_axis_title)) options$fi_axis_title <-
ifelse(is.null(attr(loss_function, "loss_name")), "drop-out loss", attr(loss_function, "loss_name"))

options <- c(list(time = time,
model_name = label,
Expand Down
25 changes: 18 additions & 7 deletions R/ms_options.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,19 @@
#' \item{default_color}{\code{#371ea3} for Break Down bar and highlighted line.}
#' }
#' }
#' \subsection{Plot specific options:}{
#' \subsection{Plot-specific options:}{
#' \code{**} is a two letter code unique to each plot, might be
#' one of \code{[bd,sv,cp,fi,pd,ad,rv,fd,tv,at]}.\cr
#'
#' \describe{
#' \item{**_title}{Plot specific title. Default varies.}
#' \item{**_subtitle}{Plot specific subtitle. Default is \code{subtitle}.}
#' \item{**_bar_width}{Plot specific width of bars. Default is \code{bar_width},
#' \item{**_title}{Plot-specific title. Default varies.}
#' \item{**_subtitle}{Plot-specific subtitle. Default is \code{subtitle}.}
#' \item{**_axis_title}{Plot-specific axis title. Default varies.}
#' \item{**_bar_width}{Plot-specific width of bars. Default is \code{bar_width},
#' ignored when \code{scale_plot = TRUE}.}
#' \item{**_line_size}{\code{line_size} Plot specific width of lines. Default is \code{line_size}.}
#' \item{**_point_size}{Plot specific point radius. Default is \code{point_size}.}
#' \item{**_*_color}{Plot specific \code{[bar,line,point]} color. Default is \code{[bar,line,point]_color}.}
#' \item{**_line_size}{Plot-specific width of lines. Default is \code{line_size}.}
#' \item{**_point_size}{Plot-specific point radius. Default is \code{point_size}.}
#' \item{**_*_color}{Plot-specific \code{[bar,line,point]} color. Default is \code{[bar,line,point]_color}.}
#' }
#' }
#'
Expand Down Expand Up @@ -131,18 +132,21 @@ ms_options <- function(...) {
default_color = "#371ea3",
bd_title = "Break Down",
bd_subtitle = NULL,
bd_axis_title = "contribution",
bd_bar_width = NULL,
bd_positive_color = NULL,
bd_negative_color = NULL,
bd_default_color = NULL,
sv_title = "Shapley Values",
sv_subtitle = NULL,
sv_axis_title = "contribution",
sv_bar_width = NULL,
sv_positive_color = NULL,
sv_negative_color = NULL,
sv_default_color = NULL,
cp_title = "Ceteris Paribus",
cp_subtitle = NULL,
cp_axis_title = "prediction",
cp_bar_width = NULL,
cp_line_size = NULL,
cp_point_size = 3,
Expand All @@ -151,34 +155,41 @@ ms_options <- function(...) {
cp_point_color = "#371ea3",
fi_title = "Feature Importance",
fi_subtitle = NULL,
fi_axis_title = NULL,
fi_bar_width = NULL,
fi_bar_color = NULL,
pd_title = "Partial Dependence",
pd_subtitle = NULL,
pd_axis_title = "average prediction",
pd_bar_width = NULL,
pd_line_size = NULL,
pd_bar_color = NULL,
pd_line_color = NULL,
ad_title = "Accumulated Dependence",
ad_subtitle = NULL,
ad_axis_title = "accumulated prediction",
ad_bar_width = NULL,
ad_line_size = NULL,
ad_bar_color = NULL,
ad_line_color = NULL,
rv_title = "Residuals vs Feature",
rv_subtitle = NULL,
rv_axis_title = "residuals",
rv_point_size = NULL,
rv_point_color = NULL,
fd_title = "Feature Distribution",
fd_subtitle = NULL,
fd_axis_title = "count",
fd_bar_width = NULL,
fd_bar_color = NULL,
tv_title = "Target vs Feature",
tv_subtitle = NULL,
tv_axis_title = "target",
tv_point_size = NULL,
tv_point_color = NULL,
at_title = "Average Target vs Feature",
at_subtitle = NULL,
at_axis_title = "average target",
at_bar_width = NULL,
at_line_size = NULL,
at_point_size = 3,
Expand Down
2 changes: 0 additions & 2 deletions R/prepare.R
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,6 @@ prepare_ceteris_paribus <- function(x, variables = NULL) {
}

prepare_feature_importance <- function(x, max_features = 10, show_boxplot = TRUE,
x_title = NULL,
margin = 0.15, digits = 3, rounding_function = round,
...) {
### Return the object for the FeatureImportance plot ###
Expand Down Expand Up @@ -357,7 +356,6 @@ prepare_feature_importance <- function(x, max_features = 10, show_boxplot = TRUE
ret$x <- new_x
ret$m <- m
ret$x_min_max <- min_max
ret$x_title <- ifelse(is.null(x_title), "drop-out loss", x_title)
ret$desc <- data.frame(type = "desc",
text = gsub("\n","</br>", desc))

Expand Down
Loading

0 comments on commit 91da18c

Please sign in to comment.