Abstract
Automate the explanatory analysis of machine learning predictive models. Generate advanced interactive model explanations in the form of a serverless HTML site with only one line of code. This tool is model-agnostic, therefore compatible with most of the black-box predictive models and frameworks. The main function computes various (instance and model-level) explanations and produces a customisable dashboard, which consists of multiple panels for plots with their short descriptions. It is possible to easily save the dashboard and share it with others. modelStudio facilitates the process of Interactive Explanatory Model Analysis introduced in Baniecki et al. (2023) <a href="https://doi.org/10.1007%2Fs10618-023-00924-w" target="_top">doi:10.1007/s10618-023-00924-w</a>.
Introduction
As machine learning models grow in complexity, the "black-box" nature of their predictions becomes a significant barrier to trust and deployment. While various techniques for Explanatory Model Analysis (EMA) exist—such as SHAP values or Partial Dependence plots—implementing them often requires fragmented workflows and manual plotting.
The authors identify a gap in the "Interactive" side of EMA. Most existing tools produce static images or require a live backend server (like Shiny) to remain interactive. modelStudio solves this by automating the generation of a comprehensive, interactive dashboard that lives entirely within a standalone HTML file, making it easy for researchers to explore model behavior and share findings with stakeholders without infrastructure overhead.
Methodology
The package is built upon the robust DALEX ecosystem, specifically leveraging the ingredients and iBreakDown packages for its underlying calculations. Its core methodology focuses on Interactive Explanatory Model Analysis (IEMA):
- Model-Agnosticism: It uses a "wrapper" approach (via
DALEX::explain()), meaning it can analyze any predictive model regardless of the framework (e.g.,randomForest,xgboost,keras). - D3.js Integration: The dashboard is rendered using the
r2d3package, allowing for fluid animations and responsive transitions when users switch between different variables or observations. - Dual-Level Explanations: It simultaneously computes instance-level (local) explanations like Break Down and Shapley values, and model-level (global) explanations like Feature Importance and Partial Dependence.
- Serverless Architecture: All necessary data and visualization logic are embedded into the output HTML, allowing the dashboard to function offline or on static hosting services.
Datasets and Evaluation
The documentation highlights several datasets used for demonstration and testing of the framework:
- World Happiness Report: Features variables like GDP per capita and social support to predict happiness scores.
- Titanic: Used for classification examples (predicting survival).
- Apartments: Used for regression examples (predicting housing prices).
- HR Dataset: Used to demonstrate integration with
xgboostfor classification tasks.
Key Insights: The "One-Line" Workflow
The most significant contribution is the abstraction of complex EMA tasks. A single call to modelStudio(explainer) handles data sampling, explanation computation, and dashboard assembly.
Unlike static plots, the dashboard allows users to click on bars in one plot to update the variable being viewed in others, facilitating a "detective-like" exploration of feature interactions. To handle the heavy lifting of permutation-based explanations (like Shapley values), the package includes parameters to control the number of observations (N) and permutation rounds (B), as well as support for parallel processing.
Results and Customization
The dashboard supports a wide array of plots, including Break Down (BD), Shapley Values (SV), Ceteris Paribus (CP), Feature Importance (FI), Partial Dependence (PD), Accumulated Dependence (AD), and Residuals vs. Features. Users have granular control over the dashboard's behavior through various function parameters.
Through ms_update_observations and ms_update_options, users can iteratively add new data points to an existing dashboard or tweak its aesthetics without re-running the entire analysis. The function returns an htmlwidget object that can be saved as a standalone file, embedded in R Markdown reports, or integrated into Shiny applications.
Limitations and Future Work
Because the dashboard is serverless, all data used for the plots must be stored within the HTML file. Including too many observations or features could lead to very large file sizes and browser performance issues. To maintain speed, the tool defaults to sampling 300 observations for global plots. While adjustable, this means the visualizations are approximations of the model's behavior on the full dataset.
Future development may focus on deeper integration with various ML frameworks and further optimizing the D3.js rendering for even larger datasets.
Summary updated