Comments (3)
Thanks for the above code chunk. Hopefully, this discussion helps someone in the future (do not hesitate to reopen if needed).
from modelstudio.
Hi, I did some tests concerning this issue, and at this moment:
- I have no clue why simply adding
removeUI(selector = paste0("#", WIDGET_ID), immediate = TRUE)
inobserveEvent()
doesn't fix the issue. Looking at the (web) console: the whole widget with modelStudio is properly removed from the HTML code, and then, when it is (re)rendered, it appears with doubled elements for some unknown reason. Is there some invisible caching mechanism? (open question) - I used
removeUI()
withshinyjs::refresh()
to fix the above issue, but I believe it is not satisfactory, as there could be drawbacks of refreshing with respect to other UI elements in the app.
Example:
library(r2d3)
library(modelStudio)
library(DALEX)
library(shiny)
ui <- fluidPage(
shinyjs::useShinyjs(), # ------------------------------------ need to add this
actionButton(inputId = 'go', "Go"),
uiOutput('dashboard')
)
ms <- reactiveValues(model = NULL, iter = 0)
server <- function(input, output) {
#:# id of div where modelStudio will appear
WIDGET_ID = 'MODELSTUDIO'
observeEvent(input$go, {
removeUI(selector = paste0("#", WIDGET_ID), immediate = TRUE) # ---- shiny
shinyjs::refresh() # ----------------------------------------------- shinyjs
ms$iter <- ms$iter + 1 # ---- change explain() label to see the change in ms
print(ms$iter)
model <- glm(survived ~., data = titanic_imputed, family = "binomial")
explainer <- DALEX::explain(model,
data = titanic_imputed,
y = titanic_imputed$survived,
label = ifelse(ms$iter == 1, "Titanic GLM", "IT CHANGED"),
verbose = FALSE)
x <- modelStudio(explainer,
widget_id = WIDGET_ID, #:# use the widget_id
show_info = TRUE)
x$elementId <- NULL #:# remove elementId to stop the warning
ms$model <- x
})
#:# basic render d3 output
output[[WIDGET_ID]] <- renderD3({
ms$model
})
#:# use render ui to set proper width and height
output$dashboard <- renderUI({
d3Output(WIDGET_ID, width=ms$model$width, height=ms$model$height)
})
}
shinyApp(ui = ui, server = server)
from modelstudio.
Thank you for the prompt reply! I incorporated your fix but just needed to capture some tab switching logic since it refreshes everything. Here's what I did in case you're curious:
observeEvent(input$tabs, {
if(input$tabs == 'Data Explorer' & !is.null(input$i_file)){
removeUI(selector = paste0("#", WIDGET_ID), immediate = TRUE) # ---- shiny
shinyjs::refresh() # ----------------------------------------------- shinyjs
}
})
from modelstudio.
Related Issues (20)
- There is a plan to export modelStudio to python? HOT 2
- add `verbose` as an alias to `show_info`
- add `ms_merge_observations()` function to merge multiple modelStudio into one
- add `happiness` dataset
- update DALEX, ingredients, and iBreakDown versions? HOT 1
- add information about css needed for a proper modelStudio rendering in rmd -> html (vignette)
- update GIFs with the happiness demo example
- modelStudio fails on R v4.2 (devel) due to changes in logical operators HOT 1
- model_diagnostics fails due to no rows to aggregate HOT 10
- add `variable_splits` to modelStudio HOT 1
- Add a parameter to set, which plots to open and on which positions
- Error in check_explainer(explainer): For Python support, use precalculate=True in Explainer init HOT 5
- Why are Break Down plot intercepts the same for different regression models? HOT 8
- Is 4x4 panels the only way to present ModelStudio? HOT 2
- smart choosing of observations
- v2.1.0 release checklist
- Support for explainer objects from the `survex` package HOT 2
- Error in R - Error in eval(predvars, data, env) : object 'Breach' not found HOT 1
- Parsing error for only one variable model HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from modelstudio.