Explaining vibrational spectra
The latest publication of Spec-ReX has hit Scientific Reports. You can read it here: https://www.nature.com/articles/s41598-026-62343-3 but I’ll give a high level overview here.

First, the motivation. Deep learning methodologies are being increasingly applied for classification tasks in vibrational spectroscopy. This comes with a number of methodological dangers. One is that these models, even if they achieve excellent performance by traditional metrics such as AUROC, they are typically opaque with no way of telling why any particular classification was given. This is the so called black-box problem.

Why is one one spectra classed healthy, another as diseased?
Not everyone agrees this is a problem, which I briefly discuss here, but there is certainly demand for making AI models more transparent for the intended end-users: healthcare professionals in any medical applications. Post-hoc explainable AI is one such method, in which a method is applied to a trained model to explain a particular classification (perhaps a single spectrum).
There are many existing general methods out there: SHAP, LIME, Grad-CAM, each with their own strengths and weaknesses. They generally work by highlighting which features drive the model’s classification. However, they are general methods, designed within the context of image or tabular data classification. While they are certainly model agnostic (i.e they can be applied to any model – except Grad-CAM which only explains CNNS), and technically datatype agnostic, the nuances of the datatype can have a huge influence. This manifests as different XAI techniques giving very different explanations given the same spectrum and model.

Which explanation, if any, is correct? And how do we know?
Spec-ReX
Spec-ReX is an adaption of the more general XAI framework ReX (causal Responsibility eXplanations), which takes into account the nature of vibrational spectra. The method works by taking the spectrum to be explained and partially occluding it to remove some spectral features (called a mutant). What it means to remove a feature is an interesting and subtle nuance – in Spec-ReX we do this by interpolating a quadratic function in the occluded space. This partially occluded is then passed to the model and we see whether the classification has changed. If it has changed, then we know we removed something important to the model for its classification. We iteratively repeat this process, building up a ‘responsibility map’ of important spectral features, guided by successful mutants.

But is it correct?
A curious subtlety, surprisingly often over-looked in XAI research, is how to evaluate a explanation: does it really say something true and useful about the features the model uses to classify spectra. This is what I think is the great strength of this paper: we spend a lot of time assessing explanations against some sense of a ground-truth. We first do this with in silico experiments – synthetic spectra we a known class defining feature artificially injected and making sure a trained model learns that (and only that) feature. This is harder than it sounds, deep learning will take any short-cut on offer so you really have to be stringent when creating class discriminative differences. We then move onto in vitro experiments in which lab bio-materials are added to different mixes with the ground-truth signal added being DNA. Real spectra were then taken. Although DNA associated peaks are in theory the ground-truth, we can’t control exactly which of these any model will learn, so the ground-truth is softer but still useful. Finally we take a couple of real cancer datasets, one Raman one FTIR. In these we have no concept of a ground-truth, but this is the intended use case, so we can track how various XAI methods perform under the different conditions.
We throw a number of XAI assessment methods, such as overlap metrics when we have a ground-truth and insertion/deletion curves and remove and retrain when we don’t. When we have objective ground-truths, Spec-ReX outperforms gradSHAP and Grad-CAM. Without a ground-truth it’s harder to say anything definitive, but Spec-ReX retains one very nice property, it’s explanations are often much simpler.
Obviously I’m biased, so I’ll let you decide which XAI method is best.
If you are interested in trying Spec-ReX out for yourself there is a tutorial video here:
The main ReX repository
https://github.com/ReX-XAI/ReX
Spec-ReX tutorial
https://github.com/nathanblakekcl/ReX/tree/feature/spec_tutorial
We’re always looking to improve Spec-ReX so do let us know if you have any feedback or any features you’d like to see in upcoming versions.





Leave a comment