Abstract
Surface-Enhanced Raman Spectroscopy (SERS) substrates offer a promising solution for the sensitive and specific detection of agrochemicals, enabling timely interventions to mitigate their harmful effects on humans and ecosystems. However, the analysis of SERS spectra can be challenging due to the complexity of interpreting the data, often requiring advanced computational tools and expertise. This limitation highlights the need for continued innovation in both SERS technology and data analysis methods to fully realize its potential in real-world applications. In this context, we present a machine-learning model based on a feedforward neural network for the rapid and accurate classification of SERS spectra. Our approach consists of a highly compact neural network combined with feature engineering that was trained using SERS patterns from experimental measurements. The spectra used to train this model were acquired using substrates made of gold nanostars, which were deposited onto aluminum foil via drop-casting. The model utilizes a compact two-layer architecture, with five Leaky ReLU neurons in the hidden layer and four softmax neurons in the output layer. This design ensures computational efficiency by using only dense layers for matrix-vector multiplications. Notably, we performed feature engineering to optimize the input data; specifically, we derived 20 key features from transformation functions applied to the SERS spectra. The model demonstrates strong predictive performance, achieving high precision and recall values across all classes, with an overall classification accuracy of 98.5% for organophosphate pesticides and their mixtures. Compared to other machine-learning algorithms, our approach offers reduced computational complexity while maintaining or exceeding the accuracy of more complex models. This makes the proposed model particularly suitable for deployment in resource-limited environments, providing an efficient and effective tool for agrochemical compound classification in diverse environmental and food matrices.

