Enhancing Chemical Explainability Through Counterfactual Masking

Authors

  • Łukasz Janisiów Faculty of Mathematics and Computer Science, Jagiellonian University, Krakow 30-348, Poland Doctoral School of Exact and Natural Sciences, Jagiellonian University, Krakow 30-348, Poland Faculty of Economic Sciences, University of Warsaw, Warsaw 00-241, Poland
  • Marek Kochańczyk Faculty of Mathematics and Computer Science, Jagiellonian University, Krakow 30-348, Poland
  • Bartosz Michał Zieliński Faculty of Mathematics and Computer Science, Jagiellonian University, Krakow 30-348, Poland
  • Tomasz Danel Faculty of Mathematics and Computer Science, Jagiellonian University, Krakow 30-348, Poland Faculty of Chemistry, Jagiellonian University, Krakow 30-387, Poland

DOI:

https://doi.org/10.1609/aaai.v40i26.39371

Abstract

Molecular property prediction is a crucial task that guides the design of new compounds, including drugs and materials. While explainable artificial intelligence methods aim to scrutinize model predictions by identifying influential molecular substructures, many existing approaches rely on masking strategies that remove either atoms or atom-level features to assess importance via fidelity metrics. These methods, however, often fail to adhere to the underlying molecular distribution and thus yield unintuitive explanations. In this work, we propose counterfactual masking, a novel framework that replaces masked substructures with chemically reasonable fragments sampled from generative models trained to complete molecular graphs. Rather than evaluating masked predictions against implausible zeroed-out baselines, we assess them relative to counterfactual molecules drawn from the data distribution. Our method offers two key benefits: (1) molecular realism that underpins robust and distribution-consistent explanations, and (2) meaningful counterfactuals that directly indicate how structural modifications may affect predicted properties. We demonstrate that counterfactual masking is well-suited for benchmarking model explainers and yields more actionable insights across multiple datasets and property prediction tasks. Our approach bridges the gap between explainability and molecular design, offering a principled and generative path toward explainable machine learning in chemistry.

Published

2026-03-14

How to Cite

Janisiów, Łukasz, Kochańczyk, M., Zieliński, B. M., & Danel, T. (2026). Enhancing Chemical Explainability Through Counterfactual Masking. Proceedings of the AAAI Conference on Artificial Intelligence, 40(26), 22155–22163. https://doi.org/10.1609/aaai.v40i26.39371

Issue

Section

AAAI Technical Track on Machine Learning III