Raman spectrum-based beef producing area tracing method and device and electronic equipment
By introducing a stacked integrated training layer and meta-feature analysis layer into the beef origin traceability model, combined with multiple base learners, the problem of existing models being sensitive to data changes is solved, and higher traceability accuracy and model stability are achieved.
Patent Information
- Application Number
- CN202510646265.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-20
- Publication Date
- 2025-06-20
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The existing beef origin traceability model is sensitive to data changes, the number of samples in the training set is limited or the correction method is unstable, the prediction accuracy and stability of the model are insufficient, resulting in low traceability accuracy.
Using the beef origin traceability method based on Raman spectroscopy, the model of the stacked integrated training layer and the meta-eigen analysis layer is set up sequentially connected, and multiple parallel-set basic learners are used for training and prediction to improve the overall performance, robustness and generalization ability of the model.
It significantly improves the traceability accuracy of beef products, improves the prediction performance and stability of the model, and can more accurately distinguish beef from different origins.
Smart Images

Figure CN120177460A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of meat product analysis, and in particular to a method, device and electronic device for tracing the origin of beef based on Raman spectroscopy. Background Art
[0002] Nowadays, beef not only provides people with rich nutrients but also can enhance the body's immunity. Establishing a technical system for tracing and supervising the origin of beef is beneficial to protecting regional brands, protecting special products, ensuring fair competition, preventing the spread of pathogenic bacteria, effectively recalling products, and reducing economic losses.
[0003] The technologies for tracing the origin of beef mainly include stable isotopes, mineral elements, metabolomics, and spectroscopy. At present, most of the research on tracing the origin of agricultural products by researchers is based on a single algorithm, that is, using different single algorithms to establish an optimal model for tracing the origin analysis of agricultural products. However, due to the high sensitivity of the model constructed based on a single algorithm to data changes, when the number of training set samples is limited or the calibration method is unstable, the prediction accuracy and stability of the model are often not satisfactory, the overall performance, robustness, and generalization ability of the model are poor, and the tracing accuracy is not high. Summary of the Invention
[0004] The purpose of the present invention is to provide a method, device and electronic device for tracing the origin of beef based on Raman spectroscopy. The beef origin tracing model is provided with a stacked ensemble training layer and a meta-feature analysis layer connected in sequence, and the overall performance, robustness, and generalization ability of the model are greatly improved compared with the existing model, improving the tracing accuracy of beef products.
[0005] In a first aspect, the present invention provides a method for tracing the origin of beef based on Raman spectroscopy, which is applied to a beef origin tracing system. The method includes: Obtaining a beef sample and performing preprocessing to obtain a beef sample slice; wherein, the preprocessing includes successively: drying treatment, grinding and screening treatment, and pressing treatment; Performing Raman spectroscopy detection on the beef sample slice to obtain a Raman characteristic spectrum; Inputting the Raman characteristic spectrum into a pre-trained beef origin tracing model, and outputting the traced origin of the beef sample; wherein, the beef origin tracing model includes: a stacked ensemble training layer and a meta-feature analysis layer connected in sequence; the stacked ensemble training layer includes: a plurality of base learners arranged in parallel.
[0006] In some preferred embodiments of the present invention, the method further includes: training the beef origin tracing model through the following steps: Taking the Raman characteristic spectrum of the training beef sample as a training sample; Dividing the training sample into a training set and a test set according to a preset ratio; Train the stacked ensemble training layer based on the training set until the stacked ensemble training layer reaches a preset training goal; Input the training set into the stacked ensemble training layer that has reached the training goal and output meta-features; Train the meta-feature analysis layer based on the meta-features and the true labels of the beef samples in the training set until the training is completed; Determine the completed stacked ensemble training layer and the meta-feature analysis layer as the beef origin traceability model.
[0007] In some preferred embodiments of the present invention, the method further includes: Evaluate the indicators of the beef origin traceability model based on the test set; wherein, the indicators at least include one of the following: accuracy, precision, and recall.
[0008] In some preferred embodiments of the present invention, the base learners include: support vector machine, logistic regression, ridge regression classifier, random forest, gradient boosting decision tree, linear discriminant analysis, and stochastic gradient descent classifier.
[0009] In some preferred embodiments of the present invention, the steps of obtaining a beef sample and performing preprocessing to obtain a beef sample slice include: Process the beef sample in a dryer until the difference in weight between two consecutive weighings is less than a preset weight difference; Grind and screen the dried beef sample to obtain beef powder with a particle size less than a preset diameter; Press a preset weight of the beef powder to obtain a beef sample slice.
[0010] In some preferred embodiments of the present invention, the steps of performing Raman spectroscopy detection on the beef sample slice to obtain a Raman characteristic spectrum include: Collect a Raman spectrum at different positions of the beef sample slice respectively; Perform an average calculation on multiple Raman spectra to obtain a Raman characteristic spectrum.
[0011] In a second aspect, the present invention provides a beef origin traceability device based on Raman spectroscopy, which is applied to a beef origin traceability system. The device includes: A sample processing module, configured to obtain a beef sample and perform preprocessing to obtain a beef sample slice; wherein, the preprocessing sequentially includes: drying treatment, grinding and screening treatment, and pressing treatment; A Raman spectrum processing module, configured to perform Raman spectroscopy detection on the beef sample slice to obtain a Raman characteristic spectrum; The origin tracing module is used to input the Raman characteristic spectrum into the pre-trained beef origin tracing model and output the traced origin of the beef sample. Among them, the beef origin tracing model includes: a stacked ensemble training layer and a meta-feature analysis layer connected in sequence; the stacked ensemble training layer includes: multiple base learners arranged in parallel.
[0012] In some preferred embodiments of the present invention, the device further includes: The model training module is used to train the beef origin tracing model through the following steps: taking the Raman characteristic spectrum of the training beef sample as the training sample; dividing the training sample into a training set and a test set according to a preset ratio; training the stacked ensemble training layer based on the training set until the stacked ensemble training layer reaches the preset training goal; inputting the training set into the stacked ensemble training layer that has reached the training goal and outputting the meta-features; training the meta-feature analysis layer based on the meta-features and the true labels of the beef samples in the training set until the training is completed; determining the completed stacked ensemble training layer and the meta-feature analysis layer as the beef origin tracing model.
[0013] In a third aspect, the present invention provides an electronic device, including a processor and a memory. The memory stores computer-executable instructions that can be executed by the processor. The processor executes the computer-executable instructions to implement the method for tracing the origin of beef based on Raman spectroscopy provided in the first aspect above.
[0014] In a fourth aspect, the present invention provides a computer-readable storage medium. The computer-readable storage medium stores computer-executable instructions. When the computer-executable instructions are called and executed by the processor, the computer-executable instructions cause the processor to implement the method for tracing the origin of beef based on Raman spectroscopy provided in the first aspect above.
[0015] The present invention brings the following beneficial effects: The present invention provides a method, device and electronic device for tracing the origin of beef based on Raman spectroscopy, which are applied to a beef origin tracing system. The method includes: obtaining a beef sample and performing preprocessing to obtain a beef sample slice; where the preprocessing sequentially includes: drying treatment, grinding and screening treatment, and pressing treatment; performing Raman spectroscopy detection on the beef sample slice to obtain a Raman characteristic spectrum; inputting the Raman characteristic spectrum into the pre-trained beef origin tracing model and outputting the traced origin of the beef sample; where the beef origin tracing model includes: a stacked ensemble training layer and a meta-feature analysis layer connected in sequence; the stacked ensemble training layer includes: multiple base learners arranged in parallel; the beef origin tracing model is provided with a stacked ensemble training layer and a meta-feature analysis layer connected in sequence, and the overall performance, robustness and generalization ability of the model are greatly improved compared with the existing model, and the tracing accuracy of beef products is improved. Description of the Drawings
[0016] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the following will briefly introduce the drawings required for the description of the specific embodiments or the prior art. Obviously, the drawings in the following description are some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.
[0017] Figure 1 It is a flowchart of a method for tracing the origin of beef based on Raman spectroscopy provided by an embodiment of the present invention; Figure 2 It is a schematic diagram of the overall structure of a beef origin tracing model provided by an embodiment of the present invention; Figure 3 It is a schematic diagram of the overall structure of another beef origin tracing model provided by an embodiment of the present invention; Figure 4 It is a schematic spectral diagram of the average original Raman spectra of beef samples from four origins provided by an embodiment of the present invention; Figure 5 It is a schematic diagram of the scores of beef from four origins based on the PCA model provided by an embodiment of the present invention; Figure 6 It is a schematic diagram of the Kappa coefficient based on different origin discrimination models provided by an embodiment of the present invention; Figure 7 It is a schematic diagram of the structure of a device for tracing the origin of beef based on Raman spectroscopy provided by an embodiment of the present invention; Figure 8 It is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention.
[0018] Icons: 310 - Sample processing module; 320 - Raman spectrum processing module; 330 - Origin tracing module; 400 - Memory; 401 - Processor; 402 - Bus; 403 - Communication interface. Specific Embodiments
[0019] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are some, but not all, of the embodiments of the present invention. Usually, the components of the embodiments of the present invention described and illustrated in the drawings here can be arranged and designed in various different configurations.
[0020] Accordingly, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely represents selected embodiments of the present invention. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the scope of protection of the present invention.
[0021] It should be noted that like reference numerals and letters denote like items in the following drawings. Therefore, once an item is defined in one drawing, it does not require further definition and explanation in subsequent drawings.
[0022] In the description of the present invention, it should be noted that the orientation or positional relationship indicated by the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc. is based on the orientation or positional relationship shown in the drawings, or the orientation or positional relationship in which the product of the invention is customarily placed during use. It is only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of the present invention. In addition, the terms "first", "second", "third", etc. are only used for descriptive distinction and should not be construed as indicating or implying relative importance.
[0023] In addition, the terms "horizontal", "vertical", "hanging", etc. do not mean that the components are required to be absolutely horizontal or hanging, but may be slightly inclined. For example, "horizontal" only means that its direction is more horizontal relative to "vertical", and does not mean that the structure must be completely horizontal, but may be slightly inclined.
[0024] In the description of the present invention, it should also be noted that unless otherwise clearly specified and defined, the terms "set", "install", "connect", "couple" should be understood in a broad sense. For example, it may be a fixed connection, a detachable connection, or an integral connection; it may be a mechanical connection or an electrical connection; it may be directly connected or indirectly connected through an intermediate medium, and it may be the communication inside two elements. For those of ordinary skill in the art, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0025] Nowadays, beef not only provides people with rich nutrients, but also can improve the body's immunity. The existing traceability system for the cattle industry is not yet perfect. Most live cattle and beef products cannot trace their sources, increasing the food safety risks of beef products. Establishing a technical system for tracing and supervising the origin of beef is conducive to protecting regional brands, protecting special products, ensuring fair competition, preventing the spread of pathogenic bacteria, effectively recalling products, and reducing economic losses. Therefore, it is of great significance to quickly identify beef from different regions.
[0026] Beef origin traceability technologies mainly include stable isotopes, mineral elements, metabolomics, and spectroscopy, etc. Among these methods, the inexpensive, rapid, and non-destructive spectroscopy technology is becoming increasingly popular and has the potential to meet the rapid detection requirements of the beef market. Raman spectroscopy is an optical technology based on the inelastic scattering of light by vibrating molecules. Based on Raman spectroscopy, chemical fingerprint maps of cells, tissues, or biological fluids can be provided, enabling rapid, accurate, and non-destructive detection. Compared with other spectroscopy technologies, Raman spectroscopy is less sensitive to water and is not easily interfered by water during the detection process. Some studies have shown that Raman spectroscopy technology exhibits a higher origin traceability accuracy compared with other spectroscopy technologies. Some researchers used near-infrared spectroscopy, mid-infrared spectroscopy, and Raman spectroscopy analysis techniques combined with chemometric methods to identify the origin of rice. Among them, the rice origin identification model combining Raman spectroscopy with the Least Squares-Support Vector Machine (LSSVM, LS-SVM) algorithm was the best. The recognition accuracies of its LS-SVM calibration set and test set were 100% and 93.48% respectively. The accuracy of the test set of this model was increased by 6.52% and 2.18% respectively compared with the optimal models of near-infrared spectroscopy and mid-infrared spectroscopy. Some researchers also used different spectroscopy technologies (visible light, ultraviolet, near-infrared, fluorescence, Raman, etc.) combined with Partial Least Squares Discriminant Analysis (PLS-DA) method to achieve the origin traceability of olive oil from different origins in Greece. Among them, visible light and Raman spectroscopy were superior to other spectroscopy technologies, and the origin classification accuracy reached more than 94%. In addition, some researchers have also used Raman spectroscopy technology to achieve the origin traceability of agricultural products such as tea, cherries, yellow rice wine, red wine, almonds, honey, red peppers, and peanuts. However, in the research on the origin traceability of animal-source foods, there has been no progress in the research on the origin traceability of livestock and poultry meat products.
[0027] At present, most of the research on the traceability of the origin of agricultural products by some researchers is based on a single algorithm, that is, using different single algorithms to establish an optimal model for the traceability analysis of the origin of agricultural products. Researchers used Raman spectroscopy combined with PLS-DA to achieve the traceability of the origin of agricultural products such as rice, Ophiopogon japonicus, and Astragalus membranaceus, and the accuracy of the origin was 90%-100%. Some researchers used Support Vector Machine (SVM), Decision Tree (DT), and Random Forest (RF) algorithms to achieve the traceability of lilies from different origins, and their classification accuracy was 91.7%-95.8%. Some researchers used Raman spectroscopy combined with Long Short-Term Memory (LSTM) to construct a cherry origin discrimination model. The P value and R value of the LSTM model were both above 97%, and the F value was above 98%, indicating that the established LSTM model had a high precision rate and recall rate, and could achieve the origin discrimination of cherries from different origins with better performance. Some researchers used Raman spectroscopy to achieve the discrimination of honey from different origins, and the Soft Independent Modeling of Class Analogy had a higher origin classification accuracy than the SVM algorithm. Some researchers found that in the study of almond origin discrimination based on Raman spectroscopy, the accuracy of Convolutional Neural Networks (CNN) was higher than that of the other three models (logistic regression model, random forest model, Bayesian network model).
[0028] The above research provides a new research idea and feasibility for the first time to achieve the traceability of beef origin based on Raman spectroscopy technology. However, due to the high sensitivity of the model constructed based on a single algorithm to data changes, when the number of training set samples is limited or the calibration method is unstable, the prediction accuracy and stability of the model are often not satisfactory.
[0029] The present invention proposes a method for tracing the origin of beef based on Raman spectroscopy technology combined with a multi-model Stacking integration model. This method fuses multiple models such as Support Vector Machine (SVM), Logistic Regression, Ridge Classifier, Random Forest, Extreme Gradient Boosting (XGBoost), Linear Discriminant Analysis (LDA), Stochastic Gradient Descent Classifier (SGDClassifier), etc., trains and predicts the origin of beef, comprehensively utilizes the advantages of each model, makes up for their deficiencies, reduces the risk of overfitting, improves the overall prediction performance and generalization ability, and thus realizes more accurate and robust discrimination results for beef from different origins.
[0030] The following will, with reference to the accompanying drawings, elaborate on some embodiments of the present invention. Without conflict, the following embodiments and the features in the embodiments can be combined with each other.
[0031] Embodiment 1 The embodiment of the present invention provides a method for tracing the origin of beef based on Raman spectroscopy, which is applied to a beef origin tracing system. Refer to Figure 1 the flowchart of the method for tracing the origin of beef based on Raman spectroscopy provided by the embodiment of the present invention as shown. The method includes: Step S102, obtain a beef sample and perform preprocessing to obtain a beef sample slice; wherein, the preprocessing sequentially includes: drying treatment, grinding and screening treatment, and pressing treatment.
[0032] Specifically, the beef sample can be directly dried using an oven; in some preferred embodiments of the present invention, the moisture inside the beef sample is first fixed by freezing, and then it is dried to make the water content of the beef sample less than a preset value, such as 5%. This can effectively retain the thermosensitive components (such as proteins and vitamins) in the beef sample and avoid the nutrient loss or denaturation caused by traditional high-temperature drying; further, the dried sample is ground and screened, and the humidity needs to be controlled during the grinding process to avoid caking of the sample powder; further, the screened sample powder is evenly filled into a mold and pressed in a constant temperature and humidity environment to ensure the consistency of the sample slice density.
[0033] Further, in some preferred embodiments of the present invention, the steps of obtaining a beef sample and performing pretreatment to obtain a beef sample slice include: processing the beef sample in a dryer until the difference in weight between two consecutive weighings is less than a preset weight difference; grinding and screening the dried beef sample to obtain beef powder with a particle size smaller than a preset diameter; and pressing a preset weight of the beef powder to obtain a beef sample slice.
[0034] Specifically, put 5 g of each beef sample into a petri dish and place it in a dryer until it reaches a constant weight, that is, the weight difference between two weighings before and after does not exceed 2 mg. The dryer can be a WGL-230D electrothermal blast drying oven. After drying, use a SCIENTZ-48 high-throughput tissue grinder to grind the powder. The frequency of the grinder is 70, and grind for 5 min to obtain dried beef powder. The obtained beef powder is passed through a 100-mesh sieve to obtain beef powder with a particle size smaller than 100 mesh. Weigh 0.1 g of the beef powder passing through 100 mesh and place it in a 304 stainless steel mold with an inner diameter of 6 mm. Keep the pressure at 4 t for 2 min to press it into a circular beef sample slice with a diameter of 6 mm.
[0035] Step S104, perform Raman spectroscopy detection on the beef sample slice to obtain a Raman characteristic spectrum.
[0036] Specifically, place the pressed beef sample slice on the surface of a clean quartz slide, cover the edge of the sample slice with a transparent sealing film to avoid interference from external contaminants during the detection process; fix the slide with a three-dimensional adjustable sample stage, and adjust the level of the sample slice through a laser positioning system to ensure that the surface of the detection area is perpendicular to the optical axis of the spectrometer.
[0037] Use a RamTracer-200-HS high-sensitivity laser Raman spectrometer to perform Raman spectroscopy detection. The wavelength is 785 nm, the spectral range , the spectral resolution , the laser intensity is 100 mW, the integration time is 5 s, the integration times is 2 times, and the distance between the laser and the sample surface is 7 mm. Keep a dark environment during collection, and keep the temperature and humidity constant. Randomly select detection points on the surface of the sample slice to collect spectral data.
[0038] The embodiment of the present invention adopts a non-destructive detection technology to retain the integrity of the sample slice for subsequent repeated analysis; the near-infrared laser light source effectively suppresses the interference of the pigment fluorescence background in beef; the standardized acquisition process and data preprocessing algorithm ensure the repeatability and comparability of the characteristic spectrum.
[0039] Further, in some preferred embodiments of the present invention, the steps of performing Raman spectroscopy detection on the beef sample slice to obtain a Raman characteristic spectrum include: collecting a Raman spectrum for different positions of the beef sample slice respectively; and performing an average calculation on the multiple Raman spectra to obtain a Raman characteristic spectrum.
[0040] Specifically, considering the non-uniformity of the samples, one Raman spectrum was collected at each of 5 different positions on the beef round sample. Finally, the average spectrum was calculated from the 5 Raman spectra measured for each sample and used as the Raman characteristic spectrum of the sample.
[0041] Step S106: Input the Raman characteristic spectrum into the pre-trained beef origin traceability model to output the traceable origin of the beef sample. Among them, the beef origin traceability model includes a stacked ensemble training layer and a meta-feature analysis layer connected in sequence; the stacked ensemble training layer includes multiple base learners arranged in parallel.
[0042] Specifically, the beef origin traceability model can be an ensemble learning model. The ensemble learning model is a hierarchical ensemble architecture that combines different algorithm models. First, multiple heterogeneous base models (i.e., base learners) are used to form the first layer for parallel learning of data. Then, the results obtained by each base model are input into the meta-feature analysis layer of the second layer for training, thereby obtaining a complete ensemble learning model. The model uses the prediction data of each different algorithm as the training data for the next layer of the model, which combines the advantages of each model well and improves the prediction accuracy.
[0043] Furthermore, in some preferred embodiments of the present invention, the base learners include: support vector machine, logistic regression, ridge regression classifier, random forest, gradient boosting decision tree, linear discriminant analysis, and stochastic gradient descent classifier.
[0044] In some preferred embodiments of the present invention, the Stacking (an ensemble learning technique) ensemble learning model is used as the beef origin traceability model. See Figure 2Schematic diagram of the overall structure of a beef origin traceability model provided by an embodiment of the present invention. This model is based on the Stacking method and selects 7 heterogeneous classification models, namely Support Vector Machine (SVM), Logistic Regression (LR), Ridge Classifier, Random Forest, Gradient Boosting Decision Tree (XGBoost), Linear Discriminant Analysis (LDA), and Stochastic Gradient Descent Classifier (SGDClassifier) as the base learners. The meta-feature analysis layer is a Logistic Regression meta-model (a generalized linear regression analysis model). The Stacking ensemble learning algorithm combines the prediction results of multiple base models to improve the performance and robustness of the overall model, thereby enhancing the generalization ability of the classification system.
[0045] In some preferred embodiments of the present invention, a Soft Voting (a voting mechanism used in ensemble learning) ensemble model is used as the beef origin traceability model. The Soft Voting ensemble model has some similarities with the Stacking ensemble model in terms of construction method, but there are significant differences in its core mechanism. See Figure 3 Schematic diagram of the overall structure of another beef origin traceability model provided by an embodiment of the present invention. Different from the Stacking ensemble model, the Soft Voting ensemble model does not make decisions through the meta-model in the second layer. Instead, by synthesizing the prediction probabilities of multiple base models, it uses a weighted average voting method to select the category with the highest probability as the final result. Its basic principle is to average and fuse the category prediction probabilities output by each base model, and the reliability of the result can be further improved through probability calibration. The Soft Voting ensemble model has significant advantages: First, it can effectively improve the prediction accuracy; Second, by fusing the prediction results of multiple models, it enhances the stability of the model; In addition, it can integrate different types of base models to flexibly handle complex tasks; At the same time, it has strong processing ability for unbalanced data and strong interpretability, which is convenient for understanding the decision-making process of the model.
[0046] The present invention provides a method for tracing the origin of beef based on Raman spectroscopy, which is applied to a beef origin tracing system. The method includes: obtaining a beef sample and performing preprocessing to obtain a beef sample slice; wherein, the preprocessing sequentially includes: drying treatment, grinding and screening treatment, and pressing treatment; performing Raman spectroscopy detection on the beef sample slice to obtain a Raman characteristic spectrum; inputting the Raman characteristic spectrum into a pre-trained beef origin tracing model, and outputting the traced origin of the beef sample; wherein, the beef origin tracing model includes: a stacked ensemble training layer and a meta-feature analysis layer connected in sequence; the stacked ensemble training layer includes: a plurality of base learners arranged in parallel; the beef origin tracing model is provided with a stacked ensemble training layer and a meta-feature analysis layer connected in sequence, and the overall performance, robustness and generalization ability of the model are greatly improved compared with the existing model, and the tracing accuracy of beef products is improved.
[0047] Embodiment 2 On the basis of the above embodiment, the embodiment of the present invention provides a training method for a beef origin tracing model, and trains the beef origin tracing model through the following steps A1 to A6: Step A1, using the Raman characteristic spectrum of the training beef sample as a training sample.
[0048] Step A2, dividing the training sample into a training set and a test set according to a preset ratio.
[0049] Step A3, training the stacked ensemble training layer based on the training set until the stacked ensemble training layer reaches a preset training target.
[0050] Step A4, inputting the training set into the stacked ensemble training layer that has reached the training target, and outputting meta-features.
[0051] Step A5, training the meta-feature analysis layer based on the meta-features and the true labels of the beef samples in the training set until the training is completed.
[0052] Step A6, determining the trained stacked ensemble training layer and meta-feature analysis layer as the beef origin tracing model.
[0053] Exemplarily, 30 beef samples from region A are collected, and 90 beef samples are collected from the other 3 origins (region B, region C, region D), with 30 beef samples collected from each origin. The geographical and environmental information of the sampling locations is shown in Table 1.
[0054] Table 1
[0055] The sample processing and Raman characteristic spectrum have been described in detail in Embodiment 1, and will not be elaborated here again.
[0056] During the training process, first, in the way of cross-validation (cv = 5), the training data (i.e., 70% of the training set data divided from the original data) is divided into multiple subsets.
[0057] For each subset, it will be successively selected as the test set, and the remaining subsets will be used as the training set. The specific operations are as follows: ① Use the current training set data to train all the base models (in this process, the hyperparameters of each base model are adjusted by grid search); ② Use the trained base models to predict the test set, and each base model will give a prediction result (for classification problems, it is the probability of each class); ③ The prediction results of these base models on the test set constitute the meta-features of the test set samples. For example, assume there are 7 base models (Model A, Model B, Model C, etc.) and a test set containing 16 samples. After each base model has determined the optimal hyperparameters of the model through the current training set data, use the obtained optimal base models to predict these 16 samples, and each sample will get 7 prediction probability values (corresponding to 7 base models), and these 7 values form the meta-features of the sample. Repeat the above steps until each subset has been used as the test set once. Finally, combine the meta-features of all subsets to obtain the meta-features of the entire training set.
[0058] Using the generated meta-features as the input and the true labels of the training set data as the output, the logistic regression algorithm will learn the relationship between the meta-features and the true labels, so as to obtain a final model that can comprehensively integrate the prediction results of the base models.
[0059] Due to the small amount of data, to make full use of the data and avoid overfitting, first send the training data into the base models of the first layer for learning. Through grid search, adjust the model hyperparameters to make each base model achieve the best generalization performance on the test set. Secondly, send the training data into the base models to obtain the meta-features of the second layer, and send the meta-features into the meta-models of the second layer for learning. Finally, use the obtained optimal integrated model to conduct discriminant analysis on the origin of beef on the test set.
[0060] Furthermore, in some preferred embodiments of the present invention, the method further includes: evaluating the indicators of the beef origin traceability model based on the test set; wherein, the indicators at least include one of the following: accuracy, precision, and recall.
[0061] Specifically, evaluate the created model on the training set and the test set, and calculate various evaluation indicators.
[0062] Exemplarily, the performance of the model is evaluated by sample precision (Precision, P), recall (Recall, R), F1 score, AUC (Area Under Curve, the area enclosed by the ROC curve and the coordinate axes) value, and Kappa (an index to measure classification accuracy) coefficient.
[0063] The sample precision (Precision, P) is the ratio of the number of predicted samples correctly discriminated to the number of all samples predicted to be from this origin. The sample recall (Recall, R) is the ratio of the number of predicted samples correctly discriminated to the number of all samples from this origin. The F1 score is the harmonic mean of P and R, and F1 = 2PR / (P + R). The larger the sample accuracy, sample precision (P), sample recall (R), and F1 score, the better the model discrimination effect.
[0064] The Receiver Operating Characteristic curve (ROC curve) uses the false positive rate (False Positive Rate, FPR) and true positive rate (True Positive Rate, TPR) as the horizontal and vertical axes to show the classification performance of the model at all possible thresholds. The farther the curve is from the baseline, the better the model performance. The AUC value is the area under the ROC curve, and its value range is 0 to 1. The closer it is to 1, the better the model performance.
[0065] To further evaluate the results of the selected model, the classification performance of the model is evaluated based on the Kappa coefficient of the confusion matrix. When the Kappa coefficient is between 0.8 and 1, it indicates that the prediction performance of the model is almost completely consistent with the true value, indicating that the model prediction performance has extremely high reliability and robustness.
[0066] First, analyze the original Raman spectroscopy spectrum and perform PCA discriminant analysis. The basic chemical components of beef are similar, but different origins will cause differences in the content of their chemical components. This difference is reflected as different Raman scattering intensities on the spectrometer. See Figure 4 the schematic diagram of the average original Raman spectrum of beef samples from four origins provided in the embodiment of the present invention shown in the original Raman spectra in the Figure 4 band. It can be seen from that the average spectra of beef from the four origins all have significant absorption peaks in the range. The peak intensities of beef from different origins are different, but the peak positions are basically the same. In the Interval. This may indicate the presence of multiple vibrations of similar chemical bonds or complex intermolecular interactions in beef from this origin, such as a relatively high degree of cross-linking between proteins and other substances. Due to the complex chemical composition of beef, it is difficult to detect the differences in Raman spectra from different origins with the naked eye. Therefore, chemometric methods are needed to achieve origin traceability.
[0067] Based on the original Raman spectral data of beef from 4 origins, a principal component analysis (PCA) model was constructed. The scores of the first and second principal components were selected, and a score plot of all samples was drawn, as shown in Figure 5 the schematic diagram of the scores of beef from four origins based on the PCA model provided in the embodiment of the present invention shown. As can be seen from Figure 5 it, principal component 1 and principal component 2 explained 99.9% and 0.1% of the data variance respectively, and the cumulative explained variance reached 100.0%, which could effectively interpret the information in the samples. In terms of the sample distribution characteristics, the clustering degree of beef samples in region A was relatively high, while the clustering degrees of samples in regions B, C, and D were relatively low. It is worth noting that the projection points of the principal component scores of beef samples from the four origins overlapped with each other, and based on the PCA model of the original beef spectra, the differences between the 4 origins could not be identified. To achieve more effective discrimination of different origins, we constructed a Stacking and Soft Voting ensemble model based on the original Raman spectra of beef samples.
[0068] Secondly, discriminant analysis of the origin of the base models (base learners). Seven methods, namely SVM, Logistic Regression, RidgeClassifier, Random Forest, XGBoost, LDA, and SGDClassifier, were used to establish beef origin discriminant models. As shown in Table 2, the performance index table of the beef origin discriminant models based on the base models, it can be seen from the table that support vector machine and Logistic Regression performed optimally in terms of overall performance, especially in key indicators such as precision, recall, F1 score, and AUC value, which were significantly better than other models. SVM performed particularly well in regions A, B, and C, while the AUC value of Logistic Regression reached 0.9959 in regions B and C, showing excellent performance. In contrast, Random Forest and XGBoost performed poorly in all origins and indicators. Especially in the D region origin, the precision and recall of XGBoost were as low as 0.2500 and 0.1111 respectively, indicating that these models may not be suitable for the current task or need further optimization. LDA performed relatively stably, but its performance decreased in the D region origin. Generally speaking, SVM and Logistic Regression are the most reliable models in the beef origin discrimination task.
[0069] Table 2
[0070] For the Stacking ensemble model, a Stacking ensemble model was established based on the optimal parameters of 7 models: SVM, Logistic Regression, Ridge Classifier, Random Forest, XGBoost, LDA, and SGDClassifier.
[0071] Table 3
[0072] Refer to the schematic diagram of the performance indicators of a beef discrimination model based on the Stacking ensemble model provided in the embodiment of the present invention shown in Table 3. This model performs excellently in the classification tasks of beef in Region A and Region B, and its precision, recall rate, F1 score, and AIC value all reach 1.0000. For the beef in Region C and Region D, the precision rates of the model are 1.0000 and 0.9000 respectively, and the recall rates are 0.8889 and 1.0000 respectively. Further analysis shows that the reason why the recall rate and precision rate of the beef in Region C and Region D cannot reach 1.0000 simultaneously is that some beef in Region D is misjudged as beef in Region C. The overall performance of the Stacking ensemble model is still excellent, with an overall precision rate of 0.9750, a recall rate of 0.9722, an F1 score of 0.9721, and an AUC value as high as 1.0000.
[0073] For the Soft Voting ensemble model, a Soft Voting ensemble model was established based on the optimal parameters of 7 models: SVM, Logistic Regression, Ridge Classifier, Random Forest, XGBoost, LDA, and SGDClassifier. Continuing to refer to Table 3, the precision rate, recall rate, F1 score, and AUC value of the beef in Region A and Region B are relatively high. Among them, the recall rate of the beef in Region A reaches 1.0000, and the precision rate of the beef in Region B is 1.0000; the indicators of the beef in Region D are all 0.7778, showing relatively poor performance; the precision rate of the beef in Region C is 0.8750, the recall rate is 0.7778, the F1 score is 0.8235, and the AUC value is 0.9630. The overall precision rate of this model is 0.8677, the recall rate is 0.8611, the F1 score is 0.8606, and the AUC value is 0.9655, which can distinguish beef from different origins.
[0074] Furthermore, the discrimination models were compared for different production areas. Based on 9 models including SVM, Logistic Regression, Ridge Classifier, Random Forest, XGBoost, LDA, SGDClassifier, Stacking, and SoftVoting, discrimination models for beef from 4 production areas were constructed. Through analysis, it was found that by comparing the precision, recall, F1-score, and AUC value, all evaluation indicators of the Stacking ensemble model performed the best and could more accurately discriminate beef from different production areas.
[0075] To further evaluate the classification consistency and reliability of the model, the Kappa coefficient was introduced. The higher the Kappa coefficient, the better the consistency between the classification result of the model and the true label, and the better the performance of the model. See Figure 6 The schematic diagram of the Kappa coefficient of a discrimination model based on different production areas provided by the embodiment of the present invention shown in
[0076] Based on the above verification, in the beef production area traceability model provided by the embodiment of the present invention, the Stacking ensemble learning method can effectively identify the beef production area.
[0077] The beef origin traceability model established by the Stacking ensemble learning method disclosed in the embodiments of the present invention uses SVM, Logistic Regression, Ridge Classifier, Random Forest, XGBoost, LDA, and SGDClassifier as base learners, and Logistic Regression as a meta-learner to construct a Stacking model. At the same time, it is compared with the results of the PCA and SoftVoting ensemble models. The results show that the use of principal component analysis combined with Raman spectroscopy technology cannot accurately identify beef from different origins; the Soft Voting model uses the method of ensemble learning, but its model performance is slightly worse than that of single models (SVM and Logistic Regression); while the performance of the Stacking ensemble model is higher than that of any single model, PCA, and Soft Voting ensemble models. The Precision of the test set of this model is 0.9750, Recall is 0.9722, F1 value is 0.9721, AUC value is 1.0000, and Kappa coefficient is 0.9630, which can accurately identify the origin of beef.
[0078] In summary, the Stacking model constructed by the embodiments of the present invention using a portable Raman spectroscopy instrument to measure the original Raman spectrum of the sample brings higher feasibility to the future on-site inspection of the beef origin link.
[0079] Embodiment 3 Based on the above embodiments, the embodiments of the present invention provide a beef origin traceability device based on Raman spectroscopy, which is applied to a beef origin traceability system. Refer to Figure 7 the structural schematic diagram of a beef origin traceability device based on Raman spectroscopy provided by the embodiments of the present invention shown in A sample processing module 310, configured to obtain a beef sample and perform preprocessing to obtain a beef sample slice; wherein, the preprocessing sequentially includes: drying treatment, grinding and screening treatment, and pressing treatment.
[0080] A Raman spectrum processing module 320, configured to perform Raman spectroscopy detection on the beef sample slice to obtain a Raman characteristic spectrum.
[0081] An origin traceability module 330, configured to input the Raman characteristic spectrum into a pre-trained beef origin traceability model, and output the traceable origin of the beef sample; wherein, the beef origin traceability model includes: a stacked ensemble training layer and a meta-feature analysis layer connected in sequence; the stacked ensemble training layer includes: a plurality of base learners arranged in parallel.
[0082] Further, in some preferred embodiments of the present invention, the device further includes: a model training module, configured to train a beef origin traceability model through the following steps: taking the Raman characteristic spectrum of the training beef samples as training samples; dividing the training samples into a training set and a test set according to a preset ratio; training a stacked ensemble training layer based on the training set until the stacked ensemble training layer reaches a preset training goal; inputting the training set into the stacked ensemble training layer that has reached the training goal to output meta-features; training a meta-feature analysis layer based on the meta-features and the true labels of the beef samples in the training set until the training is completed; and determining the completed stacked ensemble training layer and the meta-feature analysis layer as the beef origin traceability model.
[0083] Further, in some preferred embodiments of the present invention, the device further includes: a model evaluation module, configured to perform index evaluation on the beef origin traceability model based on the test set; wherein the index at least includes one of the following: accuracy, precision, and recall.
[0084] Further, in some preferred embodiments of the present invention, the base learners include: support vector machine, logistic regression, ridge regression classifier, random forest, gradient boosting decision tree, linear discriminant analysis, and stochastic gradient descent classifier.
[0085] Further, in some preferred embodiments of the present invention, the sample processing module 310 is configured to process the beef samples in a dryer until the difference in weight between two consecutive weighings is less than a preset weight difference; grind and screen the dried beef samples to obtain beef powder with a particle size less than a preset diameter; and press a preset weight of the beef powder to obtain beef sample slices.
[0086] Further, in some preferred embodiments of the present invention, the Raman spectrum processing module 320 is configured to collect a Raman spectrum for each different position of the beef sample slice; and perform an average calculation on the multiple Raman spectra to obtain a Raman characteristic spectrum.
[0087] Those skilled in the art can clearly understand that for the convenience and brevity of description, the specific working process of the above-described beef origin traceability device based on Raman spectroscopy can refer to the corresponding process in the embodiment of the beef origin traceability method based on Raman spectroscopy described above, and will not be elaborated here.
[0088] Embodiment 4 The embodiment of the present invention further provides an electronic device for running the beef origin traceability method based on Raman spectroscopy; see Figure 8Schematic structural diagram of an electronic device provided by an embodiment of the present invention. The electronic device includes a memory 400 and a processor 401. Among them, the memory 400 is used to store one or more computer instructions, and the one or more computer instructions are executed by the processor 401 to implement the above-mentioned beef origin traceability method based on Raman spectroscopy.
[0089] Furthermore, Figure 8 The shown electronic device further includes a bus 402 and a communication interface 403. The processor 401, the communication interface 403, and the memory 400 are connected through the bus 402.
[0090] Among them, the memory 400 may include a high-speed random access memory (RAM, Random Access Memory), and may also include a non-volatile memory, such as at least one disk memory. Through at least one communication interface 403 (which can be wired or wireless), a communication connection between the system network element and at least one other network element is realized, and the Internet, wide area network, local area network, metropolitan area network, etc. can be used. The bus 402 can be an ISA bus, a PCI bus, an EISA bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For the sake of representation, Figure 8 only a bidirectional arrow is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0091] The processor 401 may be an integrated circuit chip with the ability to process signals. In the implementation process, each step of the above method can be completed by the integrated logic circuit of the hardware in the processor 401 or the instructions in the form of software. The above-mentioned processor 401 may be a general-purpose processor, including a central processing unit (CPU for short), a network processor (NP for short), etc.; it may also be a digital signal processor (DSP for short), an application specific integrated circuit (ASIC for short), a field-programmable gate array (FPGA for short) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. It can implement or execute the various methods, steps and logic block diagrams disclosed in the embodiments of the present invention. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc. The steps of the method disclosed in combination with the embodiments of the present invention can be directly embodied as being executed and completed by the hardware decoding processor, or executed and completed by the combination of the hardware and software modules in the decoding processor. The software module may be located in a mature storage medium in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, etc. This storage medium is located in the memory 400, and the processor 401 reads the information in the memory 400 and combines its hardware to complete the steps of the method in the foregoing embodiments.
[0092] The embodiment of the present invention also provides a computer-readable storage medium, which stores computer-executable instructions. When the computer-executable instructions are called and executed by the processor, the computer-executable instructions cause the processor to implement the above-mentioned beef origin traceability method based on Raman spectroscopy. For the specific implementation, reference can be made to the method embodiment, and details are not described herein again.
[0093] The computer program product of the beef origin traceability method, device and electronic device based on Raman spectroscopy provided by the embodiment of the present invention includes a computer-readable storage medium storing program codes. The instructions included in the program codes can be used to execute the methods in the foregoing method embodiments. For the specific implementation, reference can be made to the method embodiments, and details are not described herein again.
[0094] Those skilled in the art can clearly understand that for the convenience and brevity of description, the specific working processes of the above-described system and / or device can refer to the corresponding processes in the foregoing method embodiments, and details are not described herein again.
[0095] In addition, in the description of the embodiments of the present invention, unless otherwise clearly defined and limited, the terms "installation", "connection", and "coupling" should be understood in a broad sense. For example, it may be a fixed connection, a detachable connection, or an integral connection; it may be a mechanical connection or an electrical connection; it may be directly connected or indirectly connected through an intermediate medium, and it may be the communication inside two components. For those of ordinary skill in the art, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0096] If the above-mentioned functions are implemented in the form of software function units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the embodiments of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as USB flash drives, mobile hard disks, read-only memories (ROMs), random access memories (RAMs), magnetic disks, or optical discs.
[0097] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit them. Although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements for some or all of the technical features. These modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for tracing the origin of beef based on Raman spectroscopy, characterized in that: Applied to the beef origin traceability system, the method comprises: Obtaining a beef sample and pre-processing it to obtain a beef sample slice; wherein the pre-processing includes, in sequence: drying, grinding and screening, and pressing; Performing Raman spectroscopy on the beef sample to obtain a Raman characteristic spectrum; The Raman signature spectrum is input into a pre-trained beef origin traceability model, and the traceability origin of the beef sample is output; wherein the beef origin traceability model comprises: a stacked integrated training layer and a meta-feature analysis layer connected in sequence; the stacked integrated training layer comprises: a plurality of base learners arranged in parallel.
2. The method for tracing the origin of beef based on Raman spectroscopy according to claim 1, characterized in that: The method further comprises: training the beef origin tracing model by the following steps: Using the Raman characteristic spectrum of the training beef sample as a training sample; Dividing the training samples into a training set and a test set according to a preset ratio; Training the stacked integrated training layer based on the training set until the stacked integrated training layer reaches a preset training target; Inputting the training set into the stacked integrated training layer that achieves the training target, and outputting meta-features; Training the meta-feature analysis layer based on the meta-feature and the true labels of the beef samples in the training set until the training is completed; The stacked integrated training layer and the meta-feature analysis layer that have completed training are determined as the beef origin traceability model.
3. The beef origin tracing method based on Raman spectroscopy according to claim 2 is characterized in that: The method further comprises: An indicator evaluation is performed on the beef origin traceability model based on a test set; wherein the indicator includes at least one of the following: accuracy, precision and recall.
4. The method for tracing the origin of beef based on Raman spectroscopy according to claim 1, characterized in that: The base learners include: support vector machine, logistic regression, ridge regression classifier, random forest, gradient boosting decision tree, linear discriminant analysis, and stochastic gradient descent classifier.
5. The method for tracing the origin of beef based on Raman spectroscopy according to claim 1, characterized in that: The step of obtaining a beef sample and pre-processing it to obtain a beef sample comprises: Processing the beef sample in a dryer until the difference between two consecutive weighings is less than a preset weight difference; Grinding and screening the dried beef sample to obtain beef powder with a particle size smaller than a preset diameter; The beef powder of a preset weight is pressed to obtain the beef sample slices.
6. The method for tracing the origin of beef based on Raman spectroscopy according to claim 1, characterized in that: The step of performing Raman spectroscopy detection on the beef sample to obtain a Raman characteristic spectrum comprises: Collecting a Raman spectrum from different positions of the beef sample; The Raman characteristic spectrum is obtained by averaging a plurality of the Raman spectra.
7. A beef origin tracing device based on Raman spectroscopy, characterized in that: Applied to the beef origin tracing system, the device comprises: The sample processing module is used to obtain beef samples and perform pretreatment to obtain beef slices; wherein the pretreatment includes: drying treatment, grinding and screening treatment and pressing treatment in sequence; A Raman spectrum processing module is used to perform Raman spectrum detection on the beef sample to obtain a Raman characteristic spectrum; The origin tracing module is used to input the Raman characteristic spectrum into a pre-trained beef origin tracing model, and output the traceability origin of the beef sample; wherein the beef origin tracing model comprises: a stacked integrated training layer and a meta-feature analysis layer connected in sequence; the stacked integrated training layer comprises: a plurality of base learners arranged in parallel.
8. The beef origin tracing device based on Raman spectroscopy according to claim 7, characterized in that: The device also includes: A model training module is used to train the beef origin traceability model through the following steps: using the Raman characteristic spectrum of the training beef sample as a training sample; dividing the training sample into a training set and a test set according to a preset ratio; training the stacked integrated training layer based on the training set until the stacked integrated training layer reaches a preset training target; inputting the training set into the stacked integrated training layer that reaches the training target, and outputting meta-features; training the meta-feature analysis layer based on the meta-features and the real labels of the beef samples in the training set until the training is completed; determining the stacked integrated training layer and the meta-feature analysis layer that have completed training as the beef origin traceability model.
9. An electronic device, characterized in that: It comprises a processor and a memory, wherein the memory stores computer executable instructions that can be executed by the processor, and the processor executes the computer executable instructions to implement the beef origin tracing method based on Raman spectroscopy as described in any one of claims 1 to 6.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions. When the computer-executable instructions are called and executed by the processor, the computer-executable instructions prompt the processor to implement the beef origin traceability method based on Raman spectroscopy as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Method and system for defect classification
CN107820620A
Method for classifying Raman spectrums by using stacking ensemble learning model
CN115862007A
Method for identifying production places of almonds based on Raman spectrum and multi-mode hybrid model
CN117949429A
Terahertz time-domain spectroscopy detection method for identifying millets from multiple producing areas
CN118837324A
Processing method and apparatus for stacked integrated model for molecular attribute prediction
WO2024212496A1