Nondestructive detection method and system for formaldehyde residues in aquatic products
By combining Raman spectroscopy technology and deep learning algorithms, the InceptionTime model is constructed to conduct non-destructive testing of formaldehyde residues in aquatic products, solving the problems of slow detection speed and low accuracy in the existing technology, and achieving fast and accurate detection results.
Patent Information
- Application Number
- CN202411904897.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-23
- Publication Date
- 2025-04-11
- Estimated Expiration
- 2044-12-23
AI Technical Summary
The existing formaldehyde detection methods for aquatic products have problems such as slow speed and low detection accuracy, which is difficult to meet the needs of fast and accurate detection.
Raman spectroscopy technology combined with deep learning algorithms is used to construct the InceptionTime model to conduct non-destructive testing of formaldehyde residues in aquatic products. This method includes establishing a formaldehyde residue data set, building a classification model, verifying model performance and optimizing model structure.
It has achieved rapid, accurate and non-destructive testing of formaldehyde residues in aquatic products, improved detection efficiency and accuracy, and has a wide range of food safety application prospects.
Smart Images

Figure CN119804410A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of formaldehyde detection, and in particular relates to a nondestructive detection method and system for formaldehyde residue in aquatic products. Background Art
[0002] Formaldehyde (FA) is a colorless, flammable, highly reactive gas that is prone to polymerization under normal conditions. It is irritating and has a distinct odor. Exposure to high concentrations can cause a burning sensation in the eyes, nasal cavity, and lungs. Long-term excessive exposure to formaldehyde may irritate the mucous membranes and cause inflammation of the liver and kidneys. Formaldehyde may also cause damage to the gastrointestinal tract, kidneys, liver, and lungs, and pose a risk of cancer. Formaldehyde has been included in the list of non-edible substances and food additives prohibited for use in food, and is prohibited from use in food production and operation. However, in reality, there are still cases of illegal use of formaldehyde in the breeding and sales of aquatic products, mainly for the purpose of achieving preservation and sterilization effects. Eating foods containing formaldehyde may cause a variety of health problems, and the internationally recognized safety standard is 5mg / kg. However, researchers have found that the formaldehyde content in seafood that has been illegally added with formaldehyde as a preservative generally exceeds 300mg / kg, and in extreme cases it is as high as 4250mg / kg.
[0003] Compared with other formaldehyde detection methods, the surface enhanced Raman method can detect formaldehyde at the nmol level, and it is simple to operate and has a fast detection speed. In addition, a variety of small portable spectrometers have been developed, which are a potential excellent on-site rapid analysis technology for formaldehyde detection in aquatic products. However, current detection and analysis methods still face challenges in time efficiency, especially in the reaction stage between formaldehyde and reactants, which usually requires at least 20 minutes to perform subsequent detection steps. In view of this, developing new detection strategies to shorten analysis time has become the key to improving detection efficiency.
[0004] In recent years, machine learning algorithms have been widely used in the field of spectral signal analysis. Machine learning is a branch of artificial intelligence, which corresponds to a system that can acquire knowledge by extracting features from raw data, and then use this newly acquired knowledge to solve real-world problems by making decisions. When dealing with complex background interference, although portable Raman spectrometers are more in line with actual detection scenarios, their sensitivity is relatively low, and it is difficult to judge the value of information by vision alone, and it is also difficult to highlight the characteristics of the target detection object and conduct quantitative analysis. Therefore, it has become an urgent need to use artificial intelligence technology to deeply explore the deep information of Raman spectra and significantly improve the accuracy of judgment of the detected substances. Combining portable Raman spectroscopy technology with artificial intelligence can meet the needs of specific application scenarios and realize the possibility of real-time monitoring. In addition, by integrating or connecting professional spectral analysis software, it can not only reduce the difficulty of use for users, but also effectively solve complex problems such as mixture identification and similar substance analysis. Summary of the invention
[0005] The purpose of the present invention is to provide a non-destructive detection method and system for formaldehyde residues in aquatic products, so as to solve the problems of slow speed and low detection accuracy in the prior art of formaldehyde detection in aquatic products mentioned in the above background technology.
[0006] To achieve the above object, the present invention adopts the following technical solutions:
[0007] The first aspect of the present invention provides a non-destructive detection method for formaldehyde residue in aquatic products, comprising the following steps:
[0008] S1. Establish a formaldehyde residue data set; collect Raman spectra of aquatic product samples after being soaked in formaldehyde solutions of different concentrations, measure the formaldehyde residue in the aquatic product samples, divide the collected Raman spectrum data into different groups according to the formaldehyde residue measurement results, and construct a Raman spectrum formaldehyde residue data set;
[0009] S2. Construct a classification model; use random forest, support vector machine, XGBoost, convolutional neural network for comparison and InceptionTime model to classify the Raman spectroscopy formaldehyde residue data, evaluate the model performance by classification accuracy, and select InceptionTime model as the classification model;
[0010] S3. Establish a selective data set; collect Raman spectra of aquatic product samples soaked in formaldehyde-like substances, use the same label for the aquatic product data soaked in formaldehyde-like substances, use the same label for the aquatic product data soaked in water and formaldehyde, and use the mixed data to construct a selective data set;
[0011] S4. Verify the selectivity of the classification model for formaldehyde; use the InceptionTime model to select mixed data to determine the accuracy of formaldehyde recognition;
[0012] S5. Optimize the classification model structure; use different spectral preprocessing methods to process the Raman spectral formaldehyde residue dataset and select the optimal spectral preprocessing method; optimize the InceptionTime model structure based on the preprocessed Raman spectral formaldehyde residue dataset;
[0013] S6. Verify and analyze the classification results of the classification model.
[0014] Preferably, before data collection, aquatic products are immersed in formaldehyde of different concentrations, and the formaldehyde preservative effect is evaluated by observing changes in appearance and changes in volatile basic nitrogen content.
[0015] Preferably, the formaldehyde residue in the aquatic product sample is measured by spectrophotometry according to the SC-T 3025-2006 standard in S1. In order to verify the accuracy of the spectrophotometry, some of the measurement results are compared and verified with the measurement results of HPLC. The formaldehyde residue of each aquatic product is measured by steam distillation combined with spectrophotometry as the formaldehyde residue label of the corresponding spectrum, and the data are divided into 6 groups according to the formaldehyde residue measurement results: ≥1000mg / kg, 500-1000mg / kg, 100-500mg / kg, 5-100mg / kg, >100mg / kg and >5mg / kg.
[0016] Preferably, the InceptionTime model in S2 is as follows:
[0017] The InceptionTime model consists of residual blocks, each of which contains three Inception submodules. When processing an M-dimensional multivariate time series, the data first passes through the bottleneck layer of the Inception submodule, which uses m filters of length 1 and stride 1 to convert the M-dimensional signal into m-dimensional.
[0018] After the residual block, the InceptionTime model uses a global average pooling layer to average the multivariate time series in the time dimension; it then performs classification through a standard fully connected Softmax layer, whose number of neurons matches the number of categories in the dataset, to output the classification results.
[0019] Furthermore, all Raman spectral data of 20% of individual aquatic products are randomly selected from the aquatic product data set to form a test set. The remaining aquatic product spectral data are used as a training set. In order to improve the reliability of the results, the present invention adopts three repeated tests, and the average result of these three tests is used as the final evaluation index. Two deep learning models, InceptionTime and Cmp_CNN, and traditional machine learning models RF, XGBoost and SVM are used to classify the data set, and the performance is compared according to the classification ACC.
[0020] The model performance was evaluated by classification accuracy (ACC), and the applicability and efficiency of machine learning in the classification of non-destructive Raman spectroscopy datasets were analyzed in combination with the confusion matrix results.
[0021] Preferably, S3 is specifically as follows:
[0022] Methanol, ethanol and acetaldehyde were selected as formaldehyde-similar substances. Raman spectra of aquatic product samples soaked in methanol, ethanol and acetaldehyde were collected, and the data of aquatic products soaked in methanol, ethanol and acetaldehyde were marked in the same way.
[0023] Furthermore, the Raman spectra of the surface of aquatic products immersed in methanol (20%), ethanol (20%) and acetaldehyde (7%) for 1 hour were collected and marked as "1", while the Raman spectra of the surface of aquatic products immersed in water and formaldehyde for 1 hour were marked as "0". In order to maintain the balance of the data, the "0" data were stratified according to the individual aquatic products, and these data were used for classification tests.
[0024] Preferably, the S4 is specifically as follows:
[0025] According to the detection limit category, the corresponding classifier is designed in the InceptionTime model; the four substances including formaldehyde are distinguished by the InceptionTime model to determine the selectivity of the model for formaldehyde.
[0026] Preferably, the different spectrum preprocessing methods in S5 are specifically as follows:
[0027] Different spectral preprocessing methods include multivariate scattering correction, standard normal variable transformation, wavelet transform, SG and baseline correction; the Raman spectral formaldehyde residue data set was preprocessed by multivariate scattering correction, standard normal variable transformation, wavelet transform, SG and baseline correction, and the model was verified to evaluate the influence of different spectral preprocessing methods on the classification results of the classification model.
[0028] Preferably, the InceptionTime model structure is improved and optimized in S5, specifically as follows:
[0029] The number of residual blocks was adjusted, and the number of residual blocks of the InceptionTime model was set to 1, 2, and 3 respectively, while other model parameters remained unchanged. The optimal residual block configuration was determined based on the classification results of the preprocessed Raman spectroscopy formaldehyde residue dataset. After the InceptionTime model structure was optimized, it consisted of two residual blocks.
[0030] Furthermore, when determining the optimal residual block configuration, Attention, LSTM, GRU, and Transformer modules are added to compare model performance, and the TimesNet model is used to compare with the InceptionTime model.
[0031] Preferably, S6 is specifically as follows: analyzing the model classification result in combination with the Shap model classification weight visualization result.
[0032] Furthermore, the model classification results are analyzed in combination with the Shap model classification weight visualization results, as follows:
[0033] The Shap model is used to assign a Shap value to each feature of each predicted sample to indicate the contribution of the feature to the prediction, and the weights of different features are projected on the spectrum for visualization. The Shapley addition interpretation method is used to explain and verify the classification basis of the model, thereby enhancing the transparency and credibility of the model decision-making process.
[0034] A second aspect of the present invention provides a nondestructive detection system for formaldehyde residues in aquatic products, including an InceptionTime model obtained by the above-mentioned nondestructive detection method for formaldehyde residues in aquatic products after optimizing the InceptionTime model structure.
[0035] Compared with the prior art, the present invention has the following beneficial effects:
[0036] (1) The method of the present invention successfully uses Raman spectroscopy combined with deep learning to achieve non-destructive detection of formaldehyde residues in aquatic products, proving the advantages of this method being fast, accurate, non-destructive and non-invasive. This method has broad application prospects in the field of food safety. In the future, this technology can be extended to the rapid detection of other foods and related products, such as identifying harmful substances (such as heavy metals, pesticide residues) or detecting food adulteration and deterioration. In terms of market supervision, portable devices that combine Raman spectroscopy with deep learning algorithms can achieve real-time detection, improve regulatory efficiency, reduce costs, and provide rapid feedback at all stages of the supply chain. With further optimization of the detection range and sensitivity, combined with big data and Internet of Things technologies, this method is expected to support the intelligent development of food safety monitoring systems.
[0037] (2) The present invention designs and constructs a deep neural network model InceptionTime suitable for Raman spectroscopy data sets on the surface of aquatic products, designs corresponding classifiers according to different formaldehyde residue groups and detection limit categories, and trains and tests the two types of data respectively. The results of the present invention prove that the model has excellent detection performance in different formaldehyde residue concentration groups. The accuracy of the model is 85.17% and 84.40% when the detection limits are 100 mg / kg and 5 mg / kg, respectively. Weight visualization shows that the model pays special attention to peaks related to amino acids, lipids and nucleotides. The research of the present invention shows that deep learning provides an accurate, simple and economical method for detecting formaldehyde in aquatic products, and has broader application prospects in food safety.
[0038] (3) In the present invention, the InceptionTime model and other models are used to classify and analyze Raman spectroscopy data sets processed by different preprocessing methods. The classification performance of the InceptionTime model is optimal on the Raman spectroscopy data sets processed by different preprocessing methods. Compared with other preprocessing methods, the SG preprocessing method can further improve the classification performance. When the number of residual blocks is configured to 2, the InceptionTime model has the highest accuracy on the test data set, and this optimal performance may be attributed to the balance achieved under this specific setting. A comprehensive comparison of model performance shows that neither the improved InceptionTime model nor alternative architectures (such as TimesNet) can match the high accuracy obtained by the InceptionTime model with two residual blocks. This finding clearly shows that in the current experimental environment, the InceptionTime model with 2 residual blocks represents the best choice. The model structure is optimized to improve classification accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] Figure 1 It is a flow chart of the nondestructive detection method of formaldehyde residue in aquatic products in the present invention;
[0040] Figure 2 A schematic diagram of the data set construction process in the present invention;
[0041] Figure 3 The figures are analysis diagrams of the formaldehyde antiseptic effect in the present invention in terms of appearance change and volatile basic nitrogen content change (Figure a is an appearance change diagram, and Figure b is a volatile basic nitrogen content change diagram);
[0042] Figure 4 This is the architecture diagram of the InceptionTime model in the present invention;
[0043] Figure 5Schematic diagram of the comparison of the classification performance of formaldehyde residue by different pretreatment methods in the present invention (Figures a to c are respectively the accuracy change curve, loss change curve and test set classification accuracy result of the model in the training process of 500-1000 mg / kg data set after being treated by different pretreatment methods);
[0044] Figure 6 For the spectrum analysis in the present invention Figure 1 (Figure a is the distribution diagram of negative and positive aquatic products containing formaldehyde residues in non-destructive Raman spectroscopy data, and Figure b is the difference diagram between negative and positive data);
[0045] Figure 7 For the spectrum analysis in the present invention Figure 2 (Figure c is the spectrum of negative data and different groups of positive data, and Figure d is the difference between the mean of negative data and the mean of positive data);
[0046] Figure 8 For the spectrum analysis in the present invention Figure 3 (Figure e shows the top 20 feature maps of the InceptionTime model focused on by the SHAP interpreter, and Figure f shows a visualization of all feature weights on the spectrum. The color depth indicates the weight of each feature: the darker the color, the higher the feature weight, indicating greater importance to the model prediction results). DETAILED DESCRIPTION
[0047] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0048] Embodiment 1:
[0049] In this embodiment, the aquatic product is prawns, and the formaldehyde residue in prawns is specifically detected. Figure 1 As shown, the present invention provides a non-destructive detection method for formaldehyde residue, which specifically includes:
[0050] Step 1: Soak shrimps in formaldehyde of different concentrations and evaluate the preservative effect of formaldehyde by observing changes in appearance and volatile basic nitrogen content.
[0051] Prawns were purchased from supermarkets, put on crushed ice to kill suddenly, washed with water and air-dried. Prawns were soaked in formaldehyde solutions of different concentrations and stored at 4°C for 7 days. Total volatile basic nitrogen, an indicator of prawn freshness, was determined by microdiffusion method. Specifically, the heads, shells and intestines of the prawns were removed from the prawns, the prawn meat was minced and ground into a uniform paste using a pre-cooled mortar. 2 g of prawn meat was weighed and mixed with 10 mL of 10% trichloroacetic acid solution. Stirred for 1 min, allowed to stand for 30 min, centrifuged at 8000 rpm for 5 min, and the supernatant was separated. 1 mL of boric acid solution plus 1 drop of mixed indicator was added to the central chamber of the diffusion disk. In the outer chamber, 1 mL of supernatant was placed, covered with frosted glass, and quickly mixed with 1 mL of saturated potassium carbonate solution. The culture dish was tightly sealed, gently rotated, and incubated at 37°C for 2 h. After cooling to room temperature, the lid was removed and the inner circle solution was titrated with 0.01 mol / L hydrochloric acid. The hydrochloric acid consumption was used to quantify the volatile basic nitrogen. Including the reagent blank, each treatment was analyzed in triplicate.
[0052] The control group was found to show obvious decay on the fourth day, with blackening of the head and joints. In contrast, the decay rate of prawns immersed in formaldehyde solutions with a concentration greater than 1 mol / L was significantly reduced, with no obvious signs of decay. The volatile basic nitrogen content in these samples remained below the threshold of 20 mg / 100 g.
[0053] Step 2: Collect Raman spectra of shrimps soaked in formaldehyde solutions of different concentrations, collect data of multiple batches of shrimp samples, and construct a shrimp Raman spectrum dataset for non-destructive testing, such as Figure 2-Figure 3 .
[0054] The shrimps were soaked in different solutions (0, 0.1, 0.25, 0.5, 1, 2 mol / L) for 1 h, wiped clean, and the Raman spectra of the shrimp surface were collected directly. The Raman spectra of the samples were obtained using a handheld Raman spectrometer (RMS1000, Oceanhood) equipped with a 785 nm laser, with a laser power of 300 mW and an integration time of 1 s. For each shrimp sample, at least 30 points were collected from the shrimp surface, covering a range of 300–3500 cm -1 ( Figure 2 ). The "findpeaks" function in Python was used to identify characteristic Raman peaks, and outliers were excluded based on criteria such as peak position, peak intensity, and full width at half maximum. The present invention collected surface Raman spectra of 482 prawns in total, and obtained a data set of 19,504 Raman spectra.
[0055] The actual residual formaldehyde in shrimp samples was determined by spectrophotometry as specified in the SC-T 3025-2006 standard. 5 g of mashed shrimp meat was mixed with 20 mL of distilled water, stirred and allowed to stand for 30 min. Then 10 mL of phosphoric acid solution was added and distilled to 200 mL of distillate, including a blank control. A certain volume (1-10 mL) of distillate was diluted with water to a final volume of 10 mL, and then 1 mL of acetylacetone solution was added. The mixture was then heated in a boiling water bath for 10 min and cooled to room temperature. The absorbance was measured at 413 nm using an ELISA reader (SYNERGY-H1, BioTek, USA). According to the different residual formaldehyde contents, the positive data set was subdivided into 5-100 mg / kg, 100-500 mg / kg, 500-1000 mg / kg and ≥1000 mg / kg groups, as shown in Table 1. Before model training, each spectral data point was normalized to increase the training speed.
[0056] Table 1 Dataset of formaldehyde residues in shrimp
[0057]
[0058] Step 3: Classification model selection, construction and performance comparison.
[0059] Random forest (RF), support vector machine (SVM), XGBoost (Extreme gradient boosting), Compare Convolutional Neural Network (Cmp_CNN) and InceptionTime model were used to classify shrimp samples with different formaldehyde concentration levels. The model performance was evaluated by classification accuracy (ACC), and the applicability and efficiency of machine learning in the classification of non-destructive Raman spectroscopy datasets were analyzed by combining the confusion matrix results. At the same time, the classification performance was further improved by spectral data preprocessing and model structure optimization.
[0060] In this embodiment, InceptionTime is used to analyze Raman spectroscopy data.
[0061] The model structure of InceptionTime consists of two different residual blocks. Each residual block contains three Inception sub-modules, replacing the traditional fully connected layer, such as Figure 4As shown in the figure. The Inception module is designed to process time series data in parallel through multiple filters, so that different features can be extracted. This design allows the input to be passed directly to the input of the next residual block through a shortcut connection, which effectively alleviates the problem of gradient vanishing and improves the scalability of the model while maintaining prediction accuracy. Apply multiple filters to extract features. When processing an M-dimensional multivariate time series, the data first passes through the bottleneck layer of the Inception module, which uses m filters of length 1 and step size 1 to convert the M-dimensional signal into m-dimension. After the residual block, the network uses a global average pooling layer to average the multivariate time series in the time dimension. Finally, classification is performed through a standard fully connected Softmax layer, the number of neurons in this layer matches the number of categories in the dataset, and the final classification result is output.
[0062] In the implementation of the present invention, four convolution kernels with sizes of 1, 5, 11, and 23 were used in each Inception module. 20% of the Raman spectra were randomly selected from the prawn samples as the test set, and the remaining spectra were used for model training. To ensure the reliability of the results, the process was repeated for more than 10 iterations, and the average result was used as the final performance indicator. During the training process, the training set was further divided into two subsets, 80% for model training and 20% as a validation set to evaluate the reliability of the training process and results.
[0063] All models were cross-validated 5-fold, and the weights that performed best in training were used in the final testing phase. In order to accurately classify Raman spectroscopy data, the performance of InceptionTime was compared with other models, including Cmp_CNN, XGBoost, RF, and SVM, and the results are shown in Table 2.
[0064] Table 2 Classification accuracy of different models
[0065] Group RF SVM XGBoost Cmp_CNN InceptionTime ≥1000 mg / kg 0.7688 0.8101 0.8170 0.8457 0.8911 500~1000mg / kg 0.7815 0.8096 0.8216 0.8380 0.8702 100~500mg / kg 0.7209 0.7505 0.7556 0.7592 0.8032 5–100 mg / kg 0.7206 0.7124 0.7625 0.7714 0.7888 >100 mg / kg 0.7845 0.8171 0.8055 0.8174 0.8517 >5 mg / kg 0.7871 0.8017 0.8026 0.8206 0.8440
[0066] Table 2 shows that in all concentration groups, the InceptionTime model consistently outperformed the other four models (RF, SVM, XGBoost, and Cmp_CNN), achieving the highest classification accuracy, with a classification accuracy of 0.8911 in the ≥1000mg / kg group and 0.8702 in the 500-1000mg / kg group. Even in the lower concentration groups of 100-500mg / kg and 5-100mg / kg, InceptionTime still maintained a high accuracy (0.8032 and 0.7888, respectively).
[0067] Step 4: Classify the data set into single concentration groups and different detection limits.
[0068] The present invention collects Raman spectra of shrimp surfaces immersed in methanol (20%), ethanol (20%) and acetaldehyde (7%) for 1 hour, which are marked as "1", while the Raman spectra of shrimp surfaces immersed in water and formaldehyde for 1 hour are marked as "0". The detailed information of the data set is shown in Table 1. In order to maintain the balance of the data, the "0" data are stratified by individual shrimps. These data are then used for classification tests.
[0069] Step 5: Conduct selective analysis and verification of the model for formaldehyde.
[0070] In this embodiment, the InceptionTime model is used to distinguish four substances including formaldehyde to determine the selectivity of the model for formaldehyde.
[0071] Table 3 Recognition results of formaldehyde in similar substances by different models
[0072] Similar substances RF SVM XGBoost Cmp_CNN InceptionTime Acetaldehyde 0.9442 0.9540 0.9587 0.9710 0.9734 Ethanol 0.8772 0.9104 0.8970 0.9241 0.9372 Methanol 0.8688 0.9057 0.9086 0.9139 0.9170
[0073] As shown in Table 3, the InceptionTime model has a high recognition accuracy for the three substances, and the recognition and classification performance for acetaldehyde is 0.9734. This shows that the InceptionTime model can effectively distinguish the Raman spectra of shrimp soaked in formaldehyde and shrimp soaked in other structurally similar substances.
[0074] Step 6: Optimize the model structure.
[0075] In this embodiment, a variety of preprocessing methods are used, including multiplicative scatter correction (MSC), standard normal variate transform (SNV), Hilbert transform (HT), Savitzky-Golay (SG) and baseline correction; the data are processed by MSC, SNV, HT, SG and baseline correction, and then the model is verified to evaluate the impact of preprocessing on the model results.
[0076] As one of the commonly used preprocessing methods, MSC aims to solve the problem of spectral data scattering caused by individual differences in samples. Since the spectral changes caused by scattering are often greater than the changes in the sample composition itself, MSC can effectively correct these changes and obtain more realistic spectral information. This preprocessing algorithm focuses on processing errors caused by scattering. It assumes that the spectral intensity distribution is approximately normal and adjusts the spectral data through transformation to reduce the scattering effect.
[0077] The process of MSC conversion can be expressed as:
[0078]
[0079] Among them, X ij is the element in the original data matrix X, X msc is the element in the data matrix after MSC transformation, b i and k i are the intercept and slope obtained by linear regression of the ith row in the original data matrix X and the mean spectrum of the entire data matrix.
[0080] The SNV preprocessing algorithm focuses on dealing with errors caused by scattering. It assumes that the spectral intensity distribution is approximately normal and adjusts the spectral data through transformation to reduce the scattering effect.
[0081] The process of SNV conversion can be expressed as:
[0082]
[0083] Among them, X snv is the element in the data matrix after SNV transformation, X i is the mean of the i-th row in the original data matrix X. The denominator is the standard deviation of the i-th row in the original data matrix X.
[0084] For wavelet transform, considering that the effective signal in the spectral information often appears in the form of low frequency, while the noise usually appears as a high frequency component, the present invention uses HT to process the original spectral data, and decomposes the spectrum into components of different frequencies through this method. Subsequently, the present invention uses a threshold algorithm, especially the Hilbert function in the signal module in the scipy library, to effectively filter out the decomposed high-frequency noise, thereby achieving the effect of noise reduction.
[0085] SG smoothing uses the savgol_filter function in the SciPy library to apply the Savitzky-Golay filter for smoothing and denoising. The length of the filter window is set to 21, and the data of 21 points before and after the point (including the point itself) are considered for smoothing; the order of the polynomial used to fit each window subset is 5, and a 5th-order polynomial is used to fit the data within the window. This technology can reduce the errors caused by random and mechanical noise, make the wavelength information smoother, and help eliminate the impact of noise on spectral data.
[0086] Use NumPy's polyfit function to perform polynomial fitting on the data for baseline correction, and set the fitting order to 5. The process of polynomial fitting to remove the baseline can be expressed as:
[0087] X corrected =X ij -P i (j)
[0088] For a spectral data matrix X, each row i (i=1, 2, ..., m) represents a sample, and each column j (j=1, 2, ..., n) represents a spectral variable. corrected is the element in the data matrix after removing the baseline, P i (j) is the baseline obtained by polynomial fitting of the i-th row in the original data matrix X.
[0089] The purpose of baseline correction is to eliminate the baseline offset phenomenon in the spectral signal caused by environmental factors, instrument response inhomogeneity or sample scattering. Baseline offset will cause the shape of the spectral curve to be distorted and the peak position to shift, thereby affecting the accuracy of qualitative and quantitative analysis of spectral data. Through baseline correction, the present invention will adjust the baseline part in the spectral data to make it close to the zero baseline, reduce or eliminate the interference of the baseline on the real spectral peak, and ensure that the recovered spectral signal is closer to the real absorption characteristics of the sample.
[0090] like Figure 5 As shown, each group of models began to converge approximately after 40 steps of training. After reaching stability, the accuracy of the original model is comparable to that of the standard normal variable transformation (SNV) model, the Hilbert transform (HT) model, and the Savitzky-Golay (SG) model. However, the multiplicative scatter correction (MSC) and baseline correction methods show relatively poor performance. This trend is consistent with the change in the loss function. Different models were used to classify and analyze the Raman spectroscopy datasets processed by different preprocessing methods. From Figure 5 It can be seen that the classification performance of the InceptionTime model is the best on the Raman spectroscopy datasets processed by different preprocessing methods. In addition, compared with other methods, the SG preprocessing method can further improve the classification performance. Therefore, the subsequent classification work of the present invention is carried out using the Raman spectroscopy dataset preprocessed by the SG method.
[0091] Table 4 Structural optimization verification results of InceptionTime model
[0092]
[0093] Data analysis in Table 4 shows that the InceptionTime model achieves the highest accuracy of 0.8797 on the test dataset when the number of residual blocks is configured as 2. This optimal performance may be attributed to the balance achieved in this particular setting. With only 1 residual block, the model lacks sufficient depth to capture a sufficient amount of information. In contrast, increasing the number of residual blocks to 3 may make the model too deep, leading to possible learning bias and subsequent decrease in accuracy. Therefore, setting the number of residual blocks to 2 can effectively balance the risks of feature extraction and overfitting while also saving computational power. A comprehensive comparison of model performance shows that neither the improved InceptionTime model nor alternative architectures such as TimesNet can match the high accuracy achieved by the InceptionTime model with two residual blocks. This finding clearly indicates that the InceptionTime model with 2 residual blocks represents the best choice in the current experimental setting.
[0094] Step 7: Analyze the model classification results based on the Shap model classification weight visualization results.
[0095] The present invention uses the SHapley Additive Interpretation (Shap) interpreter to visualize the classification weights of the InceptionTime model, such as Figure 6-Figure 8 The Shap analysis clearly highlights the most important features of the model. It determines that the 1003 cm -1 、1492cm -1 and 1150cm -1 The model focuses on the shoulders of these three peaks. In particular, the wavenumbers close to 1003 correspond to 7 of the top 20 features. In addition, at 300-400 cm -1 Fluorescent bands within the range are also highlighted.
[0096] The Shap model is used to assign a Shap value to each feature of each predicted sample, indicating the contribution of the feature to the prediction, and the weights of different features are projected on the spectrum for visualization. The Shapley Additive Interpretation (SHAP) method is used to explain and verify the classification basis of the model, thereby enhancing the transparency and credibility of the model decision-making process.
[0097] In this study, we demonstrated the feasibility of nondestructive detection of formaldehyde residues in shrimp using Raman spectroscopy. By collecting Raman data of shrimp samples and using spectrophotometric measurements of formaldehyde residues as classification labels, we evaluated the classification performance of the model in different concentration groups. In all concentration groups, the InceptionTime model consistently outperformed other models, including Cmp_CNN, RF, XGBoost, and SVM, and maintained the highest accuracy across various detection limits.
[0098] Further analysis showed that the InceptionTime model showed more stable performance on different test sets compared to other models, thus highlighting its robustness in dealing with different data conditions. In addition, the present invention's study of spectral preprocessing methods showed that the SG preprocessing technique improved the performance of the model. This finding emphasizes that specific methods of spectral preprocessing are beneficial for classification tasks. During the optimization of the InceptionTime model structure, the present invention observed that the performance of the model peaked in two residual blocks, indicating that this configuration is optimal for the present invention's dataset. Adding other modules, such as Attention, LSTM, GRU, and Transformer, did not significantly improve the performance of the model, indicating that the added complexity of these modules may not be necessary or beneficial for this particular application. In addition, the present invention found that the TimesNet model consistently performed poorly compared to InceptionTime, which highlights the effectiveness of the InceptionTime architecture in capturing relevant features of the data. These findings suggest that for the classification of shrimp Raman spectra, simpler structures and fewer residual blocks may provide sufficient accuracy without the need for more complex modules or alternative models. Future work could explore fine-tuning the existing structure or combining it with lightweight enhancements to further optimize the performance without sacrificing computational efficiency.
[0099] The above description is only used to help understand the method of the present invention and its core essence, but the protection scope of the present invention is not limited thereto. For those skilled in the art in the art, equivalent replacement or change according to the technical solution and inventive concept of the present invention within the technical scope disclosed by the present invention should be included in the protection scope of the present invention. In summary, the content of this specification should not be understood as limiting the present invention.
Claims
1. A non-destructive detection method for formaldehyde residue in aquatic products, characterized in that: The steps include: S1. Establish a formaldehyde residue data set; collect Raman spectra of aquatic product samples after being soaked in formaldehyde solutions of different concentrations, measure the formaldehyde residue in the aquatic product samples, divide the collected Raman spectrum data into different groups according to the formaldehyde residue measurement results, and construct a Raman spectrum formaldehyde residue data set; S2. Construct a classification model; use random forest, support vector machine, XGBoost, convolutional neural network for comparison and InceptionTime model to classify the Raman spectroscopy formaldehyde residue data, evaluate the model performance by classification accuracy, and select InceptionTime model as the classification model; S3, establish a selective data set; The Raman spectra of aquatic product samples soaked in formaldehyde-like substances were collected, and the data of aquatic products soaked in formaldehyde-like substances were labeled with the same label, and the data of aquatic products soaked in water and formaldehyde were labeled with the same label, and the mixed data were used to construct a selective data set; S4. Verify the selectivity of the classification model for formaldehyde; use the InceptionTime model to select mixed data to determine the accuracy of formaldehyde recognition; S5. Optimize the classification model structure; use different spectral preprocessing methods to process the Raman spectral formaldehyde residue data set and select the optimal spectral preprocessing method; Based on the preprocessed Raman spectroscopy formaldehyde residue dataset, the InceptionTime model structure was optimized; S6. Verify and analyze the classification results of the classification model.
2. The nondestructive detection method for formaldehyde residue in aquatic products according to claim 1, characterized in that: The InceptionTime model in S2 is as follows: The InceptionTime model consists of residual blocks, each of which contains three Inception submodules. When processing an M-dimensional multivariate time series, the data first passes through the bottleneck layer of the Inception submodule, which uses m filters of length 1 and stride 1 to convert the M-dimensional signal into m-dimensional. After the residual block, the InceptionTime model uses a global average pooling layer to average the multivariate time series in the time dimension; Classification is then performed through a standard fully connected Softmax layer, the number of neurons in this layer matches the number of categories in the dataset, and the classification results are output.
3. The nondestructive detection method for formaldehyde residue in aquatic products according to claim 2, characterized in that: The S3 is as follows: Methanol, ethanol and acetaldehyde were selected as formaldehyde-similar substances. Raman spectra of aquatic product samples soaked in methanol, ethanol and acetaldehyde were collected, and the data of aquatic products soaked in methanol, ethanol and acetaldehyde were marked in the same way.
4. The nondestructive detection method for formaldehyde residue in aquatic products according to claim 3, characterized in that: The S4 is specifically as follows: designing a corresponding classifier in the InceptionTime model according to the detection limit category.
5. The nondestructive detection method for formaldehyde residue in aquatic products according to claim 2, characterized in that: The different spectral preprocessing methods in S5 are specifically as follows: Different spectral preprocessing methods include multivariate scattering correction, standard normal variable transformation, wavelet transform, SG and baseline correction; the Raman spectral formaldehyde residue data set was preprocessed by multivariate scattering correction, standard normal variable transformation, wavelet transform, SG and baseline correction, and the model was verified to evaluate the influence of different spectral preprocessing methods on the classification results of the classification model.
6. The nondestructive detection method for formaldehyde residue in aquatic products according to claim 5, characterized in that: The InceptionTime model structure is improved and optimized in S5, as follows: The number of residual blocks was adjusted, and the number of residual blocks of the InceptionTime model was set to 1, 2, and 3 respectively, while other model parameters remained unchanged. The optimal residual block configuration was determined based on the classification results of the preprocessed Raman spectroscopy formaldehyde residue dataset. After the InceptionTime model structure was optimized, it consisted of two residual blocks.
7. A non-destructive detection method for formaldehyde residue in aquatic products according to any one of claims 1 to 6, characterized in that: The S6 is specifically as follows: analyzing the model classification results in combination with the Shap model classification weight visualization results.
8. The nondestructive detection method for formaldehyde residue in aquatic products according to claim 7, characterized in that: The model classification results are analyzed by combining the Shap model classification weight visualization results, as follows: The Shap model is used to assign a Shap value to each feature of each predicted sample to indicate the contribution of the feature to the prediction, and the weights of different features are projected on the spectrum for visualization. The Shapley addition interpretation method is used to explain and verify the classification basis of the model.
9. A non-destructive detection system for formaldehyde residue in aquatic products, characterized in that: The invention comprises an InceptionTime model obtained by the non-destructive detection method for formaldehyde residue in aquatic products as claimed in claim 8, wherein the structure of the InceptionTime model is optimized.
Citation Information
Patent Citations
Device and method for detecting formaldehyde
CN102749318A
Correction method in Raman spectroscopy quantitative detection under temperature fluctuation condition
CN103674927A
Kalman filtering formaldehyde detection method based on neural network
CN103743867A
Application of semiconductor compound in benzaldehyde specificity detection, and benzaldehyde specificity detection method
CN109596595A
Rapid formaldehyde detection method and application
CN118130443A