A method for detecting freshness of fresh food

Through the fresh food freshness detection method based on single sensor, using random forests and one-dimensional convolutional neural network, the high cost and destructive problems of traditional detection methods are solved, and the high accuracy freshness detection is achieved, suitable for biotechnology Cold chain and daily storage scenarios of fresh food.

CN117589951BActive Publication Date: 2024-12-20SHANDONG INST OF BUSINESS & TECH +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311685196.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-12-08
Publication Date
2024-12-20
Estimated Expiration
2043-12-08

AI Technical Summary

Technical Problem

Traditional fresh food freshness detection methods require complex equipment, high time and labor costs, high destructiveness to food, and single gas sensors are difficult to comprehensively detect the freshness of fresh food.

Method used

Using a fresh food freshness detection method based on a single sensor, the food odor response signal is obtained by selecting a gas sensor, data preprocessing and feature extraction are carried out, and a freshness evaluation model is established in combination with random forests and one-dimensional convolutional neural network to realize fresh food. Food freshness testing.

Benefits of technology

The accuracy of fresh food freshness detection is achieved to reach more than 92%, and it provides cost-effective testing equipment, suitable for cold chain and daily storage scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117589951B_ABST
    Figure CN117589951B_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of detection of hygienic quality and freshness of fresh food, and specifically relates to a method for detecting freshness of fresh food, comprising: selecting a suitable sensor according to the characteristics of volatile odor components of fresh food, performing odor test on fresh food, and establishing a fresh food freshness odor response data set; using physical and chemical detection, sensory evaluation and other methods as parallel evaluation criteria for sample freshness; extracting waveform features, statistical features, fast Fourier transform and wavelet transform and other features of data set samples; designing a one-dimensional convolutional neural network evaluation model for freshness evaluation, first analyzing feature importance through a random forest algorithm, and then sequentially sending features into the model according to feature importance from large to small, to find an optimal classification model and an optimal feature combination; results show that the feature set obtained by sorting feature importance by using the random forest feature is combined with the one-dimensional convolutional neural network algorithm to detect the freshness of fresh food.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the technical field of detection of hygienic quality and freshness of fresh food, and particularly relates to a method for detecting the freshness of fresh food. Background Art

[0002] With the continuous development of my country's economy and the improvement of people's living standards, consumers have higher and higher requirements for food quality and safety, especially for the hygiene quality and freshness of fresh food. Fresh food logistics mainly includes picking, sorting, packaging, storage, transportation and sales. Storage and transportation are the most critical links in fresh food logistics, and their quality directly affects the freshness and quality of fresh food. During storage and transportation, appropriate temperature, humidity and ventilation conditions must be maintained to extend the shelf life of fresh food. With the development of Internet of Things technology, agricultural product logistics parameters such as temperature, humidity, oxygen, carbon dioxide, and ethylene are gradually included in the monitoring scope, and the monitoring parameters are gradually diversified, showing a trend from simple temperature to multi-parameter monitoring and freshness intelligent monitoring. In particular, the influence of gas composition parameters in the microenvironment of fresh food logistics on the quality of fresh food is prominent, and it has become an important research trend and focus of attention.

[0003] Traditional physical and chemical testing methods for fresh food require complex experimental equipment, high time and labor costs, and are highly destructive to food, which is not conducive to real-time detection of the freshness of fresh food. Gas sensors have the characteristics of low cost, fast response speed, wide measurement concentration range, easy mass production, simple operation, and the ability to enter places that humans cannot enter. They occupy a dominant position in the current research and application of gas / odor detection. In particular, gas sensing technology has developed rapidly, and metal oxide semiconductor (MOS) gas sensors with high sensitivity, low power consumption, and small size have attracted widespread attention. Gas sensor technology has been proposed since the 1980s. With the rapid development of signal processing technology, it has gradually become the core technology of gas detection and analysis instruments. It has been widely used in industrial fields such as air pollution, industrial waste gas and building environment, and in the agricultural (food) field (in the form of electronic noses for variety classification, freshness assessment, and detection).

