Editor’s introduction
The study evaluates ProtoCAM, an explainable few-shot learning method, on the BUSI dataset for breast lesion classification in ultrasound imaging. It compares performance against standard CNN models under data-scarce conditions, using a 3-way 5-shot setting where ProtoCAM achieves a macro F1-score of 0.910, showing superior performance. The model uses lesion masks to guide feature extraction and constructs class prototypes in an embedding space, enabling reliable classification with minimal training samples. ResNet18 achieved the highest performance at 91.65% F1-score in a 15-shot scenario, providing interpretable visual explanations through Grad-CAM. The evaluation employs stratified group k-fold cross-validation to avoid patient-level data leakage, ensuring robustness. A key limitation is the use of a single public dataset, which may restrict generalizability to diverse clinical settings. Additionally, the method depends on manually annotated lesion masks, which are not always available in routine clinical practice.
Introduction
Cancer is a pathological condition in which cells acquire the ability to proliferate uncontrollably, bypassing the normal regulatory mechanisms that govern cell division and apoptosis. In breast cancer, this abnormal growth originates in the epithelial cells of the breast ducts or lobules, leading to the formation of malignant tumours. These cancerous cells can invade surrounding breast tissue and, in advanced stages, spread to other parts of the body via the lymphatic system or bloodstream. Breast cancer is the most frequently diagnosed cancer among women globally, with over 2.3 million cases reported in 2022. It remains one of the leading causes of cancer-related mortality in women, accounting for approximately 670,000 deaths, around 7% of all cancer deaths worldwide. Incidence rates show marked geographic variation, exceeding 80 cases per 100,000 women in developed regions such as Europe, North America, Australia, and New Zealand.
Early and accurate detection of breast cancer is critical for improving survival outcomes, as it enables the timely initiation of effective treatment. While conventional diagnostic modalities—such as mammography, ultrasound, and biopsy—are widely used, each presents inherent limitations, including operator dependence, inter-observer variability, and the need for specialized expertise. Biopsy, although regarded as the diagnostic gold standard, is invasive and can cause patient discomfort. Ultrasound (US) imaging is a non-invasive, well-tolerated, real-time diagnostic technique commonly used in the evaluation of breast abnormalities. Owing to its accessibility, absence of ionizing radiation, and ability to differentiate between cystic and solid lesions, it is often preferred as an initial assessment tool in breast cancer diagnosis over modalities such as mammography or biopsy.
Computer-aided diagnosis (CADx) systems play a vital role in the early detection of breast cancer and other malignancies. Traditional CAD solutions based on classical machine learning often struggled to generalize across diverse populations and imaging conditions, whereas deep learning–based approaches have demonstrated substantial improvements by automatically learning complex, discriminative features from raw data. Recent studies applying deep learning to breast cancer detection in ultrasound images have reported promising results; however, their performance is frequently constrained by the limited availability of large, diverse medical imaging datasets, which are essential for building robust and generalizable models. Medical imaging datasets are typically scarce due to several factors, such as privacy restrictions, high acquisition costs, and the difficulty of obtaining expert-labelled samples. In such data-scarce scenarios, few-shot learning (FSL) offers a compelling alternative, enabling models to adapt to new cases and classes using only a small number of labelled examples. Metric learning strategies are particularly well-suited for this task, as they learn embedding spaces that capture meaningful similarities between samples, facilitating accurate classification even in low-resource settings.
Another critical challenge is the inherent opacity of deep learning models, often described as “black boxes”, whose internal decision-making processes are difficult to interpret even for domain experts. In medicine, explainability is not merely a technical preference but a clinical necessity, essential for fostering trust among practitioners, meeting regulatory requirements, and ensuring ethical accountability. Explainable artificial intelligence (XAI) offers a means to address these challenges by producing interpretable outputs that link artificial intelligence (AI) predictions to clinical reasoning. Techniques such as visual heatmaps in medical images or textual justifications help highlight the features influencing a model’s decision, thereby enhancing transparency and trust in AI-assisted diagnosis.
This work presents a high-performing mask-guided few-shot solution for ultrasound lesion classification, called ProtoCAM, by integrating data-driven metric learning with rigorous validation and explainability assessments. By employing prototypical networks optimized with dataset-specific normalization, the pipeline overcomes the severe data scarcity and low-contrast challenges inherent to few-shot medical imaging, systematically outperforming standard convolutional neural network (CNN) baselines. The solution seamlessly embeds Grad-CAM feature visualizations to verify that the model’s performance is driven by genuine pathological regions, such as irregular tumour margins, rather than background artifacts, providing an auditable end-to-end architecture tailored for reliable medical assessment and deployment.
The main contributions of this work are summarized as follows. First, we propose ProtoCAM, an explainable few-shot learning framework for breast ultrasound image classification that integrates mask-guided feature encoding with prototypical metric learning to address the challenge of limited annotated medical data. Second, we incorporate lesion-aware feature extraction using ground-truth masks provided in the dataset to guide the network toward clinically relevant regions, improving representation quality and classification performance. Third, we conduct a comprehensive experimental evaluation on the BUSI dataset using a stratified group K-fold cross-validation protocol to prevent patient-level data leakage and ensure reliable performance assessment. Finally, we provide model interpretability through Grad-CAM visualizations, demonstrating that the proposed framework focuses on meaningful lesion regions and produces clinically interpretable explanations for its predictions.
Methodology
This study proposes a few-shot learning framework for breast cancer classification from ultrasound images using a prototypical network architecture. The framework integrates lesion-aware feature extraction, episodic meta-learning, and patient-wise cross-validation to address the limited availability of labelled medical data. The methodology is described in detail in this section.
Episodic Learning Framework
The default experimental configuration uses 5-shot support samples and 20 query samples per class, though experiments were conducted with larger support sizes such as 10-shot, 15-shot, and 20-shot settings. Episodes are generated using a custom episodic sampler that ensures balanced sampling across classes.
Backbone Feature Extractor
Feature representations are extracted using pre-trained convolutional neural network backbones. The classification layers of these networks are removed, and only the feature embeddings are used. Several architectures were evaluated, including: ResNet18, ResNet50, ResNet101, MobileNetV2, DenseNet121, EfficientNetB0, EfficientNetB1, and VGG16. Among these, ResNet18 served as the primary backbone due to its favourable balance between representation capacity and computational efficiency.
Cross-Validation Strategy and Evaluation Metrics
To ensure robust evaluation and prevent patient-level data leakage, a Stratified Group K-Fold cross-validation scheme is employed. This strategy preserves class distribution across folds while ensuring that all images from the same patient remain within a single fold. The number of splits is set to three folds. For each fold, the dataset is partitioned into training and validation subsets and episodic sampling is performed independently within each subset. The best-performing model is selected based on validation Macro F1-score, which balances both false positives and false negatives independently for each class and then averages them equally. This prevents the model from hiding behind overall accuracy by simply predicting the majority class, which in breast cancer screening would be a potentially life-threatening blind spot. Model checkpoints are stored whenever a new best validation performance is observed. The final trained model is also serialized for future analysis.
Model Interpretability
Grad-CAM visualizations are generated to improve interpretability. Grad-CAM is applied to the final convolutional layer of the backbone network. Heatmaps are overlaid on the original ultrasound images to visually assess whether the model focuses on relevant lesion regions.
Computational Environment and Implementation Details
All experiments were implemented in Python 3.14 using the PyTorch deep learning framework. Training was conducted on a workstation equipped with an NVIDIA RTX A6000 GPU and 128 GB RAM. Random seeds were fixed to ensure reproducibility across experimental runs. Model checkpoints, training logs, and evaluation metrics were automatically recorded during training to facilitate experiment tracking and analysis.
Comparative Analysis of Backbone Models
Among the evaluated models, ResNet18 achieved the best overall performance, obtaining a macro F1-score of 91.65 percent with a standard deviation of 2.38 across validation folds. It also achieved the highest recall and precision values. Despite being a relatively lightweight architecture compared to deeper variants such as ResNet50 and ResNet101, ResNet18 demonstrated superior generalization in the few-shot learning setting. Deeper networks did not yield improved performance, likely due to the limited number of training samples available in the episodic learning framework. Models with larger parameter counts, such as ResNet101 and VGG16, showed slightly lower performance, which may be attributed to increased risk of overfitting. Conversely, lightweight models such as MobileNetV2 achieved comparable results while using significantly fewer parameters. Another observation is the near-equality of the three metrics, which indicates balanced classification behaviour across the three classes.
Sensitivity Analysis of Episodic Parameters
The best performance is obtained with the 15-shot, 25-query configuration, which achieves a macro F1-score of 91.65%. This configuration likely provides a good balance between prototype stability and training diversity for the examined dataset. With 15 support samples per class, the class prototypes are sufficiently representative and increasing the support set size may have introduced near-duplicate examples that do not provide meaningful new information for prototype estimation. In addition, larger support sets can alter the balance between support and query samples within an episode. Since the optimization objective of prototypical networks is computed on the query set, increasing the support size without proportionally increasing query samples may reduce the relative amount of training signal available for gradient updates. The effect of increasing query size from 20 to 25 samples is generally positive but modest. Larger query sets provide more examples for computing the episodic loss, which can lead to more stable gradient estimates during training. This effect is particularly noticeable in the 10-shot and 15-shot configurations, where increasing the query size slightly improves the macro F1-score.
Domain-Specific vs. General-Purpose Pre-training
To evaluate the impact of domain-specific feature representations on low-contrast medical data, we compared a ResNet50 backbone initialized with weights from HuggingFace RadImageNet, a large-scale radiologic imaging dataset, against a ResNet50 baseline initialized with traditional ImageNet natural image weights22 2 RadImageNet does not offer pretrained weights for ResNet18, therefore, we used ResNet50 in this experiment.. Empirically, the RadImageNet-initialized prototypical network achieved a Macro F1-score of 87.87% at 40 epochs, which steadily climbed to a peak of 90.79% at 80 epochs before succumbing to overfitting at 100 epochs (dropping to 89.93%). Unexpectedly, the standard ImageNet initialization outperformed the peak medical-specific pre-training by a noticeable margin, reaching a Macro F1-score of 90.96% in 40 epochs.
Several factors may explain why the medical domain-specific model did not yield superior performance under these few-shot parameters. First, while RadImageNet contains a vast library of multiple medical modalities, these modalities primarily feature high-contrast structural landmarks and sharp bone-to-tissue boundaries. In contrast, ultrasound images are highly unique, dominated by severe speckle noise, low-contrast shadowing, and localized acoustic variations. Second, this may highlight the critical role of “feature diversity” versus “feature specificity” in few-shot metric spaces. Natural image datasets, e.g., ImageNet, force a network to learn highly versatile, diverse primitives such as curves, textures, scales, and fine gradients across various heterogeneous classes. This expansive, generalized geometric vocabulary may provide a robust, adaptable canvas for the episodic sampler to construct flexible metric boundaries. Conversely, RadImageNet weights are highly specialized toward fixed medical target distributions. When forced into an ultra-low sample domain (3-way 5-shot), this hyper-specificity restricted the prototype space, causing the model to adapt slowly (requiring 80 epochs to reach its peak) and making it highly vulnerable to episodic feature collapse and overfitting shortly thereafter.
Comparative Analysis: ProtoCAM vs. Conventional CNNs
The conventional CNN baselines uniformly collapsed or struggled to generalize under these extreme data constraints. The standard ResNet18 classifier yielded the highest baseline performance with a Macro F1-score of 0.531, followed closely by EfficientNetB1 at 0.517 and MobileNetV2 at 0.471. As expected, scaling the network depth severely degraded baseline performance; ResNet50 and ResNet101 stalled at Macro F1-scores of 0.419 and 0.411, respectively. Conversely, ProtoCAM utilizing the exact same ResNet18 backbone achieved a Macro F1-score of 0.910 under identical few-shot constraints, outperforming its direct supervised counterpart by an absolute margin of 37.9%. These empirical results demonstrate that achieving clinical-grade accuracy on scarce ultrasound data may require a shift away from traditional supervised cross-entropy optimization and toward sample-efficient architectures.
Visual Interpretation of ProtoCAM Predictions
In the normal case (e–f), the Grad-CAM visualization shows relatively diffuse and low-intensity activation across the image, without a strong localized focus. This may indicate that the model does not detect a suspicious region resembling a lesion. These visualizations demonstrate that ProtoCAM produces clinically meaningful explanations by focusing attention on anatomically relevant regions. Specifically, in lesion-containing images, the model concentrates on the tumour area.
Conclusion
This study presented ProtoCAM, an explainable few-shot learning framework for breast cancer classification in ultrasound imaging that integrates mask-guided feature encoding, prototypical metric learning, and Grad-CAM–based interpretability. The proposed approach was evaluated on the BUSI dataset using a rigorous Stratified Group K-Fold cross-validation protocol to prevent patient-level data leakage. Experimental results demonstrated that ProtoCAM significantly outperforms conventional CNN classifiers under severe data constraints, achieving a macro F1-score of 0.910 in a 3-way 5-shot setting.
Among the evaluated backbone architectures, ResNet18 provided the best balance between representation capacity and generalization, achieving the highest macro F1-score of 91.65 percent. Sensitivity analysis of episodic parameters further showed that a 15-shot configuration with 25 query samples per class produced the best performance, indicating an optimal balance between prototype stability and training diversity. Additionally, Grad-CAM visualizations confirmed that the model focuses on clinically meaningful lesion regions rather than background artifacts, supporting the interpretability of the framework. The results demonstrate that the proposed ProtoCAM architecture provides an effective and interpretable solution for breast ultrasound analysis in data-scarce medical imaging environments, highlighting the potential of few-shot metric learning for reliable computer-aided diagnosis.
Limitations and Future Work
Despite the promising results, several limitations should be acknowledged. First, the experiments were conducted on a single public dataset (BUSI), which may limit the generalizability of the proposed ProtoCAM framework to ultrasound data acquired from different institutions, imaging devices, or patient populations. Second, the approach relies on the availability of lesion masks for mask-guided feature encoding, which may not always be readily available in real clinical settings and typically require manual annotation by experts. Future work will therefore focus on evaluating the model across multiple multi-centre ultrasound datasets to assess its robustness and generalization capability. Additionally, incorporating automatic or weakly supervised lesion localization methods could reduce the dependence on manual annotations.


