Hybrid Machine Learning-Assisted Raman Spectroscopy with Generative Feature Augmentation for Pharmaceutical Identification
Summary
This paper proposes HyMLRaman, a hybrid framework combining EfficientNet-B3 spectral embeddings with classical classifiers (notably SVM) and DDPM-based generative feature augmentation to identify six pharmaceutical compounds via Raman spectroscopy, achieving 96.31% accuracy.
View Cached Full Text
Cached at: 10/05/26, 10:00 AM
# Hybrid Machine Learning-Assisted Raman Spectroscopy with Generative Feature Augmentation for Pharmaceutical Identification
Source: [https://arxiv.org/html/2610.02224](https://arxiv.org/html/2610.02224)
\[\]
\[\]
\[\]
\[\]
\[orcid=0000\-0003\-4156\-6230\]
Quach Thi Thai BinhFaculty of Physics and Physics Engineering, University of Science, Ho Chi Minh City 700000, Viet NamVietnam National University, Ho Chi Minh City 700000, Viet NamThang B\. PhanAdvanced Materials Technology Institute Vietnam National University Ho Chi Minh City \(formerly Affiliated with Center for Innovative Materials and Architectures\), Ho Chi Minh City 700000, Viet NamUniversity of Health Sciences \(UHS\), Viet Nam National University Ho Chi Minh City, Ho Chi Minh City 700000, Viet NamVu Thi Hanh Thuvththu@hcmus\.edu\.vnNguyen Tuan HungFrontier Research Institute for Interdisciplinary Sciences, Tohoku University, Sendai 980\-8578, Japannguyen\.tuan\.hung\.e4@tohoku\.ac\.jp
###### Abstract
Rapid and reliable identification of pharmaceutical residues is important for safeguarding public health, ensuring food safety, and enabling practical Raman\-based screening\. In this study, we propose HyMLRaman, a hybrid Raman spectroscopy framework that combines deep spectral feature extraction, generative models, and classical machine\-learning classifiers to identify six pharmaceutical compounds, including amoxicillin, chloramphenicol, ciprofloxacin, tetracycline, ibuprofen, and paracetamol\. Raman spectra are converted into spectral images and encoded with several deep neural\-network backbones, among which EfficientNet\-B3 yields the most effective representation\. The resulting 1536\-dimensional embeddings are then used to train downstream classifiers, including SVM, KNN, logistic regression, random forest, XGBoost, and ANN, using stratified 10\-fold cross\-validation\. The hybrid EfficientNet\-B3–SVM configuration achieves the strongest baseline performance, reaching 96\.31% accuracy and a macro\-F1 score of 96\.36%, outperforming the standalone CNN baseline\. To address limited\-data conditions, a generative model, a DDPM\-based feature augmentation, is introduced in a PCA\-reduced EfficientNet\-B3 latent space\. The low\-data ablation results show that DDPM augmentation provides selective benefits, particularly for KNN with reduced training fractions, and that its effect remains classifier\-dependent\. Finally, an application\-level Raman Pharmaceutical Analyzer demonstrates the feasibility of embedding the trained model into an interactive Raman analysis workflow\. These results suggest that HyMLRaman provides a practical and interpretable route for rapid Raman\-based pharmaceutical screening\.
###### keywords
Raman spectroscopy ,Pharmaceutical identification ,Hybrid machine\-learning ,Feature augmentation ,Generative AI
††credit:Writing original draft, Visualization, Data curation, Methodology, Investigation, Formal analysis††credit:Data curation, Formal analysis††credit:Resources, Funding acquisition††credit:Supervision, Writing \- review, Visualization, Investigation††credit:Supervision, Writing \- review, Validation, Methodology, Investigation, Formal analysis\. All authors have given their approval for the final version of the manuscript\.††corresponding:Corresponding author††corresponding:Principal corresponding author## 1INTRODUCTION
The growing presence of pharmaceutical residues in food, water, and clinical samples has raised increasing public\-health concerns, motivating the need for rapid identification of widely used drugs such as amoxicillin \(AMX\), chloramphenicol \(CHL\), tetracycline \(TET\), ciprofloxacin \(CIP\), ibuprofen \(IBU\), and paracetamol \(PAR\)[Patel et al\. \(2019\)](https://arxiv.org/html/2610.02224#bib.bib2);[Maghsodian et al\. \(2022\)](https://arxiv.org/html/2610.02224#bib.bib3);[Gyesi et al\. \(2022\)](https://arxiv.org/html/2610.02224#bib.bib4)\. Raman spectroscopy provides a fast, non\-destructive analytical tool with molecule\-specific vibrational signatures, making it an appealing solution for on\-site screening[Liu et al\. \(2025\)](https://arxiv.org/html/2610.02224#bib.bib5);[Chandra et al\. \(2024\)](https://arxiv.org/html/2610.02224#bib.bib6)\. However, the spectral variability encountered in practical measurements often challenges traditional chemometric approaches and motivates the integration of modern machine learning techniques[Liu et al\. \(2025\)](https://arxiv.org/html/2610.02224#bib.bib5);[Liu et al\. \(2026\)](https://arxiv.org/html/2610.02224#bib.bib7);[Pocheville et al\. \(2025\)](https://arxiv.org/html/2610.02224#bib.bib8)\.
In response to these challenges, machine learning \(ML\) techniques, including contemporary neural\-network–based models, have been increasingly coupled with Raman spectroscopy[Liu et al\. \(2025\)](https://arxiv.org/html/2610.02224#bib.bib5);[Liu et al\. \(2026\)](https://arxiv.org/html/2610.02224#bib.bib7);[Wang et al\. \(2024\)](https://arxiv.org/html/2610.02224#bib.bib9);[Sunil et al\. \(2024\)](https://arxiv.org/html/2610.02224#bib.bib10);[Luo et al\. \(2022\)](https://arxiv.org/html/2610.02224#bib.bib11);[Rashidi et al\. \(2025\)](https://arxiv.org/html/2610.02224#bib.bib12);[Zarei et al\. \(2023\)](https://arxiv.org/html/2610.02224#bib.bib13);[Wang et al\. \(2025\)](https://arxiv.org/html/2610.02224#bib.bib21)\. Classical ML algorithms such as large\-margin methods \(e\.g\., support vector machines, SVMs\) and random forests can handle complex decision boundaries but typically rely on carefully engineered features extracted from one\-dimensional spectra[Liu et al\. \(2025\)](https://arxiv.org/html/2610.02224#bib.bib5);[Liu et al\. \(2026\)](https://arxiv.org/html/2610.02224#bib.bib7);[Pocheville et al\. \(2025\)](https://arxiv.org/html/2610.02224#bib.bib8);[Sunil et al\. \(2024\)](https://arxiv.org/html/2610.02224#bib.bib10);[Rahman et al\. \(2024\)](https://arxiv.org/html/2610.02224#bib.bib14)\. In contrast, convolutional neural networks \(CNNs\) are specifically designed to learn hierarchical representations from spectral images, enabling the extraction of subtle structures that are not easily captured by manually constructed descriptors[Liu et al\. \(2025\)](https://arxiv.org/html/2610.02224#bib.bib5);[Liu et al\. \(2026\)](https://arxiv.org/html/2610.02224#bib.bib7);[Wang et al\. \(2024\)](https://arxiv.org/html/2610.02224#bib.bib9);[Rieger et al\. \(2023\)](https://arxiv.org/html/2610.02224#bib.bib15);[Binh et al\. \(2025\)](https://arxiv.org/html/2610.02224#bib.bib16)\. Several recent investigations have reported that CNN\-based feature encoders, when combined with powerful ensemble classifiers such as the gradient boosting algorithm \(XGBoost\), can substantially improve predictive accuracy and robustness compared with CNN\-only or purely classical pipelines[Binh et al\. \(2025\)](https://arxiv.org/html/2610.02224#bib.bib16);[Jiao et al\. \(2021\)](https://arxiv.org/html/2610.02224#bib.bib17);[Zou et al\. \(2025\)](https://arxiv.org/html/2610.02224#bib.bib18)\. Despite these advances, most existing Raman ML studies adopt a single modeling paradigm \(either classical ML or deep learning\), thereby underutilizing the complementary strengths of both[Liu et al\. \(2026\)](https://arxiv.org/html/2610.02224#bib.bib7);[Luo et al\. \(2022\)](https://arxiv.org/html/2610.02224#bib.bib11);[Binh et al\. \(2025\)](https://arxiv.org/html/2610.02224#bib.bib16);[Jiao et al\. \(2021\)](https://arxiv.org/html/2610.02224#bib.bib17)\. This motivates a hybrid strategy that combines the representational power of deep networks with the decision robustness and regularization benefits of classical classifiers[Rieger et al\. \(2023\)](https://arxiv.org/html/2610.02224#bib.bib15);[Binh et al\. \(2025\)](https://arxiv.org/html/2610.02224#bib.bib16);[Zou et al\. \(2025\)](https://arxiv.org/html/2610.02224#bib.bib18);[Wójcik et al\. \(2026\)](https://arxiv.org/html/2610.02224#bib.bib19)\.
Figure 1:Schematic overview of the proposed HyMLRaman framework\. \(a\) Cross\-validation pipeline: \(1\) the data preprocessing, in which interpolated spectra are reshaped into128×128128\\times 128spectral images, \(2\) feature embeddings \(1536\-D\) are extracted using several ML architectures \(EfficientNet\-B0, EfficientNet\-B3, RegNetY\-400M, and ViT\-B16\), and multiple classifiers \(SVM, KNN, LR, RF, ANN, XGBoost\) are evaluated under stratified 10\-fold cross\-validation with visualization and confusion\-matrix analysis, \(3\) an end\-to\-end application is built based on the trained EfficientNet\-B3 classifier\. \(b\) DDPM\-based diffusion augmentation for generating feature embeddings via forward noise injection and learned reverse denoising\.In this work, we introduce HyMLRaman, a hybrid machine\-learning framework for rapid identification of six pharmaceutical compounds from Raman spectra\. A total of 1003 Raman spectral images are collected from publicly accessible datasets acquired under comparable measurement conditions\. This dataset is used to fine\-tune an EfficientNet\-B3 encoder, whose embeddings serve as a unified feature space for downstream classifiers, including SVM,kk\-nearest neighbors \(KNN\), logistic regression, random forest, XGBoost, and a shallow neural network\. These hybrid pipelines achieve accuracies ranging from 94\.62% to 96\.31% across the evaluated downstream classifiers, with the EfficientNet\-B3–SVM configuration providing the strongest baseline performance of 96\.31% accuracy and 96\.36% macro\-F1\. To further stabilize learning with limited data, a denoising diffusion probabilistic model \(DDPM\) is trained in the embedding space to perform feature\-level augmentation\. Furthermore, by comparing the CNN and Vision Transformer \(ViT\-B16\) models, we also highlight the localized peak characteristics in Raman spectra\. Finally, an end\-to\-end EfficientNet\-B3 classifier integrated into a PyQt interface demonstrates the practical feasibility of real\-time Raman\-based drug screening\.
Figure 2:Overview of the Raman spectral dataset\. \(a\) Number of Raman spectral images in each pharmaceutical class: amoxicillin \(AMX\), chloramphenicol \(CHL\), ciprofloxacin \(CIP\), ibuprofen \(IBU\), paracetamol \(PAR\), and tetracycline \(TET\)\. \(b\) Representative normalized Raman spectra of the six pharmaceutical compounds, vertically offset for clarity\. \(c\) t\-SNE visualization of the EfficientNet\-B3 feature embeddings for the six pharmaceutical classes\. \(d\) Summary of the dataset, including the total number of samples, number of classes, data type, and classification task\.
## 2METHODS AND MATERIALS
### 2\.1HyMLRaman: A Hybrid Machine Learning Framework for Raman Spectra
In Figure[1](https://arxiv.org/html/2610.02224#S1.F1)a, we illustrate the HyMLRaman framework used in this study\. The HyMLRaman framework begins with the Raman spectral dataset and preprocessing, then proceeds to feature extraction with several deep neural\-networks models, including the CNN models with EfficientNet\-B0, EfficientNet\-B3, and RegNetY\-400M, and the vision transformer model with ViT\-B16, followed by dimensionality reduction and classification using several ML models, including SVM, KNN, LR, RF, ANN, and XGBoost\. The performance of the HyMLRaman framework is measured with accuracy, F1\-score, and a confusion matrix\. The framework ends with a user interface, developed to enable practical use of the model for the rapid detection of pharmaceutical residues from Raman spectra\. To improve the limited dataset, a generative model based on the DDPM is adopted for feature augmentation from the dimensionality\-reduced space, as shown in Figure[1](https://arxiv.org/html/2610.02224#S1.F1)b\. All code and the user interface application are available for download on the GitHub page:[https://github\.com/nguyen\-group/HyMLRaman](https://github.com/nguyen-group/HyMLRaman)\.
### 2\.2Raman Spectral Acquisition and Image Construction
Raman spectra of six pharmaceutical compounds are collected from publicly accessible datasets acquired under comparable measurement conditions, yielding a total of 1003 samples, as shown in Figure[2](https://arxiv.org/html/2610.02224#S1.F2)a\. In the implemented pipeline, the spectral data are prepared as Raman spectral images and resized to the deep neural\-networks \(CNN and transformer models\) input resolution by applying additional Raman\-specific baseline correction, despiking, or smoothing\. For deep neural network architectures, the images are converted to a three\-channel grayscale format and normalized using ImageNet statistics, enabling the pretrained deep neural network backbones to extract localized Raman peak patterns\. The dataset is summarized in Figure[2](https://arxiv.org/html/2610.02224#S1.F2)d and is available on the GitHub page:[https://github\.com/nguyen\-group/HyMLRaman/data](https://github.com/nguyen-group/HyMLRaman/data)\.
### 2\.3Feature Extraction from Deep Neural\-Networks
A comprehensive evaluation of several state\-of\-the\-art ML architectures is conducted to identify an optimal feature extractor for Raman spectral images, including the CNN models \(EfficientNet\-B0, EfficientNet\-B3, and RegNetY\-400M\) and the transformer model \(Vision Transformer ViT\-B16\)\. Here, RegNetY\-400M and EfficientNet\-B0 serve as architectural baselines that probe different depth–width regimes, ensuring that the observed performance trends are attributable to structural advantages rather than mere increases in parameter count\. This comparative design provided a rigorous basis for selecting an optimal backbone for Raman\-specific embeddings\.
To complement the CNN\-based backbones, ViT\-B16 is included as a representative patch\-based self\-attention architecture\. Compared with convolutional networks, Vision Transformers possess weaker built\-in spatial locality biases and model interactions between image patches primarily through self\-attention mechanisms\. For Raman spectral classification, however, chemically informative information is often concentrated in localized vibrational bands and peak structures\. Previous Raman studies have shown that both convolutional and transformer\-based models can learn discriminative spectral representations, although their relative performance depends on the spectral representation and available training data[Wang et al\. \(2024\)](https://arxiv.org/html/2610.02224#bib.bib9);[Rieger et al\. \(2023\)](https://arxiv.org/html/2610.02224#bib.bib15)\. In the present dataset, the convolutional backbones outperform ViT\-B16, suggesting that the locality\-preserving characteristics of CNNs are advantageous for the Raman spectral\-image representation used in this work\.
Across the evaluated architectures, EfficientNet\-B3 achieves the strongest classification performance and is therefore selected as the feature extractor for the subsequent analyses\. Accordingly, the 1536\-dimensional activations obtained from its global average pooling layer are adopted as the unified feature representation for all downstream classifiers\. As shown in Figure[2](https://arxiv.org/html/2610.02224#S1.F2)c, the EfficientNet\-B3 embeddings are visualized using t\-distributed stochastic neighbor embedding \(t\-SNE\)[van der Maaten and Hinton \(2008\)](https://arxiv.org/html/2610.02224#bib.bib29)\. The resulting two\-dimensional projection exhibits six visually distinguishable class regions, suggesting that the learned EfficientNet\-B3 representation contains substantial class\-discriminative information for the six pharmaceutical compounds\.
### 2\.4Machine Learning Classifiers
The 1536\-dimensional EfficientNet\-B3 embeddings are used as inputs to multiple supervised classifiers\. Let𝐱i∈ℝ1536\\mathbf\{x\}\_\{i\}\\in\\mathbb\{R\}^\{1536\}denote the embedding extracted from theii\-th Raman spectral image, and letyi∈\{1,…,M\}y\_\{i\}\\in\\\{1,\\ldots,M\\\}denote the corresponding class label, whereMMis the number of pharmaceutical classes andi=1,…,Ni=1,\\ldots,N\. When required by a downstream classifier, feature standardization is fitted only on the training split within each cross\-validation fold and then applied to the corresponding validation split\. This fold\-wise procedure prevents information leakage during model evaluation\.
For SVM classification, a radial basis function \(RBF\) kernel is employed following the standard support\-vector formulation[Cortes and Vapnik \(1995\)](https://arxiv.org/html/2610.02224#bib.bib20):
f\(𝐱\)=∑i=1NαiyiK\(𝐱i,𝐱\)\+b,f\(\\mathbf\{x\}\)=\\sum\_\{i=1\}^\{N\}\\alpha\_\{i\}y\_\{i\}K\(\\mathbf\{x\}\_\{i\},\\mathbf\{x\}\)\+b,\(1\)where the RBF kernel is defined asK\(𝐱i,𝐱\)=exp\(−γ‖𝐱i−𝐱‖2\)K\(\\mathbf\{x\}\_\{i\},\\mathbf\{x\}\)=\\exp\\\!\\left\(\-\\gamma\\\|\\mathbf\{x\}\_\{i\}\-\\mathbf\{x\}\\\|^\{2\}\\right\)\. Here,𝐱\\mathbf\{x\}is the query embedding to be classified,𝐱i\\mathbf\{x\}\_\{i\}is theii\-th training embedding,αi\\alpha\_\{i\}is the learned coefficient associated with theii\-th support vector,yiy\_\{i\}is the class label of theii\-th training sample, andbbis the bias term\. The parameterγ\\gammacontrols the width of the RBF kernel and thus the locality of the decision boundary\. In the present implementation,γ\\gammais optimized by grid search using the training data\.
For the KNN classifier, the predicted label of a query embedding is determined by majority voting among itskk\-nearest neighbors[Cover and Hart \(1967\)](https://arxiv.org/html/2610.02224#bib.bib22):
y^=mode\(\{yi\}i∈𝒩k\(𝐱\)\),\\hat\{y\}=\\operatorname\{mode\}\\\!\\left\(\\\{y\_\{i\}\\\}\_\{i\\in\\mathcal\{N\}\_\{k\}\(\\mathbf\{x\}\)\}\\right\),\(2\)wherey^\\hat\{y\}is the predicted class label,𝒩k\(𝐱\)\\mathcal\{N\}\_\{k\}\(\\mathbf\{x\}\)denotes the index set of thekk\-nearest training samples to𝐱\\mathbf\{x\}under the selected distance metric, and\{yi\}i∈𝒩k\(𝐱\)\\\{y\_\{i\}\\\}\_\{i\\in\\mathcal\{N\}\_\{k\}\(\\mathbf\{x\}\)\}is the set of class labels associated with those neighbors\. The neighborhood sizekkis selected by cross\-validation using the training data\.
For multinomial logistic regression[Böhning \(1992\)](https://arxiv.org/html/2610.02224#bib.bib23), the posterior probability that a sample belongs to classkkis estimated using the softmax function:
P\(y=k∣𝐱\)=exp\(𝐰kT𝐱\+bk\)∑j=1Kexp\(𝐰jT𝐱\+bj\),P\(y=k\\mid\\mathbf\{x\}\)=\\frac\{\\exp\\\!\\left\(\\mathbf\{w\}\_\{k\}^\{T\}\\mathbf\{x\}\+b\_\{k\}\\right\)\}\{\\sum\_\{j=1\}^\{K\}\\exp\\\!\\left\(\\mathbf\{w\}\_\{j\}^\{T\}\\mathbf\{x\}\+b\_\{j\}\\right\)\},\(3\)whereP\(y=k∣𝐱\)P\(y=k\\mid\\mathbf\{x\}\)is the predicted probability that embedding𝐱\\mathbf\{x\}belongs to classkk,𝐰k\\mathbf\{w\}\_\{k\}is the weight vector associated with classkk, andbkb\_\{k\}is the corresponding bias term\. The denominator sums the unnormalized scores over allKKclasses to produce a valid probability distribution\. Model parameters are estimated withL2L\_\{2\}regularization, and the regularization strength is tuned using the training data\.
Random forest \(RF\) is additionally evaluated as an ensemble\-based classifier operating on the EfficientNet\-B3 embeddings\. Multiple decision trees are constructed from resampled training data and subsets of candidate features, and the final class prediction is obtained by aggregating the predictions of the individual trees\. RF is included to provide a tree\-ensemble baseline with nonlinear decision capability\. XGBoost is also evaluated as a gradient\-boosted tree classifier\. In contrast to RF, where multiple trees contribute to an aggregated ensemble prediction, XGBoost constructs trees sequentially, with successive learners optimized to improve the objective of the preceding ensemble\. Tree\-based ensemble approaches, including RF and XGBoost, have demonstrated strong performance in vibrational\-spectroscopy classification and feature\-learning applications[da Silva et al\. \(2025\)](https://arxiv.org/html/2610.02224#bib.bib30);[Zou et al\. \(2025\)](https://arxiv.org/html/2610.02224#bib.bib18)\.
A multilayer perceptron \(MLP\) is also trained directly on the embedding vectors\. The MLP includes two fully connected hidden layers with 256 and 128 neurons, respectively, each followed by rectified linear unit \(ReLU\) activation and dropout \(p=0\.3p=0\.3\)[Srivastava et al\. \(2014\)](https://arxiv.org/html/2610.02224#bib.bib24)\. The output layer uses softmax activation to generate class probabilities over theKKtarget classes, and the network parameters are optimized using Adam\.
In addition to the classical machine\-learning classifiers, an embedding\-level one\-dimensional CNN is implemented as a neural baseline operating on the same EfficientNet\-B3 feature representation\. In this case, the input is not the raw Raman spectrum but the 1536\-dimensional embedding vector extracted from the Raman spectral image\. Let𝐱i∈ℝ1536\\mathbf\{x\}\_\{i\}\\in\\mathbb\{R\}^\{1536\}denote the input embedding\. The embedding is treated as a one\-dimensional feature sequence and passed through convolutional blocks to capture local dependencies among neighboring embedding components:
𝐅\(ℓ\)=σ\(Conv1D\(𝐅\(ℓ−1\),𝐖\(ℓ\),𝐛\(ℓ\)\)\),𝐅\(0\)=𝐱i,\\mathbf\{F\}^\{\(\\ell\)\}=\\sigma\\left\(\\mathrm\{Conv1D\}\\left\(\\mathbf\{F\}^\{\(\\ell\-1\)\};\\mathbf\{W\}^\{\(\\ell\)\},\\mathbf\{b\}^\{\(\\ell\)\}\\right\)\\right\),\\quad\\mathbf\{F\}^\{\(0\)\}=\\mathbf\{x\}\_\{i\},\(4\)where𝐅\(ℓ−1\)\\mathbf\{F\}^\{\(\\ell\-1\)\}and𝐅\(ℓ\)\\mathbf\{F\}^\{\(\\ell\)\}denote the input and output feature maps of theℓ\\ell\-th convolutional block, respectively, and𝐖\(ℓ\)\\mathbf\{W\}^\{\(\\ell\)\}and𝐛\(ℓ\)\\mathbf\{b\}^\{\(\\ell\)\}are the learnable convolution kernel and bias\. The activation function is denoted byσ\(⋅\)\\sigma\(\\cdot\)\. This embedding\-level CNN provides a neural\-network baseline within the same 1536\-dimensional EfficientNet\-B3 feature space used by the downstream classifiers\.
After the final convolutional block, the extracted representation is mapped to class probabilities as
𝐩^=softmax\(𝐖c𝐳\+𝐛c\),\\hat\{\\mathbf\{p\}\}=\\mathrm\{softmax\}\\left\(\\mathbf\{W\}\_\{c\}\\mathbf\{z\}\+\\mathbf\{b\}\_\{c\}\\right\),\(5\)where𝐳\\mathbf\{z\}is the compact latent representation produced by the convolutional network,𝐩^∈ℝK\\hat\{\\mathbf\{p\}\}\\in\\mathbb\{R\}^\{K\}is the predicted class\-probability vector, andKKis the number of target classes\. The final predicted label is determined asy^=argmaxkp^k\\hat\{y\}=\\arg\\max\_\{k\}\\hat\{p\}\_\{k\}\.
### 2\.5DDPM\-Based Feature\-Embedding Augmentation
We use a DDPM\-based module for feature\-level augmentation in the limited\-data experiments\. The module operates on EfficientNet\-B3 embeddings and does not generate raw Raman spectra\. For each Raman spectral image, the fine\-tuned EfficientNet\-B3 encoder produces a 1536\-dimensional embedding𝐱i∈ℝ1536\\mathbf\{x\}\_\{i\}\\in\\mathbb\{R\}^\{1536\}with class labelyi∈\{1,…,K\}y\_\{i\}\\in\\\{1,\\ldots,K\\\}\. DDPM generation is then performed in a PCA\-reduced latent version of this feature space\. This design follows recent diffusion\-based augmentation strategies for Raman and spectroscopic learning under limited\-data conditions[Yao et al\. \(2025\)](https://arxiv.org/html/2610.02224#bib.bib25), while restricting generation to the learned feature domain rather than the original Raman intensity domain\. Within each cross\-validation fold, all preprocessing and DDPM operations are fitted only on the training split\. The validation fold is not used for standardization, PCA fitting, DDPM training, candidate generation, or filtering\.
The training embeddings are standardized and projected into a PCA latent space[Jolliffe and Cadima \(2016\)](https://arxiv.org/html/2610.02224#bib.bib26):
𝐳i=𝐏⊤\(𝐱i−𝝁tr𝝈tr\),𝐳i∈ℝd,\\mathbf\{z\}\_\{i\}=\\mathbf\{P\}^\{\\top\}\\left\(\\frac\{\\mathbf\{x\}\_\{i\}\-\\boldsymbol\{\\mu\}\_\{\\mathrm\{tr\}\}\}\{\\boldsymbol\{\\sigma\}\_\{\\mathrm\{tr\}\}\}\\right\),\\qquad\\mathbf\{z\}\_\{i\}\\in\\mathbb\{R\}^\{d\},\(6\)where𝝁tr\\boldsymbol\{\\mu\}\_\{\\mathrm\{tr\}\}and𝝈tr\\boldsymbol\{\\sigma\}\_\{\\mathrm\{tr\}\}are computed from the training embeddings,𝐏\\mathbf\{P\}is the PCA projection matrix fitted within the same fold, andd=64d=64\. This PCA\-reduced feature space is used as the input domain for DDPM training and generation\.
The DDPM is trained on the original latent features𝐳0\\mathbf\{z\}\_\{0\}\. Following the standard discrete\-time DDPM formulation[Chang et al\. \(2026\)](https://arxiv.org/html/2610.02224#bib.bib27), the forward diffusion process progressively adds Gaussian noise according to
q\(𝐳t\|𝐳t−1\)=𝒩\(1−βt𝐳t−1,βt𝐈\),q\(\\mathbf\{z\}\_\{t\}\|\\mathbf\{z\}\_\{t\-1\}\)=\\mathcal\{N\}\\left\(\\sqrt\{1\-\\beta\_\{t\}\}\\mathbf\{z\}\_\{t\-1\},\\beta\_\{t\}\\mathbf\{I\}\\right\),\(7\)whereβt\\beta\_\{t\}denotes the variance schedule\. Definingαt=1−βt\\alpha\_\{t\}=1\-\\beta\_\{t\}andα¯t=∏s=1tαs\\bar\{\\alpha\}\_\{t\}=\\prod\_\{s=1\}^\{t\}\\alpha\_\{s\}, the latent feature at timestepttcan be sampled directly from𝐳0\\mathbf\{z\}\_\{0\}as
𝐳t=α¯t𝐳0\+1−α¯tϵ,ϵ∼𝒩\(𝟎,𝐈\)\.\\mathbf\{z\}\_\{t\}=\\sqrt\{\\bar\{\\alpha\}\_\{t\}\}\\mathbf\{z\}\_\{0\}\+\\sqrt\{1\-\\bar\{\\alpha\}\_\{t\}\}\\boldsymbol\{\\epsilon\},\\qquad\\boldsymbol\{\\epsilon\}\\sim\\mathcal\{N\}\(\\mathbf\{0\},\\mathbf\{I\}\)\.\(8\)A class\-conditional denoising networkϵθ\(𝐳t,t,y\)\\boldsymbol\{\\epsilon\}\_\{\\theta\}\(\\mathbf\{z\}\_\{t\},t,y\)is trained to predict the injected noise from the noisy latent feature𝐳t\\mathbf\{z\}\_\{t\}, the timesteptt, and the class labelyy, following the conditional latent\-diffusion paradigm used for Raman data generation[Yao et al\. \(2025\)](https://arxiv.org/html/2610.02224#bib.bib25)\. In our implementation, timestep and class embeddings are concatenated with the noisy latent feature and provided to the denoising network\. The model is optimized using the standard DDPM noise\-prediction objective[Chang et al\. \(2026\)](https://arxiv.org/html/2610.02224#bib.bib27):
ℒDDPM=𝔼𝐳0,y,t,ϵ\[‖ϵ−ϵθ\(𝐳t,t,y\)‖22\]\.\\mathcal\{L\}\_\{\\mathrm\{DDPM\}\}=\\mathbb\{E\}\_\{\\mathbf\{z\}\_\{0\},y,t,\\boldsymbol\{\\epsilon\}\}\\left\[\\left\\\|\\boldsymbol\{\\epsilon\}\-\\boldsymbol\{\\epsilon\}\_\{\\theta\}\(\\mathbf\{z\}\_\{t\},t,y\)\\right\\\|\_\{2\}^\{2\}\\right\]\.\(9\)
After training, the DDPM generates class\-conditioned latent candidates from Gaussian noise\. These candidates are not directly added to the training set\. We first screen them by classifier confidence and nearest\-neighbor consistency\. A balanced logistic\-regression classifier is fitted on the original latent features of the training split\. A generated candidate𝐳~\\tilde\{\\mathbf\{z\}\}conditioned on classccis retained only if
y^\(𝐳~\)=c,P\(y=c\|𝐳~\)≥τ,\\hat\{y\}\(\\tilde\{\\mathbf\{z\}\}\)=c,\\qquad P\(y=c\|\\tilde\{\\mathbf\{z\}\}\)\\geq\\tau,\(10\)whereτ=0\.85\\tau=0\.85\. The candidate must also satisfy a nearest\-neighbor distance constraint:
d\(𝐳~,𝒵c\)=min𝐳j∈𝒵c‖𝐳~−𝐳j‖2≤dcthr,d\(\\tilde\{\\mathbf\{z\}\},\\mathcal\{Z\}\_\{c\}\)=\\min\_\{\\mathbf\{z\}\_\{j\}\\in\\mathcal\{Z\}\_\{c\}\}\\\|\\tilde\{\\mathbf\{z\}\}\-\\mathbf\{z\}\_\{j\}\\\|\_\{2\}\\leq d\_\{c\}^\{\\mathrm\{thr\}\},\(11\)where𝒵c\\mathcal\{Z\}\_\{c\}is the set of original latent features from classcc\. The threshold is computed from the original within\-class nearest\-neighbor distances:
dcthr=λ⋅Percentile95\(\{min𝐳j∈𝒵c,j≠i‖𝐳i−𝐳j‖2\}\),d\_\{c\}^\{\\mathrm\{thr\}\}=\\lambda\\cdot\\mathrm\{Percentile\}\_\{95\}\\left\(\\left\\\{\\min\_\{\\mathbf\{z\}\_\{j\}\\in\\mathcal\{Z\}\_\{c\},\\,j\\neq i\}\\\|\\mathbf\{z\}\_\{i\}\-\\mathbf\{z\}\_\{j\}\\\|\_\{2\}\\right\\\}\\right\),\(12\)withλ=1\.25\\lambda=1\.25\.
The accepted DDPM\-generated features form𝒟DDPM\\mathcal\{D\}\_\{\\mathrm\{DDPM\}\}and are concatenated with the original training features:
𝒟aug=𝒟original∪𝒟DDPM\.\\mathcal\{D\}\_\{\\mathrm\{aug\}\}=\\mathcal\{D\}\_\{\\mathrm\{original\}\}\\cup\\mathcal\{D\}\_\{\\mathrm\{DDPM\}\}\.\(13\)Downstream classifiers are trained on either𝒟original\\mathcal\{D\}\_\{\\mathrm\{original\}\}or𝒟aug\\mathcal\{D\}\_\{\\mathrm\{aug\}\}, and evaluation is performed only on the untouched validation fold\. The effect of DDPM augmentation is evaluated in the low\-data ablation study using 25%, 50%, 75%, and 100% of the training data, with the average numbers of original and accepted DDPM\-generated samples listed in Table S3\.
### 2\.6Cross\-Validation Strategy
A stratified ten\-fold cross\-validation protocol is used to preserve comparable class distributions across folds and to obtain fold\-wise estimates of predictive performance under repeated train–validation partitioning[Varoquaux et al\. \(2017\)](https://arxiv.org/html/2610.02224#bib.bib28)\. In each fold, the classifier is trained on nine folds and evaluated on the remaining fold, and the reported results are averaged over the ten fold\-wise estimates\. Accuracy, macro\-precision, macro\-recall, and macro\-F1 score are used as the main evaluation metrics for multiclass Raman identification\. Confusion matrices and one\-vs\-rest ROC–AUC curves are additionally reported for selected classifiers\. All cross\-validation experiments use a fixed random seed \(SEED = 1337\) to ensure consistent data partitioning\.
### 2\.7Implementation Details
All spectral processing, deep feature extraction, diffusion modeling, and classifier training routines are implemented in Python\. Deep learning models, including EfficientNet, RegNet, and ViT, and the DDPM architecture, are implemented in PyTorch, whereas classical machine\-learning models are implemented in scikit\-learn\. Training is performed on an NVIDIA GPU workstation\. The computational efficiencies are listed in Tables S1 and S2 for NVIDIA GeForce RTX 3060 and 4090\. Hyperparameters such as learning rate, batch size, number of training epochs, and augmentation ratios are selected via preliminary validation experiments\. All random seeds, model configurations, and preprocessing scripts are archived to enable complete reproducibility of the experimental pipeline\.
Figure 3:Top\-1 accuracy comparison between standalone deep learning backbones and classical machine\-learning classifiers trained on EfficientNet\-B3 embeddings\. The orange bar highlights the best\-performing model, SVM, which achieves 96\.31% accuracy\. Deep learning backbones are shown in light gray, while classical machine\-learning classifiers are shown in blue\.
### 2\.8Experimental Raman Measurement
Experimental Raman/SERS measurements are conducted using a Horiba XploRA PLUS Raman system equipped with a 50×\\timesobjective lens and a 532 nm excitation laser, following the measurement protocol reported by Trang et al\.[Trang et al\. \(2023\)](https://arxiv.org/html/2610.02224#bib.bib1)\. Four pharmaceutical compounds, namely paracetamol, tetracycline, ciprofloxacin, and ibuprofen, are experimentally measured as external test samples for evaluating the practical identification capability of the ML\-assisted Raman framework\.
All samples are dried under ambient conditions at room temperature prior to measurement\. The Raman/SERS signals are subsequently collected from the dried sample spots, with the laser focused to an approximately 2μ\\mum spot diameter\. These experimentally measured spectra are independent of the data used for model training and are employed only for the application\-level demonstration of the proposed framework\.
## 3RESULTS AND DISCUSSION
### 3\.1Cross\-Validation Consistency
The stratified ten\-fold split produces nearly identical validation proportions across all folds\. Because the dataset contains 1003 Raman samples, the validation folds contain either 100 or 101 samples, corresponding to a narrow range of 9\.97–10\.07%\. The average validation proportion is 10\.00%, with a standard deviation of only 0\.048%, as shown in Figure S1\. This confirms that the evaluation is not influenced by large fold\-size variation\. More importantly, the stratified design maintains comparable class representation across the ten validation folds\. Therefore, the reported cross\-validation metrics reflect classifier behavior across the full Raman dataset rather than the outcome of a single favorable train–validation split\. All subsequent performance values are reported as averages over the ten validation folds\.
### 3\.2Overall Performance of CNN–ML Classifiers
Figures[3](https://arxiv.org/html/2610.02224#S2.F3)a and[3](https://arxiv.org/html/2610.02224#S2.F3)b show the Top\-1 accuracy of standalone deep learning backbones and classical machine\-learning classifiers trained on EfficientNet\-B3 embeddings, respectively\. Among the standalone CNN/transformer backbones, EfficientNet\-B3 gives the best result, with an accuracy of 89\.60%, while RegNetY, EfficientNet\-B0, and ViT\-B16 achieve lower accuracies of 88\.12%, 86\.63%, and 85\.64%, respectively\. Based on this comparison, EfficientNet\-B3 is selected as the feature extractor for the subsequent hybrid CNN–ML classification pipeline\. In Figure S2, we show the accuracy and loss of the EfficientNet\-B3 backbone as a function of the number of epochs\. The validation accuracy increases rapidly during the early epochs and stabilizes near 89%, while the validation loss remains low after convergence\. Next, we use the EfficientNet\-B3 embeddings as input features for classical classifiers\. The accuracy increases to above 94% for all six downstream classifiers, as shown in Figure[3](https://arxiv.org/html/2610.02224#S2.F3)b\. This indicates that the extracted embeddings form a suitable feature representation for downstream pharmaceutical identification\. SVM achieves the highest accuracy of 96\.31%, followed by ANN, LR, and XGBoost with accuracies of 95\.91%, 95\.61%, and 95\.31%, respectively\. RF and KNN remain slightly lower but still comparable, reaching 94\.91% and 94\.62%\.
Overall, the hybrid CNN–ML configuration performs better than the standalone deep learning backbones in this dataset\. These results suggest that EfficientNet\-B3 is more effective as a feature extractor than as a standalone classifier\. The best performance obtained by SVM further indicates that the EfficientNet\-B3 feature space is well suited to margin\-based classification for multi\-class pharmaceutical identification\.
### 3\.3Baseline Performance and Low\-Data DDPM Ablation
Table 1:Baseline performance of the hybrid EfficientNet\-B3–ML classifiers without DDPM augmentation, in which ML includes SVM, ANN, LR, XGB, RF, KNN, and CNN models\.Hybrid ML modelAcc\. \(%\)Prec\. \(%\)Rec\. \(%\)F1 \(%\)Acc\. std\.F1 std\.EfficientNet\-B3–SVM96\.3196\.5796\.3596\.362\.142\.12EfficientNet\-B3–ANN95\.9196\.1995\.9195\.931\.611\.61EfficientNet\-B3–LR95\.6195\.8695\.5895\.622\.142\.15EfficientNet\-B3–XGB95\.3195\.6995\.4395\.421\.851\.86EfficientNet\-B3–RF94\.9195\.2694\.9994\.971\.601\.55EfficientNet\-B3–KNN94\.6295\.0394\.6494\.661\.751\.77EfficientNet\-B3–CNN92\.6292\.9592\.4592\.532\.462\.59
The hybrid EfficientNet\-B3–ML results provide the reference performance before introducing the DDPM augmentation branch\. As shown in Table[1](https://arxiv.org/html/2610.02224#S3.T1), SVM achieves the strongest baseline performance on the original 1536\-dimensional EfficientNet\-B3 embeddings, with an accuracy of 96\.31% and a macro\-F1 score of 96\.36%\. ANN and LR also perform strongly, reaching accuracies of 95\.91% and 95\.61%, respectively, followed by XGBoost at 95\.31%\. RF and KNN remain slightly lower but still comparable, with accuracies of 94\.91% and 94\.62%\. In comparison, the embedding\-level CNN baseline trained on the same EfficientNet\-B3 feature representation reaches 92\.62% accuracy and 92\.53% macro\-F1 score, which is lower than all classical machine\-learning classifiers trained on EfficientNet\-B3 embeddings\. This result supports using EfficientNet\-B3 as a feature extractor, followed by a separate downstream classifier for final decision\-making\.
For the strongest classifiers, accuracy, macro\-precision, macro\-recall, and macro\-F1 remain close to each other\. This indicates that the reported performance is not driven by a single dominant class, but is maintained across the six pharmaceutical compounds\. Among the tested classifiers, the hybrid EfficientNet\-B3–SVM provides the strongest baseline and therefore serves as the main reference for the overall classification framework\.
Table 2:Low\-data ablation of DDPM\-based feature augmentation using PCA\-reduced EfficientNet\-B3 latent features\. Accuracy and macro\-F1 values are reported as mean percentages over stratified ten\-fold cross\-validation\. PositiveΔ\\Deltavalues indicate improvement after DDPM\-based feature augmentation\.Frac\.ModelOriginal Acc\.DDPM Acc\.𝚫\\boldsymbol\{\\Delta\}Acc\.Original F1DDPM F1𝚫\\boldsymbol\{\\Delta\}F125%KNN93\.61694\.115\+0\.49993\.62894\.154\+0\.52625%SVM94\.51094\.811\+0\.30194\.58294\.861\+0\.27925%RF93\.71593\.714\-0\.00193\.73793\.756\+0\.01925%LR94\.31194\.212\-0\.09994\.35694\.235\-0\.12125%XGB93\.11992\.919\-0\.20093\.17992\.902\-0\.27725%ANN94\.81094\.210\-0\.60094\.83894\.225\-0\.61350%KNN93\.91894\.713\+0\.79593\.95994\.807\+0\.84850%SVM95\.51195\.410\-0\.10195\.59295\.454\-0\.13850%RF93\.91593\.815\-0\.10093\.98793\.809\-0\.17850%LR94\.01293\.813\-0\.19994\.07493\.865\-0\.20950%ANN94\.81394\.514\-0\.29994\.85994\.604\-0\.25650%XGB93\.21492\.918\-0\.29693\.30792\.882\-0\.42575%LR94\.01594\.315\+0\.30094\.02894\.350\+0\.32275%KNN94\.31794\.514\+0\.19794\.42294\.569\+0\.14675%SVM95\.51495\.612\+0\.09895\.57995\.653\+0\.07475%ANN95\.21195\.014\-0\.19795\.24695\.057\-0\.18875%XGB94\.11493\.415\-0\.69994\.20093\.409\-0\.79175%RF94\.91094\.113\-0\.79795\.01994\.172\-0\.847100%SVM95\.91296\.012\+0\.10095\.94996\.035\+0\.086100%RF94\.81294\.812\+0\.00094\.86894\.880\+0\.012100%LR94\.51894\.316\-0\.20294\.47094\.263\-0\.208100%KNN95\.21495\.014\-0\.20095\.24895\.017\-0\.231100%XGB94\.41294\.013\-0\.39994\.46094\.047\-0\.413100%ANN95\.81394\.715\-1\.09895\.81394\.655\-1\.158
In Table[2](https://arxiv.org/html/2610.02224#S3.T2), we summarize the low\-data ablation results of the DDPM branch\. In this case, the 1536\-dimensional EfficientNet\-B3 embeddings are first standardized and reduced to a 64\-dimensional PCA latent space within each fold\. Classifiers trained only with original PCA\-reduced features are then compared with classifiers trained using original latent features together with filtered DDPM\-generated latent samples\. The results show that the effect of DDPM augmentation is selective rather than uniform, depending on both the training\-data fraction and the downstream classifier\.
At the 25% training fraction, KNN and SVM show the clearest positive changes\. KNN accuracy increases from 93\.616% to 94\.115%, while its macro\-F1 score increases from 93\.628% to 94\.154%\. SVM also improves from 94\.510% to 94\.811% accuracy and from 94\.582% to 94\.861% macro\-F1\. In contrast, LR shows a slight decrease after augmentation at the same fraction\. At the 50% training fraction, KNN again shows the largest improvement, with accuracy increasing by 0\.795 percentage points and macro\-F1 increasing by 0\.848 percentage points\. This suggests that the accepted DDPM\-generated latent samples are particularly helpful for KNN when the original feature distribution is still sparsely sampled\.
At higher training fractions, the effect becomes less pronounced\. In the 75% setting, LR, KNN, and SVM show small positive gains, with accuracy improvements of 0\.300, 0\.197, and 0\.098 percentage points, respectively\. With the full training set, SVM improves only slightly by 0\.100 percentage points, whereas LR and KNN decrease slightly after augmentation\. This trend indicates that DDPM\-based augmentation is more useful when original training samples are limited, while its added value becomes weaker once the original latent distribution is better represented\.
Overall, the original baseline and DDPM ablation results support two main findings\. First, SVM is the strongest CNN–ML baseline on the original EfficientNet\-B3 embeddings\. Second, DDPM\-generated features provide selective low\-data benefits in the PCA\-reduced latent space rather than a universal improvement across classifiers\. The most consistent positive effect appears for KNN under reduced training\-data fractions, with smaller gains for SVM in selected settings\. Therefore, DDPM is best interpreted as an auxiliary feature\-augmentation module for sparse\-data conditions, not as a replacement for the original CNN–ML baseline\.
Figure 4:t\-SNE visualization of original and filtered DDPM\-generated latent features under the 25% training\-data setting\. The original samples are shown as circles, whereas DDPM\-generated samples are shown as cross markers\. The synthetic samples are generated in the 64\-dimensional PCA\-reduced EfficientNet\-B3 feature space and retained after classifier\-confidence and nearest\-neighbor filtering\.
### 3\.4Feature\-Space Consistency of DDPM\-Generated Samples
In Figure[4](https://arxiv.org/html/2610.02224#S3.F4), we show the t\-SNE projection of original and DDPM\-generated latent features under the 25% training\-data setting\. For this visualization, we standardize the 1536\-dimensional EfficientNet\-B3 embeddings and reduce them to a 64\-dimensional PCA latent space before DDPM training\. The plotted data include 225 original training samples and 154 filtered DDPM\-generated samples\. As shown in Figure[4](https://arxiv.org/html/2610.02224#S3.F4), most accepted DDPM\-generated samples lie within or close to the class regions formed by the original samples\. This pattern is consistent with the confidence\-based and nearest\-neighbor filtering strategy, which removes generated candidates that deviate strongly from the original training distribution\. Therefore, the DDPM samples are interpreted as additional local latent candidates rather than synthetic Raman spectra\.
This visualization serves as a qualitative check of feature\-space consistency\. The proximity between original and DDPM\-generated samples in the t\-SNE map does not, by itself, demonstrate a performance gain\. The quantitative effect of DDPM augmentation is evaluated separately through the low\-data ablation results in Table[2](https://arxiv.org/html/2610.02224#S3.T2)\. Together, the t\-SNE result and the ablation table support the interpretation that the DDPM branch can provide useful additional local samples under sparse\-data conditions, particularly for neighborhood\-sensitive classifiers such as KNN\.
### 3\.5Class\-Level Classification and Discrimination Performance
In Figures[5](https://arxiv.org/html/2610.02224#S3.F5)a\-[5](https://arxiv.org/html/2610.02224#S3.F5)g, we provide an overview of the averaged confusion matrices for the embedding\-level CNN baseline and the hybrid CNN–ML classifiers, where CNN is the EfficientNet\-B3 model and ML includes ANN, RF, XGBoost, SVM, KNN, and LR models, respectively\. The matrices are normalized on a per\-class basis; therefore, each diagonal entry represents the recall of the corresponding pharmaceutical class under stratified ten\-fold cross\-validation\.
Figure 5:Averaged confusion matrices of the embedding\-level CNN baseline and hybrid CNN–ML classifiers under stratified ten\-fold cross\-validation, where CNN is the EfficientNet\-B3 model and ML includes ANN, RF, XGBoost, SVM, KNN, and LR models\. Values are reported as class\-wise recall percentages\. Class labels denote amoxicillin \(AMX\), chloramphenicol \(CHL\), ciprofloxacin \(CIP\), ibuprofen \(IBU\), paracetamol \(PAR\), and tetracycline \(TET\)\.The hybrid CNN–ML classifiers generally exhibit stronger diagonal dominance than the CNN baseline\. The CNN model still provides reasonable class\-level identification, with recall values ranging from 86% for ibuprofen to 96% for amoxicillin\. However, its off\-diagonal errors are more pronounced, particularly for ibuprofen and paracetamol\. This pattern is consistent with the lower aggregate performance of the CNN baseline reported in Table[1](https://arxiv.org/html/2610.02224#S3.T1)\. In contrast, the hybrid classifiers achieve higher class\-wise recall for most compounds, indicating that the EfficientNet\-B3 embeddings provide a more discriminative representation when they are coupled with an independent downstream classifier\.
Figure 6:Class\-level performance of the best\-performing EfficientNet\-B3–support vector machine \(SVM\) classifier under stratified ten\-fold cross\-validation\. \(a\) Class\-normalized confusion matrix, with values reported as class\-wise recall percentages\. \(b\) One\-vs\-rest ROC curves for the six pharmaceutical classes, together with the micro\-averaged ROC curve and corresponding AUC values\.To examine representative decision mechanisms in greater detail, we calculate the confusion matrices and one\-vs\-rest ROC–AUC curves of SVM \(see Figures[6](https://arxiv.org/html/2610.02224#S3.F6)a\-[6](https://arxiv.org/html/2610.02224#S3.F6)b\), ANN, LR, XGBoost, RF, and KNN \(see Figures S3a\-S3j\)\. These classifiers represent margin\-based, ensemble\-based, and distance\-based decision principles, respectively\. Among the six ML classifiers, SVM demonstrates the most balanced class\-level behavior, with high recall across all six compounds and a minimum recall of 94\.0% for ibuprofen, as shown in Figure[6](https://arxiv.org/html/2610.02224#S3.F6)a\. Its remaining errors are concentrated in a small number of class pairs, while the other classes retain recall values above 95%\. LR \(in Figure S3b\) and XGBoost \(in Figure S3c\) show a similarly strong diagonal pattern, although slightly larger off\-diagonal entries appear for paracetamol and ciprofloxacin\-related predictions\. ANN \(in Figure S3a\) and KNN \(in Figure S3e\) remain competitive but exhibit more visible confusion between ibuprofen and paracetamol, with a fraction of ibuprofen samples assigned to the paracetamol class\. RF \(in Figure S3d\) performs better for chloramphenicol but worse for amoxicillin, ibuprofen, and paracetamol\.
The ROC–AUC results reinforce the patterns observed in the confusion matrices\. SVM achieves class\-wise AUC values ranging from 0\.995 to 0\.999, together with a micro\-averaged AUC of 0\.998, as shown in Figure[6](https://arxiv.org/html/2610.02224#S3.F6)b\. ANN, LR, XGBoost, and RF \(in Figures S3f, S3g, S3h, and S3i, respectively\) provide similarly strong discrimination, with class\-wise AUC values from 0\.995 to 0\.999 and a micro\-averaged AUC of 0\.997\-0\.998\. These results indicate that the EfficientNet\-B3 feature representation clearly separates each target pharmaceutical class from the remaining classes for both margin\-based and ensemble\-based classifiers\. KNN \(see Figure S3j\) also achieves high class\-wise separability, although its ROC performance remains slightly lower than that of other ML models\. Its micro\-averaged AUC reaches 0\.989, while the lowest class\-wise AUC values occur for ibuprofen and paracetamol, at 0\.981 and 0\.989, respectively\. This behavior is consistent with the corresponding confusion matrix, in which these two classes show the most prominent residual overlap\.
Overall, the confusion\-matrix and ROC–AUC analyses provide consistent evidence that the hybrid CNN–ML classifiers maintain strong discrimination across all six pharmaceutical compounds\. SVM provides the strongest and most balanced overall baseline, while ANN, LR, XGBoost, and RF remain closely comparable\. KNN also performs competitively but is more sensitive to local overlap between spectrally similar samples, particularly ibuprofen and paracetamol\. These findings demonstrate that the EfficientNet\-B3 feature representation supports reliable class\-wise identification and high one\-vs\-rest separability, rather than producing high aggregate accuracy alone\.
### 3\.6Application\-Level Demonstration Using a Raman Pharmaceutical Analyzer
To examine the practical applicability of the proposed framework beyond offline model evaluation, we integrate the trained EfficientNet\-B3 classifier into a custom Raman Pharmaceutical Analyzer\. The application receives a Raman spectrum as input and returns the predicted compound class, the corresponding probability distribution, and a spectral response map for interpretation\.
Figure 7:Application\-level demonstration using the deployed Raman Pharmaceutical Analyzer for an independently measured paracetamol \(PAR\) sample\. The interface displays the input Raman spectrum, the model\-attention visualization, and the predicted class\-probability distribution\. The sample is correctly identified as PAR with a prediction confidence of 98\.0%\. Additional representative results for CIP, IBU, and TET are provided in Figure S4 of the Supporting Information\.In Figure[7](https://arxiv.org/html/2610.02224#S3.F7), we show representative inference results for the paracetamol case\. Similar results for other compounds, including tetracycline, ciprofloxacin, and ibuprofen, are shown in Figure S4\. These examples cover both antibiotic and non\-antibiotic pharmaceutical compounds in the dataset\. For each test case, the application displays the raw Raman spectrum, the spectral response map highlighting informative regions, and the predicted class probabilities\. In the illustrated examples, the target compounds are correctly identified with high confidence, with prediction probabilities exceeding 98%\. It is noted that the Raman spectra used for testing the application are not included in the training dataset and were obtained from independent experiments\.
The highlighted spectral regions provide a qualitative indication of the Raman features that contribute to the model decision\. These regions are not used as independent chemical evidence, but they help show that the inference output is associated with structured spectral information rather than only a final class label\. This behavior is consistent with the class\-level confusion matrix and ROC–AUC analyses presented earlier, where the strongest CNN–ML classifiers show high recall and stable class\-wise separability\.
Overall, the Raman Pharmaceutical Analyzer serves as an application\-level demonstration of the proposed framework, showing that the trained EfficientNet\-B3 classifier can perform direct inference on experimentally measured Raman spectral images and provide interpretable outputs, including the predicted compound class, confidence distribution, and spectral response map\. Although this application does not replace broader external validation on newly collected samples, it demonstrates the feasibility of embedding a trained Raman image classifier into an interactive workflow for rapid pharmaceutical identification\.
## 4CONCLUSION
This study presents HyMLRaman, a hybrid Raman identification framework that combines CNN\-derived spectral embeddings with classical machine\-learning classifiers for pharmaceutical compound classification\. Among the evaluated deep feature extractors, EfficientNet\-B3 provides the most effective representation for downstream classification\. When its 1536\-dimensional embeddings are coupled with classical classifiers, the hybrid CNN–ML pipeline clearly outperforms the corresponding deep\-learning baselines\. In particular, SVM achieves the strongest overall baseline performance, with 96\.31% accuracy and a macro\-F1 score of 96\.36% under stratified ten\-fold cross\-validation\.
The DDPM module is introduced as a feature\-level augmentation component for limited\-data learning\. Rather than generating raw Raman spectra, the model operates in a PCA\-reduced EfficientNet\-B3 latent space and produces class\-conditioned synthetic feature candidates that are retained only after confidence\-based and nearest\-neighbor filtering\. The low\-data ablation results show that DDPM augmentation provides selective benefits rather than uniform improvements across all classifiers\. The clearest gains are observed for KNN under reduced training fractions, with smaller improvements for SVM in selected settings\. These findings indicate that DDPM is most useful as an auxiliary low\-data support module, particularly when the original feature distribution is sparsely sampled\.
Class\-level confusion matrices and ROC–AUC analyses further show that the strongest CNN–ML classifiers maintain stable discrimination across the six pharmaceutical compounds\. Five ML models, including SVM, ANN, LR, XGBoost, and RF, exhibit high class\-wise AUC values and strong diagonal recall patterns, while KNN remains competitive but is more affected by residual overlap between spectrally similar compounds such as ibuprofen and paracetamol\. These results demonstrate that the proposed feature representation supports reliable class\-wise identification, not only high aggregate accuracy\.
Finally, the Raman Pharmaceutical Analyzer provides an application\-level proof\-of\-concept for deploying the trained model in an interactive Raman analysis workflow\. The illustrated inference examples show high\-confidence predictions together with spectral response maps that help relate the model output to informative Raman regions\. Although further validation on newly collected external samples is still required before practical deployment, the present results show that HyMLRaman provides a promising and interpretable route for rapid Raman\-based pharmaceutical screening\.
## Declaration of competing interest
The authors declare that they have no known competing financial interests or personal relationships that could have appeared to influence the work reported in this paper\.
## Acknowledgements
This research is funded by Ho Chi Minh City Department of Science and Technology, Vietnam under contract number 25/2025/HD\-QKHCN; through the Project for Developing Mechanisms to Foster the Establishment and Growth of International\-Standard Centers of Excellence \(CoE Project\) as per Decision No\. 5721/QD\-UBND dated December 11, 2023, of the People Committee of Ho Chi Minh City\.
## Supplementary Information
The Supporting Information contains additional details on the computational efficiency of the HyMLRaman framework and DDPM\-based augmentation; fold\-wise validation proportions and dataset class distributions; class\-level confusion matrices and ROC–AUC analyses of the additional CNN–ML classifiers; and representative outputs of the HyMLRaman prediction interface\.
## Data availability
## References
- Binhet al\.\(2025\)Q\. T\. T\. Binh, T\. Phuoc, X\. Hai, T\. B\. Phan, V\. T\. H\. Thu, and N\. T\. HungRapid machine learning\-driven detection of pesticides and dyes using raman spectroscopy\.Cited by:[§1](https://arxiv.org/html/2610.02224#S1.p2.1)\.
- Böhning \(1992\)D\. BöhningMultinomial logistic regression algorithm\.Annals of the Institute of Statistical Mathematics44,pp\. 197–200\.External Links:[Document](https://dx.doi.org/10.1007/BF00048682)Cited by:[§2\.4](https://arxiv.org/html/2610.02224#S2.SS4.p4.1)\.
- Chandraet al\.\(2024\)A\. Chandra, V\. Kumar, U\. C\. Garnaik, R\. Dada, I\. Qamar, V\. K\. Goel, and S\. AgarwalUnveiling the molecular secrets: a comprehensive review of raman spectroscopy in biological research\.ACS Omega9,pp\. 50049–50063\.External Links:[Document](https://dx.doi.org/10.1021/acsomega.4c00591),ISSN 2470\-1343Cited by:[§1](https://arxiv.org/html/2610.02224#S1.p1.1)\.
- Changet al\.\(2026\)Z\. Chang, G\. A\. Koulieris, H\. J\. Chang, and H\. P\. H\. ShumOn the design fundamentals of diffusion models: a survey\.Pattern Recognition169,pp\. 111934\.External Links:[Document](https://dx.doi.org/10.1016/j.patcog.2025.111934)Cited by:[§2\.5](https://arxiv.org/html/2610.02224#S2.SS5.p3.1),[§2\.5](https://arxiv.org/html/2610.02224#S2.SS5.p3.3)\.
- Cortes and Vapnik \(1995\)C\. Cortes and V\. VapnikSupport\-vector networks\.Machine Learning20,pp\. 273–297\.External Links:[Document](https://dx.doi.org/10.1007/BF00994018),ISSN 0885\-6125Cited by:[§2\.4](https://arxiv.org/html/2610.02224#S2.SS4.p2.1)\.
- Cover and Hart \(1967\)T\. M\. Cover and P\. E\. HartNearest neighbor pattern classification\.IEEE Transactions on Information Theory13\(1\),pp\. 21–27\.External Links:[Document](https://dx.doi.org/10.1109/TIT.1967.1053964)Cited by:[§2\.4](https://arxiv.org/html/2610.02224#S2.SS4.p3.1)\.
- da Silvaet al\.\(2025\)L\. P\. da Silva, M\. D\. L\. Oliveira, and J\. E\. L\. VillaA comparison of decision tree\-based algorithms for food discrimination using vibrational spectroscopy\.Food Chemistry488,pp\. 144909\.External Links:[Document](https://dx.doi.org/10.1016/j.foodchem.2025.144909)Cited by:[§2\.4](https://arxiv.org/html/2610.02224#S2.SS4.p5.1)\.
- Gyesiet al\.\(2022\)J\. N\. Gyesi, B\. A\. Nyaaba, G\. Darko, F\. C\. Mills\-Robertson, K\. Miezah, N\. A\. Acheampong, F\. Frimpong, G\. Gyimah, B\. Quansah, and L\. S\. BorquayeOccurrence of pharmaceutical residues and antibiotic\-resistant bacteria in water and sediments from major reservoirs \(owabi and barekese dams\) in ghana\.Journal of Chemistry2022,pp\. 1–14\.External Links:[Document](https://dx.doi.org/10.1155/2022/1802204),ISSN 2090\-9071Cited by:[§1](https://arxiv.org/html/2610.02224#S1.p1.1)\.
- Jiaoet al\.\(2021\)W\. Jiao, X\. Hao, and C\. QinThe image classification method with cnn\-xgboost model based on adaptive particle swarm optimization\.Information12,pp\. 156\.External Links:[Document](https://dx.doi.org/10.3390/info12040156),ISSN 2078\-2489Cited by:[§1](https://arxiv.org/html/2610.02224#S1.p2.1)\.
- Jolliffe and Cadima \(2016\)I\. T\. Jolliffe and J\. CadimaPrincipal component analysis: a review and recent developments\.Philosophical Transactions of the Royal Society A: Mathematical, Physical and Engineering Sciences374\(2065\),pp\. 20150202\.External Links:[Document](https://dx.doi.org/10.1098/rsta.2015.0202)Cited by:[§2\.5](https://arxiv.org/html/2610.02224#S2.SS5.p2.1)\.
- Liuet al\.\(2026\)Y\. Liu, Y\. Wu, J\. Wang, J\. Qi, C\. Zhou, and Y\. XueRecent advances in raman spectral classification with machine learning\.Sensors26,pp\. 341\.External Links:[Document](https://dx.doi.org/10.3390/s26010341),ISSN 1424\-8220Cited by:[§1](https://arxiv.org/html/2610.02224#S1.p1.1),[§1](https://arxiv.org/html/2610.02224#S1.p2.1)\.
- Liuet al\.\(2025\)Y\. Liu, S\. Chen, X\. Xiong, Z\. Wen, L\. Zhao, B\. Xu, Q\. Guo, J\. Xia, and J\. PeiArtificial intelligence guided raman spectroscopy in biomedicine: applications and prospects\.Journal of Pharmaceutical Analysis15,pp\. 101271\.External Links:[Document](https://dx.doi.org/10.1016/j.jpha.2025.101271),ISSN 20951779Cited by:[§1](https://arxiv.org/html/2610.02224#S1.p1.1),[§1](https://arxiv.org/html/2610.02224#S1.p2.1)\.
- Luoet al\.\(2022\)R\. Luo, J\. Popp, and T\. BocklitzDeep learning for raman spectroscopy: a review\.Analytica3,pp\. 287–301\.External Links:[Document](https://dx.doi.org/10.3390/analytica3030020),ISSN 2673\-4532Cited by:[§1](https://arxiv.org/html/2610.02224#S1.p2.1)\.
- Maghsodianet al\.\(2022\)Z\. Maghsodian, A\. M\. Sanati, T\. Mashifana, M\. Sillanpää, S\. Feng, T\. Nhat, and B\. RamavandiOccurrence and distribution of antibiotics in the water, sediment, and biota of freshwater and marine environments: a review\.Antibiotics11,pp\. 1461\.External Links:[Document](https://dx.doi.org/10.3390/antibiotics11111461),ISSN 2079\-6382Cited by:[§1](https://arxiv.org/html/2610.02224#S1.p1.1)\.
- Patelet al\.\(2019\)M\. Patel, R\. Kumar, K\. Kishor, T\. Mlsna, C\. U\. Pittman, and D\. MohanPharmaceuticals of emerging concern in aquatic systems: chemistry, occurrence, effects, and removal methods\.Chemical Reviews119,pp\. 3510–3673\.External Links:[Document](https://dx.doi.org/10.1021/acs.chemrev.8b00299),ISSN 0009\-2665Cited by:[§1](https://arxiv.org/html/2610.02224#S1.p1.1)\.
- Pochevilleet al\.\(2025\)A\. Pocheville, I\. Uria, P\. España, and S\. ArnaizRaman spectroscopy integrated with machine learning techniques to improve industrial sorting of waste electric and electronic equipment \(weee\) plastics\.Journal of Environmental Management373,pp\. 123897\.External Links:[Document](https://dx.doi.org/10.1016/j.jenvman.2024.123897),ISSN 03014797Cited by:[§1](https://arxiv.org/html/2610.02224#S1.p1.1),[§1](https://arxiv.org/html/2610.02224#S1.p2.1)\.
- Rahmanet al\.\(2024\)M\. H\. Rahman, R\. Sikder, M\. Tripathi, M\. Zahan, T\. Ye, E\. G\. Z\., B\. K\. Jasthi, A\. B\. Dalton, and V\. GadhamshettyMachine learning\-assisted raman spectroscopy and sers for bacterial pathogen detection: clinical, food safety, and environmental applications\.Chemosensors12,pp\. 140\.External Links:[Document](https://dx.doi.org/10.3390/chemosensors12070140),ISSN 2227\-9040Cited by:[§1](https://arxiv.org/html/2610.02224#S1.p2.1)\.
- Rashidiet al\.\(2025\)M\. Rashidi, Z\. Kianpoor, H\. Wu, X\. Wang, J\. Liu, N\. Maeda, and X\. ZhangSurface\-enhanced raman spectroscopy–machine learning for multiplex naphthenic acid profiling in water\.Analytical Chemistry97,pp\. 27674–27687\.External Links:[Document](https://dx.doi.org/10.1021/acs.analchem.5c04463),ISSN 0003\-2700Cited by:[§1](https://arxiv.org/html/2610.02224#S1.p2.1)\.
- Riegeret al\.\(2023\)L\. H\. Rieger, M\. Wilson, T\. Vegge, and E\. FloresUnderstanding the patterns that neural networks learn from chemical spectra\.Digital Discovery2,pp\. 1957–1968\.External Links:[Document](https://dx.doi.org/10.1039/D3DD00203A),ISSN 2635\-098XCited by:[§1](https://arxiv.org/html/2610.02224#S1.p2.1),[§2\.3](https://arxiv.org/html/2610.02224#S2.SS3.p2.1)\.
- Srivastavaet al\.\(2014\)N\. Srivastava, G\. Hinton, A\. Krizhevsky, I\. Sutskever, and R\. SalakhutdinovDropout: a simple way to prevent neural networks from overfitting\.Journal of Machine Learning Research15\(56\),pp\. 1929–1958\.Cited by:[§2\.4](https://arxiv.org/html/2610.02224#S2.SS4.p6.1)\.
- Sunilet al\.\(2024\)M\. Sunil, N\. Pallikkavaliyaveetil, MIthun\. N, A\. Gopinath, S\. Chidangil, S\. Kumar, and J\. LukoseMachine learning assisted raman spectroscopy: a viable approach for the detection of microplastics\.Journal of Water Process Engineering60,pp\. 105150\.External Links:[Document](https://dx.doi.org/10.1016/j.jwpe.2024.105150),ISSN 22147144Cited by:[§1](https://arxiv.org/html/2610.02224#S1.p2.1)\.
- Tranget al\.\(2023\)T\. N\. Q\. Trang, N\. T\. P\. Trinh, N\. T\. G\. Bao, and V\. T\. H\. ThuHotspot\-type silver\-polymers grafted nanocellulose paper with analyte enrichment as flexible plasmonic sensors for highly sensitive sers sensing\.J\. Sci\.: Adv\. Mater\. Dev\.8\(3\),pp\. 100597\.Cited by:[§2\.8](https://arxiv.org/html/2610.02224#S2.SS8.p1.1)\.
- van der Maaten and Hinton \(2008\)L\. van der Maaten and G\. HintonVisualizing data using t\-sne\.Journal of Machine Learning Research9,pp\. 2579–2605\.Cited by:[§2\.3](https://arxiv.org/html/2610.02224#S2.SS3.p3.1)\.
- Varoquauxet al\.\(2017\)G\. Varoquaux, P\. R\. Raamana, D\. A\. Engemann, A\. Hoyos\-Idrobo, Y\. Schwartz, and B\. ThirionAssessing and tuning brain decoders: cross\-validation, caveats, and guidelines\.NeuroImage145,pp\. 166–179\.External Links:[Document](https://dx.doi.org/10.1016/j.neuroimage.2016.10.038)Cited by:[§2\.6](https://arxiv.org/html/2610.02224#S2.SS6.p1.1)\.
- Wanget al\.\(2024\)Z\. Wang, Y\. Li, J\. Zhai, S\. Yang, B\. Sun, and P\. LiangDeep learning\-based raman spectroscopy qualitative analysis algorithm: a convolutional neural network and transformer approach\.Talanta275,pp\. 126138\.External Links:[Document](https://dx.doi.org/10.1016/j.talanta.2024.126138),ISSN 00399140Cited by:[§1](https://arxiv.org/html/2610.02224#S1.p2.1),[§2\.3](https://arxiv.org/html/2610.02224#S2.SS3.p2.1)\.
- Wanget al\.\(2025\)Z\. Wang, J\. C\. Ranasinghe, D\. C\. Y\. Chan, A\. Gomm, R\. E\. Tanzi, C\. Zhang, N\. Zhang, and S\. HuangMachine learning\-enhanced hyperspectral raman imaging for label\-free molecular atlas of alzheimer’s brain\.ACS Applied Materials & Interfaces\.External Links:[Document](https://dx.doi.org/10.1021/acsami.5c22623),ISSN 1944\-8244Cited by:[§1](https://arxiv.org/html/2610.02224#S1.p2.1)\.
- Wójciket al\.\(2026\)S\. Wójcik, M\. Król, and P\. StochMachine learning\-assisted raman spectroscopy for enhanced plastic identification\.Spectrochimica Acta Part A: Molecular and Biomolecular Spectroscopy347,pp\. 126973\.External Links:[Document](https://dx.doi.org/10.1016/j.saa.2025.126973),ISSN 13861425Cited by:[§1](https://arxiv.org/html/2610.02224#S1.p2.1)\.
- Yaoet al\.\(2025\)H\. Yao, W\. Luo, A\. Gao, T\. Zhou, and X\. WangDiffRaman: a conditional latent denoising diffusion probabilistic model for enhancing bacterial identification via raman spectra generation under limited data\.Analytica Chimica Acta1372,pp\. 344372\.External Links:[Document](https://dx.doi.org/10.1016/j.aca.2025.344372)Cited by:[§2\.5](https://arxiv.org/html/2610.02224#S2.SS5.p1.1),[§2\.5](https://arxiv.org/html/2610.02224#S2.SS5.p3.3)\.
- Zareiet al\.\(2023\)M\. Zarei, N\. V\. Solomatova, H\. Aghaei, A\. Rothwell, J\. Wiens, L\. Melo, T\. G\. Good, S\. Shokatian, and E\. GrantMachine learning analysis of raman spectra to quantify the organic constituents in complex organic–mineral mixtures\.Analytical Chemistry95,pp\. 15908–15916\.External Links:[Document](https://dx.doi.org/10.1021/acs.analchem.3c02348),ISSN 0003\-2700Cited by:[§1](https://arxiv.org/html/2610.02224#S1.p2.1)\.
- Zouet al\.\(2025\)X\. Zou, Q\. Wang, Y\. Chen, J\. Wang, S\. Xu, Z\. Zhu, C\. Yan, P\. Shan, S\. Wang, and Y\. FuFusion of convolutional neural network with xgboost feature extraction for predicting multi\-constituents in corn using near infrared spectroscopy\.Food Chemistry463,pp\. 141053\.External Links:[Document](https://dx.doi.org/10.1016/j.foodchem.2024.141053),ISSN 03088146Cited by:[§1](https://arxiv.org/html/2610.02224#S1.p2.1),[§2\.4](https://arxiv.org/html/2610.02224#S2.SS4.p5.1)\.Similar Articles
Machine Learning for Biomedical Raman Spectroscopy: From Spectral Acquisition to Clinical Translation
This review examines the role of machine learning across the biomedical Raman spectroscopy pipeline, from preprocessing and signal correction to clinical translation, highlighting barriers and future directions for reliable Raman-AI systems.
Sharpness-Aware Minimization (SAM) Improves Classification Accuracy of Bacterial Raman Spectral Data Enabling Portable Diagnostics
This paper demonstrates the use of Sharpness-Aware Minimization (SAM) to enhance the generalization of machine learning models for classifying bacterial Raman spectral data, improving accuracy by up to 10.5% and advancing portable diagnostic tools for antimicrobial resistance.
Multi-Scale Feature Attention Network for Polymer Classification using THz Dual-Comb Spectroscopy
This paper introduces the Multi-Scale Feature Attention Network (MSFAN), a deep learning architecture for classifying 12 types of polymers using THz Dual-Comb Spectroscopy, achieving 85.2% accuracy and outperforming state-of-the-art models.
Machine Learning Modeling for Real-Time Melt Pool Monitoring in Laser Powder Bed Fusion Additive Manufacturing: A Hybrid Approach
This paper presents a hybrid machine learning approach for real-time melt pool monitoring in laser powder bed fusion additive manufacturing, combining EfficientNetB0 feature extraction with Random Forest classification to achieve high accuracy and sub-millisecond inference time.
Biologically Informed Representation Learning for Robust Cross-Center Generalization of MALDI-TOF Mass Spectrometry
Introduces DALMA, a probabilistic representation learning framework that uses biological supervision to improve cross-center generalization of MALDI-TOF mass spectrometry models for clinical microbiology tasks like microbial identification and antimicrobial resistance prediction.