[0004] In past studies, it was difficult to comprehensively and correctly detect the freshness of fresh food with a single gas sensor due to the wide variety of gases volatilized during the corruption of fresh food. Gas sensor array technology can comprehensively evaluate the potential of overall gas information and become a powerful means of detecting the freshness of fresh food. However, the composition of gas sensor arrays is complex and the patterns are diverse. At present, the demand for freshness detection of fresh food is constantly upgrading, and in practical applications, it is necessary to consider the economic cost and the overall detection effect of sensor technology. With the continuous development of deep learning, its advantages have promoted the exploration space of freshness detection of fresh food based on single sensor feature extraction and classification evaluation methods. Therefore, the present invention combines deep learning to design a freshness detection method for fresh food based on a single sensor. Summary of the invention

[0005] In order to overcome the problems in the prior art, the present invention proposes a method for detecting the freshness of fresh food.

[0006] The technical solution of the present invention to solve the above technical problems is as follows:

[0007] The present invention provides a method for detecting the freshness of fresh food, comprising the following steps:

[0008] Step 100: Select a gas sensor, use the selected gas sensor to obtain a response signal of food odor, and establish a freshness odor response data set of the corresponding food;

[0009] Step 200: Preprocess the gas sensor response signal in the freshness odor response data set, extract waveform features, statistical features and transform domain features from the preprocessed sensor response signal, and perform normalization processing on it;

[0010] Step 300. Calculate the importance of waveform features, statistical features and transform domain features extracted from sensor response signals based on the Gini importance of random forest, send the features to the deep learning or pattern recognition model in descending order of importance, evaluate the freshness of fresh food with reference to the food freshness evaluation standard, and establish a food freshness evaluation model;

[0011] Step 400: embed the above freshness evaluation model in the freshness test system of the tested environment to evaluate the freshness of fresh food.

[0012] Furthermore, in step 200, data preprocessing is performed on the gas sensor response signal in the freshness odor response data set, and the preprocessing includes filtering processing and baseline removal processing:

[0013] The filtering process uses the SG filter parameters set to order 1 and window width 31;

[0014] The baseline removal process adopts the fractional difference method, and the specific formula is:

[0015]

[0016] Where V t represents the sensor response value before baseline processing at time t; x t Represents the sensor value at time t after baseline removal; V air Represents the response value of the sensor in air.

[0017] Furthermore, the step 200 of extracting waveform features from the preprocessed sensor response signal includes:

[0018] The waveform characteristics include the steady-state value V SS , maximum positive slope K max+ and the maximum negative slope K max- , the corresponding calculation method is as follows:

[0019]

[0020] K max+ =Max(x n+1 -x n )(0≤n <N,n∈Z);

[0021] K max- =|Min(x n+1 -x n )|(0≤n <N,n∈Z);

[0022] In the formula, x n is the value of the sensor response curve after preprocessing at the nth second,

[0023] x n+1 is the value of the sensor response curve after preprocessing at the n+1th second, |·| represents the absolute value, N represents the number of sample points contained in a sensor in a single sample, Z represents an integer, i represents the starting sample number of the steady state, and j represents the ending sample number of the steady state.

[0024] Furthermore, three types of variance VAR, skewness SK and kurtosis KU are extracted from the statistical features, and the corresponding calculation methods are as follows:

[0025]

[0026]

[0027]

[0028] Where N represents the number of sample points contained in a sensor in a single sample, xn Represents the value of the nth sample point in the sensor signal, Indicates the average value of all sample points of the sensor.

[0029] Furthermore, the transform domain features include the amplitude-frequency characteristics of the fast Fourier transform and the db5 wavelet discrete wavelet transform component features, and the amplitude-frequency characteristics of the fast Fourier transform and the db5 wavelet discrete wavelet transform component features are respectively subjected to PCA dimensionality reduction, and the first five principal components are retained.

[0030] Furthermore, the step 300 includes: constructing a one-dimensional convolutional neural network evaluation model; analyzing feature importance, and then sending the features into the one-dimensional convolutional neural network evaluation model in order from large to small according to feature importance, to obtain a freshness evaluation result, if the evaluation result accuracy threshold is reached; combining the input features, and establishing a food freshness evaluation model based on the constructed one-dimensional convolutional neural network evaluation model.

