scieee AI-readable full text Open interactive document viewer

Evaluating the Trade-Offs of Explainable AI for Galaxy Classification

Gouda, Ayush; M Naik, Gajanan

Full text

Evaluating the Trade-Offs of Explainable AI for Galaxy Classification Ayush Gouda1, Gajanan M Naik2 Department of Computer Science and Engineering, RV Institute of Technology and Management, Bengaluru, India - 560076 Department of Mechanical Engineering, RV Institute of Technology and Management, Bengaluru, India - 560076 rvit23b[email protected]u.in, gajananmn[email protected] Abstract—Deep learning models have been advanced to excel at Galaxy image classification, yet there’s a limit to their trust and utility. This is due to their inherent “black box” nature, which hides the thinking and reasoning of the deep learning framework. A quantitative comparison of popular Explainable AI (XAI) methods is needed to determine their practical trade-offs in an astronomical context. This can be achieved by evaluating three prominent XAI techniques i.e. Grad-CAM, LIME, and DeepSHAP, by applying to a fine-tuned ResNet-18 model for four-class galaxy classification. We quantitatively assessed each method based on computational efficiency and explanation fidelity. The obtained results reveal that there lies a trade-off: Grad-CAM, despite being the least computationally efficient in our implementation, demonstrated significantly higher fidelity, proving its explanations were most aligned with the model's core reasoning. This work concludes that for scientific applications where trustworthiness is paramount, explanation fidelity outweighs computational cost, making Grad-CAM the recommended tool. These findings underscore the importance of careful method selection for generating reliable scientific insights and suggest future work should validate these trade-offs on larger-scale models. Keywords— Explainable AI (XAI), Interpretability, Galaxy Classification, Deep Learning, LIME, Grad-CAM, DeepSHAP, Fidelity, Astroinformatics I. INTRODUCTION A. Background and Motivation The classification of galaxy morphology is fundamental to decoding cosmic structure history and timeline. Traditionally, this task relied on visual inspection by trained astronomers or large-scale citizen science projects, such as Galaxy Zoo [8]. Deep learning has enabled the rapid and automated classification of vast datasets, with Convolutional Neural Networks (CNNs) [9], like ResNet [2], consistently achieving human-level performance. However, high accuracy often comes at the cost of opacity: these models, acting as "black boxes," hinder scientific trust and discovery because the features driving their decisions remain hidden [6]. High accuracy comes with high stakes. In scientific domains, the simple confirmation of high accuracy is insufficient [1]. It is imperative to verify that the model is making classifications based on scientifically meaningful features (e.g., spiral arms, central bulge, or disc orientation) rather than relying on spurious data artifacts or backgrounds. This necessity has driven the development of Explainable Artificial Intelligence (XAI), a field dedicated to providing human-interpretable insights into the mechanics and predictions of machine learning models [6]. For astronomical image processing, XAI can validate the model's physical reasoning, turning a black-box classifier into a tool for scientific insight [1]. B. Explainable AI Methods and Research Gap To address the interpretability challenge, this study evaluates three distinct and widely adopted classes of XAI methods. Each was selected for its unique theoretical underpinnings and operational characteristics, representing a different approach to unveiling the model's decision-making process. Grad-CAM (Gradient-weighted Class Activation Mapping): Grad-CAM is a model-specific approach that produces a heatmap to explain a model’s image classification [5]. It works by using the feature maps from a model’s final convolutional layer and weighting against the gradients for the specific class. The algorithm produces coarse heatmaps using a feature mapping matrix calculated from the logits. The coarse heatmaps are then up sampled using interpolation techniques, in order to match the original image’s dimensions. Grad-CAM works only for CNNs, and is highly efficient in the environment due to their architecture, in the sense that the final layers capture the most important features. Grad-CAM isn't the only CAM, but was chosen for this experiment because it's a popular, CNN-specific approach, and is generally considered computationally cheap. LIME (Local Interpretable Model-agnostic Explanations): LIME is a model-agnostic approach designed to explain the individual predictions of any given classifier [4]. It operates by fitting a simple, interpretable surrogate model to the local decision boundary of the complex "black box" model. The core assumption is that while the global behavior of the model may be highly complex, its behavior in the immediate vicinity of a single instance can be reasonably approximated by a simpler, linear model. In practice, LIME generates a new dataset of perturbed samples, often by modifying segments or "superpixels" of the original input. These new samples are then weighted based on their proximity to the original instance. This weighted dataset is used to train an intrinsically interpretable model, such as a linear regression or a decision tree. The resulting coefficients or rules of this simple surrogate model serve as the final explanation, quantifying the contribution of each feature to the original prediction. While this method offers great flexibility due to its model-agnostic nature, the stability of its explanations is highly dependent on the definition of the local neighborhood and the chosen surrogate model. DeepSHAP (via GradientSHAP): DeepSHAP is a model-specific attribution method designed to efficiently approximate SHAP (SHapley Additive exPlanations) values for deep learning architectures. The SHAP framework itself is derived from cooperative game theory, providing a principled approach to explain model predictions by treating features as "players" in a game and fairly distributing the "payout" (the prediction) among them [3]. While calculating these Shapley values exactly is computationally infeasible for complex models, DeepSHAP offers a high-speed, gradient-based approximation. It achieves this by combining the theoretical properties of SHAP with the backpropagation-based rules of DeepLIFT, another interpretability method [14]. Instead of retraining the model on all possible feature subsets, DeepSHAP calculates attributions by comparing the model's output against a set of baseline inputs (e.g., a black image). This comparison is propagated backward through the network to efficiently assign a contribution score to each individual pixel. The resulting output is a high-resolution attribution map that reveals both positive (supporting) and negative (contradicting) influences on the model's final decision. Prior research has established the general utility of CNNs in galaxy classification [1], but that leaves a gap in the quantitative comparison of these core XAI methods within this domain. Their theoretical differences in approach; localization (Grad-CAM), local approximation (LIME), and feature attribution (DeepSHAP), present practical trade-offs. Yet, there is a lack of systematic analysis that concurrently assesses their computational efficiency, the fidelity (faithfulness) of their explanations to the model's actual behavior, and the scientific interpretability of the resulting feature maps for complex morphological tasks [6]. This study aims to fill that gap. C. Contribution and Thesis Statement This paper contributes to the field of astroinformatics and XAI by providing a multi-faceted evaluation of three prominent interpretability techniques applied to a fine-tuned ResNet-18 model for fourclass galaxy classification. Thesis Statement: “In this study, we investigate explanation fidelity, computational efficiency, and scientific interpretability in three popular explainable AI methods; Grad-CAM, LIME, and DeepSHAP, applied to a deep learning model for galaxy image classification. By quantifying how faithfully and efficiently each method reveals model reasoning, and assessing alignment with astrophysically meaningful image regions, this study highlights the importance of selecting appropriate XAI tools for scientific applications.” The remainder of the paper is organized as follows: Section II details the methodology. Section III presents the quantitative results for model accuracy, computational efficiency, and explanation fidelity, followed by a discussion of the scientific interpretability of the outputs. Section IV provides the conclusion and outlines directions for future research. II. METHODOLOGY A. Dataset and Classification Task The objective of this work was to develop an image classification model capable of distinguishing between four distinct galaxy morphologies: edge_on (galaxies viewed along their plane), elliptical, spiral, and a residual class, other (encompassing irregular or unclassifiable structures). The model was trained on a custom-curated dataset where each of the four classes contained between 3000 and 5000 images. This training set was further divided, allocating 80% for training and 20% for validation to monitor performance and prevent overfitting. Model evaluation was conducted on a separate, independent test set, which strictly adhered to a balanced distribution of 140 images per class, resulting in a total of 560 test samples. Figure 2 Fig. 2: Representative image of a spiral galaxy (ID: 821251) from the test set. This example is used as the input for the qualitative analysis of the Explainable AI (XAI) in Section I.B. B. Model Architecture and Training The deep learning classification framework was implemented using the ResNet-18 architecture within the PyTorch library and support [10]. To leverage general-purpose feature extraction capabilities learned from large-scale image corpora, the weights and biases were retained in the model, with the only changes made by me being the final layer. The final, or fully connected, layer was modified and finetuned to map the extracted features to the four target galaxy classes [9]. All images underwent a standardized preprocessing pipeline. Input images were first resized to (224x224) pixels to match the expected input dimensions of the classifier. The training set was subjected to data augmentation using the TrivialAugmentWide policy to enhance model robustness and invariance. Finally, all images (from the training, validation, and test sets) were normalized using a per-channel mean of (0.4914, 0.4822, 0.4465) and a standard deviation of (0.2023, 0.1994, 0.2010). The fine-tuning process was conducted over 25 training epochs using the AdamW optimizer, an initial learning rate of 1e-4, and a batch size of 128. The Cross-Entropy Loss function was employed, suitable for this multi-class classification task. To address potential class imbalances in the training data, PyTorch’s WeightedRandomSampler was used to ensure each training batch contained a balanced distribution of classes. The compute architecture used was Google Colab’s T4 GPU. C. Explainable AI Implementation and Evaluation To facilitate interpretability and transparency, three state-of-the-art Explainable AI (XAI) methods were applied to the trained ResNet-18 model to generate local feature attributions (saliency maps) for predictions on the test set: 1. DeepSHAP (GradientSHAP): The DeepSHAP explanation was generated using the GradientShap algorithm from a PyTorch-based interpretability library, Captum. [3] As a prerequisite for this gradient-based method, the ResNet-18 model was modified to replace all in-place ReLU operations with their out-of-place equivalents. A critical implementation choice for SHAP-based methods is the baseline distribution [7]. For this study, a baseline was established by creating 10 reference tensors of random noise. Attributions for each test image were then computed with respect to the model's own predicted class, with a small amount of noise added to the inputs (stdevs=0.0001) to smooth the resulting attribution map. 2. LIME (Local Interpretable Model-agnostic Explanations): LIME was configured with minimal parameters to test its performance under resource-constrained settings. It was set to generate 200 perturbed samples and fit a surrogate model based on the top 10 features. This low sample count was chosen specifically to manage the high memory (RAM) usage observed during LIME's feature perturbation process. 3. Grad-CAM (Gradient-weighted Class Activation Mapping): Grad-CAM was implemented using the pytorch_grad_cam library. As required by the method, the final basic block of the ResNet-18 architecture (model.layer4[-1]) was selected as the target convolutional layer. For each test image, the ClassifierOutputTarget utility was used to generate an explanation for the model's own predicted class, rather than the ground-truth label. The resulting coarse localization map was then upsampled using cv2.resize and overlaid on the original image to produce the final visual explanation. The explainers were quantitatively assessed using two primary metrics: computational efficiency (runtime per image) and a composite measure of explanation quality, the Fidelity-Efficiency Score (FES) [13]. Furthermore, fidelity was analyzed via Mean Confidence Drop (MCD) curves [11], which measure the degradation in model confidence on the true class after masking the most relevant pixels identified by the explainer. The MCD was calculated as the average difference between the model's confidence in the true class for the original image (f(x)true) and the masked image (f(xmasked)true) over all N test images: 𝑀𝐶𝐷 = 1 𝑁∑(𝑓 𝑁 𝑖=1 (xi)true – (𝑓(xi,masked)true) Using the obtained MCD values, we calculated the Fidelity-Efficiency Score (FES). The trade-off was measured as the ratio of fidelity (area under the MCD curve i.e. AUCMCD) to the average runtime (Tavg): 𝐹𝐸𝑆 = 𝐴𝑈𝐶𝑀𝐶𝐷 𝑇𝑎𝑣𝑔 III. RESULTS AND DISCUSSION A. Galaxy Classification Performance The fine-tuned ResNet-18 model demonstrated a high level of predictive performance on the test set. The overall accuracy was 0.9893, with the weighted F1-Score matching this performance. The weighted Jaccard Similarity Coefficient was also very high at 0.9788, as detailed in Table 1 [12]. TABLE 1 Table 1: The table summarizes the key performance indicators for the fine-tuned ResNet-18 model on the test dataset, demonstrating high overall predictive accuracy. The class-wise metrics, presented in Table 2, confirm the uniformity of the model's performance across all four classes. The model exhibited nearperfect precision and recall for all categories. These strong results establish the ResNet-18 model as a highly reliable and robust baseline classifier for the subsequent XAI analysis. 1. Precision measures the accuracy of the model's predictions. 2. Recall measures the model's ability to find all instances of a class. 3. F1-Score is the harmonic mean of Precision and Recall, and provides a single score that balances both. 4. Support is the number of actual instances of each class in the test dataset. TABLE 2 Table 2: This table details the model's performance for each galaxy class. B. Computational Efficiency Analysis Computational efficiency, measured as the average time to generate a single explanation, was a primary differentiator among the XAI methods. The results are graphically summarized in Fig. 3. Figure 3 Fig. 3: Average time in seconds to generate an explanation for a single image. Lower is better. The specific runtimes were 0.060s per image for DeepSHAP, 0.069s for LIME, and 0.361s for GradCAM. In our implementation, both DeepSHAP and LIME were highly efficient, generating explanations in near-real time. Conversely, Grad-CAM was approximately 6 times slower than DeepSHAP, representing a significant computational overhead. This result is highly contrary to many standard benchmarks where Grad-CAM is often the fastest method. The observed slowness is likely due to the specific implementation of the method. Overhead within the library used, which may not leverage batch processing efficiently for computing the necessary gradients, may be the defining factor, rather than the inherent complexity of the algorithm. Second, LIME appeared highly efficient at 0.069s per image, a speed comparable to DeepSHAP (0.060s). This high speed is a direct consequence of the hyperparameters chosen for this experiment: LIME was configured to use only 200 samples and 10 features. The process of generating, storing, and fitting models to even this small number of perturbed samples proved to be memory-intensive. Therefore, the analysis reveals a complex, three-way trade-off for LIME: its computation time can be minimized, but only by sacrificing explanation quality (via fewer samples) or by incurring a high cost in system memory. This makes LIME a potentially problematic choice for systems with limited RAM. C. Fidelity and Performance Trade-Offs To assess the quality of the explanations, we first measured fidelity using the Mean Confidence Drop (MCD) metric, shown in the fidelity curves in Fig. 4. This metric evaluates how much the model's confidence drops when the most important pixels (as identified by the explainer) are masked. A steeper drop indicates a more faithful explanation. Figure 4 Fig. 4: Curves representing the Mean Confidence Drop (MCD) for each explainer. Grad-CAM's Superior Fidelity: The MCD curve for Grad-CAM shows a steep descent. When retaining only the top 5% of pixels identified by Grad-CAM (i.e., masking 95%), the model's confidence drops by over 60% (MCD > 0.6). This confirms that the regions highlighted by Grad-CAM are exceptionally critical to the model's prediction, making it the most faithful explainer by a significant margin. LIME and DeepSHAP Behavior: DeepSHAP and LIME show much flatter MCD curves. Even after masking 85% of the image (retaining the top 15%), the confidence drop remains below 10%. This suggests that the features these methods identify are less essential to the model's core decision, possibly because they produce broader, less focused attributions. Lastly, to quantify the overall utility, we combined these two aspects into a Fidelity-Efficiency Score (FES), where higher values indicate a better balance. Despite its poor computational efficiency in our setup, Grad-CAM achieved the highest FES. This result, represented in Fig. 5, demonstrates that its vastly superior fidelity more than compensated for its longer runtime. For scientific purposes, where identifying physically meaningful features should be prioritized, Grad-CAM's ability to provide faithful explanations makes it the most valuable tool of the three, even with a computational trade-off. Figure 5 Fig. 5: The final FES scores were: DeepSHAP ≈ 0.95, LIME ≈ 0.56, Grad-CAM ≈ 1.23 IV. CONCLUSION In this paper, we set out to investigate the practical trade-offs between three popular Explainable AI methods; Grad-CAM, LIME, and DeepSHAP, when applied to the scientific task of galaxy morphology classification. By utilizing the preexisting weights and biases of a highly efficient fine-tuned ResNet-18 model, we aimed to quantify their computational efficiency and overall utility to guide the selection of appropriate XAI tools for scientific research. My findings reveal a stark trade-off between these methods. While DeepSHAP and LIME offered near real-time computational performance, our fidelity analysis, based on the Mean Confidence Drop metric, showed that their explanations were not strongly aligned with the model's most critical predictive features. Our analysis confirmed that Grad- CAM produced explanations with vastly superior fidelity, proving that the regions it highlighted were exceptionally influential to the model's final decision. This high fidelity came at the cost of significantly slower computation in our specific implementation. However, when these factors were balanced using a Fidelity-Efficiency Score (FES), Grad-CAM emerged as the most valuable tool. The primary conclusion of this study is that for scientific applications like astroinformatics, where the goal is not just prediction but understanding and validation, explanation fidelity is a more critical metric than raw computational speed. An explanation that is fast may be misleading due to scientific inaccuracies. The superior ability of Grad-CAM to identify the most salient image regions makes it the recommended choice in this context, despite potential performance overheads. This work is not without its limitations. The analysis was conducted on a single dataset and model architecture. Furthermore, the performance findings are highly implementation-specific: the unexpectedly slow runtime of Grad-CAM is likely due to library/architecture overhead, while the high speed of LIME (Fig. 3) was only achieved by using a minimal configuration (200 samples). This low sample count was necessitated by LIME's high memory (RAM) consumption, revealing a complex, three-way trade-off between its fidelity, computation time, and memory cost. Future research should systematically explore this LIME-specific trade-off and extend this entire comparative framework to other models, such as Vision Transformers. REFERENCES [1] M. Mohammadi, J. Mutatiina, T. Saifollahi, and K. Bunte, "Detection of extragalactic Ultra-compact dwarfs and Globular Clusters using Explainable AI techniques," Astronomy and Computing, vol. 39, 2022, Art. no. 100555. [2] K. He, X. Zhang, S. Ren, and J. Sun, "Deep Residual Learning for Image Recognition," in Proc. IEEE Conf. Comput. Vis. Pattern Recognition (CVPR), 2016, pp. 770–778. [3] S. M. Lundberg and S. I. Lee, "A Unified Approach to Interpreting Model Predictions," in Advances in Neural Information Processing Systems (NIPS), 2017. [4] M. T. Ribeiro, S. Singh, and C. Guestrin, ""Why Should I Trust You?": Explaining the Predictions of Any Classifier," in Proc. 22nd ACM SIGKDD Int. Conf. Knowl. Discovery Data Mining, 2016, pp. 1135–1144. [5] R. R. Selvaraju, M. Cogswell, A. Das, R. Vedantam, D. Parikh, and D. Batra, "Grad-CAM: Visual Explanations from Deep Networks via GradientBased Localization," in Proc. IEEE Int. Conf. Computer Vision (ICCV), 2017, pp. 618–626. [6] J. Brasse et al., "Explainable artificial intelligence in information systems: A review of the status quo and future research directions," Electronic Markets, vol. 33, no. 26, 2023. [7] N. Aftab. (2025, May). Deep Learning Model Interpretability with SHAP. [Online]. Available: https://medium.com/@naveed88375/deep-learningmodel-interpretability-with-shap-63598b7aeff8 [8] C. J. Lintott et al., "Galaxy Zoo: morphologies derived from visual inspection of galaxies from the Sloan Digital Sky Survey," Monthly Notices of the Royal Astronomical Society, vol. 389, no. 3, pp. 1179–1187, 2008. [9] S. Dieleman, K. W. Willett, and J. Dambre, "Rotation-invariant convolutional neural networks for galaxy morphology prediction," Monthly Notices of the Royal Astronomical Society, vol. 450, no. 2, pp. 1441–1459, 2015. [10] A. Paszke et al., "PyTorch: An Imperative Style, High-Performance Deep Learning Library," in Advances in Neural Information Processing Systems (NeurIPS), 2019. [11] R. C. Fong, and A. Vedaldi, "Interpretable Explanations of Black Boxes by Meaningful Perturbation," in Proc. IEEE Int. Conf. Computer Vision (ICCV), 2017. [12] T. Hastie, R. Tibshirani, and J. Friedman, The Elements of Statistical Learning: Data Mining, Inference, and Prediction, 2nd ed. New York: Springer, 2009. [13] S. Hooker, D. Erhan, P.-J. Kindermans, and B. Kim, "A Benchmark for Interpretability Methods in Deep Neural Networks," in Advances in Neural Information Processing Systems (NeurIPS), 2019. [14] A. Shrikumar, P. Greenside, and A. Kundaje, "Learning Important Features Through Propagating Activation Differences," in Proc. International Conference on Machine Learning (ICML), 2017, pp. 3145–3153, arXiv:1704.02685.