Original content from this work may be used under the terms of the Creative Commons Attribution 4.0 license. Any further distribution of this work must maintain attribution to the author(s) and the title of the work, journal citation and DOI.
1. Introduction
Pesticide contamination is a global challenge with significant environmental, health, and food security implications. It harms biodiversity, disrupts ecosystems, and impacts agricultural trade and sustainability. Addressing this issue requires stricter regulations, the adoption of sustainable practices, and the development of advanced detection methods to effectively monitor and mitigate pesticide exposure [1]. The use of phytosanitary products such as pesticides has been essential for protecting crops or plants of agronomic importance, as they allow the elimination, control, or eradication of pests, which can include insects, rodents, or certain types of animals that harm crops [2]. They are also used to prevent or control diseases caused by plant pathogens, as well as to avoid or eradicate other invasive or unwanted plant species that affect plant development [3].
Recent years have witnessed increasing apprehension regarding their detrimental impacts on human health and the environment. organophosphate pesticides (OPs), introduced in the 1960s, have become so extensively utilized that they now represent approximately 40% of all pesticides used globally. They are classified based on their chemical structure or functional groups, such as carbamates, pyrethroids, polychlorinated biphenyls, chlorinated compounds, organophosphates, and neonicotinoids [3, 4]. Importantly, certain insects have acquired resistance to OPs, diminishing their efficacy and requiring the application of greater amounts. This increases the likelihood that these substances enter the environment or interact with humans [5].
Surface-Enhanced Raman Spectroscopy (SERS) has emerged as a promising alternative for pesticide analysis, offering several advantages over traditional methods. SERS provides high sensitivity and rapid response times, making it ideal for detecting low concentrations of pesticides in real-time. By utilizing noble metal nanomaterials, SERS amplifies the Raman signal through the generation of 'hot spots' by localized surface plasmon resonance, significantly improving detection capabilities [6]. In contrast, routine techniques such as High-Performance Liquid Chromatography (HPLC) and Gas Chromatography coupled with Mass Spectrometry (GC-MS) are effective for detecting pesticides at nanomolar concentrations but require complex sample preparation and are often time-consuming [7]. These methods are typically more resource-intensive and not suitable for on-site or high-throughput applications. While Raman spectroscopy offers a simpler preparation process, it is limited by low analytical sensitivity, susceptibility to noise, and signal masking by interferents. However, SERS addresses these limitations, making it a more efficient and accessible technique for pesticide detection [8].
Unfortunately, as the signal from the sample is amplified, the signals from some interferences are also enhanced, making it challenging to discriminate between organophosphorus pesticide signals and those from other molecules [9]. Additionally, the examination of spectra is intricate and frequently labor-intensive, hindering the widespread application of this analytical approach. Automation is crucial for SERS-based pesticide detection due to several challenges inherent in the analysis process. First, the complex nature of the spectra can lead to overlapping peaks, where the signals from the target analytes are often obscured by signals from other molecules. This phenomenon is particularly problematic because the enhanced signal from the sample also amplifies interference, making it difficult to differentiate pesticide signals from those of other substances. Second, the manual interpretation of these spectra is not only time-consuming but also prone to errors, especially when dealing with large datasets or when spectra overlap in subtle ways that are difficult to discern visually.
In this regard, Machine learning (ML) has emerged as a transformative force, showcasing its capacity to identify intricate patterns and provide novel insights across various scientific disciplines [10]. Fields that rely on artificial intelligence have seen a significant transformation due to the capacity of ML algorithms to uncover complex and concealed relationships within extensive data sets [11]. Raman spectrum classification is a notable application of ML, with numerous studies demonstrating its effectiveness. For instance, deep learning models have been used to categorize deep-sea cold seep microorganisms based on their Raman spectra, achieving an exceptional average accuracy exceeding 97% using a transformer model; a novel approach in this context [12]. On the other hand, SERS spectral analysis, have seen a significant transformation due to ML's ability to automate and enhance tasks like spectral classification, pattern recognition, and noise mitigation [10, 12, 13]. For instance, convolutional neural networks (CNNs) have been employed to automate peak detection and denoising in Raman spectra, while compact architectures like feedforward neural networks (FNNs) enable rapid classification with minimal computational overhead [14]. Additionally, ML algorithms have proven effective in discerning cell phenotypes from Raman data, addressing challenges posed by unordered, high-dimensional datasets [15].
While traditional methods such as the principal component analysis method combined with the linear discriminant analysis method have historically been applied, recent advances in deep learning have significantly outperformed these techniques in classifying SERS spectra of pesticides [16, 17]. These developments underscore the transformative potential of integrating ML with Raman spectroscopy, particularly in environmental and food safety applications.
This work utilizes the self-learning attributes of artificial neural networks to detect OPs from SERS spectra. Our approach consists of a highly compact neural network combined with feature engineering that was trained using SERS patterns from experimental measurements. This method improves spectral analysis accuracy, facilitating the development of more efficient analytical techniques for detecting pesticides in diverse environmental matrices.
2. Methodology
2.1. Chemicals
Chloroauric acid , sodium citrate, HCl, , ascorbic acid, and hexadecyltrimethylammonium bromide (CTAB) were provided by Merck–Sigma Aldrich. Edifenphos and parathion analytical standards were purchased from AccuStandard. Certified Reference Materials were used as analyte pesticides. The purity level of edifenphos and parathion were 99.4 % and 99.6 %, respectively, as determined by GC-MS. This was verified through the Certificate of Analysis provided by AccuStandard.
2.2. Synthesis of plasmonic materials and SERS substrates
The SERS spectra were obtained using substrates based on gold nanostars (AuNS) on aluminum supports, as shown in figure 1(a). Four groups of samples were analyzed: (i) Edifenphos, (ii) Parathion, (iii) a combination of both pesticides, and (iv) various random sources labeled as the control group. Figure 1(b) displays a conceptual representation of SERS spectra corresponding to those groups.
Figure 1. (a) SERS Set-up showing the analyte over the substrate been studied with a 785 nm laser. (b) SERS spectra from four different sources: Edifenphos (Green), Parathion (Blue), a mixture of both (Purple) and unidentified sources as a control group (Red). Each main group was analyzed at different concentrations. (c) Database of 116 records, shuffled from all four classes, which was analyzed to extract key features, specifically 20 engineered ones. This feature vector is then fed into a compact Artificial Neural Network for classifying the four classes. After 100 realizations, the model achieves a prediction accuracy of 98.5%.
Download figure:
Standard image High-resolution imageThe AuNS were synthesized according to the following protocol. Gold seeds (AuNp) were first obtained using the Turkevich method, starting with a solution of chloroauric acid , 0.5 mM, 10 mL), which was heated to 90 ∘C with constant stirring. Once this temperature was reached, sodium citrate ,34 mM, 1 mL) was added, and the reaction was allowed to proceed for 6 min until a color change from black to blue, then to purple, and finally to a deep red was observed. The gold seeds were removed from the heat source and stored in a glass vial covered with aluminum foil to protect them from light.
To synthesize gold nanostars (AuNS), a solution of chloroauric acid (, 0.25 mM, 10 mL), gold seeds (7.2 µL), and hydrochloric acid (HCl, 1 M, 40 µL) was mixed under magnetic stirring for 2 min. Subsequently, a solution of silver nitrate (, 3 mM, 400 µL) and ascorbic acid (, 0.1 M, 400 µL) was added concurrently, allowing the reaction to proceed for 3 min. Finally, hexadecyltrimethylammonium bromide (CTAB, 2 M, 2 mL) was introduced and stirred magnetically for 30 min. The AuNS were then centrifuged and washed twice at 6000 revolutions per minute (rpm) for 10 min, and subsequently suspended in 2 ml of distilled water. The substrates were prepared on aluminum foil on a microscope slide, where 5 µL of the nanomaterials suspended in water were placed and left to dry at room temperature inside Petri dishes. For each measurement, 5 µL of the pesticide solutions were placed in concentrations of 10, 8, 6, 4, 2, 1, 0.8, 0.6, 0.4, 0.2, 0.1, and 0.01 µM. As a blank, the pesticide measurement without nanostructures was used. Mixtures of these pesticides with varying concentrations were also analyzed. The binary pesticide mixtures were prepared by keeping the concentration of one pesticide constant while varying the concentration of the other. In five of the mixtures, the concentration of Edifenphos was fixed at 600 nM, and the concentrations of Ethyl Parathion were varied at 1, 0.8, 0.6, 0.4, and 0.2 µM. In the other five mixtures, the procedure was reversed, with the concentration of Ethyl Parathion fixed at 600 nM and the concentration of Edifenphos varied at 1, 0.8, 0.6, 0.4, and 0.2 µM. The spectra of fifteen random samples (intentionally not identified in this work) were used as a negative control. After adding the analytes, the substrates were left to dry at room temperature inside covered Petri dishes to prevent contamination. They were shielded from direct light and stored in these dishes before measurement. Raman spectra were acquired using a Bruker Senterra Raman spectrometer, with a 785 nm laser, 20× objective, integration times of 6 s, 6 scans, 3 repetitions, and powers of 50 and 100 mW, within a range of 440 to 1800 cm−1.
2.3. ML
This study uses artificial neural networks to categorize four distinct compounds according to their SERS spectra. SERS spectra encompass substantial information, including peaks linked to distinct vibrational modes, allowing for the application of ML algorithms to discern underlying patterns within this data. SERS spectra were acquired from both ediphenfos and parathion molecules, along with control molecules from random sources, to establish a unique set of SERS spectra that guarantees unbiased classification. Additionally, ediphenfos and parathion were combined to produce blends of varying concentrations, resulting in four classification categories. Subsequent to acquisition, the SERS spectra were organized into a dataset, with each spectrum represented as a column vector of numerical intensity values. The spectra were categorized based on their respective classifications: Edifenphos, Parathion, their combination, or the control group. Prior to training the ML model, the spectra underwent pre-processing to ensure uniformity and enhance model efficacy. The intensity values were standardized utilizing StandardScaler, which adjusts the data to possess a mean of zero and a standard deviation of one.
The proposed machine-learning model is a FNN implemented in Python using the TensorFlow framework and Keras API. The architecture comprises a two-layer neural network, as shown in figure 1(c), with the hidden layer including five Leaky ReLU neurons. Finally, we employed four softmax neurons in the output layer for the classification task, this way, softmax activation functions in the output layer ensure that the model provides a probability distribution over predicted output classes. This four neurons correspond directly to the four sample groups (Edifenphos, Parathion, their mixture, and the control group). This architecture is compact and utilizes solely dense layers that execute matrix-vector multiplications. Compact machine-learning models have been shown to effectively solve regression and classification tasks [18–22]. Note that our architecture is designed to minimize computational complexity, allowing for efficient implementation in resource-constrained devices while maintaining high classification performance. In contrast, deep learning models such as CNNs require substantial datasets for training and significant computational resources to achieve comparable performance. Similarly, other ML approaches, such as support vector machines (SVMs) with nonlinear filters, typically necessitate meticulous hyperparameter tuning and greater processing power than our shallow neural network.
The database includes a total of 116 SERS spectra: 36 of edifenphos, 36 of parathion, 29 of their mixes, and 15 negative spectra. Each spectrum spans 2721 points in total, with each point corresponding to an intensity. Notably, we include the intensities of the spectrum in the feature vector alongside 20 additional features obtained through the feature engineering process. The resultant data frame consists of 2741 features and 116 rows.
Given the relatively small size of the dataset, we employed the K-Fold Cross Validation (KCV) algorithm to evaluate the performance of our model. This approach involves partitioning the data into clusters known as folds [23]. For this study, we implemented 15 folds. The model is then trained using 14 of these folds, with the remaining fold reserved for testing. The classification accuracy of the model is evaluated using the 15th fold, and the result is recorded. Subsequently, the synaptic weights of the neural network are reset, and the process is repeated, excluding a different fold for validation each time. In each iteration, one fold works as the validation set while the remaining folds are used for training. After completing all iterations, the recorded performance metrics are averaged. Due to the compact architecture of the model, we selected the Adam optimizer which has been widely used and has demonstrated effectiveness in shallow neural networks [24]. To avoid overfitting we used L2 regularization with a penalty coefficient of . Additionally, we incorporated the sparse categorical cross-entropy, a widely used loss function for classification algorithm optimization [25], which is defined as:
where y is the true label, represented as an integer. is the predicted probability of the model. N is the number of classes. is an indicator function that equals 1 if (i.e. the true label for the class), and 0 otherwise. is the natural logarithm of the predicted probability for the class i. For each KCV iteration, the model was trained over 50 epochs with a learning rate of . To ensure statistical reliability, the KCV algorithm was independently repeated 10 times. It is important to mention that the data was randomized using a distinct random seed for independent realization. This procedure ensured that the data was randomly partitioned into training and validation sets for each fold, thereby mitigating potential biases arising from the sequence of the samples. The hyperparameters, including the learning rate, number of epoch, and architecture, were selected through empirical testing informed by prior studies on compact neural networks for spectral data, followed by iterative manual validation to balance performance and computational efficiency.
2.4. Feature Engineering
Feature engineering is a fundamental process in data preparation for ML. It entails the utilization of transformation functions, including arithmetic and aggregation operators, on existing features to create new ones [26]. As demonstrated by the study of [27], feature engineering is a key process to extract hidden features in SERS spectra. Although data and feature extraction mechanisms for SERS spectra can be certainly simplified with the incorporation of CNNs as demonstrated by [14], we aim to reduce the computational complexity of the algorithm to allow its implementation in resource-limited environments. This process allows neural networks to be more efficient than other algorithms like SVMs. In this work, we propose the implementation of 20 engineered features. All engineered features were computed per-sample (row-wise), ensuring no leakage from test data into training.
The mean represents the average intensity across the SERS spectral range and can be defined with the following equation:
where N is the total number of data points (or spectral readings), and yi represents the intensity value at each point i in the spectrum. The mean has been a widely employed and powerful feature for signal classification tasks [28]. The standard deviation measures the spread of the intensity values in a SERS spectrum. It is defined as follows,
The standard deviation has been employed as a feature for predictive models by [29] for acute hypotensive episodes prediction using only non-invasive parameters. The Euclidean norm, also known as the magnitude of the vector, measures the distance of a vector from the origin. For the intensities vector of the Raman spectra , the Euclidean norm is calculated as follows:
Similarly, the sum of squares is the sum of the squared components of the intensities vector y,
The variance is computed as the average squared deviation from the mean intensity in a SERS spectrum:
Importantly, variance is an easy-to compute feature that has been incorporated for predictive purposes by [30].
In addition, we define the signal stability as the inverse of the variance:
The kurtosis provides a meaningful insight into the peakedness of the spectrum [31], and it is defined by the following equation:
The skewness measures the asymmetry of the spectrum's distribution, which was incorporated by [32] for precise predictive purposes. The equation for the skewness is as follows,
The normalized energy measures the overall energy of the spectrum, and it is computed as the normalized sum of the squared intensities,
Mean Absolute Deviation (MAD) is a metric of the dispersion or variability in the spectrum intensity and it is defined by the following equation:
The max value represents the highest intensity in the spectrum,
whereas the minimum value represents the smallest intensity value,
Notably, the minimum and maximum values are features widely used for neural network ML models [33]. In fact, the range is defined as the difference between the highest and lowest intensity values,
The interquartile range is a measure of the spread of the middle 50% of the data [33]. It is computed as follows:
where Q1 and Q3 are the first and third quartiles, respectively.
On the other hand, the maximum deviation from the mean is the absolute value of the difference between the highest intensity value and the mean intensity:
Similarly, the minimum deviation from the mean is the absolute value of the difference between the lowest spectrum intensity value and the mean intensity:
The coefficient of variation (CV) is a mathematical relationship between the standard deviation and the mean intensity of a SERS spectrum. It was defined by [34]:
The peak count indicates the number of intensity peaks detected in the spectrum. The average peak distance measures the average distance between consecutive peaks in the spectrum,
where pi and refer to two consecutive peaks, and k corresponds to the total number of peaks detected. We employed a peak-finding algorithm that compares local maxima that stand out relative to its surroundings based on the spectrum amplitude [35].
The max position represents the index of the highest intensity value in the spectrum. It can be defined as:
where represents the Raman spectra as a function of Raman shift, Λ.
Finally, we incorporated differential calculus computations to include features related to the rate of change of the spectra. The gradient function calculates the instantaneous derivative of a set of data points. Once the set of instantaneous derivatives is computed for each SERS spectrum, two features are extracted One of them is the maximum value of the gradient or the highest rate of change in the data and the other is the standard deviation of the gradient set of values. All the previously computed features were extracted from the SERS spectra in our database and used as input for our neural network algorithm.
3. Results and discussions
The synthesized AuNS suspensions exhibit a characteristic intense blue color, which is related to their size and morphology. Morphological characterization by Scanning Electron Microscopy revealed stars with cores averaging 45 nm in radius and a mean peak-to-peak distance of 80 nm, as shown in figure 2(a). The efficiency of localized plasmon resonance is commonly higher than rods or spheres when structures with spikes are used. Their sharp tips generate multiple hot spots that enhance the Raman signal, enabling the detection of analytes at very low concentrations and providing more uniform and consistent SERS enhancements. Additionally, their high surface area facilitates better functionalization and interactions with probe molecules, further improving sensitivity and specificity. Furthermore, gold nanostars exhibit broad tunability of plasmonic properties, allowing optimization for different excitation wavelengths, and more specifically, the 785 nm excitation wavelength used in this work. SERS substrates were prepared by simply depositing 5 µL of an AuNS suspension onto an aluminum foil support. While conventional glass or silicon wafers are viable alternatives for developing SERS substrates, aluminum foil was preferred in this work due to several advantages. These include its high reflectivity, which enhances Raman signal sensitivity, and its ability to support localized surface plasmon resonance without generating noise or signals that may interfere with the spectra. Aluminum is also more cost-effective, readily available, and easier to manipulate compared to glass or silicon wafers. Furthermore, its flexibility and lightweight nature make it ideal for portable, field-based applications, unlike glass and silicon, which are heavier and more rigid [36, 37]. The homogeneous particle size distribution, as well as their concentration, ensures adequate spacing for the formation of hotspots essential for the SERS effect and guarantees the repeatability of the analytical response.
Figure 2. (a) Scanning Electron Microscopy (SEM) image of the synthesized AuNS, (b) Raman spectra of 10 µM Edifenphos as a function of the AuNS concentration, and (c) the corresponding intensity of the peaks at 1080 cm−1.
Download figure:
Standard image High-resolution imageSince the SERS enhancement effect depends on the AuNS concentration, spectra were obtained from the substrates using this variable while keeping the edifenphos concentration constant (figure 2(b)). Regardless of the AuNS concentration used, the set of characteristic signals of the pesticide was clearly identified. The signals at 1000 and 1020 cm−1 are attributed to aromatic rings, while those at 1080 and 1580 cm−1 correspond to C–H and P–O bonds, respectively. To select an optimal AuNS concentration, the most intense peak representative of the fingerprint region (1080 cm−1) was chosen, and the graph shown in figure 2(c) was prepared. It was determined that the optimal AuNS concentration is 400 , as higher concentrations induce aggregation, leading to decreased signal intensity due to shielding effects of the excitation source (figure 2(c)).
Using this optimal AuNS concentration, SERS spectra were obtained for different concentrations of edifenphos (figure 3(a)) and ethyl parathion (figure 3(b)), where the characteristic signal sets for each pesticide are observed. The spectra in figure 3(a) shows the characteristics spectral fingerprint of edifenphos, as described in figure 2(b), whereas the spectra of ethyl parathion (figure 3(b)) shows main bands at 853 cm−1 (P–O), 1114 cm−1 (C–N), 1265 cm−1 (N–O), 1349 cm−1 (C–H), and 1585 cm−1 (P–O). A gradual increase in the intensity of some significant peaks was demonstrated as pesticide concentrations increased in the range of 10 nM to 8 µM. For the preparation of calibration curves, the SERS signals at 1080 and 1265 cm−1 were considered for edifenphos and ethyl parathion, respectively, and the results are shown in figures 4(a) and (b). The enhancement factors (EF) calculated for the determination of both pesticides were obtained using the next equation [38]
Figure 3. Raman spectra of (a) Edifenphos, (b) Parathion, (c) Mixtures of both, and (d) Examples of sources as a control group.
Download figure:
Standard image High-resolution imageFigure 4. (a) and (b) are the calibration curves considering the intensities of the representative peaks measured at 1080 and 1265 cm−1.
Download figure:
Standard image High-resolution imagewhere ISERS is the Raman intensity of the selected pesticide peak measured on the AuNS substrate, IRaman is the signal intensity of the peak obtained on the bare aluminum foil substrate, and NSERS and NRaman represent the number of pesticide molecules contributing to the SERS and Raman measurement signals, respectively. Accordingly, EFs of and were calculated for edifenphos and ethyl parathion, respectively. These results allow for the correlation of intensity with pesticide concentration, regardless of some signals remaining practically unchanged within this concentration range. For their part, the spectra of the pesticide mixtures presented in figure 3(c) shows the entire set of peaks at the positions previously described for each pesticide individually, although with significant variations in the ratio of their intensities, as well as small shifts. Additionally, the spectra of the mixtures show some signals that were not present in the spectra of each pesticide individually. The appearance of additional SERS spectral signals in pesticide mixtures, which are not present in individual pesticide spectra, can result from several factors, primarily molecular interactions between the pesticides or with the SERS substrate. These interactions can alter vibrational modes, producing new peaks or variations in intensity. Synergistic effects may also lead to the formation of new chemical species or complexes, generating new Raman signals. Additionally, charge transfer or electron transfer processes could occur between pesticide molecules or between a pesticide molecule and the substrate, altering the electron density and leading to shifts or new Raman signals. Non-specific interactions, such as simple adsorption, may also contribute to subtle shifts or peak broadening. However, this did not represent a challenge for the development of our automated classification model.
This approach effectively facilitates the categorization and prediction of an agrochemical compound based on its SERS spectrum. In this regard, we have trained and tested a neural network to classify the four distinct compounds according to their SERS spectra shown in figure 3. The final average test accuracy of the model was 98.58%, with a standard deviation of 0.41%, indicating minimal dispersion. Table 1 presents a comprehensive analysis of performance metrics for each class, encompassing precision, recall and F1-score. The results, especially the elevated precision and recall values for all classes, underscore the model's strong predictive ability across the categories. Figure 7 illustrates the confusion matrix generated by the prediction procedure, further validating the model's effectiveness where just the 1.42% has resulted in misclassifications, mostly for the mixture group. Figure 8 shows a Receiver Operating Characteristic (ROC) chart. The ROC curve shows the relationship between the true positive rate (sensitivity) and the false positive rate (1 - specificity) for different classification thresholds in each of the evaluated classes. The area under the ROC curve AUC is a key metric that summarizes the performance of the model. The loss curve from the learning process can be observed in figure 5. We also estimated feature importance using the feature visualization method [39]. Figure 6 presents the normalized importance of the features obtained through our feature engineering procedure and the raw SERS spectra. The darkest regions correspond to the proposed engineered features and specific bands in the raw SERS spectra, highlighting their relevance in the classification process. Additionally, to assess the computational efficiency of our classification algorithm, we calculated the floating-point operations (FLOP) for the proposed model, as well as for an SVM and a CNN with comparable performance. Our algorithm achieves approximately 106 FLOP, whereas the SVM and CNN require around 107 and 109 FLOP, respectively. Notably, both alternative models demand significantly higher computational resources than our approach. Specifically, the CNN performs approximately three orders of magnitude more operations than our model. The training and testing phases for all models were conducted on a system equipped with a 13th Gen Intel Core i7-13 650HX processor operating at 2.60 GHz.
Figure 5. Loss curve for the training process.
Download figure:
Standard image High-resolution imageFigure 6. Estiamted feature importance of the proposed neural network for agrochemical compound classification.
Download figure:
Standard image High-resolution imageFigure 7. Confussion Matrix showing classification accuracy for each class.
Download figure:
Standard image High-resolution imageFigure 8. ROC Curve for Multi-Class Classification.
Download figure:
Standard image High-resolution imageTable 1. Performance metrics for each class.
Class | Precision | Recall | F1 Score |
---|---|---|---|
Edifenphos | 0.9973 | 0.9978 | 0.9871 |
Parathion | 0.9760 | 0.9994 | 0.9850 |
Mixture | 0.9836 | 0.9759 | 0.9794 |
Control | 0.9875 | 1.0000 | 0.9935 |
Remarkably, the performance of the developed neural network model is comparable to that of other state-of-the-art models. Fang et al (2024) [16] proposed a CNN approach for the detection of four pesticides (thiram, triadimefon, benzimidazole, and thiamethoxam), achieving an overall accuracy of 100%. However, CNNs are complex machine-learning algorithms that can be challenging to implement in resource-limited environments. Sahin et al (2022) [40] presented a k-Nearest Neighbors algorithm for the detection of four pesticides (phosmet, thiram, abamectin, and myclobutanil) in water using their SERS spectra, achieving an accuracy of 92.46%. The same study also proposed a decision tree approach with an accuracy of 89.98%, an AdaBoost algorithm with 88.94%, a linear SVM with 85.93%, and a Radial Basis Function SVM with 88.44%. Li et al (2022) [41] developed a highly complex ResNet-based deep learning model for the detection of various organophosphates (methamidophos, dimethoate, glufosinate ammonium, ethyl para-nitro-phenyl, parathion (PT), and phosmet), achieving an accuracy of 96%. As demonstrated, our neural network-based algorithm outperforms most existing models. Nevertheless, performance metrics reported in this study should be interpreted in the context of our specific experimental setup (gold nanostar substrates, organophosphate analytes, and spectral range of 440–1800 cm−1).
One potential limitation in deploying this model in real-world agrochemical detection scenarios is the influence of matrix effects in environmental and food samples. While the model demonstrated high accuracy (98.58%) in controlled conditions using SERS spectra acquired from drop-cast AuNS substrates, complex sample matrices could introduce spectral variations due to interfering substances, background fluorescence, or inconsistent signal intensities. These factors may impact on the model's ability to generalize effectively to real-world samples, which represents a current limitation of most SERS substrate-based detection strategies. Additionally, variations in sample preparation and environmental conditions might necessitate further optimization of the feature engineering process or additional model calibration to maintain accuracy across diverse detection settings.
Notwithstanding, our goal is to offer minimal computational complexity while achieving comparable or even higher accuracy while keeping a very compact architecture. The reported SERS-based method automated through ML offers several advantages over conventional pesticide detection methods like HPLC and GC-MS, particularly in terms of time and cost. SERS analysis can be conducted in situ, without the need for extensive sample preparation, resulting in faster results. Additionally, automation allows for rapid spectral data processing and classification, eliminating the need for manual interpretation, which can be slow. The total analysis time can be reduced from hours to some minutes due to the algorithm's performance. The cost of SERS analysis is typically lower, especially for field applications. The equipment needed for SERS (e.g. portable Raman spectrometers) is generally less expensive to purchase, maintain, and operate compared to the large-scale, sophisticated instruments used in HPLC and GC-MS. This makes SERS a cost-effective solution for large-scale or routine pesticide monitoring, as it allows for rapid and high-throughput analysis with minimal human intervention.
4. Conclusions
A machine-learning model utilizing a FNN was implemented herein for the rapid, automated, and precise classification of SERS spectra, including those of the OPs edifenphos, ethyl PT, their mixtures, and unidentified substances. The spectra were acquired using easily prepared substrates consisting of standard gold nanostars (AuNS) deposited via drop-casting onto aluminum foil. This approach unlocks new opportunities for the accessible and efficient detection of OPs across diverse environmental and food matrices. The proposed architecture features a compact two-layer neural network, comprising a hidden layer with five Leaky ReLU neurons and an output layer with four softmax neurons. By exclusively utilizing dense layers for matrix-vector multiplications, the model achieves an optimal balance between computational simplicity and predictive performance, making it suitable for deployment in resource-limited environments. Feature engineering played a pivotal role in optimizing the model's input data. A total of 20 engineered features were obtained using transformation functions and arithmetic operators applied to the SERS spectra. These features combined with the intensity values from each spectrum, formed the input vector for the neural network, simplifying the architecture while enhancing accuracy. Indeed, the integrated model achieved an overall accuracy of 98.5% during testing, demonstrating its proficiency in classifying spectra associated with various pesticides and unidentified substances. Although CNNs have been shown to simplify feature extraction and improve accuracy, their high computational complexity can hinder implementation in resource-constrained settings. In contrast, the compact FNN proposed here achieves comparable or superior accuracy with significantly reduced computational demands. This approach underscores the practicality of employing a streamlined neural network for SERS-based analysis in diverse resource settings, making it a valuable tool for classifying agrochemical compounds in real-world applications.
Acknowledgments
This work was supported by UNAM-PAPIIT IA100424 and IA103325, and by CONAHCYT through Ciencia Básica y de Frontera CBF2023-2024-1041/C-549/2024 and Ciencia de Frontera CF-2023-I-1496. M F A thankfully acknowledges financial support by CONAHCyT for posdoctoral Grant. M O E thankfully acknowledges financial support by CONAHCyT for doctoral grant.
Data availability statement
The data cannot be made publicly available upon publication because they are not available in a format that is sufficiently accessible or reusable by other researchers. The data that support the findings of this study are available upon reasonable request from the authors.
Conflict of interests
The authors declare no competing interests