[0031] Furthermore, the one-dimensional convolutional neural network evaluation model is a one-dimensional convolutional neural network, which includes a convolution layer, a maximum pooling layer, a flattening layer and two fully connected layers.

[0032] Compared with the prior art, the present invention has the following technical effects:

[0033] The present invention selects a suitable sensor according to the characteristics of the volatile components of the odor of fresh food, performs an odor test on the fresh food, and establishes a fresh food freshness odor response data set; extracts waveform features, statistical features and other features of the data set samples; designs a one-dimensional convolutional neural network evaluation model for freshness evaluation, first analyzes the feature importance through a random forest algorithm, and then sequentially sends the features into the model according to the feature importance from large to small, to establish a food freshness evaluation model; the results show that the accuracy of freshness detection of fresh food using a feature set obtained by sorting the feature importance of random forest features combined with a one-dimensional convolutional neural network algorithm can reach more than 92%; the present invention provides a specific reference for the construction of freshness detection equipment for fresh food in cold chain or daily storage scenarios. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] In order to more clearly illustrate the technical solutions and advantages in the embodiments of the present invention or the prior art, the drawings required for use in the embodiments or the prior art descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0035] Figure 1 It is a specific implementation flow chart of the present invention;

[0036] Figure 2 This is a circuit diagram of the gas path automatic selection module of the present invention;

[0037] Figure 3(a) shows Figure 1 Figure 3(b) is a flowchart of the odor collection of selected oyster samples; Figure 1 Flow chart of odor collection of selected yellow peach and blueberry samples;

[0038] Figure 4 is the sensor response signal diagram;

[0039] Figure 5 Schematic diagram of the 1D-CNN model in the present invention;

[0040] Figure 6 The accuracy of oyster freshness evaluation changes with the number of features;

[0041] Figure 7(a) shows the variation trend of the accuracy of freshness evaluation of intact yellow peach samples with the number of features; Figure 7(b) shows the variation trend of the accuracy of freshness evaluation of damaged yellow peach samples with the number of features;

[0042] Figure 8(a) shows the variation trend of the freshness evaluation accuracy of intact blueberry samples with the number of features; Figure 8(b) shows the variation trend of the freshness evaluation accuracy of damaged blueberry samples with the number of features. DETAILED DESCRIPTION

[0043] In order to further explain the technical means and effects taken by the present invention to achieve the predetermined invention purpose, the specific implementation methods, structures, features and effects of the technical solutions proposed by the present invention are described in detail below in conjunction with the accompanying drawings and preferred embodiments. The specific features, structures or characteristics in one or more embodiments may be combined in any suitable form. Unless otherwise defined, all technical and scientific terms used in the present invention have the same meaning as those commonly understood by technicians in the technical field of the present invention.

[0044] In one embodiment of the present invention, a method for detecting the freshness of fresh food is provided, comprising the following steps:

[0045] Step 100: Select a gas sensor, use the selected gas sensor to obtain a response signal of food odor, and establish a freshness odor response data set of the corresponding food.

[0046] Step 110: Select a gas sensor, install it in the food freshness testing system, and preheat the gas sensor.

[0047] The food freshness test system uses STM32F103 as the controller and multi-channel 12-bit analog-to-digital converter TLC1543 for analog signal acquisition. The data is finally transmitted through the universal serial bus and stored in the computer. Figure 2 The solenoid valve control shown in the figure can select to collect a single sample or two samples in sequence, realizing the automatic selection of the gas path. At the same time, the system is equipped with an LCD display screen, which prints the collected sensor voltage, temperature and humidity of the test chamber, and the switch status of the solenoid valve and air pump on the display screen in real time, so that the test personnel can observe the status of the experiment intuitively.

[0048] According to the selectivity of the gas sensor, a sensor that is sensitive to the smell of food spoilage is selected. If there is no corresponding sensitive sensor, try to select a broad-spectrum sensor that can respond to the relevant odor components to use its sensitivity to generate unique fingerprint information for each gas or odor. Considering that the gas emitted by spoiled fruits contains volatile organic compounds such as alcohols, esters, hydrocarbons, and benzene series, and the protein in oyster meat will also produce amines and sulfides when it deteriorates, different sensors are selected for fresh food according to the different volatile odors. Information such as commonly used sensor parameters is shown in Table 1.

