A method for detecting damage to fruit based on a gas sensor
By using a multifunctional sensor array and an improved particle swarm optimization support vector machine model, the problems of high equipment cost and low accuracy in portable fruit damage detection are solved, and high-precision qualitative and quantitative detection of fruit damage is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SOUTH CHINA AGRICULTURAL UNIVERSITY
- Filing Date
- 2023-07-13
- Publication Date
- 2026-04-17
AI Technical Summary
Existing technologies for fruit damage detection suffer from problems such as large and expensive equipment, low detection accuracy, and high cross-sensitivity, making it difficult to achieve portable and efficient qualitative and quantitative detection of fruit damage.
By employing a multifunctional sensor array and an improved particle swarm optimization support vector machine model, the detection accuracy is improved through sensor signal preprocessing, feature extraction, feature selection, and pattern recognition, thereby optimizing feature combinations.
It achieves high-precision qualitative and quantitative detection of fruit damage, meets the needs of portable detection equipment, and improves the detection accuracy of fruit damage prediction.
Smart Images

Figure CN116879409B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of gas environment monitoring technology, and more specifically to an analytical detection method for fruit damage based on gas sensors. Background Technology
[0002] With increasing national support for agricultural development, the demand for agricultural monitoring is growing. Delicate fruits are susceptible to mechanical damage, which can cause softening of the pulp tissue, browning of the damaged area, and accelerated aging of the fruit. Furthermore, damaged areas on the fruit surface are highly susceptible to infection by pathogens, leading to rot. Therefore, it is crucial to select mechanically damaged fruits early on to prevent significant economic losses during later storage.
[0003] Currently, hyperspectral and near-infrared technologies are mainly used to identify damaged fruits, and their discrimination effect is relatively good. However, these devices are usually large and expensive, and the damage to fruits during actual transportation is not consistent, which brings certain difficulties to visual imaging technology. In portable detection devices, the sensor is affected by noise and manufacturing precision, which leads to a decrease in detection effect. At the same time, the gas environment at the detection site is complex, and a single sensor has cross sensitivity, which may be sensitive to multiple gases in the environment of the detection object, resulting in the recognition accuracy not reaching the expected level.
[0004] In fruit damage detection based on gas sensors, input features can have different effects on the recognition effect. The selection of sensor response curve characteristics will also affect the recognition effect. At the same time, different features are associated with qualitative and quantitative detection. How to select the feature combination that has the best detection and recognition effect has become a technical challenge for the qualitative and quantitative detection of fruit damage. Summary of the Invention
[0005] In view of this, the present invention provides a method for analyzing and detecting fruit damage based on a gas sensor; it can solve the problem of how to select the feature combination with the best detection and identification effect, improve the accuracy of fruit damage prediction and detection, and realize effective qualitative and quantitative output of fruit damage.
[0006] To achieve the above objectives, the present invention adopts the following technical solution:
[0007] A method for analyzing and detecting fruit damage based on a gas sensor, wherein the gas sensor includes a multifunctional sensing element that responds to multiple gases and multiple single sensing elements that respond to each of the multiple gases, and the single sensing element has different response values at different concentrations of the corresponding gas.
[0008] The analytical detection method includes the following steps:
[0009] S1. Acquire the sensor response signal of the fruit to be detected through a sensor array, and filter the sensor response signal of the fruit to be detected.
[0010] S2. Extract features from the sensor response signal of the fruit to be detected after filtering and construct a feature matrix; construct a feature vector by obtaining the feature values of the fruit to be detected and the corresponding detection environment through sensor filtering; and normalize each data to obtain initial feature data.
[0011] S3. A feature selection algorithm is used to perform three-stage feature selection on the initial feature data to finally obtain the input feature combination;
[0012] S4. The input feature combination is input into the improved particle swarm optimization support vector machine model to perform multi-task recognition and prediction, and the damage calculation formula is used to obtain the fruit damage data of the detected fruit.
[0013] Preferably, step S1 specifically includes the following steps:
[0014] S11. Collect the AD response values of the detected fruit from the gas sensor array during a preset time period, and process the response signals of the detected fruit collected by each sensor through Kalman filtering.
[0015] S12. Perform wavelet filtering with an improved wavelet threshold function on the response signal of the detected fruit after Kalman filtering to smooth the data.
[0016] S13. Extract the steady-state values t, h, v, p, and m of the temperature and humidity sensor, airflow velocity sensor, air pressure sensor, and weight sensor in the detection environment corresponding to the fruit being tested.
[0017] Preferably, step S12 specifically includes the following steps:
[0018] S121. Obtain the response signal sequence of the detected fruit after Kalman filtering, and perform wavelet transform on the original signal using a predetermined wavelet basis function to obtain wavelet coefficients.
[0019] S122. The wavelet coefficients are quantized and filtered using an improved wavelet threshold function.
[0020] S123. Based on the low-frequency coefficients of the Nth layer of wavelet decomposition and the high-frequency coefficients of the 1st to Nth layers after quantization, wavelet reconstruction of the signal is performed to obtain the final filtered signal of the detected fruit.
[0021] Preferably, step S2 specifically includes the following steps:
[0022] S21. Based on the length of the air path in the hardware structure, the signal sequence of the detected fruit is filtered by removing the front-end time 0-t0, and finally the signal sequence t0-t is obtained. n The signal response sequence of the detected fruit is used to extract features and construct a feature matrix.
[0023] S22. Extract relevant features from the signal response sequence, including the first integral value, relative steady-state value, average derivative value, maximum response value, response difference value, maximum first derivative value, and T. A S, T B The response values at two time points are used to construct the feature data of the detected fruit.
[0024] S23. Obtain the steady-state values of temperature, humidity, airflow velocity, air pressure, and weight in the corresponding detection environment, and construct the feature data of the corresponding detection environment; the feature data of the detected fruit and the feature data of the corresponding detection environment constitute a feature vector;
[0025] S24. Normalize the feature matrix, feature vector and multi-task output features to eliminate the adverse effects caused by singular sample data and obtain the initial feature data.
[0026] Preferably, step S3 specifically includes the following steps:
[0027] S31. Perform correlation analysis on the initial feature data and remove features whose correlation coefficient reaches a set threshold to obtain the features of the first stage.
[0028] S32. Using the features of the first stage, calculate the maximum information coefficient between each input feature and the multi-task output feature to obtain the feature importance, and remove features less than the feature importance threshold to obtain the features of the second stage.
[0029] S33. Substitute the features from the second stage into the improved particle swarm optimization support vector machine model for multi-task detection, and iteratively improve the accuracy of multi-task detection to obtain the optimal combination of input features.
[0030] Preferably, step S31 specifically includes the following steps:
[0031] S311. Calculate the Pearson correlation coefficient between each input feature, and simultaneously calculate the sum of the absolute values of the Pearson correlation coefficients between each input feature and other input features.
[0032] S312. By gradually substituting the features of the accumulated values into the improved particle swarm optimization support vector machine model, different tasks are identified and predicted. The threshold of the accumulated absolute value of the correlation coefficient is determined by the root mean square error of the test set, and redundant features are removed.
[0033] S313. Based on the threshold of the cumulative absolute value of the correlation coefficient, features are removed to obtain the features of the first stage.
[0034] Preferably, step S32 specifically includes the following steps:
[0035] S321. Calculate the maximum information coefficient between each input feature and the multi-task output feature in the first stage to obtain the feature importance of each input feature to the task output.
[0036] S322. Sort the damage severity task and damage time task by feature importance, set a feature importance threshold, and remove features that have little impact on both the damage severity task and damage time task to obtain the feature ranking combination for each task in the second stage.
[0037] Preferably, step S33 specifically includes the following steps:
[0038] S331. Substitute the feature ranking combination of the damage degree task and the damage time task in the second stage into the improved particle swarm optimization support vector machine model step by step to obtain the root mean square error of the training set when the features are increased.
[0039] S332. When the root mean square error of the training sets for the damage degree task and the damage time task reaches a steady state value, obtain the feature combination of the two tasks at this time, take the union of the feature combinations of the two tasks to obtain the main feature combination, and take the rest as the secondary feature combination. Then, sort the features of the secondary feature combination according to the cumulative value of the feature importance of the two tasks.
[0040] S333. Substitute the main feature combination described in S332 and the feature vector described in S23 into the improved particle swarm optimization support vector machine model, and gradually add features according to the sorting of secondary feature combinations. Calculate the decision coefficients for model training. When the decision coefficients of the training set reach a steady state, determine the optimal input feature combination.
[0041] Preferably, step S4 specifically includes the following steps:
[0042] S41. For ASPSO-LSSVM, the introduction of a shrinkage factor for the average particle size of the initial population and an adaptive inertia weight improves the parameter optimization and regression accuracy compared to the original SVM.
[0043] S42. Substitute the input feature combination into the improved particle swarm optimization support vector machine model for identification and prediction, and obtain the damage degree quantification value and damage time quantification value after inverse normalization.
[0044] S43. Obtain the physical parameters of the object being tested, and output the degree of damage and the time of damage to the individual fruit using the damage calculation formula; the damage calculation formula is:
[0045]
[0046] In the formula, k is the category coefficient of the test object; s is the influence coefficient of the test system; H is the quantitative value of the degree of damage; m is the weight of the tested fruit object; DEI is the degree of damage of the individual test object, which represents the quantitative damage of the actual individual and the damage rating is performed for different individuals.
[0047] Compared with existing technologies, the fruit damage analysis and detection method based on gas sensors provided by this invention has the following advantages:
[0048] This invention utilizes multiple gas sensors to detect and analyze the fruit being tested. It optimizes the design from four aspects: sensor signal preprocessing, feature extraction, feature selection, and pattern detection, thereby improving feature effectiveness, reducing feature redundancy, and enhancing the accuracy of fruit damage prediction and detection. At the same time, it establishes a practically usable model for evaluating fruit damage, enabling effective qualitative and quantitative output of fruit damage, which can meet the method requirements of portable detection equipment. Attached Figure Description
[0049] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0050] Figure 1 A flowchart of the fruit damage analysis and detection method based on a gas sensor provided by the present invention;
[0051] Figure 2 The present invention provides a flowchart of sensor array signal filtering preprocessing.
[0052] Figure 3 A flowchart for feature selection provided by the present invention;
[0053] Figure 4 The flowchart for pattern recognition prediction provided by this invention;
[0054] Figure 5Flowchart of the improved support vector machine model algorithm for particle swarm optimization provided by this invention;
[0055] Figure 6 The improved wavelet threshold function curve provided by this invention. Detailed Implementation
[0056] Exemplary embodiments of the present disclosure will now be described in more detail with reference to the accompanying drawings. Although exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that they can be implemented in various forms.
[0057] This disclosure should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of this disclosure to those skilled in the art.
[0058] When delicate and fragile fruits are mechanically damaged during agricultural production, the concentration and types of volatile organic compound (VOC) gases produced by the different degrees of damage will change over time. How to combine the concentration and types of VOC gases with the damage information of the fruit has become the key to improving the accurate detection and identification of fruits.
[0059] In practical implementation, the changes in volatile organic compound (VOC) gases produced by different types of fruit damage will vary. The embodiments of the invention target single or several types of damaged fruits. Taking the detection of mechanical impact damage to apples as an example, during the sensor selection process, research revealed that various VOC gases change accordingly over time: concentrations change from low to high, from high to low, from low to high and then back to low, from high to low and then back to high, and the types of VOCs change from none to present. For example, after mechanical impact damage to apples, the concentration of hydrocarbon gases such as toluene changes from low to high and then back to low; the concentration of n-hexane changes from high to low and then to none; the concentration of aldehyde gases such as n-hexaldehyde changes from low to high; the concentration of ketone gases such as acetone changes from low to high; the concentration of ester gases such as ethyl octanoate changes from none to high; and the concentration of alcohol gases such as n-hexanol changes from low to high and then back to low. Therefore, the selection of sensors needs to be based on the types of gas changes corresponding to the fruit damage. The sensitive gas corresponding to the sensor can be selected according to the types of gas changes. One or more types of gases can be detected, such as hydrocarbon gases (toluene, n-hexane), aldehyde gases (n-hexaldehyde, benzaldehyde), ketone gases (acetone), ester gases (propyl acetate, butyl acetate), and alcohol gases (n-hexanol, n-butanol), which show significant changes after an apple is mechanically damaged. Simultaneously, without affecting the detection of gases with significant changes, sensors for other sensitive gases and sensors with cross-sensitivity can be selected, such as the WSP7110 sensitive to toluene, the SMD1015 sensitive to acetone, the WSP2110 sensitive to both toluene and acetone, the TGS2612 and MQ-5 sensitive to hydrocarbon gases, the MQ-138 sensitive to ketone gases, and the TGS2602 sensitive to multiple VOC gases. The more types of sensors selected, the more effective detection information will be retained after algorithm selection, thus improving the final detection and recognition accuracy. During the design process, users can select the most suitable combination of sensor components according to technical requirements to obtain the optimal solution.
[0060] In this embodiment, the specific fruit damage detection process is as follows: Figure 1 As shown, the detection method includes the following steps:
[0061] S1. Acquire the sensor response signal of the fruit to be detected through a sensor array, and filter the sensor response signal of the fruit to be detected.
[0062] S2. Extract features from the sensor response signal of the fruit to be detected after filtering and construct a feature matrix; construct a feature vector by obtaining the feature values of the fruit to be detected and the corresponding detection environment through sensor filtering; and normalize each data to obtain initial feature data.
[0063] S3. A feature selection algorithm is used to perform three-stage feature selection on the initial feature data to finally obtain the input feature combination;
[0064] S4. The input feature combination is input into the improved particle swarm optimization support vector machine model to perform multi-task recognition and prediction, and the damage calculation formula is used to obtain the fruit damage data of the detected fruit.
[0065] In this embodiment, the gas sensor includes a multifunctional sensing element that responds to multiple gases and multiple single sensing elements that respond to multiple gases respectively. The multiple single sensing elements are composed of multiple metal oxide semiconductor gas sensors of different types, and the single sensing element has different response values at different concentration values of the corresponding gas.
[0066] The system detects a variety of gases, including volatile organic compounds (VOCs) produced by different types of fruits during their healthy and damaged states and through chemical reactions. These VOCs include hydrocarbons, aldehydes, ketones, esters, and alcohols. To address damage detection in both single and multiple types of vulnerable fruits, such as apples and strawberries, the detection range of a single sensor element should cover as many VOC gas categories as possible to meet the needs of portable fruit damage detection systems.
[0067] In this embodiment, as Figure 2 As shown, in step S1, when the system is working, the sampling time is set to collect the AD output values of the gas sensor, temperature and humidity sensor, airflow velocity sensor, air pressure sensor, and weight sensor in the detection environment at a certain sampling frequency f, to obtain the raw detection data sequence; the raw detection data sequence is then filtered, which includes the following steps:
[0068] S11. Collect the AD response values of the detected fruit from the gas sensor array during a preset time period. The response signals of the detected fruit collected by each sensor are processed by Kalman filtering. According to the object analyzed by this method, the filtering calculation is performed as follows.
[0069] Prediction process
[0070]
[0071] P k' =AP k-1 A T +Q
[0072] Update process
[0073] K k =P k' H T HP k' +R) -1
[0074]
[0075] P k =(IK k H)P k'
[0076] In the formula, The predicted value at the current moment. P is the predicted value from the previous time step; A is the state transition matrix; P k' Let be the covariance matrix of the prior estimate at time k; Q is the covariance matrix of the process noise with a mean of 0 and following a normal distribution; H is the measurement matrix; R is the covariance matrix of the measurement noise with a mean of 0 and following a normal distribution. The predicted value after Kalman filtering; P k Let I be the posterior estimated covariance matrix at time k; I is the identity matrix; in this embodiment of the invention, A is [1] and H is [1];
[0077] S12. Perform wavelet filtering with an improved wavelet threshold function on the response signal of the detected fruit after Kalman filtering to smooth the data.
[0078] S13. Extract the steady-state values t, h, v, p, and m of the temperature and humidity sensor, airflow velocity sensor, air pressure sensor, and weight sensor in the detection environment corresponding to the fruit being tested, in order to achieve a better recognition mapping relationship.
[0079] In this embodiment, step S12 specifically includes the following steps:
[0080] S121. Obtain the response signal sequence of the detected fruit after Kalman filtering, and perform wavelet transform on the original signal using a predetermined wavelet basis function to obtain wavelet coefficients. Figure 6 To improve the wavelet threshold function curve (short dashed line represents the soft threshold function, long dashed line represents the hard threshold function, and solid line represents the improved threshold function);
[0081] S122. The wavelet coefficients are quantized and filtered using an improved wavelet threshold function.
[0082]
[0083] In the formula, ω j,k The wavelet coefficients of each level after wavelet transform multi-scale decomposition; sign(ω) j,k ) for ω j,k The sign function; P takes values in the range (0, T), where T is the VisuShrink threshold. Where σ is the standard deviation of noise and N is the signal length. In practical applications, σ is taken as median(x) / 0.6745, where x is the median of the amplitude of all high-frequency subband wavelet coefficients.
[0084] S123. Based on the low-frequency coefficients of the Nth layer of wavelet decomposition and the high-frequency coefficients of the 1st to Nth layers after quantization, wavelet reconstruction of the signal is performed to obtain the final filtered signal of the detected fruit.
[0085] In this embodiment, step S2 specifically includes the following steps:
[0086] S21. Based on the length of the air path in the hardware structure, the signal sequence of the detected fruit is filtered by removing the front-end time 0-t0, and finally the signal sequence t0-t is obtained. n The signal response sequence of the detected fruit is used to extract features and construct a feature matrix.
[0087] S22. Extract relevant features from the signal response sequence, including the first integral value, relative steady-state value, average derivative value, maximum response value, response difference value, maximum first derivative value, and T. A S, T B The response values at two time points are used to construct the feature data of the detected fruit; the calculation of the first-order integral value, the relative steady-state value, and the average differential value is shown in the following formula;
[0088] The first-order integral value reflects the overall response of the sensor to the volatile components of the analyte, and is calculated as follows:
[0089]
[0090] In the formula, T is the time it takes for the sensor to collect a sample; x i Δt represents the response value at the i-th second; Δt is the time interval between two adjacent sampling points.
[0091] The relative steady-state value is used to characterize the steady-state characteristics by averaging the sensor response signal relative to the steady-state range. It is calculated as follows:
[0092]
[0093] In the formula, t0 is the time corresponding to the point when steady state is reached; x i Let be the response value at the i-th second; T is the sensor's acquisition time for a sample.
[0094] The average derivative reflects the rate of change of the sensor response curve, and is calculated as follows:
[0095]
[0096] In the formula, T is the time it takes for the sensor to collect a sample; x i Δt represents the response value at the i-th second; Δt is the interval between two adjacent sampling points.
[0097] S23. Obtain the steady-state values of temperature, humidity, airflow velocity, air pressure, and weight in the corresponding detection environment, and construct the feature data of the corresponding detection environment; the feature data of the detected fruit and the feature data of the corresponding detection environment constitute a feature vector;
[0098] S24. Normalize the feature matrix, feature vector and multi-task output features to eliminate the adverse effects caused by singular sample data and obtain the initial feature data.
[0099] The obtained input feature vector and multi-task output features are normalized to [0,1] using the following formula;
[0100]
[0101] In the formula, X i X represents the feature values of the original data. min X is the minimum value of the original feature; max The maximum value of the original feature;
[0102] In this embodiment, as Figure 3 As shown, step S3 includes the following steps:
[0103] S31. Perform correlation analysis on the initial feature data and remove features whose correlation coefficient reaches a set threshold to obtain the features of the first stage.
[0104] S32. Using the features of the first stage, calculate the maximum information coefficient between each input feature and the multi-task output feature to obtain the feature importance, and remove features less than the feature importance threshold to obtain the features of the second stage.
[0105] S33. Substitute the features from the second stage into the improved particle swarm optimization support vector machine model (ASPSO-LSSVM) for multi-task detection, and iteratively improve the detection accuracy of multi-task to obtain the optimal combination of input features.
[0106] Furthermore, step S31 specifically includes the following steps:
[0107] S311. Calculate the Pearson correlation coefficient between each input feature, and simultaneously calculate the sum of the absolute values of the Pearson correlation coefficients between each input feature and other input features; the calculation is as follows;
[0108]
[0109]
[0110] In the formula, x i Let y be the relative change of feature value x with respect to the i-th sample;i Let y be the relative change of the feature value y with respect to the i-th sample; Let x be the mean of the feature value over all samples; Let y be the mean of the feature value y over all samples; n be the total number of samples; R xy The Pearson correlation coefficient between feature values x and y is given by r; N is the total number of feature dimensions in the sample; i This is the sum of the absolute values of the Pearson correlation coefficients between a given feature and other features.
[0111] S312. By gradually substituting the features of the accumulated values into the improved particle swarm optimization support vector machine model (ASPSO-LSSVM), different tasks are identified and predicted. The threshold of the accumulated absolute value of the correlation coefficient is determined by the root mean square error of the test set, and redundant features are removed.
[0112]
[0113] In the formula, y i The true value output by the model; The predicted value is the output of the model; n is the total number of samples in the test set.
[0114] S313. Based on the threshold of the cumulative absolute value of the correlation coefficient, features are removed to obtain the features of the first stage.
[0115] Furthermore, step S32 specifically includes the following steps:
[0116] S321. Calculate the maximum information coefficient of each input feature and the multi-task output feature in the first stage to obtain the feature importance of each input feature to the task output; the calculation is as follows;
[0117]
[0118]
[0119]
[0120] MI(F,C)=H(F)+H(C)-H(F,C
[0121] I * (F,C,a,b)=max MI(F,C) a,b
[0122]
[0123] MIC(F,X)=max[MIC(F,C) a,b ]stab <n 0.6
[0124] In the formula, f is the feature value of the sample input feature, and c is the feature value of the sample output feature; H(F,C) is the cross-entropy of feature F and feature C, and H(F) and H(C) represent the information entropy of feature F and feature C, respectively; P(f) and P(c) represent the marginal distributions of feature F and feature C, respectively, and P(f,c) is the joint distribution of feature F and feature C; a,b are the number of grid divisions in row a and column b; MI(F,C) is the mutual information value of feature F and feature C; I * (F,C,a,b) represents the maximum mutual information value between feature F and feature C when dividing the grid into rows a and columns b; MIC(F,C) a,b MIC(F,C) represents the maximum information coefficient for features F and C when the grid is divided into a rows and b columns; MIC(F,C) represents the maximum information coefficient for different numbers of divisions; n represents the amount of data.
[0125] S322. Sort the damage severity task and damage time task by feature importance, set a feature importance threshold, and remove features that have little impact on both the damage severity task and damage time task to obtain the feature ranking combination for each task in the second stage.
[0126] In this embodiment, step S33 specifically includes the following steps:
[0127] S331. The feature ranking combination of the damage degree task and the damage time task in the second stage is used to gradually replace the improved particle swarm optimization support vector machine model (ASPSO-LSSVM) to obtain the root mean square error of the training set when the features are increased.
[0128] S332. When the root mean square error of the training sets for the damage degree task and the damage time task reaches a steady state value, obtain the feature combination of the two tasks at this time, take the union of the feature combinations of the two tasks to obtain the main feature combination, and take the rest as the secondary feature combination. Then, sort the features of the secondary feature combination according to the cumulative value of the feature importance of the two tasks.
[0129] S333. Substitute the main feature combination described in S332 and the feature vector described in S23 into the improved particle swarm optimization support vector machine model (ASPSO-LSSVM), and gradually add features according to the sorting of secondary feature combinations. Calculate the decision coefficient of the model training using the following formula. When the decision coefficient of the training set reaches a steady state, determine the optimal input feature combination.
[0130]
[0131] In the formula, y i The true value output by the model; The predicted value output by the model; is the predicted value output by the model; n is the total number of samples in the training set.
[0132] In this embodiment, as Figure 4 As shown, step S4 includes the following steps:
[0133] S41. For ASPSO-LSSVM, the introduction of a shrinkage factor for the average particle size of the initial population and an adaptive inertia weight improves the parameter optimization and regression accuracy compared to the original SVM.
[0134] like Figure 5 As shown, the above ASPSO-LSSVM model includes:
[0135] LSSVM is a support vector machine with a quadratic loss function, transforming the quadratic optimization in the original SVM algorithm into solving a linear equation, reducing the difficulty and increasing the speed of the solution. In actual training, the input space is mapped to a high-dimensional feature space through a nonlinear function φ(x). The regression function in this embodiment is as follows:
[0136] y(x)=w T φ(x)+bw∈Z,b∈R
[0137] In the formula, w is the weight; x is the sample feature; and b is the bias.
[0138] The LSSVM regression problem can be expressed as finding the minimum structural risk under constraints;
[0139]
[0140] sty i =w T φ(x i )+b+e i i = 1, 2, ..., l
[0141] In the formula, C is the penalty factor; e i Let be the error between the actual output and the predicted output of the i-th data point;
[0142] The corresponding Lagrange function is
[0143]
[0144] In the formula, α i For Lagrange factor; y i This is the actual output for the i-th data.
[0145] The analytical solution to the following equation can be obtained by transforming the KKT optimization conditions;
[0146]
[0147] In the formula, y=[y1,y2,...,yl A = [1,1,...,1] T ; α = [α1, α2, ..., α l b is the bias; I is the identity matrix; K is the kernel matrix; C is the penalty factor;
[0148] The LSSVM prediction model is obtained as follows
[0149]
[0150] In the formula, α i b is obtained by solving the above formula; K(x,x) i ) is the radial basis kernel function, as shown below.
[0151] K(x,x i ) = exp(-||xx i || 2 / 2σ 2 )
[0152] In the formula, x represents the input vector; x i The center of the i-th radial basis function is σ; σ is the normalization parameter; ||xx i || is the vector xx i The norm;
[0153] The ASPSO algorithm is introduced to optimize the parameters C,σ of LSSVM. The specific steps include:
[0154] In the traditional PSO algorithm, a shrinkage factor and an adaptive inertia factor for the initial population average particle distance are introduced, resulting in the following improved form of the PSO model. In each iteration, the particle will track two extreme values, one of which is the optimal solution pbest found by the particle itself. id One is called the individual optimal solution; the other is the optimal solution found by the entire population, called the global optimal solution. During each iteration, each particle adjusts its position and velocity according to the following equations;
[0155]
[0156]
[0157] β=e -D
[0158]
[0159]
[0160] In the formula, β is the contraction factor, ω is the adaptive inertia factor; c1 and c2 are acceleration constants, and r1, r2 and r3 are mutually independent random numbers that follow a uniform distribution on [0,1]. The speed of the (k+1)th iteration; The velocity of the k-th iteration; This represents the position of the (k+1)th iteration. The position of the k-th iteration; D is the average particle spacing of the initial population, m is the number of particles in the population, L is the maximum length of the diagonal of the search space, n is the dimension of the solution space, and p id This represents the d-th dimension position coordinates of the i-th particle. This represents the average value of the d-th dimension position coordinates of the i-th particle; ω is the adaptive inertia factor. min ω is the minimum inertia factor; max The maximum inertia factor; Let be the fitness of the particle in the k-th iteration; The minimum fitness of all particles at the k-th iteration; Let C be the average fitness of all particles at the k-th iteration; in this example, the search range of C is [0.1, 150], the search range of σ is [0.1, 10], and c1 and c2 can be set to 1.5 and 1.7 respectively, ω min and ω max The values can be set to 0.4 and 0.9 respectively; the fitness function uses the root mean square error of the test set of the improved particle swarm optimization support vector machine model (ASPSO-LSSVM); the optimal parameters of the system are obtained through the final feature combination;
[0161] S42. Substitute the input feature combination into the improved particle swarm optimization support vector machine model (ASPSO-LSSVM) for identification and prediction, and obtain the damage degree quantification value and damage time quantification value after inverse normalization.
[0162] S43. Obtain the physical parameters of the object being tested, and output the degree of damage and the time of damage to the individual fruit through the damage calculation formula;
[0163]
[0164] In the formula, k is the category coefficient of the test object; s is the influence coefficient of the test system; H is the quantitative value of the degree of damage; m is the weight of the tested fruit object; DEI is the degree of damage of the individual test object, which represents the quantitative damage of the actual individual and the damage rating is performed for different individuals.
[0165] Ultimately, this invention provides a method for analyzing and detecting fruit damage based on gas sensors. This method includes sensor signal preprocessing, feature extraction, feature selection optimization, regression analysis, and pattern recognition. The sensor signal is composed of volatile organic compound signals collected by a gas sensor array after fruit damage. The collected sensor signals are then denoised and smoothed using Kalman-wavelet filtering. Feature values are extracted from the denoised and smoothed sensor response signals to form an original feature matrix, while the steady-state output signal of the sensor in the actual detection environment is also acquired. The normalized original feature data undergoes iterative feature selection using Pearson correlation analysis, maximum information coefficient analysis, and model feature importance analysis to obtain an optimized feature matrix. A two-stage recognition regression is performed on the optimized feature matrix using an improved particle swarm optimization support vector machine model (ASPSO-LSSVM) to obtain qualitative and quantitative damage detection results, providing methodological support for the design of portable fruit damage detection device systems.
[0166] The preferred embodiments of the present invention have been described above. Those skilled in the art will recognize that although embodiments of the present invention have been shown and described in detail herein, many other variations or modifications conforming to the principles of the present invention can be directly determined or derived from the disclosure of the present invention without departing from its spirit and scope. Therefore, the scope of the present invention should be understood and recognized as covering all such other variations or modifications.
Claims
1. A method for analyzing and detecting fruit damage based on a gas sensor, characterized in that, The gas sensor includes a multifunctional sensing element that responds to multiple gases and multiple single sensing elements that respond to each of the multiple gases. The single sensing element has different response values at different concentration values of the corresponding gas. The analytical detection method includes the following steps: S1. Acquire the sensor response signal of the fruit to be detected through a sensor array, and filter the sensor response signal of the fruit to be detected. S2. Extract features from the sensor response signal of the fruit to be detected after filtering and construct a feature matrix; construct a feature vector by obtaining the feature values of the fruit to be detected and the corresponding detection environment through sensor filtering; and normalize each data to obtain initial feature data. S3. A feature selection algorithm is used to perform three-stage feature selection on the initial feature data to finally obtain the input feature combination; Step S3 includes: S31, performing correlation analysis on the initial feature data and removing features whose correlation coefficient reaches a set threshold to obtain the first stage features; S32, using the first stage features to calculate the maximum information coefficient between each input feature and the multi-task output feature to obtain the feature importance, and removing features less than the feature importance threshold to obtain the second stage features; S33, substituting the second stage features into the improved particle swarm optimization support vector machine model for multi-task detection, and iteratively improving the detection accuracy of multi-task to obtain the optimal combination of input features; Step S33 includes: S331, progressively substituting the feature ranking combinations of the damage severity task and the damage time task from the second stage into the improved particle swarm optimization support vector machine model to obtain the root mean square error of the training set when features are added; S332, when the root mean square error of the training set for the damage severity task and the damage time task reaches a steady state value, obtaining the feature combination of the two tasks at this time, taking the intersection of the feature combinations of the two tasks to obtain the main feature combination, and the rest as the secondary feature combination, and ranking each feature of the secondary feature combination according to the cumulative value of the importance of the features of the two tasks; S333, substituting the main feature combination obtained in S332 into the improved particle swarm optimization support vector machine model, and progressively adding features according to the ranking of the secondary feature combinations, calculating the determination coefficient of the model training, and determining the optimal input feature combination when the determination coefficient of the training set reaches a steady state. S4. The input feature combination is input into the improved particle swarm optimization support vector machine model to perform multi-task recognition and prediction, and the damage calculation formula is used to obtain the fruit damage data of the detected fruit.
2. The method for analyzing and detecting fruit damage based on a gas sensor according to claim 1, characterized in that, Step S1 specifically includes the following steps: S11. Collect the AD response values of the detected fruit from the gas sensor array during a preset time period, and process the response signals of the detected fruit collected by each sensor through Kalman filtering. S12. Perform wavelet filtering with an improved wavelet threshold function on the response signal of the detected fruit after Kalman filtering to smooth the data. S13. Extract the steady-state values t, h, v, p, and m of the temperature and humidity sensor, airflow velocity sensor, air pressure sensor, and weight sensor in the detection environment corresponding to the fruit being tested.
3. The method for analyzing and detecting fruit damage based on a gas sensor according to claim 2, characterized in that, Step S12 specifically includes the following steps: S121. Obtain the response signal sequence of the detected fruit after Kalman filtering, and perform wavelet transform on the original signal using a predetermined wavelet basis function to obtain wavelet coefficients. S122. The wavelet coefficients are quantized and filtered using an improved wavelet threshold function. S123. Based on the low-frequency coefficients of the Nth layer of wavelet decomposition and the high-frequency coefficients of the 1st to Nth layers after quantization, wavelet reconstruction of the signal is performed to obtain the final filtered signal of the detected fruit.
4. The method for analyzing and detecting fruit damage based on a gas sensor according to claim 1, characterized in that, Step S2 specifically includes the following steps: S21. Based on the length of the air path in the hardware structure, the signal sequence of the detected fruit is filtered by removing the front-end time 0-t0, and finally the signal sequence t0-t is obtained. n The signal response sequence of the detected fruit is used to extract features and construct a feature matrix. S22. Extract relevant features from the signal response sequence, including the first integral value, relative steady-state value, average derivative value, maximum response value, response difference value, maximum first derivative value, and T. A S, T B The response values at two time points are used to construct the feature data of the detected fruit. S23. Obtain the steady-state values of temperature, humidity, airflow velocity, air pressure, and weight in the corresponding detection environment, and construct the feature data of the corresponding detection environment; the feature data of the detected fruit and the feature data of the corresponding detection environment constitute a feature vector; S24. Normalize the feature matrix, the feature vector, and the multi-task output features to eliminate the adverse effects caused by singular sample data and obtain the initial feature data.
5. The method for analyzing and detecting fruit damage based on a gas sensor according to claim 1, characterized in that, Step S31 specifically includes the following steps: S311. Calculate the Pearson correlation coefficient between each input feature, and simultaneously calculate the sum of the absolute values of the Pearson correlation coefficients between each input feature and other input features. S312. By gradually substituting the features of the accumulated values into the improved particle swarm optimization support vector machine model, different tasks are identified and predicted. The threshold of the accumulated absolute value of the correlation coefficient is determined by the root mean square error of the test set, and redundant features are removed. S313. Based on the threshold of the cumulative absolute value of the correlation coefficient, features are removed to obtain the features of the first stage.
6. The method for analyzing and detecting fruit damage based on a gas sensor according to claim 1, characterized in that, Step S32 specifically includes the following steps: S321. Calculate the maximum information coefficient between each input feature and the multi-task output feature in the first stage to obtain the feature importance of each input feature to the task output. S322. Sort the damage severity task and damage time task by feature importance, set a feature importance threshold, and remove features that have little impact on both the damage severity task and damage time task to obtain the feature ranking combination for each task in the second stage.
7. The method for analyzing and detecting fruit damage based on a gas sensor according to claim 1, characterized in that, Step S4 specifically includes the following steps: S41. For ASPSO-LSSVM, a shrinkage factor for the initial population average particle spacing and an adaptive inertia weight are introduced to improve the parameter optimization and regression accuracy compared to the original SVM. S42. Substitute the input feature combination into the improved particle swarm optimization support vector machine model for identification and prediction, and obtain the damage degree quantification value and damage time quantification value after inverse normalization. S43. Obtain the physical parameters of the object being tested, and output the degree of damage and the time of damage to the individual fruit using the damage calculation formula; the damage calculation formula is: ; In the formula, k is the category coefficient of the test object; s is the influence coefficient of the test system; H is the quantitative value of the degree of damage; m is the weight of the tested fruit object; DEI is the degree of damage of the individual test object, which represents the quantitative damage of the actual individual and the damage rating is performed for different individuals.
Citation Information
Patent Citations
Electronic nose data feature selection method based on filter-crapper framework
CN110378229A
Feature selection method and system based on Pearson-MI-RF
CN116226631A