modelStudio in R Markdown HTML

Hubert Baniecki

2022-03-05

To properly generate modelStudio in R Markdown HTML, add additional CSS into the .Rmd file.

One can either make the space wider, e.g.:

<style type="text/css">

.body {
  max-width: 1200px;
}

.main-container {
  max-width: 1200px;
}

</style>

Or/and move the dashboard to the left, e.g.:

<style type="text/css">

.r2d3 {
  position: relative !important;
  left: -180px !important;
}

</style>

Then, proceed to generate the modelStudio:

library("DALEX")
library("ranger")
library("modelStudio")

# fit a model
model <- ranger(score ~., data = happiness_train)

# create an explainer for the model    
explainer <- explain(model,
                     data = happiness_test,
                     y = happiness_test$score,
                     label = "Random Forest",
                     verbose = FALSE)

# make a studio for the model
modelStudio(explainer)
Root mean square error (RMSE)0.550.600.650.700.750.800.85gdp_per_capitahealthy_life_expectancyfreedom_life_choicessocial_supportperceptions_of_corruptiongenerosityFeature ImportanceDInteractive Studio for Random Forest ModelSite built with modelStudio v3.1.0 on 2022-03-05 22:53:19mse: 0.316 | rmse: 0.562 | r2: 0.743 | mad: 0.378XBreak Down [Local]Shapley Values [Local]Ceteris Paribus [Local]Partial Dependence [Global]Residuals vs Feature [Global]Feature Distribution [EDA]Target vs Feature [EDA]Average Target vs Feature [EDA]