[0049] Among them, according to the volatile components in the process of quality change, the sensor for oyster detection was TGS2602, and the sensor for fruit detection was TGS2600 for testing.

[0050] Table 1 Sensor models and parameters

[0051]

[0052] Step 120. Select fresh food representatives.

[0053] When testing fresh food, in order to ensure the validity of the test data, the fresh food representatives selected should be as comprehensive as possible, and the freshest ones should be selected as much as possible. You can also select damaged samples and conduct separate comparative experiments.

[0054] Step 121. Select fresh food:

[0055] There are many kinds of fresh food, among which the added value of cold chain transportation of aquatic products is high. It is difficult for aquatic products such as oysters to remain active after leaving their original living environment. If they are not properly preserved after inactivation, a series of physical and chemical changes will quickly occur in the body, causing the oysters to deteriorate and become inedible. Therefore, oysters were selected as representatives of meat and aquatic products for odor testing. Fruits are the most common fresh food and are in great demand. According to the changes in respiration rate during the ripening process, fruits can be divided into respiratory burst type and non-respiratory burst type. Two representative fruits, a respiratory burst type fruit, yellow peach, and a non-respiratory burst type fruit, blueberry, were selected as fruit freshness test samples.

[0056] Step 122. Fresh representative sample processing method:

[0057] The method for processing oyster samples is as follows: fresh oysters are selected on site, shelled and cleaned, and then quickly sent back to the laboratory and placed in a test box operated at a constant temperature of 15°C.

[0058] The treatment method of yellow peach samples is as follows: 400g of blueberry samples of similar quality are selected and divided into two groups, one group is not treated, and the other group is damaged. The damaged treatment uses an injection needle with an outer diameter of 0.9mm and disinfected with alcohol to make a 5mm deep needle puncture at a random position of the fruit. Sample chamber 1 and sample chamber 2 containing the two groups of samples are placed in a test box at a constant temperature of 25℃ at the same time.

[0059] The processing method of blueberry samples is as follows: eight yellow peach samples of similar size are selected and divided into two groups, one group is not treated, and the other group is damaged. The damaged treatment uses an injection needle with an outer diameter of 0.9 mm to disinfect with alcohol and make a 5 mm deep needle prick at a random position of the fruit. Sample chamber 1 and sample chamber 2 containing the two groups of samples are placed in a test box at a constant temperature of 25°C at the same time.

[0060] Step 123. The process of fresh sample freshness smell test is as follows:

[0061] Connect the selected gas sensor to the test system and preheat the gas sensor for 3 days;

[0062] Select fresh food test samples and place them in the test bottles of the test system or in the corresponding test environment;

[0063] Connect the test chamber to the test system, turn on the airflow control switch, and at the same time open the host computer software for receiving data to start data collection;

[0064] Conduct uninterrupted cycle testing, each cycle includes 20 minutes of long cleaning and 5 collections, the sampling time and short cleaning time in each collection are 5 minutes, and the sampling frequency is 1Hz, until the sample is completely rotten and deteriorated;

[0065] After the experiment is finished, the collected data and corresponding freshness category labels are sorted out to establish a food freshness odor response dataset.

[0066] The specific implementation process of the oyster sample is shown in Figure 3(a). The specific implementation process of the yellow peach and blueberry samples is shown in Figure 3(b). The oyster freshness experiment lasted for 11 days, and a total of 995 valid experimental samples were obtained. The yellow peach freshness experiment lasted for 12 days, and a total of 1063 valid experimental samples were obtained, including 528 untreated samples and 535 damaged samples. The blueberry freshness experiment lasted for 10 days, and a total of 899 valid experimental samples were obtained, including 444 untreated samples and 455 damaged samples. The freshness odor response dataset used in the present invention was established.

[0067] Step 200: Perform data preprocessing on the gas sensor response signal in the freshness odor response data set, extract waveform features, statistical features and transform domain features from the preprocessed sensor response signal, and perform normalization processing on it.

