Closed nutle closed 4 years ago
I think it would be a great feature to support modelStudio
in Shiny. I added a widget_id
argument to the modelStudio()
function on the ms-shiny
branch. I'm not a shiny
expert but it should allow for modelStudio
rendering using the r2d3
package (modelStudio
is a r2d3
class object, see https://rstudio.github.io/r2d3/articles/shiny.html).
You can install the new version using
install.packages('devtools')
devtools::install_github('ModelOriented/modelStudio', ref='ms-shiny')
and try it out - feedback appreciated, as I can expand this feature further.
Consider the following example:
library(shiny)
library(r2d3)
ui <- fluidPage(
textInput("text", h3("Text input"),
value = "Enter text..."),
uiOutput('dashboard')
)
server <- function(input, output) {
#:# id of div where modelStudio will appear
WIDGET_ID = 'MODELSTUDIO'
#:# create modelStudio
library(modelStudio)
library(DALEX)
model <- glm(survived ~., data = titanic_imputed, family = "binomial")
explainer <- explain(model,
data = titanic_imputed,
y = titanic_imputed$survived,
label = "Titanic GLM",
verbose = FALSE)
ms <- modelStudio(explainer,
widget_id = WIDGET_ID, #:# use the widget_id
show_info = FALSE)
ms$elementId <- NULL #:# remove elementId to stop the warning
#:# basic render d3 output
output[[WIDGET_ID]] <- renderD3({
ms
})
#:# use render ui to set proper width and height
output$dashboard <- renderUI({
d3Output(WIDGET_ID, width=ms$width, height=ms$height)
})
}
shinyApp(ui = ui, server = server)
The example is now added to the vignette https://modelstudio.drwhy.ai/articles/ms-perks-features.html#shiny-1
I would like to include the model output inside an existing shiny app (or as a standalone app). Is there any existing code or wrappers for this?