Skip to content

Commit

Permalink
add performance measures
Browse files Browse the repository at this point in the history
closes #85
  • Loading branch information
hbaniecki committed Aug 26, 2020
1 parent 5e34234 commit 7734bb2
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
3 changes: 2 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ using new `widget_id` argument
* TV plot uses boxplots and barplot when the target `y` has only two unique
values (classification) [(#76)](https://github.com/ModelOriented/modelStudio/issues/76)
* added more checks for input
* added the Residuals vs Feature plot (RV) [#(84)](https://github.com/ModelOriented/modelStudio/issues/84)
* added the Residuals vs Feature plot (RV) [(#84)](https://github.com/ModelOriented/modelStudio/issues/84)
* added model performance measures to the footnote [#(85)](https://github.com/ModelOriented/modelStudio/issues/85)

# modelStudio 1.2.0
* remove redundant documentation resources so that the package weights less
Expand Down
15 changes: 10 additions & 5 deletions R/modelStudio.R
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ modelStudio.explainer <- function(explainer,
attr(loss_function, "loss_name"), ...)
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_data <- DALEX::model_performance(explainer)$measures

if (eda) {
#:# fd_data is used by targetVs and residualsVs plots
Expand Down Expand Up @@ -411,10 +412,13 @@ modelStudio.explainer <- function(explainer,
# prepare footer text and ms title
ms_package_version <- as.character(packageVersion("modelStudio"))
ms_creation_date <- Sys.time()
footer_text <- paste0("Site built with modelStudio v",
ms_package_version,
" on ",
format(ms_creation_date, usetz = FALSE))
version_text <- paste0("Site built with modelStudio v",
ms_package_version,
" on ",
format(ms_creation_date, usetz = FALSE))
measure_text <- paste(names(mp_data),
round(unlist(mp_data), 3),
sep = ": ", collapse=" | ")

if (telemetry) {
creation_time <- as.character(as.integer(as.numeric(ms_creation_date - start_time)*60))
Expand All @@ -441,7 +445,8 @@ modelStudio.explainer <- function(explainer,
model_name = label,
variable_names = variable_names,
facet_dim = facet_dim,
footer_text = footer_text,
version_text = version_text,
measure_text = measure_text,
drop_down_data = jsonlite::toJSON(drop_down_data),
eda = eda,
widget_id = widget_id,
Expand Down
13 changes: 10 additions & 3 deletions inst/d3js/modelStudio.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ var TIME = options.time,
modelName = options.model_name,
variableNames = options.variable_names,
dim = options.facet_dim,
footerText = options.footer_text,
versionText = options.version_text,
measureText = options.measure_text,
dropDownData = options.drop_down_data,
EDA = options.eda,
WIDGET_ID = options.widget_id,
Expand Down Expand Up @@ -275,9 +276,15 @@ function initializeStudio() {

BOTTOM_G.append("text")
.attr("class", "footerTitle")
.attr("x", studioWidth - 15 - getTextWidth(footerText, 12, 'Fira Sans, sans-serif'))
.attr("x", studioWidth - 15 - getTextWidth(versionText, 12, 'Fira Sans, sans-serif'))
.attr("y", studioHeight - studioMargin.bottom + 25)
.text(footerText);
.text(versionText);

BOTTOM_G.append("text")
.attr("class", "footerTitle")
.attr("x", 15)
.attr("y", studioHeight - studioMargin.bottom + 25)
.text(measureText);

BOTTOM_G.append("line")
.attr("class", "footerLine")
Expand Down

0 comments on commit 7734bb2

Please sign in to comment.