[0068] This step specifically includes the following sub-steps:

[0069] Step 210: Perform data preprocessing on the gas sensor response signal in the freshness odor response data set, wherein the preprocessing includes filtering and baseline removal.

[0070] The SG filter is used for filtering, and the parameters are set to order 1 and window width 31.

[0071] The baseline removal process uses the fractional difference method, and the specific formula is:

[0072]

[0073] Where V t represents the sensor response value before baseline processing at time t; x t Represents the sensor value at time t after baseline removal; V air Represents the sensor response in air, averaged over the last 10 seconds of the purge phase of the test for this sample.

[0074] The sensor response curve after preprocessing is as follows Figure 4 As shown in Figure 1, a single sample sensor can obtain 600 sample points, so each sample is a matrix of [600,1] consisting of 1 sensor multiplied by 600 sample points.

[0075] Step 220: Extract the following waveform features, statistical features and transform domain features from the preprocessed sensor response signal, and perform normalization processing on them.

[0076] The waveform characteristics include the steady-state value V SS , maximum positive slope K max+ and the maximum negative slope K max- There are three types, and the corresponding calculation methods are as follows:

[0077]

[0078] K max+ =Max(x n+1 -x n )(0≤n <N,n∈Z);

[0079] K max- =|Min(x n+1 -x n )|(0≤n <N,n∈Z);

[0080] In the formula, x n is the value of the sensor response curve after preprocessing at the nth second,

[0081] x n+1 is the value of the sensor response curve after preprocessing at the n+1th second, |·| represents the absolute value, N represents the number of sample points contained in a sensor in a single sample, Z represents an integer, i represents the sample number at the start of steady state, and j represents the sample number at the end of steady state. n is the sample number (the sampling frequency in this example is 1 time / second, so n is also the sampling time). In this example, the sample number of each test sampling starts from 0 and ends at 599, so N=600, and n is an integer of 0≤n<600. In this example, the signal waveform starts to stabilize from number 220 and ends at number 280, so i=220, j=280. In practical applications, the value range of n, the values ​​of i and j are determined by the actual test waveform.

[0082] The statistical characteristics include variance VAR, skewness SK and kurtosis KU. The corresponding calculation methods are as follows:

[0083]

[0084]

[0085]

[0086] Where N represents the number of sample points contained in a sensor in a single sample, x n Represents the value of the nth sample point in the sensor signal, Indicates the average value of all sample points of the sensor.

[0087] The transform domain features include the amplitude-frequency characteristics of the Fast Fourier Transform (FFT) and the db5 wavelet discrete wavelet transform (DWT) features. The FFT features and the obtained DWT component features are subjected to PCA dimensionality reduction, and the first five principal components are retained.

[0088] When extracting multiple features, since different features have different dimensions, the features must be normalized after extraction to reduce the differences caused by different feature dimensions and improve fairness between features. The normalization method uses the following formula:

[0089]

[0090] In the formula, x i Represents the current eigenvalue to be calculated, y i represents the normalized value, x max represents the maximum value of the feature, x min Represents the minimum value of this feature.

[0091] Step 300. Calculate the importance of waveform features, statistical features and transform domain features extracted from sensor response signals based on the Gini importance of random forest, send the features to various deep learning or pattern recognition models in order of importance from large to small, evaluate the freshness of fresh food with reference to the food freshness evaluation standard, find the combination of the best features and the optimal model, and establish a food freshness evaluation model.

[0092] Step 310. Calculate the importance of each feature based on the Gini importance of random forest. The calculation process of feature importance is as follows:

[0093] Suppose there are M categories, F features, p m Represents the weight of the mth category. The Gini index GI calculation formula is:

[0094]

[0095] Feature X f The Gini importance at node k is the difference between the Gini index of the node and its branch nodes VIM fk express:

[0096] VIM fk =GI k -GI l -GI r ;

[0097] In the formula, GI k Represents the Gini index on node k, GI l and GI r Represent the Gini index of the two branch nodes of node k respectively.

