Introduction
Thompson Sampling (TS) is a cornerstone algorithm for sequential decision-making under uncertainty, widely applied in fields ranging from clinical trials to A/B testing. Despite its efficacy in balancing exploration and exploitation, its probabilistic nature often renders it a "black box" for developers. When an algorithm makes a suboptimal choice, it is frequently unclear whether the decision was a logical exploration step or a result of flawed update logic. TS-Insight is an open-source visual analytics tool designed to provide transparency into these internal dynamics, moving beyond aggregate metrics like cumulative regret to offer instance-level explanations.
Visual Analytics Framework
TS-Insight is specifically tailored for Discounted Thompson Sampling (DTS), a variant designed for non-stationary environments where the optimal choice may change over time. The tool employs three primary visual components to demystify the algorithm's state:
- HDR Evolution Plot: Utilizes Highest Density Regions (HDR) to visualize the algorithm's "belief" (posterior distribution) for each arm. This shows the predicted success rate and the associated uncertainty.
- Alpha/Beta & Barcode View: Tracks raw evidence—success counts ($\alpha$) and failure counts ($\beta$). The "Barcode" provides a temporal history of arm selections and their outcomes.
- XAI Snapshot View: Provides a point-in-time bar chart comparing the expected success rate (mean) of every arm against the specific random "draw" that triggered the current decision.
Key Insights and Verification
The tool was validated using the SYNERGY dataset, applying DTS to an active learning task for systematic literature reviews. By visualizing the algorithm's internal state, developers can gain several critical insights:
- Exploration vs. Exploitation: TS-Insight distinguishes between choices made because an arm is known to be good (exploitation) and those made because of high uncertainty (exploration).
- Rare Event Detection: By plotting random draws against the HDR, developers can identify when the algorithm makes a choice based on an unlikely sample—a core mechanic of TS that is typically invisible.
- Evidence Decay: In non-stationary contexts, the tool visually confirms the "forgetting" mechanic by showing the decay of $\alpha$ and $\beta$ values for idle arms.
Explaining Decision Logic
A primary strength of TS-Insight is its ability to provide concrete explanations for specific steps. For instance, at a specific time step, the algorithm might bypass the arm with the highest average success rate in favor of another. The XAI Snapshot view clarifies this by showing that the chosen arm's random posterior draw was higher than its competitors, providing a visual justification for the exploration strategy.
Conclusion and Future Work
TS-Insight enables three levels of analysis: verification of update logic, explanation of individual decisions, and assessment of model reliability as beliefs narrow over time. While currently limited to Bayesian Thompson Sampling variants and stationary/non-stationary bandits, future iterations aim to support contextual bandits and non-Bayesian strategies like Upper Confidence Bound (UCB), alongside real-time online visualization capabilities.
Summary updated