ConceptioArchiveNCBI PubMed Central
NCBI PubMed Centralopen access

Rapid Machine Learning-Driven Detection of Pesticides and Dyes Using Raman Spectroscopy.

Thai Binh QT et al. · ncbi_pmc
NCBI PubMed Central · Papers · License: Open Access
Open Source ↗Direct PDF ↓
machine learning systems

Rapid Machine Learning-Driven Detection of Pesticides and Dyes Using Raman Spectroscopy - PMC Skip to main content An official website of the United States government Here's how you know Here's how you know Official websites use .gov A .gov website belongs to an official government organization in the United States. Secure .gov websites use HTTPS A lock ( Lock Locked padlock icon ) or https:// means you've safely connected to the .gov website. Share sensitive information only on official, secure websites. Search Log in Dashboard Publications Account settings Log out Search… Search NCBI Primary site navigation Search Logged in as: Dashboard Publications Account settings Log in Search PMC Full-Text Archive Search in PMC Journal List User Guide PERMALINK Copy As a library, NLM provides access to scientific literature. Inclusion in an NLM database does not imply endorsement of, or agreement with, the contents by NLM or the National Institutes of Health. Learn more: PMC Disclaimer | PMC Copyright Notice J Chem Inf Model . 2026 Mar 17;66(7):3803–3813. doi: 10.1021/acs.jcim.6c00396 Search in PMC Search in PubMed View in NLM Catalog Add to search Rapid Machine Learning-Driven Detection of Pesticides and Dyes Using Raman Spectroscopy Quach Thi Thai Binh Quach Thi Thai Binh † Faculty of Physics and Physics Engineering, University of Science, Ho Chi Minh City 700000, Viet Nam ‡ Vietnam National University, Ho Chi Minh City 700000, Viet Nam Find articles by Quach Thi Thai Binh †, ‡ , La Thuan Phuoc La Thuan Phuoc † Faculty of Physics and Physics Engineering, University of Science, Ho Chi Minh City 700000, Viet Nam ‡ Vietnam National University, Ho Chi Minh City 700000, Viet Nam Find articles by La Thuan Phuoc †, ‡ , Pham Xuan Hai Pham Xuan Hai † Faculty of Physics and Physics Engineering, University of Science, Ho Chi Minh City 700000, Viet Nam ‡ Vietnam National University, Ho Chi Minh City 700000, Viet Nam Find articles by Pham Xuan Hai †, ‡ , Thang Bach Phan Thang Bach Phan § Advanced 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 Nam ∥ University of Health Sciences (UHS), Viet Nam National University Ho Chi Minh City, Ho Chi Minh City 700000, Viet Nam ‡ Vietnam National University, Ho Chi Minh City 700000, Viet Nam Find articles by Thang Bach Phan §, ∥, ‡ , Vu Thi Hanh Thu Vu Thi Hanh Thu † Faculty of Physics and Physics Engineering, University of Science, Ho Chi Minh City 700000, Viet Nam ‡ Vietnam National University, Ho Chi Minh City 700000, Viet Nam Find articles by Vu Thi Hanh Thu †, ‡, * , Nguyen Tuan Hung Nguyen Tuan Hung ⊥ Department of Materials Science and Engineering, National Taiwan University, Taipei 10617, Taiwan † Faculty of Physics and Physics Engineering, University of Science, Ho Chi Minh City 700000, Viet Nam ‡ Vietnam National University, Ho Chi Minh City 700000, Viet Nam Find articles by Nguyen Tuan Hung ⊥, †, ‡, * Author information Article notes Copyright and License information † Faculty of Physics and Physics Engineering, University of Science, Ho Chi Minh City 700000, Viet Nam ‡ Vietnam National University, Ho Chi Minh City 700000, Viet Nam § Advanced 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 Nam ∥ University of Health Sciences (UHS), Viet Nam National University Ho Chi Minh City, Ho Chi Minh City 700000, Viet Nam ⊥ Department of Materials Science and Engineering, National Taiwan University, Taipei 10617, Taiwan * Email: [email protected] . * Email: [email protected] . Received 2026 Feb 6; Accepted 2026 Mar 10; Revised 2026 Mar 9; Collection date 2026 Apr 13. © 2026 The Authors. Published by American Chemical Society This article is licensed under CC-BY 4.0 PMC Copyright notice PMCID: PMC13080974  PMID: 41843405 Abstract The extensive use of pesticides and synthetic dyes poses critical threats to food safety, human health, and environmental sustainability, necessitating rapid and reliable detection methods. Raman spectroscopy offers molecularly specific fingerprints but suffers from spectral noise, fluorescence background, and band overlap, limiting its real-world applicability. Here, we propose a deep learning framework based on ResNet-18 feature extraction, combined with advanced classifiers, including XGBoost, SVM, and their hybrid integration, to detect pesticides and dyes from Raman spectroscopy, called MLRaman. The MLRaman with the CNN–XGBoost model achieved a predictive accuracy of 97.4% and a perfect AUC of 1.0, while it with the CNN–SVM model provided competitive results with robust class-wise discrimination. Dimensionality reduction analyzes (PCA, t-SNE, UMAP) confirmed the separability of Raman embeddings across 10 analytes, including 7 pesticides and 3 dyes. Finally, we developed a user-friendly Streamlit application for real-time prediction, which successfully identified unseen Raman spectra from our independent experiments and also literature sources, underscoring strong generalization capacity. This study establishes a scalable, practical MLRaman model for multiresidue contaminant monitoring, with significant potential for deployment in food safety and environmental surveillance. 1. Introduction The widespread application of pesticides and synthetic dyes has contributed to boosting crop yields , and supporting industrial advancement. , Nevertheless, their widespread application also introduces significant risks to food safety, ,, ecological balance, , and human well-being. ,, Pesticides such as carbendazim, carbaryl, thiram, thiabendazole, methyl parathion, cypermethrin, and chlorpyrifos are routinely employed in modern agriculture for crop protection, ,, while synthetic dyes, including rhodamine 6G, rhodamine B, and crystal violet, are commonly used in food processing, textiles, and biomedical industries. ,, Despite their utility, these substances have been shown to exert profound toxicological impacts: carbendazim and thiabendazole function as endocrine disruptors; − carbaryl and methyl parathion trigger neurotoxicity through cholinesterase inhibition; , thiram contributes to dermatological and neurological disorders; and rhodamine dyes, as well as crystal violet, exhibit genotoxic and carcinogenic properties. − Residues of these hazardous compounds frequently persist in agricultural produce, soil, and water, ,,, thereby creating a pressing need for sensitive, rapid, and reliable detection techniques that can safeguard ecosystems and human health. ,,, Among the available analytical techniques, Raman spectroscopy is increasingly recognized as a particularly powerful method for detecting pesticide and dye residues because it is rapid, nondestructive, requires minimal sample preparation, and provides molecularly specific vibrational fingerprints of analytes. − This makes it highly attractive for real-time and in situ monitoring of contaminants in complex food and environmental matrices. However, its practical deployment is hindered by a range of technical limitations. Fluorescence background often masks Raman peaks, baseline drift interferes with accurate spectral alignment, and overlapping vibrational bands among structurally similar compounds create significant challenges for reliable discrimination. , Furthermore, spectra acquired under field conditions tend to be noisier and less reproducible compared to those collected under controlled laboratory settings, which complicates downstream data analysis and reduces classification accuracy. Machine learning (ML) methods are being increasingly adapted for materials research due to their ability to analyze complex spectral data. − For example, ML models such as support vector machine classifiers (SVM) and ensemble tree classifiers (RF) have been applied to the detection of thiabendazole and rhodamine 6G dye from the Raman spectra, in some cases exceeding 90% accuracy on data sets of limited size and analyte diversity. , Nevertheless, these models still required extensive preprocessing steps, including baseline correction, smoothing, and normalization, to produce reliable results. The advent of deep learning has introduced a paradigm shift in Raman spectral analysis. The deep learning models, such as convolutional neural networks (CNNs), can automatically learn hierarchical feature representations directly from raw or minimally processed spectra, thereby reducing dependency on manual preprocessing and improving adaptability across diverse experimental conditions. The CNNs significantly outperformed SVM or RF models in classifying pesticide residues under noisy environments, highlighting their robustness to spectral variability. , More advanced ML architectures based on CNNs, including ResNet and Inception, have been shown to enhance generalization and discrimination across multiclass spectral data sets, enabling improved performance even in scenarios involving structurally similar compounds. , In addition, hybrid frameworks that combine CNN-based feature extraction with classical classifiers such as SVM or gradient boosting methods like XGBoost have reported competitive performance, , further demonstrating the flexibility of CNN-based approaches. In this study, we propose an end-to-end ML framework based on the ResNet-18 architecture for the classification of ten hazardous compounds, including seven pesticides (carbendazim, carbaryl, thiram, thiabendazole, methyl parathion, cypermethrin, and chlorpyrifos) and three synthetic dyes (rhodamine 6G, rhodamine B, and crystal violet). The Raman spectral data employed in this work were collected from publicly available data sets reported in prior studies, ensuring both scientific transparency and reproducibility. Instead of relying solely on one-dimensional spectral representations, the Raman spectra were transformed into spectral images, enabling ResNet-18 to leverage its two-dimensional convolutional filters to capture both global spectral patterns and local vibrational features. This design choice exploits the strength of residual connections in mitigating vanishing gradient problems while enabling deeper hierarchical feature learning, thereby enhancing the model’s robustness to noise and variability. The adoption of ResNet-18 is motivated by its well-established balance between computational efficiency and classification performance, making it suitable for both research-oriented applications and potential deployment in field-portable Raman detection systems. In doing so, this study not only extends the scope of Raman-based machine learning applications to encompass a broader set of analytes, including both pesticides and dyes, but also demonstrates the potential of deep residual networks to provide scalable and generalizable solutions for multicompound detection. Ultimately, the proposed approach aims to advance Raman spectroscopy from a powerful laboratory technique to a practical, real-world tool for ensuring food safety, protecting environmental integrity, and safeguarding human health. 2. Theoretical and Experimental Methods 2.1. MLRaman: A Machine Learning Model for Detecting Pesticides and Dyes from Raman Spectra In Figure , we illustrate the MLRaman framework used in this study. The framework begins with the Raman spectral data set and data preprocessing, then moves on to feature extraction with ResNet18, followed by dimensionality reduction and classification using several ML models, including SVM, XGBoost, and VotingClassifier. The performance of the MLRaman framework is measured with accuracy, F1-score, and a confusion matrix. A user interface has also been developed to allow for practical use of the model for the rapid detection of pesticides and dyes from Raman spectra. As shown in Table S1 , the MLRaman can be performed within a few minutes with the NVIDIA GeForce RTX 3060 or RTX 4090, while it can take 15 min with the AMD Ryzen 9 5900X and 41 min with the Intel Core i5-11400F. All code and the user interface application are available for download on the GitHub page: https://github.com/nguyen-group/MLRaman . 1. Open in a new tab Schematic workflow of the MLRaman framework. First, the Raman spectral data are collected from literature sources or experimental measurements, which undergo signal preprocessing, including baseline correction and normalization to reduce noise and variability. Then, these Raman spectra are preprocessed and transformed into 2D spectral images for CNN-based feature extraction. Then, several dimensionality reduction and machine-learning classification models are applied to select the best model for prediction. Finally, a real-time Streamlit interface is developed based on the best model and trained parameters. 2.2. Data Set and Preprocessing This study employs a data set of Raman spectral data corresponding to ten pesticide-related compounds: carbendazim (CBZ), carbaryl (CR), thiram (TMTD), thiabendazole (TBZ), rhodamine 6G (R6G), rhodamine B (RB), crystal violet (CV), methyl parathion (MP), cypermethrin (CYP), and chlorpyrifos (CPF). The raw Raman spectra are obtained from publicly available databases, published literature, and in-house measurements. Since most of the Raman data are 2D images, we convert our in-house Raman measurements from 1D spectra to 2D images to unify all data sets for training. Although 1D Raman spectra can provide additional physical insights, 2D images offer a major advantage over existing CNN models. In this study, we use well-trained CNN parameters on the large ImageNet data set. Then, these parameters are further trained with a 2D Raman image data set. This procedure may not be feasible for the 1D case. The 2D Raman data set can be found on the GitHub page: https://github.com/nguyen-group/MLRaman/data . To enable image-based deep learning, raw spectra are baseline-corrected, normalized, and interpolated, then converted into two-dimensional (2D) pseudocolor images. This conversion preserves molecular vibrational fingerprints while making them compatible with convolutional neural networks (CNNs). All images are resized to 256 × 256 pixels (see Figure ), ensuring compatibility with standard CNN backbones such as ResNet18 and EfficientNet. Intensities are rescaled to the range [0, 1] to stabilize training, and mild augmentations (random rotation, color jitter, and erasing) are applied to improve model robustness. The data set exhibited a relatively balanced distribution across classes, as shown in Figure . The total number of Raman spectra for 10 pesticides and dyes is 1347 from 507 published papers. TMTD (≈17.7%) and TBZ (≈17.0%) are the largest categories, while smaller ones such as CPF and MP still contained sufficient samples to avoid severe imbalance. This distribution supports fair training and reliable evaluation across all target pesticides. 2. Open in a new tab Raman spectra data set for 10 pesticides and dyes. (a) The Raman spectra of the 10 compounds, including carbendazim (CBZ), carbaryl (CR), thiram (TMTD), thiabendazole (TBZ), rhodamine 6G (R6G), rhodamine B (RB), crystal violet (CV), methyl parathion (MP), cypermethrin (CYP), and chlorpyrifos (CPF), and their molecular formulas. (b) Bar chart showing the distribution of Raman spectral images across 10 chemical classes. The data set shows class imbalance, with TBZ and TMTD having the largest sample counts. (c) Corresponding pie chart illustrating the proportion of each class within the data set, reflecting a relatively skewed but comprehensive representation of the target analytes. 2.3. CNN-Based Feature Extraction Using ResNet In the MLRaman, we use ResNet18 to extract discriminative spectral–spatial features from Raman pseudocolor images. Instead of training from scratch, the ResNet18 is initialized with ImageNet-pretrained weights and fine-tuned on the spectral data set. To obtain generalizable representations, features are collected from the penultimate layer, just before the classification head. These embeddings capture abstract but discriminative information, serving as compact input for subsequent ML classifiers. 2.4. Machine Learning Classifiers Extracted CNN features are used to train several ML classifiers, including SVM, XGBoost, and VotingClassifier (combining SVM and XGBoost). The hyperparameters are optimized using GridSearchCV, which systematically evaluates candidate parameter values. For the SVM, the penalty parameter C (1, 2, 4, 8), the kernel type (a linear and radial basis function (RBF) kernels), and kernel coefficient γ (0.1, 0.01, 0.001) are tuned. For the XGBoost, the parameters are the number of estimators (100–500), the learning rate (0.01, 0.05, 0.1), and the maximum depth of the tree (3–10). For the ensemble VotingClassifier, hard and soft voting strategies are evaluated. All models are validated using 5-fold cross-validation, a widely adopted method that mitigates overfitting by averaging performance across multiple data partitions. Performance is evaluated by accuracy, F1-score, and confusion matrices. 2.5. Dimensionality Reduction and Visualization To interpret the learned representations, three dimensionality reduction methods, including principal component analysis (PCA), t-distributed stochastic neighbor embedding (t-SNE), and uniform manifold approximation and projection (UMAP) are applied in the MLRaman. Each method projects high-dimensional CNN embeddings into a 2D space, facilitating the visualization of pesticide category separability. Side-by-side comparisons of the projections highlight clustering clarity and provide insights into the latent feature structure. 2.6. Experimental Raman Measurement Raman measurements are obtained on a Horiba XploRA PLUS Raman system integrated with a 532 nm laser operating at 10 mW and a 1200 L/mm diffraction grating. All spectra are recorded with 1 s of integration time and 1 accumulation. Crystal Violet (CV) and Rhodamine 6G (R6G) of different R6G:CV (%) concentration ratios of 100:0, 95:15, 85:15, 80:20, 60:40, 50:50, 40:60, 20:80, 0:100% (see Table ) are selected as target probes to evaluate the performance of the identification by MLRaman. The testing samples are prepared by dropping 10 μL of the analyte onto the Ag-deposited Si wafer as described by Trang et al. All samples are dried at room temperature before measurements. 1. Top-K (%) Identification Performance by MLRaman from the Raman Spectra of Different R6G:CV (%) Concentration Ratios. R6G:CV ratio (%) identified substance Top-K score (%) 100:0 R6G 99.74 95:15 R6G 99.75 85:15 R6G 92.15 80:20 R6G 83.37 60:40 R6G 54.48 50:50 R6G 47.88 40:60 CV 42.47 20:80 CV 58.63 0:100 CV 75.30 Open in a new tab 3. Results and Discussion 3.1. Raman Preprocessing To evaluate the impact of the preprocessing pipeline on spectral quality, we compare and process Raman spectra of Thiram, as shown in Figure . Thiram is selected as a representative compound because its raw spectrum clearly shows baseline drift and fluorescence background, making it suitable for demonstrating the effect of preprocessing. The raw spectrum (gray) shows a slowly varying baseline and background fluctuations that obscure several characteristic vibrational peaks. The estimated baseline (orange dashed line), which is obtained by asymmetric least-squares (ALS) fitting, captures this broad low-frequency trend. After baseline subtraction and subsequent Savitzky–Golay (SG) smoothing, the preprocessed spectrum (blue) shows a more flattened baseline, and peaks are more pronounced than in the raw data. 3. Open in a new tab Comparison between the raw Raman spectrum of thiram (gray), the estimated baseline via ALS (orange dashed), and the preprocessed spectrum after baseline removal and SG smoothing (blue). The pipeline suppresses baseline drift, enhances peak clarity, and reduces high-frequency noise, yielding standardized spectral inputs for machine-learning models. Three main improvements can be observed: (i) baseline suppression, which eliminates background offsets and prevents the model from learning irrelevant intensity variations; (ii) peak enhancement, where diagnostic Raman bands emerge more distinctly, facilitating feature extraction; and (iii) noise reduction, where high-frequency fluctuations are smoothed while preserving both peak position and relative intensity. Although Figure illustrates the case of thiram, similar improvements are consistently observed across the spectra of other compounds in the data set. This confirms that the ALS + SG preprocessing pipeline provides cleaner, more standardized inputs for downstream ML tasks, preserving discriminative vibrational information while minimizing irrelevant artifacts. 3.2. Baseline CNN Training Performance The proposed ResNet18-based architecture showed apparent convergence and reliable generalization. As shown in Figure , training loss decreased substantially from 2.19 to 0.35, while validation loss decreased steadily from 1.70 to 0.88 over 25 epochs. Concurrently, training accuracy improved from 46.7% to 100.0%, while validation accuracy increased steadily from 50.4% to a peak of 82.3% at epoch 24 and converged around 80%. The rapid initial gains followed by a stable plateau indicate that the network successfully learned discriminative representations that generalized robustly to unseen samples. Importantly, the stability of validation performance despite near-perfect training accuracy reflects a well-regularized learning process that avoids severe overfitting. Taken together, these findings confirm the effectiveness of CNN-based transfer learning for this classification task and establish a strong foundation for further refinement to surpass the current 80% benchmark. 4. Open in a new tab Training and validation performance of the ResNet18 model over 30 epochs, showing decreasing accuracy (a) and loss (b) history with validation accuracy plateauing at 80%. In Figure S1 , we compare validation accuracy across different CNN models, including lightweight (MobileNetV2), parameter-efficient (EfficientNet-B0), densely connected (DenseNet-121), and ResNet-18. To ensure a fair and meaningful comparison, all CNN backbones are trained and evaluated under identical experimental conditions, using the same training–validation split, optimization strategy, and evaluation metrics. The results indicate that ResNet-18 achieved the highest validation accuracy among the architectures evaluated. Therefore, ResNet-18 is selected as the backbone for the MLRaman. 3.3. Performance of the CNN-XGBoost Classification Compared with conventional strategies extensively reported in Raman spectral analysis, such as SVM or linear discriminant analysis (LDA)-based classifiers, our framework demonstrates a clear advantage. Traditional methods typically falter in the presence of overlapping vibrational bands and experimental noise, often plateauing at 80–85% precision. , Even CNN-only approaches, as reflected in both previous studies and our baseline experiments, fail to surpass 85% validation accuracy under identical conditions. In stark contrast, the CNN–XGBoost hybrid not only outperforms these baselines but also establishes a robust, stable, and highly generalizable decision boundary. In our framework, the hybrid CNN–XGBoost model shows a substantial performance leap, achieving an overall classification accuracy of 97.4%. As shown in Figure a, the confusion matrix summarizes the performance of a classification model for the validation data set. The number of validation data sets for CBZ, CPF, CR, CV, CYP, MP, R6G, RB, TBZ, and TMTD is 27, 20, 26, 23, 20, 21, 21, 20, 48, and 46, respectively. Compared with the counts in the confusion matrix, we can see that all samples in the CPF, CV, CYP, RB, and TBZ classes are correctly predicted, while the MP and R6G classes each have one failed sample, the CBZ class has two, and the CR class has three. Moreover, the area under the curve (AUC) for the validation data set shows perfect (AUC = 1.00) across all classes except CBZ (AUC = 0.99) and CR (AUC = 0.98), as shown in Figure b, indicating the near-ideal separability of Raman fingerprints. The F1-score, a harmonic mean of precision and recall, is also used to evaluate the performance of classification models, where an F1 score reaches its best value of 1 and its worst value of 0. As shown in Figure c, the CBZ and CR are the only cases with a slightly lower F1-score (0.94 and 0.92), attributable to minor recall fluctuations. However, such deviations are isolated and negligible in terms of impact on overall predictive performance. 5. Open in a new tab Performance evaluation of XGBoost model with the CNN features and the PCA dimensionality reduction, including (a) confusion matrix, (b) ROC curves, and (c) per-class F1-scores, for the validation data set. The high-performance of CNN + XGBoost comes from the complementary strengths of the two models: CNN provides a hierarchical feature representation that encodes subtle spectral variations, while XGBoost delivers a powerful ensemble-based decision mechanism capable of capturing nonlinear feature interactions and mitigating class imbalance. , This synergy effectively overcomes the limitations of both conventional classifiers and deep learning models when used in isolation. Therefore, our model sets a new benchmark for Raman-based chemical classification. The combination of high overall accuracy, excellent class consistency, and almost perfect AUC underscores the strong potential of the proposed framework for real-world deployment, which includes rapid pesticide detection, dye contamination monitoring, and broader applications in environmental and food safety surveillance. 3.4. Performance of the CNN-SVM Classification To benchmark against the XGBoost model, we also perform SVM and VotingClassifier (combining SVM and XGBoost) on the CNN features and PCA-dimensionality reduction. In Figure , we show the performance of the CNN + SVM model for the validation data set. The confusion matrix ( Figure a) shows that most classes are correctly assigned to their respective categories, with only a few misclassifications observed in cases of spectrally similar compounds. This indicates that the SVM effectively captures fine vibrational distinctions that are often obscured by baseline shifts or overlapping peaks. The performance analysis of the SVM model is also presented as ROC curves and F1-scores. Overall, the CNN + SVM model is less efficient than the CNN + XGBoost model in Raman classification. However, it is noted that the SVM performance is sensitive to kernel selection and hyperparameter optimization, which may limit its scalability to larger, more heterogeneous data sets. By using GridSearchCV to automatically optimize hyperparameters, we can improve the classification accuracy of CNN + SVM from 77.6% to 96.3%. Although it is still below CNN + XGBoost (97.4%), this complementarity suggests that integrating both approaches within a hybrid framework could enhance generalization performance, thereby advancing Raman-based contaminant detection toward real-world applications. 6. Open in a new tab Performance evaluation of the SVM model with the CNN features and the PCA dimensionality reduction, including (a) confusion matrix, (b) ROC curves, and (c) per-class F1-scores, for the validation data set. 3.5. Ensemble Learning with VotingClassifier Next, we will combine both SVM and XGBoost within a VotingClassifier framework. This ensemble strategy balances the margin-maximization property of SVM with the gradient-boosting capability of XGBoost, thereby reducing misclassification errors across closely related spectra. In Figure , we show the performance of the VotingClassifier framework using the CNN features and the PCA dimensionality reduction for the validation data set. The confusion matrix, ROC curves, and per-class F1-scores are quite similar to those of the SVM model (see Figure ). Although ensemble learning with VotingClassifier is expected to improve performance in Raman spectral classification, the VotingClassifier achieves a classification accuracy of 76.1%, which is lower than that of XGBoost (97.4%) and SVM (77.6%). This might be due to imbalanced or noisy Raman data. In this case, the SVM and XGB disagree frequently, leading to an unstable ensemble. 7. Open in a new tab Ensemble classification performance using the VotingClassifier framework (combining SVM and XGBoost) with the CNN features and the PCA dimensionality reduction, including (a) confusion matrix, (b) ROC curves, and (c) per-class F1-scores, for the validation data set. 3.6. Dimensionality Reduction and Feature Visualization In Figure , we use dimensionality reduction methods to visualize the CNN feature space in two dimensions to further elucidate why such improvements occur. These visualizations provide valuable insight into how pesticides and dyes are distributed in the embedding space and where classification challenges arise. 8. Open in a new tab Dimensionality reduction and visualization of CNN feature embeddings using (a) PCA, (b) t-SNE, and (c) UMAP. Color dots indicate 10 pesticides and dyes, including carbendazim (CBZ), carbaryl (CR), thiram (TMTD), thiabendazole (TBZ), rhodamine 6G (R6G), rhodamine B (RB), crystal violet (CV), methyl parathion (MP), cypermethrin (CYP), and chlorpyrifos (CPF). As shown in Figure a, for the PCA method, linear projection preserves the global variance of features but fails to fully separate chemically similar pesticides such as carbaryl (CR) and carbendazim (CBZ), while it well separates the thiabendazole (TBZ) and thiram (TMTD). This may be due to the data set distribution (see Figure ), where the number of samples in the TBZ and TMTD classes is significantly higher than that in the other classes. This also explains why the TBZ and TMTD classes are well classified in all models (XGBoost, SVM, and VotingClassifier). In contrast, the t-SNE method highlights the ability of CNN embeddings to form distinct clusters for most classes, as shown in Figure b, reflecting their discriminative power. The UMAP method shows the clearest separation of classes compared with PCA and t-SNT methods, as shown in Figure c. We use all dimensionality reduction methods for the CNN feature in the CNN + SVM model to test the performance. We find a slight improvement in classification accuracy: 77.6% for PCA and 79.8% for both t-SNE and UMAP. This improvement is due to the better feature separation ability of t-SNE and UMAP compared to PCA. Nevertheless, training time also increased significantly because t-SNE and UMAP are nonlinear methods, whereas PCA is linear. Therefore, the PCA is a good choice for computational efficiency. 4. App-Based External Test on Unseen Raman Spectra To assess deployability beyond curated data sets, we conducted a prospective, app-based evaluation using the Streamlit interface for the MLRaman with the CNN + XGBoost model. The application accepts a spectral image, automatically crops the plot area (binary thresholding and bounding-box extraction to remove titles/axes), rescales it to the training resolution, and applies the same normalization used during model development before forwarding the image to the MLRaman classifier. We deliberately used unseen spectradistinct from all training/validation filessourced from our experimental Raman spectra for two samples: the crystal violet (CV) and the rhodamine 6G (R6G). This app only requires uploading a Raman spectrum, as shown in Figure a, then the app returns correct top-1 predictions for every case. As shown in Figure b–e, the MLRaman can predict and correct the CV and R6G with the probability of 0.753 and 0.995, respectively. This predictive ability is remarkable because the CV and R6G are dyes with partially overlapping Raman bands, making them one of the most confusable pairs in routine analyzes. Correct assignment of unseen images indicates that the learned representation captures fine-grained, class-specific motifs rather than overfitting to data set-specific artifacts (e.g., axis grids, font styles). Therefore, the cropping-plus-normalization stage combined with residual feature extraction confers robustness to baseline drift and moderate illumination/format variability. 9. Open in a new tab A user-friendly Streamlit application based on the MLRaman model with CNN + XGBoost. (a) The app only requires uploading a Raman spectrum from a list of 10 pesticides and dyes, including carbendazim (CBZ), carbaryl (CR), thiram (TMTD), thiabendazole (TBZ), rhodamine 6G (R6G), rhodamine B (RB), crystal violet (CV), methyl parathion (MP), cypermethrin (CYP), and chlorpyrifos (CPF). (b) Unseen Raman spectrum of CV and (c) R6G. (d) and (e) show the top three prediction probabilities for CV and R6G, respectively, which are the correct predictions for the Raman spectra in (b,c), respectively. To evaluate the performance of MLRaman on a complex system. We perform the Raman experiment for the binary mixture samples, in which the R6G and CV are mixed with a ratio (in units of %) of 100:0, 95:15, 85:15, 80:20, 60:40, 50:50, 40:60, 20:80, 0:100. The observed Raman spectra of these samples are then used for MLRaman prediction. The results of 9 binary mixtures are listed in Table . The top-K score from MLRaman indicates that it can correctly identify the dominant component across a broad range of mixture ratios. As expected, confidence decreases near equimolar compositions, where spectral overlap between the two species is most pronounced. These results indicate that the MLRaman remains effective even with complex mixed systems. The MLRaman app can be extended to analyze any Raman spectra, not just those related to 10 specific pesticides and dyes. However, a significant challenge we face is obtaining reliable data sources and addressing data imbalance issues. Our goal in developing the MLRaman is to enhance our data sets through laboratory experiments and theoretical simulations. To achieve this, autonomous experiments powered by active learning and artificial intelligence, along with high-throughput computational methods, could be solutions in the near future. 5. Conclusion This work presented a machine-learning-based framework for Raman spectral classification of 10 hazardous pesticides and dyes. By leveraging ResNet-18 for feature extraction and coupling its embeddings with advanced classifiers, particularly XGBoost and SVM, we achieved consistently high accuracy (97.4%) and near-perfect AUC scores. Dimensionality reduction analyzes further confirmed the discriminative power of CNN-derived embeddings. A user-friendly Streamlit application successfully identified external spectra, including independent experimental Raman spectra of crystal violet and rhodamine 6G, demonstrating strong generalization to out-of-source data. These results highlight the promise of integrating CNN feature learning with ensemble models for real-time Raman-based contaminant detection, paving the way toward practical deployment in food safety and environmental monitoring. Supplementary Material ci6c00396_si_001.pdf (240.2KB, pdf) Acknowledgments This work was financially supported by Vietnam National University Ho Chi Minh City (NCM2024-50-01). All scripts, data sets, and source code are available at https://github.com/nguyen-group/MLRaman . The Supporting Information is available free of charge at https://pubs.acs.org/doi/10.1021/acs.jcim.6c00396 . A comparison of CPU and GPU efficiency and a comparison of validation accuracy across different CNN backbones ( PDF ) Q. T. T. B: writingoriginal draft, visualization, data curation, methodology, investigation, and formal analysis. L. T. P and P. X. H: data curation and formal analysis. T. B. P: resources and funding acquisition. V. T. H. T: supervision, writingreview, visualization, and investigation. N. T. H: supervision, writingreview, validation, methodology, investigation, and formal analysis. All authors have given their approval for the final version of the manuscript. The authors declare no competing financial interest. Published as part of Journal of Chemical Information and Modeling special issue “Machine Learning in Materials Science”. References Singh S., Singh N., Kumar V., Datta S., Wani A. B., Singh D., Singh K., Singh J.. Toxicity, monitoring and biodegradation of the fungicide carbendazim. Environ. Chem. Lett. 2016;14:317–329. doi: 10.1007/s10311-016-0566-2. [ DOI ] [ Google Scholar ] Liu B., Zhou P., Liu X., Sun X., Li H., Lin M.. Detection of Pesticides in Fruits by Surface-Enhanced Raman Spectroscopy Coupled with Gold Nanostructures. Food Bioprocess Technol. 2013;6:710–718. doi: 10.1007/s11947-011-0774-5. [ DOI ] [ Google Scholar ] Aigbe U. O., Maluleke R., Lebepe T. C., Oluwafemi O. S., Osibote O. A.. Rhodamine 6G Dye Adsorption Using Magnetic Nanoparticles Synthesized With the Support of Vernonia Amygdalina Leaf Extract (Bitter Leaf) J. Inorg. Organomet. Polym. Mater. 2023;33:4012–4031. doi: 10.1007/s10904-023-02639-3. [ DOI ] [ Google Scholar ] Alegbe E. O., Uthman T. O.. A review of history, properties, classification, applications and challenges of natural and synthetic dyes. Heliyon. 2024;10:e33646. doi: 10.1016/j.heliyon.2024.e33646. [ DOI ] [ PMC free article ] [ PubMed ] [ Google Scholar ] Ngegba P. M., Cui G., Khalid M. Z., Zhong G.. Use of Botanical Pesticides in Agriculture as an Alternative to Synthetic Pesticides. Agriculture. 2022;12:600. doi: 10.3390/agriculture12050600. [ DOI ] [ Google Scholar ] Guerra E., Llompart M., Garcia-Jares C.. Miniaturized matrix solid-phase dispersion followed by liquid chromatography-tandem mass spectrometry for the quantification of synthetic dyes in cosmetics and foodstuffs used or consumed by children. J. Chromatogr. A. 2017;1529:29–38. doi: 10.1016/j.chroma.2017.10.063. [ DOI ] [ PubMed ] [ Google Scholar ] Tang Z., Chen Z., Li G., Hu Y.. Multicolor nitrogen dots for rapid detection of thiram and chlorpyrifos in fruit and vegetable samples. Anal. Chim. Acta. 2020;1136:72–81. doi: 10.1016/j.aca.2020.08.038. [ DOI ] [ PubMed ] [ Google Scholar ] Hu B., Sun D.-W., Pu H., Wei Q.. Rapid nondestructive detection of mixed pesticides residues on fruit surface using SERS combined with self-modeling mixture analysis method. Talanta. 2020;217:120998. doi: 10.1016/j.talanta.2020.120998. [ DOI ] [ PubMed ] [ Google Scholar ] Khan M. R., Khan J. M., Alqadami A. A.. A simple solvent extraction and ultra-performance liquid chromatography-tandem mass spectrometric method for the identification and quantification of rhodamine B in commercial lip balm samples. Spectrochim. Acta, Part A. 2019;206:72–77. doi: 10.1016/j.saa.2018.07.093. [ DOI ] [ PubMed ] [ Google Scholar ] Li S.. Removal of crystal violet from aqueous solution by sorption into semi-interpenetrated networks hydrogels constituted of poly­(acrylic acid-acrylamide-methacrylate) and amylose. Bioresour. Technol. 2010;101:2197–2202. doi: 10.1016/j.biortech.2009.11.044. [ DOI ] [ PubMed ] [ Google Scholar ] Rama E. M., Bortolan S., Vieira M. L., Gerardin D. C. C., Moreira E. G.. Reproductive and possible hormonal effects of carbendazim. Regul. Toxicol. Pharmacol. 2014;69:476–486. doi: 10.1016/j.yrtph.2014.05.016. [ DOI ] [ PubMed ] [ Google Scholar ] Ferreira A. L., Loureiro S., Soares A. M.. Toxicity prediction of binary combinations of cadmium, carbendazim and low dissolved oxygen on Daphnia magna. Aquat. Toxicol. 2008;89:28–39. doi: 10.1016/j.aquatox.2008.05.012. [ DOI ] [ PubMed ] [ Google Scholar ] Zheng X., Guo L., Zhu C., Hu T., Gong X., Wu C., Wang G., Dong H., Hou Y.. A robust electrochemical sensor based on AgNWs@MoS2 for highly sensitive detection of thiabendazole residues in food samples. Food Chem. 2024;433:137304. doi: 10.1016/j.foodchem.2023.137304. [ DOI ] [ PubMed ] [ Google Scholar ] Müller C., David L., Chiş V., Pînzaru S. C.. Detection of thiabendazole applied on citrus fruits and bananas using surface enhanced Raman scattering. Food Chem. 2014;145:814–820. doi: 10.1016/j.foodchem.2013.08.136. [ DOI ] [ PubMed ] [ Google Scholar ] Mora-Gutiérrez, A. ; Rubio, C. ; Romero-López, A. A. ; Rubio-Osornio, M. . Neurotoxicity - New Advances; IntechOpen, 2022. [ Google Scholar ] Edwards F. L., Tchounwou P. B.. Environmental Toxicology and Health Effects Associated with Methyl Parathion Exposure – A Scientific Review. Int. J. Environ. Res. Public Health. 2005;2:430–441. doi: 10.3390/ijerph2005030007. [ DOI ] [ PubMed ] [ Google Scholar ] Mo Q., Kulyar M. F. e. A., Ding Y., Zhang Y., Pan H., Li J.. Thiram induces myocardial oxidative damage and apoptosis in broilers via interfering their cardiac metabolism. Ecotoxicol. Environ. Saf. 2022;247:114225. doi: 10.1016/j.ecoenv.2022.114225. [ DOI ] [ PubMed ] [ Google Scholar ] Priya P. S., Nandhini P. P., Vaishnavi S., Pavithra V., Almutairi M. H., Almutairi B. O., Arokiyaraj S., Pachaiappan R., Arockiaraj J.. Rhodamine, B. An organic environmental pollutant induces reproductive toxicity in parental and teratogenicity in F1 generation in vivo. Comp. Biochem. Physiol., Part C:Toxicol. Pharmacol. 2024;280:109898. doi: 10.1016/j.cbpc.2024.109898. [ DOI ] [ PubMed ] [ Google Scholar ] Kovacic P., Somanathan R.. Toxicity of imine–iminium dyes and pigments: electron transfer, radicals, oxidative stress and other physiological effects. J. Appl. Toxicol. 2014;34:825–834. doi: 10.1002/jat.3005. [ DOI ] [ PubMed ] [ Google Scholar ] Mani, S. ; Bharagava, R. N. . Exposure to Crystal Violet, its Toxic, Genotoxic and Carcinogenic Effects on Environment and Its Degradation and Detoxification for Environmental Safety, 2016; pp 71–104. [ DOI ] [ PubMed ] [ Google Scholar ] Peng X.-X., Bao G.-M., Zhong Y.-F., Zhang L., Zeng K.-B., He J.-X., Xiao W., Xia Y.-F., Fan Q., Yuan H.-Q.. Highly sensitive and rapid detection of thiabendazole residues in oranges based on a luminescent Tb3+-functionalized MOF. Food Chem. 2021;343:128504. doi: 10.1016/j.foodchem.2020.128504. [ DOI ] [ PubMed ] [ Google Scholar ] Zhang Z., Zhang Q., Li L., Lin D., Jiang C.. Ultrasensitive and On-Site Detection of Carbaryl Pesticides via Dual-Mode Nanosensors Utilizing Portable Devices. ACS Sustainable Chem. Eng. 2023;11:4998–5006. doi: 10.1021/acssuschemeng.2c06499. [ DOI ] [ Google Scholar ] Petersen M., Yu Z., Lu X.. Application of Raman Spectroscopic Methods in Food Safety: A Review. Biosensors. 2021;11:187. doi: 10.3390/bios11060187. [ DOI ] [ PMC free article ] [ PubMed ] [ Google Scholar ] He L., Chen T., Labuza T. P.. Recovery and quantitative detection of thiabendazole on apples using a surface swab capture method followed by surface-enhanced Raman spectroscopy. Food Chem. 2014;148:42–46. doi: 10.1016/j.foodchem.2013.10.023. [ DOI ] [ PubMed ] [ Google Scholar ] Qu C., Li Y., Du S., Geng Y., Su M., Liu H.. Raman spectroscopy for rapid fingerprint analysis of meat quality and security: Principles, progress and prospects. Food Res. Int. 2022;161:111805. doi: 10.1016/j.foodres.2022.111805. [ DOI ] [ PubMed ] [ Google Scholar ] Wei D., Chen S., Liu Q.. Review of Fluorescence Suppression Techniques in Raman Spectroscopy. Appl. Spectrosc. Rev. 2015;50:387–406. doi: 10.1080/05704928.2014.999936. [ DOI ] [ Google Scholar ] Cai Y., Yang C., Xu D., Gui W.. Baseline correction for Raman spectra using penalized spline smoothing based on vector transformation. Anal. Methods. 2018;10:3525–3533. doi: 10.1039/C8AY00914G. [ DOI ] [ Google Scholar ] Andrejevic N., Andrejevic J., Bernevig B. A., Regnault N., Han F., Fabbris G., Nguyen T., Drucker N. C., Rycroft C. H., Li M.. Machine-learning spectral indicators of topology. Adv. Mater. 2022;34:2204113. doi: 10.1002/adma.202204113. [ DOI ] [ PubMed ] [ Google Scholar ] Hung N. T., Okabe R., Chotrattanapituk A., Li M.. Universal Ensemble-Embedding Graph Neural Network for Direct Prediction of Optical Spectra from Crystal Structures. Adv. Mater. 2024;36:2409175. doi: 10.1002/adma.202409175. [ DOI ] [ PubMed ] [ Google Scholar ] Srivastava S., Wang W., Zhou W., Jin M., Vikesland P. J.. Machine learning-assisted surface-enhanced Raman spectroscopy detection for environmental applications: a review. Environ. Sci. Technol. 2024;58:20830–20848. doi: 10.1021/acs.est.4c06737. [ DOI ] [ PMC free article ] [ PubMed ] [ Google Scholar ] Liu S., Song J., Feng S., Li J., Wang X., Wang X., Wang Y., Liu G.. Composite Nanotube Arrays for Pesticide Detection Assisted with Machine Learning Based on SERS Effect. ACS Appl. Nano Mater. 2025;8:9544–9554. doi: 10.1021/acsanm.5c01351. [ DOI ] [ Google Scholar ] Yu Y., Lu W., Yao X., Jiang Y., Li J., Yang M., Huang X., Tang X.. Machine learning-integrated surface-enhanced Raman spectroscopy analysis of multicomponent dye mixtures. Spectrochim. Acta A Mol. Biomol. Spectrosc. 2025;332:125806. doi: 10.1016/j.saa.2025.125806. [ DOI ] [ PubMed ] [ Google Scholar ] Yang R., Li Y., Qin B., Zhao D., Gan Y., Zheng J.. Pesticide detection combining the Wasserstein generative adversarial network and the residual neural network based on terahertz spectroscopy. RSC Adv. 2022;12:1769–1776. doi: 10.1039/D1RA06905E. [ DOI ] [ PMC free article ] [ PubMed ] [ Google Scholar ] Hu Y., Ma B., Wang H., Zhang Y., Li Y., Yu G.. Detecting different pesticide residues on Hami melon surface using hyperspectral imaging combined with 1D-CNN and information fusion. Front. Plant Sci. 2023;14:1105601. doi: 10.3389/fpls.2023.1105601. [ DOI ] [ PMC free article ] [ PubMed ] [ Google Scholar ] Xie Y., Yang S., Zhou S., Liu J., Zhao S., Jin S., Chen Q., Liang P.. SE-ResNet-based classifier for highly similar mixtures based on Raman spectrum: Classification for alcohol systems as an example. J. Raman Spectrosc. 2023;54:191–200. doi: 10.1002/jrs.6466. [ DOI ] [ Google Scholar ] Hu J., Zou Y., Sun B., Yu X., Shang Z., Huang J., Jin S., Liang P.. Raman spectrum classification based on transfer learning by a convolutional neural network: Application to pesticide detection. Spectrochim. Acta, Part A. 2022;265:120366. doi: 10.1016/j.saa.2021.120366. [ DOI ] [ PubMed ] [ Google Scholar ] Wu Y., He Y., Wang Y.. Multi-Class Weed Recognition Using Hybrid CNN-SVM Classifier. Sensors. 2023;23:7153. doi: 10.3390/s23167153. [ DOI ] [ PMC free article ] [ PubMed ] [ Google Scholar ] Taparhudee W., Jongjaraunsuk R., Nimitkul S., Suwannasing P., Mathurossuwan W.. Optimizing Convolutional Neural Networks, XGBoost, and Hybrid CNN-XGBoost for Precise Red Tilapia (Oreochromis niloticus Linn.) Weight Estimation in River Cage Culture with Aerial Imagery. AgriEngineering. 2024;6:1235–1251. doi: 10.3390/agriengineering6020070. [ DOI ] [ Google Scholar ] Chin C.-L., Chang C.-E., Chao L.. Interpretable Multiscale Convolutional Neural Network for Classification and Feature Visualization of Weak Raman Spectra of Biomolecules at Cell Membranes. ACS Sens. 2025;10:2652–2666. doi: 10.1021/acssensors.4c03260. [ DOI ] [ PMC free article ] [ PubMed ] [ Google Scholar ] Deng, J. ; Dong, W. ; Socher, R. ; Li, L.-J. ; Li, K. ; Fei-Fei, L. . Imagenet: A large-scale hierarchical image database. In 2009 IEEE Conf. Comput. Vis. Pattern Recognit, 2009, pp 248–255. [ Google Scholar ] Trang T. N. Q., Vinh L. Q., Doanh T. T., Thu V. T. H.. Structure-adjustable colloidal silver nanoparticles on polymers grafted cellulose paper-based highly sensitive and selective SERS sensing platform with analyte enrichment function. J. Alloys Compd. 2021;867:159158. doi: 10.1016/j.jallcom.2021.159158. [ DOI ] [ Google Scholar ] Liu J., Osadchy M., Ashton L., Foster M., Solomon C. J., Gibson S. J.. Deep convolutional neural networks for Raman spectrum recognition: a unified solution. Analyst. 2017;142:4067–4074. doi: 10.1039/C7AN01371J. [ DOI ] [ PubMed ] [ Google Scholar ] Huang W., Shang Q., Xiao X., Zhang H., Gu Y., Yang L., Shi G., Yang Y., Hu Y., Yuan Y.. et al. others Raman spectroscopy and machine learning for the classification of esophageal squamous carcinoma. Spectrochim. Acta A Mol. Biomol. Spectrosc. 2022;281:121654. doi: 10.1016/j.saa.2022.121654. [ DOI ] [ PubMed ] [ Google Scholar ] Chen, T. ; Guestrin, C. . Xgboost: A scalable tree boosting system. In Proceedings of the 22nd ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, 2016, pp 785–794. [ Google Scholar ] Cheng M., Okabe R., Chotrattanapituk A., Li M.. Machine learning detection of Majorana zero modes from zero-bias peak measurements. Matter. 2024;7:2507–2520. doi: 10.1016/j.matt.2024.05.028. [ DOI ] [ Google Scholar ] Pedregosa F., Varoquaux G., Gramfort A., Michel V., Thirion B., Grisel O., Blondel M., Prettenhofer P., Weiss R., Dubourg V.. et al. Scikit-learn: Machine learning in Python. J. Mach. Learn. Res. 2011;12:2825–2830. [ Google Scholar ] Associated Data This section collects any data citations, data availability statements, or supplementary materials included in this article. Supplementary Materials ci6c00396_si_001.pdf (240.2KB, pdf) Data Availability Statement All scripts, data sets, and source code are available at https://github.com/nguyen-group/MLRaman . Articles from Journal of Chemical Information and Modeling are provided here courtesy of American Chemical Society ACTIONS View on publisher site PDF (4.9 MB) Cite Collections Permalink PERMALINK Copy RESOURCES Similar articles Cited by other articles Links to NCBI Databases Cite Copy Download .nbib .nbib Format: AMA APA MLA NLM Add to Collections Create a new collection Add to an existing collection Name your collection * Choose a collection Unable to load your collection due to an error Please try again Add Cancel Follow NCBI NCBI on X (formerly known as Twitter) NCBI on Facebook NCBI on LinkedIn NCBI on GitHub NCBI RSS feed Connect with NLM NLM on X (formerly known as Twitter) NLM on Facebook NLM on YouTube National Library of Medicine 8600 Rockville Pike Bethesda, MD 20894 Web Policies FOIA HHS Vulnerability Disclosure Help Accessibility Careers NLM NIH HHS USA.gov Back to Top

Related documents

Record · ID 14955 · SHA-256 a9349b1eff361740
Retrieved via Conceptio — every document is proof-bundled with source, license, and retrieval metadata.