[0098] Feature X f All nodes in the nth decision tree of the random forest are included in the set K, then the feature X f Gini importance VIM on the nth decision tree nffor:

[0099]

[0100] If the random forest has N decision trees, feature X f Total Gini Importance VIM in Random Forest f It is expressed as:

[0101]

[0102] Finally, the normalization process is performed to obtain the feature X f The importance of random forest based on the Gini index is:

[0103]

[0104] The greater the importance of a feature, the more information it contains and the more important the feature is. The feature importance metrics discussed here include but are not limited to Gini feature importance. Other metrics such as feature importance based on learning models, Pearson correlation coefficient, maximum information number, mutual information, etc. can also be used to measure feature importance.

[0105] Step 320. Send the above features to the deep learning or pattern recognition model in order of importance from large to small, find the combination of the best features and the optimal model, and establish a food freshness evaluation model.

[0106] The specific operation method is as follows:

[0107] 1. All the sensor features extracted above constitute the feature set A*, and an empty set A' is initialized.

[0108] 2. Based on the above method, the Gini importance of each feature in the feature set A* is calculated, and the obtained feature importance ranking is performed;

[0109] 3. Add the feature with the highest feature importance in the feature set A* to A' and delete it from A*;

[0110] 4. Obtain the freshness evaluation results of the features in A' based on deep learning or pattern recognition models;

[0111] 5. Continue to repeat steps 2, 3, and 4, continuously select the most important features from A* and add them to A', and output the freshness evaluation results of the features in A' after each feature is added, until A* is an empty set.

[0112] In this process, the above process can be terminated in advance by setting the accurate threshold of the evaluation result that needs to be reached, and the optimal feature combination and food freshness evaluation model at this time can be obtained to output the freshness evaluation result.

[0113] Specifically, a one-dimensional convolutional neural network evaluation model (1D-CNN) is designed for freshness evaluation. The structure is as follows: Figure 5 As shown, it consists of one convolution layer, one maximum pooling layer, one flattening layer and two fully connected layers. The feature importance is analyzed by the random forest algorithm, and then the features are sequentially sent to the one-dimensional convolutional neural network evaluation model according to the feature importance from large to small to obtain the freshness evaluation result. If the evaluation result reaches the accurate threshold, the food freshness evaluation model is established based on the input feature combination and the constructed evaluation model.

[0114] A third-party food safety testing agency was commissioned to conduct laboratory volatile basic nitrogen and total bacterial count tests on oyster samples, based on GB 2733-2015 "National Food Safety Standard for Fresh and Frozen Animal Aquatic Products". The products were subjected to accelerated destructive tests at 15°C, and the changes in product quality and food safety-related indicators were evaluated during the test. The volatile basic nitrogen determination method adopted the GB 5009.228-2016 (second method) standard, and the total bacterial count determination adopted the GB 4789.2-2016 standard. According to the third-party evaluation results, the samples of oysters three days before the test were calibrated as fresh samples, the samples on the fourth and fifth days were calibrated as sub-fresh samples, and the samples after the sixth day were calibrated as rotten samples.

[0115] The sensory evaluation results were used as the evaluation criteria for fruit freshness. The sensory evaluation team consisted of 5 people who evaluated the fruit samples every day according to the sensory evaluation criteria and classified the yellow peaches into three categories: fresh, sub-fresh, or corrupt. For the selected yellow peach and blueberry experimental objects, the sensory evaluation criteria shown in Table 2 were established.

[0116] Table 2 Fruit freshness testing standards

[0117]

[0118] According to the evaluators' scores and the comprehensive description of the samples, for yellow peach samples, in the intact sample group, yellow peach samples stored within three days were defined as fresh samples, yellow peach samples stored from the fourth to the seventh day were defined as second-fresh samples, and yellow peach samples stored for eight days and above were defined as rotten samples; in the damaged sample group, samples stored on the first day were defined as fresh samples, samples stored on the second and third days were defined as second-fresh samples, and samples stored after the fourth day were defined as rotten samples. For blueberry samples, in the intact sample group, blueberry samples stored within two days were defined as fresh samples, blueberry samples stored from the third to the fourth day were defined as second-fresh samples, and blueberry samples stored for more than five days were defined as rotten samples; in the damaged sample group, blueberry samples stored on the first day were defined as fresh samples, blueberry samples stored on the second day were defined as second-fresh samples, and all samples after the third day were defined as rotten samples.

