Surface enhanced Raman spectrum water pollution detection method and device based on machine learning
By combining machine learning methods with local averaging algorithms and support vector machine models, the problems of insufficient accuracy and stability in surface-enhanced Raman spectroscopy for water pollution detection are solved, achieving high-precision and high-stability water pollution detection, especially with 100% detection accuracy under low concentration conditions.
Patent Information
- Application Number
- CN202511113754.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-11
- Publication Date
- 2025-12-23
AI Technical Summary
Existing technologies for water pollution detection based on surface-enhanced Raman spectroscopy have low accuracy and poor stability, especially in low-concentration detection where the target signal is easily drowned out by background noise.
A machine learning-based approach was adopted to extract surface-enhanced Raman spectral feature vectors of polycyclic aromatic hydrocarbons using a local averaging algorithm. The detection was then performed using a support vector machine model. Combined with spectral preprocessing and feature extraction techniques, including validity verification, wavenumber range limitation, normalization, and gridded resampling, the parameters of the support vector machine model were optimized to improve detection accuracy and stability.
It significantly improves the accuracy and stability of water pollution detection, especially achieving 100% accuracy in low-concentration detection, reducing reliance on manual interpretation and data annotation costs, and providing a highly sensitive and reliable automated detection solution.
Smart Images

Figure CN121186006A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of water pollution detection technology, and in particular to a surface-enhanced Raman spectroscopy method and apparatus for water pollution detection based on machine learning. Background Technology
[0002] The detection of pollutants in water bodies is crucial for environmental protection and public health. With industrialization and urbanization, various pollutants, including organic matter, heavy metals, and microplastics, may appear in water bodies. In recent years, surface-enhanced Raman spectroscopy (SERS) has become a powerful tool for pollutant detection due to its high sensitivity, rapid response, and the elimination of the need for complex sample preparation. This technique obtains the molecular fingerprint information of a sample by measuring the scattering of monochromatic light by molecules, thereby enabling qualitative and quantitative analysis of substances. This non-destructive detection method is applicable not only to liquid, solid, and gaseous samples but also to the direct analysis of complex systems containing multiple substances without sample preparation.
[0003] Currently, while traditional surface-enhanced Raman spectroscopy (SERS) provides complete spectral information, the large amount of redundant data and noise severely impacts analytical accuracy, especially in low-concentration detection where the target signal is easily overwhelmed by background noise. Furthermore, traditional SERS relies heavily on operator experience and simple mathematical models, resulting in a highly subjective analytical process and poor reproducibility.
[0004] Therefore, existing technologies have significant shortcomings in water pollution detection based on surface-enhanced Raman spectroscopy. More advanced methods are needed to improve the accuracy and stability of water pollution detection based on surface-enhanced Raman spectroscopy. It is necessary to provide a machine learning-based surface-enhanced Raman spectroscopy water pollution detection method to solve the above problems. Summary of the Invention
[0005] This invention provides a method and apparatus for water pollution detection based on surface-enhanced Raman spectroscopy using machine learning, in order to solve the problems of low detection accuracy and poor stability in existing water pollution detection methods based on surface-enhanced Raman spectroscopy.
[0006] In a first aspect, embodiments of the present invention provide a surface-enhanced Raman spectroscopy method for detecting water pollution based on machine learning, comprising:
[0007] Surface-enhanced Raman spectral data of the water sample to be tested are acquired, and the surface-enhanced Raman spectral data of the water sample to be tested are preprocessed;
[0008] From the preprocessed surface-enhanced Raman spectral data, the spectral feature vectors of polycyclic aromatic hydrocarbons were determined using a local averaging algorithm.
[0009] Based on the feature vectors, the detection results of the water sample to be tested are determined using a support vector machine model.
[0010] Optionally, before preprocessing the surface-enhanced Raman spectral data of the water sample to be tested, the method further includes:
[0011] The validity of the surface-enhanced Raman spectroscopy data of the water sample to be tested was verified.
[0012] Optionally, the preprocessing of the surface-enhanced Raman spectroscopy data of the water sample to be tested includes:
[0013] The spectral wavenumber range of the surface-enhanced Raman spectroscopy data is defined.
[0014] The spectral intensities of the surface-enhanced Raman spectral data within the defined range are normalized.
[0015] Optionally, after preprocessing the surface-enhanced Raman spectral data of the water sample to be tested, the method further includes:
[0016] A linear interpolation algorithm was used to resample the normalized surface-enhanced Raman spectroscopy data into a grid.
[0017] Optionally, from the preprocessed surface-enhanced Raman spectral data, the surface-enhanced Raman spectral feature vectors of polycyclic aromatic hydrocarbons are determined using a local averaging algorithm, including:
[0018] Based on the chemical structure of polycyclic aromatic hydrocarbons, the positions of at least five target characteristic peaks were determined from the pretreated surface-enhanced Raman spectroscopy data;
[0019] Based on the local average feature extraction algorithm, the feature values of each target feature peak are extracted;
[0020] The feature values are arranged into a feature vector according to the order of peak wave number of each target feature from largest to smallest.
[0021] Optionally, the local average feature extraction algorithm for extracting feature values of each target feature peak includes:
[0022] Based on the positions of each target feature peak, determine the local range corresponding to each target feature peak position;
[0023] The average spectral intensity of all surface-enhanced Raman spectral data points within each local area is calculated and used as the characteristic value of each target characteristic peak.
[0024] Optionally, based on the feature vector, the detection result of the water sample to be tested is determined using a support vector machine model, including:
[0025] The feature vectors are standardized.
[0026] Based on the standardized feature vector, the probability prediction value of the presence of polycyclic aromatic hydrocarbons in the water sample to be tested is output through the support vector machine model.
[0027] Determine whether the predicted probability value is greater than or equal to a preset threshold;
[0028] If so, the detection result indicates that the water sample to be tested contains polycyclic aromatic hydrocarbons.
[0029] Optionally, training the support vector machine model includes:
[0030] A sample dataset of surface-enhanced Raman spectra with different concentrations of polycyclic aromatic hydrocarbons is constructed, wherein the sample dataset includes a training set and a test set;
[0031] The optimal support vector machine model parameters are determined using a grid search algorithm within a preset parameter space, through the training set and the test set.
[0032] Using the sample dataset, a support vector machine model with optimally configured support vector machine model parameters is retrained, and predictions are made using a test set to determine the prediction accuracy of the support vector machine model.
[0033] Optionally, the step of employing a grid search algorithm to determine the optimal support vector machine model parameters within a preset parameter space using the sample dataset includes:
[0034] Based on the preset parameter space, various combinations of support vector machine model parameters within the preset parameter space are determined, wherein the combination of support vector machine model parameters includes regularization parameters, kernel function parameters, kernel function type, and class weight balancing parameters;
[0035] Based on the training set, a support vector machine model with each of the parameter combinations is trained;
[0036] Based on the test set, the trained support vector machine models with each of the parameter combinations are tested to determine the F1 score corresponding to each parameter combination.
[0037] The grid search algorithm is used to select the parameter combination with the highest score as the optimal support vector machine model parameters.
[0038] Secondly, embodiments of the present invention provide a surface-enhanced Raman spectroscopy-based water pollution detection device, comprising:
[0039] The preprocessing module is used to acquire surface-enhanced Raman spectral data of the water sample to be tested and to preprocess the surface-enhanced Raman spectral data of the water sample to be tested.
[0040] The feature extraction module is used to determine the surface-enhanced Raman spectral feature vectors of polycyclic aromatic hydrocarbons from the preprocessed surface-enhanced Raman spectral data using a local averaging algorithm.
[0041] The determination module is used to determine the detection result of the water sample to be tested based on the feature vector and through a support vector machine model.
[0042] (1) This invention effectively suppresses spectral noise interference and improves the overall detection accuracy by fusing multi-level characteristic peaks (high-intensity main peak, medium-intensity secondary peak, and low-intensity stable peak) and extracting feature values using a local averaging algorithm. Especially in low-concentration detection, it effectively improves the accuracy compared to traditional methods, and the detection accuracy for intermediate and high-concentration (e.g., above 5 mg / L) water samples can basically reach 100%.
[0043] (2) This invention employs a local average feature extraction algorithm, which calculates the nearest points to the feature peak (e.g., ±2cm). -1 Replacing single-point intensity with the mean spectral intensity (within a given range) significantly enhances the noise resistance and reproducibility of the eigenvalues. Combining the probabilistic output pattern of Support Vector Machine (SVM) with adaptive threshold optimization solves the problem of low-concentration polycyclic aromatic hydrocarbon signals being easily overwhelmed by noise, providing reliable technical support for trace water pollution early warning.
[0044] (3) This invention establishes a standardized preprocessing workflow, from spectral validity verification, wavenumber range selection, gridded resampling (1 cm⁻¹ interval) to feature vector construction, eliminating the influence of instrument differences and human operation. Simultaneously, a grid search algorithm is used to automatically optimize SVM parameters (including regularization parameter C, kernel function parameter γ, and class weights), and the optimal model is selected through F1 scoring (balancing precision and recall), solving the subjectivity problem of traditional manual parameter tuning. This design enables the model to maintain 100% accuracy in samples with unknown concentrations (such as a 5-100 mg / L concentration test set), significantly improving the applicability and reproducibility of the method.
[0045] (4) This invention predefines the target feature peak positions based on the chemical structure of polycyclic aromatic hydrocarbons (such as CH stretching, C=C skeletal vibration, etc.), and combines automated feature extraction with machine learning classification, reducing the reliance on manual interpretation. In addition, through standardization processing (such as Z-score transformation) and class weight balancing (adaptively adjusting the loss function weights according to the sample distribution), only a small number of standard samples (such as 20 groups / concentration) are needed to train a high-precision model, which greatly reduces the cost of data annotation.
[0046] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of the present invention, nor is it intended to limit the scope of the invention. Other features of the invention will become readily apparent from the following description. Attached Figure Description
[0047] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0048] Figure 1 This is a flowchart of a surface-enhanced Raman spectroscopy method for detecting water pollution based on machine learning, provided in Embodiment 1 of the present invention.
[0049] Figure 2 This is a flowchart of a surface-enhanced Raman spectroscopy method for detecting water pollution based on machine learning, provided in Embodiment 2 of the present invention.
[0050] Figure 3 This is a schematic diagram of the technical architecture of a surface-enhanced Raman spectroscopy water pollution detection method based on machine learning, provided in Embodiment 2 of the present invention.
[0051] Figure 4 This is a schematic diagram of a machine learning pipeline that includes data standardization and support vector machine classification, provided in Embodiment 2 of the present invention.
[0052] Figure 5 This is a schematic diagram of a surface-enhanced Raman spectroscopy water pollution detection device based on machine learning, provided in Embodiment 3 of the present invention. Detailed Implementation
[0053] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0054] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0055] Example 1:
[0056] Figure 1 This is a flowchart of a machine learning-based surface-enhanced Raman spectroscopy (SERS) method for water pollution detection, provided in Embodiment 1 of the present invention. This embodiment is applicable to water pollution detection. The method can be executed by a machine learning-based SERS water pollution detection device, which can be implemented in hardware and / or software and can be configured in an electronic device. Figure 1 As shown, the method includes:
[0057] S110. Obtain the surface-enhanced Raman spectral data of the water sample to be tested, and preprocess the surface-enhanced Raman spectral data of the water sample to be tested.
[0058] The water sample to be tested refers to a water sample containing pollutants that is to be detected. Surface-enhanced Raman spectroscopy data refers to a set of information obtained through surface-enhanced Raman spectroscopy, which describes the relationship between the spectral intensity of the inelastic scattered light produced by the sample under specific laser irradiation and its spectral wavenumber. Preprocessing refers to truncating the spectral wavenumber range of the surface-enhanced Raman spectroscopy data of the water sample to be tested and normalizing the spectral intensity within the truncated range. The core idea of surface-enhanced Raman spectroscopy (SERS) is to overcome the fatal shortcomings of traditional surface-enhanced Raman spectroscopy, such as weak signals and susceptibility to fluorescence interference, by utilizing the special properties of metal nanostructures to greatly amplify the originally weak surface-enhanced Raman signal.
[0059] Specifically, multiple sets of water samples can be obtained from a target water body containing pollutants. Surface-enhanced Raman (SMR) spectrometry data of these samples can be directly acquired using a surface-enhanced Raman spectrometer. Each set of SMR spectrometry data contains spectral information consisting of two columns: spectral wavenumber and spectral intensity. For example, the acquired SMR spectrometry dataset could be S = {s1, s2, ..., s...}n}, where S represents the complete spectral data of a water sample to be tested, and n represents the total number of water samples to be tested. For the sample spectra in each set of valid spectral data, the spectral wavenumber range is limited to the interval that can cover all major surface-enhanced Raman active vibrational modes of the detected substance molecules (polycyclic aromatic hydrocarbons); then, the spectral intensity within the intercepted range is normalized to the maximum and minimum values to eliminate errors caused by different measurement conditions and differences in instrument response.
[0060] In this embodiment, by limiting the spectral wavenumber range of the surface-enhanced Raman spectroscopy data and truncating a uniform wavenumber band, edge noise caused by differences in the acquisition range of different devices is avoided, interference from non-feature regions is eliminated, and the key molecular vibrational characteristic peaks are made more prominent. The spectral intensity of the surface-enhanced Raman spectroscopy data within the limited range is normalized to eliminate errors caused by differences in measurement conditions and instrument responses, and the dimensions are unified, which significantly reduces the sensitivity of the machine learning model to absolute intensity.
[0061] S120. From the preprocessed surface-enhanced Raman spectral data, the surface-enhanced Raman spectral feature vectors of polycyclic aromatic hydrocarbons are determined by the local averaging algorithm.
[0062] Polycyclic aromatic hydrocarbons (PAHs) are a class of organic compounds containing two or more benzene rings that are widely found in the environment. They are typically composed of carbon and hydrogen, have a stable cyclic structure, and are products of incomplete combustion or high-temperature cracking of fossil fuels. They are carcinogenic. Examples of PAHs include: naphthalene, acenaphthene, acenaphthene, fluorene, phenanthrene, anthracene, pyrene, benzo[a]anthracene, indo[1,2,3-cd]pyrene, dibenzo[a,h]anthracene, benzo[g,h,i]perylene, etc. Benzo[k]fluoranthene, benzo[a]pyrene, benzo[b]fluoranthene, fluoranthene, etc. An eigenvector can refer to an eigenvector composed of multiple eigenvalues.
[0063] Specifically, based on surface-enhanced Raman spectroscopy (SERS) analysis of polycyclic aromatic hydrocarbons (PAHs) (e.g., density functional theory (DFT)) and experimental verification, multiple characteristic peaks with clearly defined chemical bond affiliations can be identified from the preprocessed SERS data. These characteristic peaks correspond to the characteristic vibrational modes of different chemical bonds in PAHs, such as the C=C symmetric stretching vibration, cyclic breathing vibration, and CH stretching vibration of aromatic rings. This approach exhibits good chemoselectivity and detection stability, and the selection of characteristic peaks encompasses high-intensity main characteristic peaks, medium-intensity secondary characteristic peaks, and low-intensity stable characteristic peaks, forming a multi-level characteristic system. Furthermore, the average spectral intensity within the local area of each characteristic peak is determined as a characteristic value, and multiple characteristic values are combined to form an eigenvector.
[0064] In this embodiment, by fusing multi-level feature peaks and using a local averaging algorithm to extract feature values, spectral noise interference is effectively suppressed, and the overall detection accuracy is effectively improved.
[0065] S130. Based on the feature vector, the detection result of the water sample to be tested is determined by a support vector machine model.
[0066] Support Vector Machine (SVM) is a type of generalized linear classifier that performs binary classification of data using supervised learning. The detection result can indicate that the water sample contains polycyclic aromatic hydrocarbons (PAHs), suggesting that the target water body is polluted. Alternatively, if the water sample does not contain PAHs, further detection of other water pollutants can be performed. This embodiment does not limit the types of other water pollutants.
[0067] Specifically, the input to the support vector machine model is the extracted feature vector, and the output adopts a probability output mode, specifically outputting the probability value of whether the test sample contains polycyclic aromatic hydrocarbons (PAHs). A preset probability threshold is set. When the output probability value of the test sample containing PAHs is greater than or equal to the threshold, the detection result is determined that the test water sample contains PAHs; when the output probability value of the test sample containing PAHs is less than the threshold, the detection result is determined that the test water sample does not contain PAHs.
[0068] In this embodiment, surface-enhanced Raman (SMR) spectral data of the water sample to be tested is acquired and preprocessed. From the preprocessed SMR spectral data, SMR spectral feature vectors of polycyclic aromatic hydrocarbons (PAHs) are extracted. The extracted feature vectors cover high / medium / low intensity stable characteristic peaks, achieving comprehensive utilization of multi-dimensional spectral information. Furthermore, the average spectral intensity of each characteristic peak within its local area is determined as a feature value. The feature vector composed of multiple feature values is input into a support vector machine model for probability prediction. Based on the probability prediction results, the water pollution detection result is determined. This solves the problems of low detection accuracy and poor stability in existing technologies using SMR spectroscopy for water pollution detection, providing a highly sensitive and low-cost automated solution for environmental monitoring.
[0069] Optionally, before preprocessing the surface-enhanced Raman spectral data of the water sample to be tested, the method further includes:
[0070] The validity of the surface-enhanced Raman spectroscopy data of the water sample to be tested was verified.
[0071] Among them, validity verification can refer to the process of verifying the compliance, accuracy, and completeness of data through a series of methods and techniques to ensure that the data conforms to preset rules or standards and can be correctly understood and used.
[0072] Specifically, it can be verified whether the spectral wavenumber of the water sample to be tested is within a reasonable spectral range (usually 150-2000 cm⁻¹). -1 If any data point is missing, the data set is discarded. The spectral intensity of the water sample is verified to be abnormal (e.g., all zeros or constant values, negative values, outliers). If abnormal, the data set is discarded. Furthermore, the integrity of the surface-enhanced Raman spectral data of the water sample is checked, specifically verifying whether the data meets expectations (usually wavenumber + intensity columns). If any data (wavenumber or intensity) is missing, the data set is discarded. Additionally, the format of each set of surface-enhanced Raman spectral data files needs to be verified to meet expectations; otherwise, the data set is discarded.
[0073] In this embodiment, by verifying the validity of the surface-enhanced Raman spectral data of the water sample to be tested, spectral data with abnormal signals, missing data, or incorrect format are eliminated, ensuring that only high-quality spectral data enters the subsequent analysis process, which significantly improves the reliability of surface-enhanced Raman data analysis.
[0074] Optionally, the preprocessing of the surface-enhanced Raman spectroscopy data of the water sample to be tested includes:
[0075] The spectral wavenumber range of the surface-enhanced Raman spectroscopy data is defined.
[0076] The spectral intensities of the surface-enhanced Raman spectral data within the defined range are normalized.
[0077] The range limitation can refer to restricting the spectral wavenumbers of the surface-enhanced Raman spectroscopy data to a preset range, which can be determined based on all the major surface-enhanced Raman active vibrational modes of polycyclic aromatic hydrocarbons. Normalization can refer to the maximum and minimum value normalization transformation.
[0078] Specifically, for each sample spectrum in the valid spectral data, the spectral wavenumber range is limited to a preset interval. This interval must be experimentally verified to cover all major surface-enhanced Raman active vibrational modes of polycyclic aromatic hydrocarbons (PAHs). For PAHs, the positions of key peaks (e.g., anthracene, pyrene, benzo[a]pyrene, etc.) must be confirmed through standard sample testing, with a limited range of 250–1750 cm⁻¹. -1 To cover its complete fingerprint region. After truncation, a set of spectral data within the standard wavenumber range is obtained. in This represents the spectral data after the i-th sample is intercepted. A maximum-minimum normalization transformation is applied to the spectral intensity I(v) within the intercepted range to eliminate errors caused by different measurement conditions and instrument response differences. The normalization transformation formula is:
[0079]
[0080] Among them, I min and I max These are the minimum and maximum intensity values of the current spectrum, respectively. The transformed spectral intensity is mapped to a value range of 0-1.
[0081] In this embodiment, by limiting the spectral wavenumber range of the surface-enhanced Raman spectroscopy data and truncating a uniform wavenumber band, edge noise caused by differences in the acquisition range of different devices is avoided, interference from non-feature regions is eliminated, and the key molecular vibrational characteristic peaks are made more prominent. The spectral intensity of the surface-enhanced Raman spectroscopy data within the limited range is normalized to eliminate errors caused by differences in measurement conditions and instrument responses, and the dimensions are unified, which significantly reduces the sensitivity of the machine learning model to absolute intensity.
[0082] Optionally, after preprocessing the surface-enhanced Raman spectral data of the water sample to be tested, the method further includes:
[0083] A linear interpolation algorithm was used to resample the normalized surface-enhanced Raman spectroscopy data into a grid.
[0084] Linear interpolation is a numerical estimation method based on adjacent data points, used to generate continuous new data between known discrete data points. Gridded resampling is a spectral data normalization technique designed to uniformly map original non-uniform or inconsistent wavenumber intervals of surface-enhanced Raman spectra onto a pre-defined, equally spaced wavenumber grid (e.g., 1 cm²). -1 interval).
[0085] Specifically, a linear interpolation algorithm is used to resample the normalized spectral data onto a standard grid, ensuring that all spectral data have the same wavenumber interval and number of data points. For example, the resampling grid refers to a grid starting from 250 cm⁻¹. -1 Start with 1cm -1 As intervals, extending to 1750cm -1 It contains 1501 standard grid points. For each grid point, a new intensity value is generated by linear interpolation based on the intensity values of adjacent data points in the original spectrum. Specifically, given the intensities y0 and y1 of adjacent wavenumber points x0 and x1, the value of the value at any intermediate position x is calculated. t Intensity y t The interpolation result y t for: By utilizing the linear proportional relationship between two points, discrete data is transformed into a continuous, computable function. For grid points outside the original spectral range, the nearest boundary value (e.g., less than 250 cm⁻¹) is used for filling. -1 The point is 250cm -1 Intensity filling at the location.
[0086] In this embodiment, a linear interpolation algorithm is used to resample the normalized surface-enhanced Raman spectroscopy data into a grid, eliminating wavenumber shifts caused by instrument differences and measurement fluctuations, ensuring that all spectral data have the same dimensions (number and location of wavenumber points), and providing standardized input for subsequent feature extraction and machine learning modeling.
[0087] Example 2:
[0088] Figure 2 This is a flowchart of a surface-enhanced Raman spectroscopy method for water pollution detection based on machine learning, provided in Embodiment 2 of the present invention. The technical solution of this embodiment is further refined based on the above embodiments. Figure 2 As shown, the method includes:
[0089] S210. Obtain the surface-enhanced Raman spectral data of the water sample to be tested, and preprocess the surface-enhanced Raman spectral data of the water sample to be tested.
[0090] S220, based on the chemical structure of polycyclic aromatic hydrocarbons, determines the positions of at least five target characteristic peaks from pretreated surface-enhanced Raman spectroscopy data.
[0091] Among them, the chemical structure of polycyclic aromatic hydrocarbons can refer to the fused aromatic ring structure and highly conjugated characteristics; the target characteristic peaks can refer to the characteristic vibration modes corresponding to different chemical bonds in polycyclic aromatic hydrocarbons, and cover the high-intensity main peak, the medium-intensity secondary peak and the stable weak peak.
[0092] Specifically, based on the chemical structure of polycyclic aromatic hydrocarbons, at least five target characteristic peak positions can be determined that cover the high-intensity main peak, the medium-intensity secondary peak, and the stable weak peak. For example, if five target characteristic peaks are determined, the positions of each target characteristic peak and the corresponding chemical bond vibration modes are shown in Table 1 below:
[0093] Table 1
[0094]
[0095] Multi-level coverage was achieved, with main characteristic peaks (1580-1620, 1360-1380 cm⁻¹) -1High signal-to-noise ratio ensures reliable basic identification and provides the most reliable and significant PAHs skeleton signal; secondary characteristic peaks (1000-1020, 1220-1280 cm⁻¹) -1 ): Provides supplementary structural details, important auxiliary features, and good stability; stabilizes weak peaks (700–800 cm⁻¹). -1 ): It can still be detected at low concentrations, enhancing detection sensitivity. Taking benzo[a]pyrene (5-ring PAHs) as an example, the characteristic peak position was measured to be 1610 cm⁻¹. -1 (High-intensity main peak, belonging to C=C symmetric stretching (G band)); 1380cm -1 (High-intensity main peak, attributed to CH in-plane bending); 1300cm -1 (Medium intensity secondary peak, attributed to CC stretching); 1020cm -1 (Medium intensity secondary peak, attributed to circumspiratory vibration); 780 cm⁻¹ (CH out-of-plane bending).
[0096] Furthermore, the position of the target characteristic peak can be dynamically adjusted within the cutoff range based on the specific type of polycyclic aromatic hydrocarbon (e.g., phenanthrene, anthracene, benzo[a]pyrene, etc.).
[0097] In this embodiment, based on the chemical structure of polycyclic aromatic hydrocarbons, at least five target characteristic peak positions are determined from the preprocessed surface-enhanced Raman spectroscopy data. Each target characteristic peak corresponds to a specific chemical bond vibration and covers high / medium / low intensity characteristic peaks. It has good chemical selectivity and detection stability. By fusing multi-level features, it effectively suppresses noise interference (high intensity peaks resist substrate interference, and low intensity peaks avoid information loss), breaking through the accuracy bottleneck of traditional single feature strategies in complex matrices.
[0098] S230. Based on the local average feature extraction algorithm, extract the feature values of each target feature peak.
[0099] Among them, the local average feature extraction algorithm is a noise reduction technique for spectral feature peaks. Its core is to improve feature stability and reproducibility by averaging the intensity of data points near the center of the feature peak and replacing the single-point intensity value. The feature value can refer to the spectral intensity value.
[0100] Specifically, for each target feature peak position p i Calculate the range around its center position (e.g., ±2cm). -1 The arithmetic mean of the spectral intensities of all data points within a given range is used as the representative characteristic value of the characteristic peak. For example, for position p... i The feature peaks are extracted within the range of [p]. i -2,p iThe arithmetic mean of the spectral intensities of the five consecutive data points (+2) is the characteristic value of the target characteristic peak.
[0101] In this embodiment, a stable feature value for each feature peak is extracted using a local averaging algorithm, which effectively reduces the impact of single-point random noise, especially for feature peaks that still have a good signal-to-noise ratio under low concentration conditions. This enables high-precision quantitative detection of polycyclic aromatic hydrocarbons and improves the stability and reproducibility of feature values.
[0102] S240. According to the order of the peak wave number of each target feature from large to small, the feature values are combined into a feature vector.
[0103] Specifically, the local average values of the selected k characteristic peaks can be combined into a k-dimensional feature vector in descending order of wavenumber:
[0104] F = [f1, f2, ..., f k ]
[0105] Where f i This represents the local average spectral intensity value of the target characteristic peak at position i after sorting by wavenumber from largest to smallest.
[0106] In this embodiment, the feature values are arranged into a feature vector according to the wavenumber of each target feature peak in descending order. This feature vector comprehensively reflects the surface-enhanced Raman spectral fingerprint characteristics of polycyclic aromatic hydrocarbons. It contains both high-intensity primary feature information and well-retained secondary feature information, providing input data for subsequent machine learning modeling.
[0107] S250. Based on the feature vector, the detection result of the water sample to be tested is determined by a support vector machine model.
[0108] In this embodiment, by fusing multi-level feature peaks (high-intensity main peak, medium-intensity secondary peak, and low-intensity stable peak) and using a local averaging algorithm to extract feature values, spectral noise interference is effectively suppressed, and the overall detection accuracy is effectively improved. The local averaging feature extraction algorithm significantly enhances the noise resistance and reproducibility of feature values by calculating the average spectral intensity of points near the feature peak as feature values.
[0109] Optionally, the local average feature extraction algorithm for extracting feature values of each target feature peak includes:
[0110] Based on the positions of each target feature peak, determine the local range corresponding to each target feature peak position;
[0111] Specifically, for each target feature peak position, its corresponding local range can be determined based on a pre-set local range threshold. For example, if the local range threshold is ±2cm...-1 The target feature peak position is p i Then the local range corresponding to the position of the target feature peak is [p i -2,p i +2].
[0112] The average spectral intensity of all surface-enhanced Raman spectral data points within each local area is calculated and used as the characteristic value of each target characteristic peak.
[0113] Specifically, for each target characteristic peak location, the arithmetic mean of the spectral intensities of all data points within a defined range (±2 cm⁻¹) around its center location is calculated as the representative characteristic value of that peak. For example, for location p... i The feature peaks are extracted within the range of [p]. i -2,p i Given 5 consecutive data points with intensity +2], calculate the arithmetic mean of the intensities of these 5 data points:
[0114]
[0115] Among them, F(p) i ) represents the local average spectral intensity value of the i-th characteristic peak, I norm (j) represents the normalized spectral intensity value at grid point j.
[0116] In this embodiment, the local range corresponding to each target characteristic peak position is determined by the position of each target characteristic peak, and the average spectral intensity of all surface-enhanced Raman spectral data points within each local range is calculated as the characteristic value of each target characteristic peak. This effectively reduces the influence of single-point random noise and retains characteristic peaks with good signal-to-noise ratios even under low concentration conditions, achieving high-precision quantitative detection of polycyclic aromatic hydrocarbons, improving the stability and reproducibility of characteristic values, and providing a reliable characteristic basis for low-concentration detection.
[0117] Optionally, based on the feature vector, the detection result of the water sample to be tested is determined using a support vector machine model, including:
[0118] The feature vectors are standardized.
[0119] Specifically, the standardization process involves calculating the mean and standard deviation for each feature dimension, and then performing z-score standardization on each feature value in the feature vector to transform the data into a standard normal distribution with a mean of 0 and a standard deviation of 1.
[0120]
[0121] Where σ is the standard deviation of each feature dimension, μ is the mean of each feature dimension, and F is the extracted feature vector.std The standardized feature vectors have zero mean and unit variance, ensuring the numerical stability and convergence of the support vector machine algorithm.
[0122] In this embodiment, the numerical scale differences between different feature dimensions are eliminated by standardizing the extracted feature vectors.
[0123] Based on the standardized feature vector, the probability prediction value of the presence of polycyclic aromatic hydrocarbons in the water sample to be tested is output through the support vector machine model.
[0124] Determine whether the predicted probability value is greater than or equal to a preset threshold;
[0125] If so, the detection result indicates that the water sample to be tested contains polycyclic aromatic hydrocarbons.
[0126] Specifically, the trained support vector machine model outputs a probability value for each water sample to be classified as positive (i.e., containing polycyclic aromatic hydrocarbons), which varies continuously between 0 and 1. Based on a pre-set fixed threshold, if the output probability prediction is greater than or equal to the fixed threshold, the water sample is determined to be positive, meaning the detection result indicates that the water sample contains polycyclic aromatic hydrocarbons; otherwise, it is determined to be negative, meaning the water sample does not contain polycyclic aromatic hydrocarbons. The fixed threshold can be determined based on performance optimization on the validation set to balance the impact of false positives and false negatives.
[0127] In this embodiment, the feature vector is standardized; based on the standardized feature vector, a support vector machine model is used to output a predicted probability value of polycyclic aromatic hydrocarbons (PAHs) in the water sample to be tested; it is determined whether the predicted probability value is greater than or equal to a preset threshold; if so, the detection result is determined to be that the water sample to be tested contains PAHs; if not, it is determined to be a negative class, that is, the detection result is determined to be that the water sample to be tested does not contain PAHs; through experimental verification of the optimal fixed threshold, only a small amount of standard samples are needed to achieve excellent low-concentration detection performance, which greatly reduces the cost of standard sample preparation and labeling.
[0128] Optionally, training the support vector machine model includes:
[0129] A sample dataset of surface-enhanced Raman spectra with different concentrations of polycyclic aromatic hydrocarbons is constructed, wherein the sample dataset includes a training set and a test set;
[0130] Specifically, a surface-enhanced Raman (SMR) spectral dataset containing different concentrations of polycyclic aromatic hydrocarbons (PAHs) can be pre-constructed. The dataset includes SMR spectral samples at concentrations of 0 mg / L (pure substrate), 0.5 mg / L, 5 mg / L, 10 mg / L, 50 mg / L, and 100 mg / L. At least 20 spectral data points should be prepared for each concentration to ensure statistical reliability. Half of the samples from the 0 mg / L and 100 mg / L concentrations are randomly selected as training samples to ensure the model learns the characteristic boundaries between the pure substrate and the target substance. The remaining 0 mg / L and 100 mg / L concentration samples, along with all intermediate concentrations (0.5 mg / L, 5 mg / L, 10 mg / L, and 50 mg / L), constitute a comprehensive test set to rigorously verify the model's generalization ability. Pure substrate samples at 0 mg / L are labeled as negative (label value 0), while pure target substance samples at other concentrations are labeled as positive (label value 1).
[0131] The optimal support vector machine model parameters are determined using a grid search algorithm within a preset parameter space, through the training set and the test set.
[0132] Among them, grid search algorithm can refer to a method to optimize the hyperparameters of a machine learning model by systematically traversing all combinations of a predefined parameter space. Its core is the combination of exhaustive search and cross-validation. The predefined parameter space can refer to the pre-set range of key parameters of the support vector machine. For example, the regularization parameter C is selected in the range of [0.01, 0.1, 1, 50, ...], and the kernel function parameter gamma is selected in the range of ['scale', 'auto', 0.01, 0.05, ...].
[0133] Specifically, a grid search algorithm is used to exhaustively search within a predefined parameter space to find the optimal parameter combination. Each parameter combination can be used to train the model on the training set. After training, performance is evaluated on the test set, with the F1 score as the optimization objective for model selection. By traversing all parameter combinations and recording the F1 score of each combination on the test set, the parameter combination with the highest score is selected as the optimal support vector machine model parameter configuration. The F1 score can be considered a core metric in machine learning for comprehensively evaluating the performance of classification models, particularly suitable for scenarios with imbalanced sample distribution (such as the scarcity of low-concentration samples in surface-enhanced Raman spectroscopy). It is defined as the harmonic mean of precision and recall. Precision is used for the accuracy of true detection, specifically the proportion of samples predicted as positive by the model that are actually positive (avoiding false positives of base samples as contaminants). Recall is used for the completeness of detection, specifically the proportion of samples that are actually positive that are correctly identified by the model (avoiding the missed detection of trace polycyclic aromatic hydrocarbons).
[0134] In this embodiment, by employing a grid search algorithm, the optimal support vector machine model parameters are determined within a preset parameter space using the training and test sets. This solves the subjectivity and inefficiency problems of traditional manual parameter tuning, ensuring the finding of the global optimal solution. Moreover, the process is fully automated, requiring no human experience, thus more effectively improving the detection accuracy of polycyclic aromatic hydrocarbons and ensuring the reproducibility of the results.
[0135] Using the sample dataset, a support vector machine model with optimally configured support vector machine model parameters is retrained, and predictions are made using a test set to determine the prediction accuracy of the support vector machine model.
[0136] The prediction accuracy is calculated as: (Number of correctly classified samples / Total number of samples) × 100%.
[0137] Specifically, after the grid search is completed, the parameter combination with the highest F1 score is selected as the optimal configuration. The training and test sets are then re-split from the sample dataset. All samples with concentrations of 0 mg / L and 100 mg / L are used as the new training sample dataset. The remaining samples with intermediate concentrations (0.5 mg / L, 5 mg / L, 10 mg / L, and 50 mg / L) constitute the new test set. The Support Vector Machine (SVM) model with the optimal configuration is trained based on the new training sample dataset to improve the model's generalization ability. During training, a sequential minimum optimization algorithm is used to solve the dual problem of the SVM to ensure convergence to the global optimum. Finally, the SVM model that has converged to the global optimum is tested using the test set. The accuracy of the prediction results output by the SVM model determines whether the trained SVM model is successful. Specifically, an accuracy rate can be preset (e.g., 94.5 mg / L). If the accuracy rate of the prediction result is greater than or equal to the preset accuracy rate, the support vector machine model training is complete. If the accuracy rate of the prediction result is less than the preset accuracy rate, the support vector machine model is retrained based on the sample dataset until the prediction accuracy rate of the support vector machine model reaches the preset accuracy rate.
[0138] Furthermore, an independent validation set is split from the sample dataset, for example, samples with a concentration of 10 mg / L, to ensure isolation from the test set. The support vector machine model completed during testing is validated based on the validation set, and the comprehensive cost function Cost = w1 × FPR + w2 × FNR is calculated, where FPR is the false positive rate = FP / (FP + TN), i.e., falsely reporting a pure substrate as contaminated; FNR is the false negative rate = FN / (FN + TP), i.e., missing trace pollutants. w1 and w2 are the weight distributions of the false positive and false negative rates, respectively. w1 can be adaptively adjusted according to the actual scenario. Specifically, in the detection of polycyclic aromatic hydrocarbons in water pollution, w2 > w1 is usually used. Fixed thresholds are traversed from 0 to 1 (step size 0.01), and the cost value corresponding to each fixed threshold is calculated. The fixed threshold that minimizes the cost is selected as the set fixed threshold (i.e., the preset threshold).
[0139] In this embodiment, a standard sample set covering a concentration range (e.g., 0-100 mg / L) is used to ensure consistency between model training and testing scenarios, avoiding overfitting due to data bias and significantly improving the robustness of predictions for unknown samples. Grid search exhaustively searches for parameter combinations within a preset space (regularization parameters, kernel function, class weights, etc.), and through training set learning and F1 scoring verification on the test set, automatically locks the optimal configuration that balances low-concentration detection sensitivity and global accuracy, solving the subjectivity problem of manual parameter tuning. Based on the optimal parameters, the model is retrained on a complete dataset, and then the accuracy is quantified using an independent test set, forming a closed loop of "training-parameter tuning-verification" to ensure that performance indicators have high reliability and engineering applicability.
[0140] Optionally, the step of employing a grid search algorithm to determine the optimal support vector machine model parameters within a preset parameter space using the sample dataset includes:
[0141] Based on the preset parameter space, various combinations of support vector machine model parameters within the preset parameter space are determined, wherein the combination of support vector machine model parameters includes regularization parameters, kernel function parameters, and kernel function types;
[0142] Specifically, a parameter space is pre-defined, meaning the candidate ranges for regularization parameters, kernel function parameters, and kernel function types are pre-determined. For example, the regularization parameter C can be selected within the range [0.01, 0.1, 1, 50, 100], the kernel function parameter gamma can be selected within the range ['scale', 'auto', 0.01, 0.05, 0.1], and the kernel function type includes three types: radial basis functions, polynomial functions, and sigmoid functions. Based on the pre-determined parameter candidate ranges, a set of all possible parameter combinations, Grid = {C}, is created. i gamma j kernel k|i=1..5,j=1..5,k=1..3}, a total of 5×5×3=75 sets of parameter combinations to be tested.
[0143] Based on the training set, a support vector machine model with each of the parameter combinations is trained;
[0144] Based on the test set, the trained support vector machine models with each of the parameter combinations are tested to determine the F1 score corresponding to each parameter combination.
[0145] Specifically, a support vector machine model with each of the specified parameter combinations is trained using the training set, and its performance is evaluated using the test set, i.e., precision and recall are calculated. The F1 score for each parameter combination is determined based on the precision and recall and recorded, until all parameter combinations have been traversed. Among these, precision... Recall rate TP represents a correctly identified positive sample (e.g., a sample containing polycyclic aromatic hydrocarbons); FP represents a negative sample that was misidentified as positive (e.g., a pure substrate that was misidentified as containing contaminants); and FN represents a positive sample that was missed (e.g., a sample containing polycyclic aromatic hydrocarbons but was identified as not containing them).
[0146] The grid search algorithm is used to select the parameter combination with the highest score as the optimal support vector machine model parameters.
[0147] Specifically, a grid search algorithm is used to perform an exhaustive search, traversing all parameter combinations and their corresponding F1 scores, and selecting the parameter combination with the highest F1 score as the optimal support vector machine model parameters.
[0148] Furthermore, the support vector machine model parameters also include class weight balancing parameters. During the training phase of the support vector machine model with configured parameter combinations based on the training set, the class weight balancing parameters can be adaptively adjusted according to the distribution of positive and negative samples in the training set. Specifically, the class weight balancing parameter W... j The number of samples N for each category j It is inversely proportional, and the calculation formula is:
[0149]
[0150] Among them, K is the total number of categories (K=2 in binary classification); N j The number of samples in class j (positive / negative). For example, if negative samples (0 mg / L concentration base) account for 80% and positive samples (including the target substance) account for 20% in the training set, then the weight allocation is as follows: negative class weight... Positive class weight Therefore, during model training, the weight of the loss function for positive class samples is 4 times that for negative class samples (2.5 / 0.625 = 4) to automatically adjust the weights of positive and negative samples to handle potential sample imbalance problems.
[0151] In this embodiment, by simultaneously covering regularization parameters (to control overfitting), kernel function parameters and type (to determine the complexity of the classification boundary), and class weight balancing parameters (to address sample imbalance), the limitations of traditional manual parameter tuning in a single dimension are overcome. An exhaustive strategy is adopted to traverse all parameter combinations within a predefined space, avoiding heuristic search from getting stuck in local optima and ensuring that the model performance reaches the theoretical optimal solution. Based on the F1 score of the test set (combining precision and recall), each parameter combination is objectively evaluated, and the configuration that performs best in low-concentration sample recognition and overall stability is prioritized. Professional experience is transformed into the boundary setting of the parameter space, and the optimal model is output through an automated training-evaluation process, which greatly improves the efficiency of analysis and the reproducibility of results.
[0152] For example, Figure 3 This is a schematic diagram of the technical architecture of a surface-enhanced Raman spectroscopy water pollution detection method based on machine learning, provided in Embodiment 2 of the present invention. Figure 3 The enhanced Raman spectrum in this paper is exemplified by the enhanced Raman spectrum of benzo(b)fluoranthene. Figure 4 This is a schematic diagram of a machine learning pipeline including data normalization and support vector machine classification, provided in Embodiment 2 of the present invention. Figure 3 , Figure 4 As shown, the specific steps of this method include: 1. Reading and validating surface-enhanced Raman spectroscopy data; 2. Truncation of spectral wavenumber range; 3. Normalization of spectral intensity; 4. Gridded resampling of spectral data; 5. Determination of target feature peak positions; 6. Extraction of feature values using a local average feature extraction algorithm; 7. Construction of multidimensional feature vectors; 8. Standardization of the extracted feature vectors and input into an SVM model; 9. Outputting the probability value of each sample belonging to the positive class and performing threshold judgment; 10. Determining the category of the sample (i.e., the water sample to be tested). If it is a positive class, the sample contains the target substance (i.e., polycyclic aromatic hydrocarbons).
[0153] Example 5:
[0154] Figure 5 This is a schematic diagram of a surface-enhanced Raman spectroscopy water pollution detection device based on machine learning, provided in Embodiment 3 of the present invention. Figure 5 As shown, the device includes:
[0155] Preprocessing module 310 is used to acquire surface-enhanced Raman spectral data of the water sample to be tested and to preprocess the surface-enhanced Raman spectral data of the water sample to be tested.
[0156] The feature extraction module 320 is used to determine the surface-enhanced Raman spectral feature vector of polycyclic aromatic hydrocarbons from the preprocessed surface-enhanced Raman spectral data using a local averaging algorithm.
[0157] The determination module 330 is used to determine the detection result of the water sample to be tested based on the feature vector using a support vector machine model.
[0158] Optional, the preprocessing module 310 is specifically used for:
[0159] The validity of the surface-enhanced Raman spectroscopy data of the water sample to be tested was verified.
[0160] Optionally, the preprocessing module 310 is also used for:
[0161] The spectral wavenumber range of the surface-enhanced Raman spectroscopy data is defined.
[0162] The spectral intensities of the surface-enhanced Raman spectral data within the defined range are normalized.
[0163] Optionally, the preprocessing module 310 is also used for:
[0164] A linear interpolation algorithm was used to resample the normalized surface-enhanced Raman spectroscopy data into a grid.
[0165] Optionally, the feature extraction module 320 includes:
[0166] The determination unit is used to identify the positions of at least five target characteristic peaks from pretreated surface-enhanced Raman spectroscopy data based on the chemical structure of polycyclic aromatic hydrocarbons.
[0167] An extraction unit is used to extract the feature values of each of the target feature peaks based on a local average feature extraction algorithm.
[0168] The vector composition unit is used to compose the feature values into feature vectors according to the order of the peak wave number of each target feature from largest to smallest.
[0169] Optional, extraction unit, specifically used for:
[0170] Based on the positions of each target feature peak, determine the local range corresponding to each target feature peak position;
[0171] The average spectral intensity of all surface-enhanced Raman spectral data points within each local area is calculated and used as the characteristic value of each target characteristic peak.
[0172] Optionally, module 330 is determined, specifically for:
[0173] The feature vectors are standardized.
[0174] Based on the standardized feature vector, the probability prediction value of the presence of polycyclic aromatic hydrocarbons in the water sample to be tested is output through the support vector machine model.
[0175] Determine whether the predicted probability value is greater than or equal to a preset threshold;
[0176] If so, the detection result indicates that the water sample to be tested contains polycyclic aromatic hydrocarbons.
[0177] Optionally, module 330 is specified, specifically applicable to:
[0178] A sample dataset of surface-enhanced Raman spectra with different concentrations of polycyclic aromatic hydrocarbons is constructed, wherein the sample dataset includes a training set and a test set;
[0179] The optimal support vector machine model parameters are determined using a grid search algorithm within a preset parameter space, through the training set and the test set.
[0180] Using the sample dataset, a support vector machine model with optimally configured support vector machine model parameters is retrained, and predictions are made using a test set to determine the prediction accuracy of the support vector machine model.
[0181] Optionally, module 330 is specified, specifically applicable to:
[0182] Based on the preset parameter space, various combinations of support vector machine model parameters within the preset parameter space are determined, wherein the combination of support vector machine model parameters includes regularization parameters, kernel function parameters, kernel function type, and class weight balancing parameters;
[0183] Based on the training set, a support vector machine model with each of the parameter combinations is trained;
[0184] Based on the test set, the trained support vector machine models with each of the parameter combinations are tested to determine the F1 score corresponding to each parameter combination.
[0185] The grid search algorithm is used to select the parameter combination with the highest score as the optimal support vector machine model parameters.
[0186] The surface-enhanced Raman spectroscopy water pollution detection device based on machine learning provided in the embodiments of the present invention can execute the surface-enhanced Raman spectroscopy water pollution detection method based on machine learning provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the method.
[0187] Example 4:
[0188] In some embodiments, the machine learning-based surface-enhanced Raman spectroscopy (SERS) method for detecting water pollution can be implemented as a computer program tangibly contained in a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program can be loaded and / or installed on electronic device 10 via ROM 12 and / or communication unit 19. When the computer program is loaded into RAM 13 and executed by processor 11, one or more steps of the machine learning-based SERS method for detecting water pollution described above can be performed. Alternatively, in other embodiments, processor 11 can be configured by any other suitable means (e.g., by means of firmware) to perform a machine learning-based SERS method for detecting water pollution.
[0189] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard parts (ASSPs), systems-on-chip (SoCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0190] Computer programs used to implement the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when executed by the processor, the computer programs cause the functions / operations specified in the flowcharts and / or block diagrams to be performed. The computer programs may be executed entirely on a machine, partially on a machine, or as a standalone software package, partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0191] In the context of this invention, a computer-readable storage medium stores computer instructions that, when executed by a processor, implement the machine learning-based surface-enhanced Raman spectroscopy method for water pollution detection provided by this invention. The computer-readable storage medium can be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, apparatus, or device. The computer-readable storage medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination thereof. Alternatively, the computer-readable storage medium can be a machine-readable signal medium. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0192] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a cathode ray tube (CRT) or a liquid crystal display (LCD)) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0193] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as data servers), or computing systems that include middleware components (e.g., application servers), or computing systems that include frontend components (e.g., user computers with graphical user interfaces or web browsers through which users can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication (e.g., communication networks) of any form or medium. Examples of communication networks include local area networks (LANs), wide area networks (WANs), blockchain networks, and the Internet.
[0194] A computing system can include clients and servers. Clients and servers are generally located far apart and typically interact through communication networks. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a hosting product within the cloud computing service system. It addresses the shortcomings of traditional physical hosts and Virtual Private Server (VPS) services, such as high management difficulty and weak business scalability.
[0195] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps described in this invention can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this invention can be achieved, and this is not limited herein.
[0196] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.
Claims
1. A surface-enhanced Raman spectroscopy method for water pollution detection based on machine learning, characterized in that, include: Surface-enhanced Raman spectral data of the water sample to be tested are acquired, and the surface-enhanced Raman spectral data of the water sample to be tested are preprocessed; From the preprocessed surface-enhanced Raman spectral data, the spectral feature vectors of polycyclic aromatic hydrocarbons were determined using a local averaging algorithm. Based on the feature vectors, the detection results of the water sample to be tested are determined using a support vector machine model.
2. The method according to claim 1, characterized in that, Before preprocessing the surface-enhanced Raman spectroscopy data of the water sample to be tested, the following steps are also included: The validity of the surface-enhanced Raman spectroscopy data of the water sample to be tested was verified.
3. The method according to claim 1, characterized in that, The preprocessing of the surface-enhanced Raman spectroscopy data of the water sample to be tested includes: The spectral wavenumber range of the surface-enhanced Raman spectroscopy data is defined. The spectral intensities of the surface-enhanced Raman spectral data within the defined range are normalized.
4. The method according to claim 3, characterized in that, After preprocessing the surface-enhanced Raman spectroscopy data of the water sample to be tested, the method further includes: A linear interpolation algorithm was used to resample the normalized surface-enhanced Raman spectroscopy data into a grid.
5. The method according to claim 1, characterized in that, From the preprocessed surface-enhanced Raman spectral data, the spectral feature vectors of polycyclic aromatic hydrocarbons were determined using a local averaging algorithm, including: Based on the chemical structure of polycyclic aromatic hydrocarbons, the positions of at least five target characteristic peaks were determined from the pretreated surface-enhanced Raman spectroscopy data; Based on the local average feature extraction algorithm, the feature values of each target feature peak are extracted; The feature values are arranged into a feature vector according to the order of peak wave number of each target feature from largest to smallest.
6. The method according to claim 5, characterized in that, The local average feature extraction algorithm extracts the feature values of each target feature peak, including: Based on the positions of each target feature peak, determine the local range corresponding to each target feature peak position; The average spectral intensity of all surface-enhanced Raman spectral data points within each local area is calculated and used as the characteristic value of each target characteristic peak.
7. The method according to claim 1, characterized in that, Based on the feature vectors, the detection results of the water sample to be tested are determined using a support vector machine model, including: The feature vectors are standardized. Based on the standardized feature vector, the probability prediction value of the presence of polycyclic aromatic hydrocarbons in the water sample to be tested is output through the support vector machine model. Determine whether the predicted probability value is greater than or equal to a preset threshold; If so, the detection result indicates that the water sample to be tested contains polycyclic aromatic hydrocarbons.
8. The method according to claim 1, characterized in that, Training the support vector machine model includes: A sample dataset of surface-enhanced Raman spectra with different concentrations of polycyclic aromatic hydrocarbons is constructed, wherein the sample dataset includes a training set and a test set; The optimal support vector machine model parameters are determined using a grid search algorithm within a preset parameter space, through the training set and the test set. Using the sample dataset, a support vector machine model with optimally configured support vector machine model parameters is retrained, and predictions are made using a test set to determine the prediction accuracy of the support vector machine model.
9. The method according to claim 8, characterized in that, The method employs a grid search algorithm to determine the optimal support vector machine model parameters within a preset parameter space using the sample dataset, including: Based on the preset parameter space, various combinations of support vector machine model parameters within the preset parameter space are determined, wherein the combination of support vector machine model parameters includes regularization parameters, kernel function parameters, kernel function type, and class weight balancing parameters; Based on the training set, a support vector machine model with each of the parameter combinations is trained; Based on the test set, the trained support vector machine models with each of the parameter combinations are tested to determine the F1 score corresponding to each parameter combination. The grid search algorithm is used to select the parameter combination with the highest score as the optimal support vector machine model parameters.
10. A surface-enhanced Raman spectroscopy-based water pollution detection device, characterized in that, include: The preprocessing module is used to acquire surface-enhanced Raman spectral data of the water sample to be tested and to preprocess the surface-enhanced Raman spectral data of the water sample to be tested. The feature extraction module is used to determine the surface-enhanced Raman spectral feature vectors of polycyclic aromatic hydrocarbons from the preprocessed surface-enhanced Raman spectral data using a local averaging algorithm. The determination module is used to determine the detection result of the water sample to be tested based on the feature vector and through a support vector machine model.