[0119] Step 400: embed the above freshness evaluation model in the freshness test system of the tested environment to evaluate the freshness of fresh food.

[0120] In this embodiment, the freshness evaluation model uses Random Forest (RF), Support Vector Classification (SVC), Naive Bayes (NB), Linear Discriminant Analysis (LDA), K-Nearest Neighbors (KNN), and the basic one-dimensional convolutional neural network model proposed in the present invention for freshness evaluation.

[0121] The above model is used for freshness evaluation. The best feature set can be selected while the best evaluation model can be selected. The number of decision trees for the RF classifier is set to 100, and the maximum depth of the decision tree is 50. After comparison, the Gaussian kernel function is selected to construct the SVC evaluation model. The Gaussian naive Bayes algorithm is selected to establish the NB evaluation model. The parameter 'n_components' of the number of retained features of the LDA algorithm is set to 1. The parameter 'k' of the number of nearest neighbors of the KNN algorithm is set to 3.

[0122] The features are added one by one in order from the largest to the smallest according to the random forest importance and sent to the evaluation model for training. The training is stopped when the number of features is greater than 13. Among them, due to the limitation of the minimum number of features, the LDA evaluation model starts to participate in the training when the features reach 2; when the features increase to 7, the CNN evaluation model starts to participate in the training. At the same time, KNN, RF, NB, LDA and SVC are selected as control models for comparison with the CNN network model in the present invention.

[0123] The trend of oyster freshness evaluation accuracy changing with the number of features is as follows Figure 6 As shown. As the number of features increases, the accuracy of the evaluation model continues to improve. When the number of features reaches about 12, the accuracy reaches a stable level. As can be seen from the figure, the accuracy of the RF, KNN and CNN algorithms increases the fastest. The accuracy of CNN exceeds 95% when 9 features are involved in the first training, and the accuracy of RF and KNN algorithms also exceeds 95% when 8 features are involved; the SVC algorithm exceeds 95% when 13 features are involved, and the accuracy of the LDA and NB algorithms only reaches 91.56% and 85.73% at most.

[0124] The trend of the accuracy of yellow peach freshness evaluation with the number of features is shown in Figure 7. Figure 7 (a) shows the accuracy of freshness evaluation of intact yellow peach samples. As the number of features increases, the accuracy of freshness evaluation continues to increase. When the number of features reaches about 13, the accuracy reaches a stable state. It can be seen from the figure that the accuracy of freshness evaluation of RF, KNN, LDA and CNN algorithms continues to increase with the increase of the number of features. When the number of features reaches about 14, it basically reaches a stable state; the accuracy of SVC algorithm hardly increases with the increase of the number of features and remains at a low level. Figure 7 (b) shows the accuracy of freshness evaluation of damaged yellow peach samples. It can be seen from the figure that with the increase of features, the accuracy of the model does not increase significantly. This is because the model accuracy is already at a high level when the first feature is sent to the model.

[0125] The variation trend of the accuracy of blueberry freshness evaluation with the number of features is shown in Figure 8. Figure 8(a) shows the accuracy of intact blueberry samples. It can be seen from the figure that the accuracy of freshness evaluation of RF, KNN, SVC, LDA and CNN algorithms continues to improve with the increase of the number of features. When the number of features reaches about 12, it basically reaches a stable state, and finally does not reach 95%; the accuracy of NB algorithm decreases with the increase of the number of features and is at a low level. Figure 8(b) shows the accuracy of damaged blueberry samples. It can be seen from the figure that with the increase of features, the accuracy of CNN, KNN and SVC algorithms gradually increases, reaching up to 98.43%, 97.98% and 97.53% respectively. The accuracy of RF algorithm has been at a high level, reaching up to 99.32%, while the accuracy of LDA and NB algorithms has been at a low level below 95%.

[0126] By comparing several models, it was found that the CNN algorithm has better accuracy and robustness. The accuracy of freshness evaluation for intact yellow peach samples is 96.59%, and the accuracy of freshness evaluation for intact blueberry samples is 92.17%. The accuracy of the remaining samples is above 98%, and the number of features does not exceed 15.

[0127] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention, and should be included in the protection scope of the present invention.

Claims

1. A method for detecting the freshness of fresh food, characterized in that: The following steps are involved: Step 100: Select a gas sensor, use the selected gas sensor to obtain a response signal of food odor, and establish a freshness odor response data set of the corresponding food; Step 200: Preprocess the gas sensor response signal in the freshness odor response data set, extract waveform features, statistical features and transform domain features from the preprocessed sensor response signal, and perform normalization processing on it; Step 300. Calculate the importance of waveform features, statistical features and transform domain features extracted from sensor response signals, and send the features to a deep learning or pattern recognition model in descending order of importance, find the combination of the best features and the best model, and establish a food freshness evaluation model; Step 400: embed the above freshness evaluation model in the freshness test system of the tested environment to evaluate the freshness of fresh food; In step 200, waveform features are extracted from the preprocessed sensor response signal, and the waveform features include steady-state values. , maximum positive slope and the maximum negative slope , the corresponding calculation method is as follows: ; , ; , ; In the formula, The sensor response curve after preprocessing is n The value of seconds, The sensor response curve after preprocessing is The value of seconds, represents the absolute value, N Represents the number of sample points contained in a sensor in a single sample, and Z represents an integer. i Indicates the starting sample number of the steady state, j Indicates the sample number at the end of steady state; The statistical characteristics include variance VAR , skewness value SK and kurtosis KU There are three types, and the corresponding calculation methods are as follows: ; ; ; In the formula, N Indicates the number of sample points contained in a sensor in a single sample. Indicates the sensor signal The value of the sample points, Indicates the average value of all sample points of the sensor; The transform domain features include the amplitude-frequency characteristic features of the fast Fourier transform and the db5 wavelet discrete wavelet transform component features, and the amplitude-frequency characteristic features of the fast Fourier transform and the db5 wavelet discrete wavelet transform component features are respectively subjected to PCA dimensionality reduction, and the first five principal components are retained; In step 300, the importance of features is analyzed by a random forest algorithm, and the features are sequentially sent to a deep learning or pattern recognition model in descending order of importance to obtain a freshness evaluation result. If the evaluation result accuracy threshold is reached, a food freshness evaluation model is established based on the input feature combination and the deep learning or pattern recognition model; wherein the deep learning or pattern recognition model includes a one-dimensional convolutional neural network evaluation model, a random forest, a classification support vector machine, a naive Bayes, a linear discriminant analysis, and a K nearest neighbor; The features are fed into the deep learning or pattern recognition model in descending order of feature importance, including: Extract all sensor features to form a feature set , initialize an empty set A'; Compute feature set The Gini importance of each feature in , and the obtained feature importance ranking; The feature set The most important feature is added to A' and removed from Delete from; Based on deep learning or pattern recognition models, the freshness evaluation results of the features in A' are obtained; Continue to repeat the above steps, from The most important features are continuously selected and added to A', and the freshness evaluation results of the features in A' are output after each feature is added, until is an empty set; The one-dimensional convolutional neural network evaluation model is a one-dimensional convolutional neural network, which includes a convolution layer, a maximum pooling layer, a flattening layer and two fully connected layers.

2. A fresh food freshness detection method according to claim 1, characterized in that: In step 200, data preprocessing is performed on the gas sensor response signal in the freshness odor response data set, and the preprocessing includes filtering processing and baseline removal processing: The filtering process uses the SG filter parameters set to order 1 and window width 31; The baseline removal process adopts the fractional difference method, and the specific formula is: ; In the formula, represent t The sensor response value before the moment baseline processing; After baseline removal t The sensor value at the moment; Represents the response value of the sensor in air.

Citation Information

Patent Citations

  • Electroencephalogram data classification method based on random forest and convolutional neural network

    CN110543832A

  • Artificial nose refrigerator food freshness detection system and method based on feature selection

    CN114970675A