A method and system for constructing a leafy vegetable freshness detection model
By constructing an adaptive fusion comprehensive freshness evaluation mechanism based on principal component analysis and the CRITIC method, and combining it with visible-near-infrared reflectance spectroscopy, the problems of single indicators and information redundancy in the freshness evaluation of leafy vegetables are solved, and rapid, accurate and non-destructive detection is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- JILIN AGRICULTURAL UNIV
- Filing Date
- 2026-05-13
- Publication Date
- 2026-06-09
AI Technical Summary
Existing methods for evaluating the freshness of leafy vegetables suffer from limitations such as single indicators, difficulty in comprehensively characterizing quality changes, and significant information redundancy and instability during spectral modeling. Consequently, these methods are difficult to implement quickly and accurately for non-destructive testing in practical applications.
An adaptive fusion freshness comprehensive evaluation mechanism based on principal component analysis and the CRITIC method was constructed. By combining visible-near infrared reflectance spectroscopy, a dimension-reduced spectral index was extracted, and comprehensive indicators related to freshness were screened to establish a rapid and accurate non-destructive testing model.
It enables rapid, accurate, and non-destructive detection of the freshness of leafy vegetables, improves the stability and cross-batch adaptability of the model, and reduces computational complexity and engineering implementation costs.
Smart Images

Figure CN122174185A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of non-destructive testing technology for leafy vegetables, specifically to a method and system for constructing a freshness detection model for leafy vegetables. Background Technology
[0002] Leafy vegetables, as an important component of the daily diet, are characterized by high water content, fragile tissue structure, and vigorous post-harvest metabolism. They are highly susceptible to quality deterioration during harvesting, storage, and transportation, such as wilting, dehydration, and leaf senescence. Therefore, rapid and accurate evaluation of the freshness of leafy vegetables is crucial for ensuring their quality and safety, reducing losses, and optimizing supply chain management.
[0003] Currently, the evaluation methods for the freshness of leafy vegetables mainly fall into two categories: sensory evaluation and physicochemical index testing. While sensory evaluation is simple to perform, it is highly subjective, and the results are easily influenced by the evaluator's experience, lacking objectivity and consistency. Physicochemical index testing methods, although able to accurately reflect quality changes, typically rely on laboratory conditions and destructive sampling, making the testing process time-consuming and inefficient, and unable to meet the rapid testing needs of actual production and distribution. Furthermore, because leafy vegetables undergo coordinated changes in multiple physiological and biochemical processes during post-harvest decay, such as water metabolism, pigment degradation, and damage to the photosynthetic system, a single index often only reflects one aspect of the information, making it difficult to comprehensively depict the overall freshness status, resulting in incomplete information and biased evaluation.
[0004] In recent years, with the development of spectroscopic technology, visible-near-infrared spectroscopy has been widely used in the field of agricultural product quality testing due to its advantages such as speed, non-destructive nature, and rich information content. By analyzing spectral signals, indirect characterization of the internal components and physiological state of samples can be achieved, thereby enabling the prediction and evaluation of quality parameters. Furthermore, in the quality testing of leafy vegetables based on spectroscopic technology, full-spectrum data or selected characteristic bands are typically used for modeling and analysis. However, the inherent characteristics of spectral data, such as strong correlations between variables and a large amount of redundant information, make it prone to noise interference, which can affect the stability and prediction accuracy of the model.
[0005] To improve the efficiency of spectral information utilization, the spectral index method is widely used in quality modeling. This method constructs feature variables by combining specific bands, which can enhance the spectral response features related to the target parameters, thereby improving model performance to some extent. However, in practical applications, taking common hyperspectral images of lettuce or spinach as an example, a single sampling corresponds to hundreds of bands, resulting in a massive increase in the scale of two-dimensional and three-dimensional spectral index combinations to hundreds of thousands. This causes the computation time for feature selection to often reach hours, and memory resources are occupied by a large number of redundant variables. More seriously, due to the high correlation between adjacent bands, the selected index combinations are prone to overfitting to leaf samples from specific batches. When the harvest batch or storage conditions are changed, the freshness prediction value will fluctuate drastically or even become completely inaccurate. This makes it almost impossible to deploy the model on handheld rapid testing equipment or industrial control computers in cold chain sites, severely restricting the practical promotion and reliable application of post-harvest quality monitoring of leafy vegetables. Summary of the Invention
[0006] To address the problems of existing leafy vegetable freshness evaluation methods, such as the reliance on single indicators that fail to comprehensively characterize quality changes, and the significant information redundancy and instability in spectral modeling, this invention aims to propose a method and system for constructing a leafy vegetable freshness detection model. The method constructs a comprehensive evaluation index that reflects various aspects of leafy vegetable quality changes. Based on this, it combines visible-near-infrared reflectance spectroscopy with this index, and further extracts representative dimensionality-reduced spectral indices to reduce spectral data redundancy interference, achieving rapid, accurate, and non-destructive detection of freshness.
[0007] The method includes the following steps: S1. Determine the weight loss rate, SPAD value, and Fv / Fm of leafy vegetables; S2. Based on the indicators measured in step S1, conduct variable correlation and fitness tests; S3. Using the test results of step S2 as the judgment condition, construct an adaptive fusion freshness comprehensive evaluation mechanism based on principal component analysis and CRITIC method, and screen the construction method of freshness comprehensive index. S4. Based on the method selected in step S3, obtain the comprehensive freshness index value of leafy vegetables; S5. Collect the raw spectral data of leafy vegetables and perform dimensionality reduction on the raw spectral data to obtain the dimensionality-reduced spectral data. S6. Using the correlation matrix method, select the spectral index with the highest correlation coefficient with the comprehensive freshness index value of leafy vegetables from the dimensionality-reduced spectral data. S7. Construct several freshness detection models, using the spectral index selected in step S6 as input and the comprehensive freshness index value of leafy vegetables as output, and train the freshness detection models. S8. Evaluate several freshness detection models and select the best freshness detection model as the freshness detection model for leafy vegetables.
[0008] Furthermore, the correlation and fitness tests for the variables include the KMO test and the Bartlett's test for sphericity.
[0009] Furthermore, the construction of the adaptive fusion comprehensive freshness evaluation mechanism based on principal component analysis and the CRITIC method specifically involves:
[0010] in, Weights were constructed for the comprehensive freshness index, KMO represents the KMO test result, and p represents the Bartlett's sphericity test result. The comprehensive freshness evaluation mechanism is as follows: ,in, A method for constructing a comprehensive index of freshness. Principal component analysis method, This is the CRITIC method.
[0011] Furthermore, in step S4, the process of obtaining the comprehensive freshness index value of leafy vegetables is as follows: using the method selected in step S3, the index measured in step S1 is analyzed to obtain the comprehensive freshness index value of leafy vegetables.
[0012] Furthermore, in step S5, the original spectral data is dimensionality reduced using principal component analysis.
[0013] Furthermore, the spectral index includes at least one of a one-dimensional spectral index, a two-dimensional spectral index, and a three-dimensional spectral index; The aforementioned freshness detection models are divided into two categories: one category contains several quantitative equations, and the other category contains several machine learning models. The fitting forms of several quantitative equations include: linear, quadratic, cubic, logarithmic, and exponential functions; Several machine learning methods include: PSO-SVR, BP-NN, and ELM models.
[0014] Furthermore, the selection process for the optimal freshness detection model is as follows: S81. Evaluate the freshness detection models separately and select the first-stage freshness detection model; The first-stage freshness detection model includes: the optimal quantitative equation and the optimal machine learning model; S82. Evaluate the first-stage freshness detection models respectively, and take the first-stage freshness detection model with the best evaluation result as the best freshness detection model.
[0015] A system for constructing a freshness detection model for leafy vegetables, the system being used in the above-mentioned method, the system comprising the following modules: Module 1 is used to determine the weight loss rate, SPAD value, and Fv / Fm of leafy vegetables; Module 2 is used to conduct correlation and fitness tests on variables based on the indicators measured in Module 1. Module 3 is used to construct an adaptive fusion freshness comprehensive evaluation mechanism based on principal component analysis and the CRITIC method, using the test results of Module 2 as the judgment condition, and to screen the construction method of the comprehensive freshness index. Module 4 is used to obtain the comprehensive freshness index value of leafy vegetables based on the methods selected in Module 3; Module 5 is used to collect the raw spectral data of leafy vegetables and perform dimensionality reduction processing on the raw spectral data to obtain the dimensionality-reduced spectral data. Module 6 is used to select the spectral index with the highest correlation coefficient with the comprehensive freshness index value of leafy vegetables from the dimensionality-reduced spectral data using the correlation matrix method. Module 7 is used to construct several freshness detection models. It takes the spectral index selected in Module 6 as input and the comprehensive freshness index value of leafy vegetables as output to train the freshness detection models. Module 8 is used to evaluate several freshness detection models and select the best freshness detection model as the freshness detection model for leafy vegetables.
[0016] An electronic device includes a memory and a processor, the memory storing a computer program, characterized in that the processor executes the computer program to implement the steps of the above-described method.
[0017] A computer-readable storage medium for storing computer instructions, characterized in that the computer instructions, when executed by a processor, implement the steps of the above-described method.
[0018] The beneficial effects of the method described in this invention are as follows: (1) This invention establishes an adaptive freshness comprehensive index construction mechanism. Based on the KMO and Bartlett test results of three types of indicators—SPAD, Fv / Fm, and weight loss rate—principal component analysis is used for information compression and principal component extraction when the conditions are met. When the conditions are not met, the CRITIC weighting method is used to quantify the weights from the dual perspectives of index dispersion and conflict. When the adaptability is insufficient, a fusion mechanism is introduced to integrate the two types of results. This mechanism avoids the problems of information redundancy amplification and weight allocation offset caused by fixed single methods or simple linear combinations in the prior art when the index-related structure changes dynamically. It enables the constructed freshness comprehensive index to simultaneously reflect the coupled evolution process of leaf color change, physiological activity decline, and water loss. It is significantly better than conventional selection in terms of consistency, stability, and cross-batch adaptability in the overall freshness change trend characterization, and achieves a synergistic enhancement effect under adaptive matching of multidimensional physiological information structure.
[0019] (2) This invention utilizes a synergistic mechanism of spectral dimensionality reduction and low-dimensional feature space index screening. First, highly correlated band information in the original high-dimensional spectral data is compressed and concentrated into a few principal components to achieve information purification and noise suppression. Then, spectral indices are traversed, screened, and constructed in the low-dimensional feature space after dimensionality reduction, with the maximum correlation coefficient as the criterion for determining the optimal combination of dimensionality-reduced spectral indices. This mechanism overcomes the shortcomings of directly constructing indices on the original high-dimensional spectral data, such as a large number of feature combinations, excessive computation time, easy overfitting of the model, and poor cross-batch adaptability. At the same time, it makes up for the deficiency that the simple principal component analysis (PCA) method cannot obtain spectral indices with a clear mathematical expression. This makes information compression and target response enhancement form an inherent logical dependency in terms of order and function, significantly improving the response stability and cross-sample generalization ability of spectral indices to the freshness comprehensive index, and effectively reducing computational complexity and engineering implementation costs.
[0020] (3) This invention constructs a three-in-one collaborative technical path of comprehensive index construction, dimensionality reduction spectral index optimization, and detection model establishment. First, a comprehensive freshness index integrating multi-source physiological information is constructed through data judgment and adaptive construction, so that the target variable has information integrity and anti-interference ability. Then, spectral dimensionality reduction and multi-dimensional spectral index optimization are carried out around the comprehensive index, so that the selected dimensionality reduction spectral index responds to water absorption characteristics and chlorophyll characteristic absorption simultaneously, enhancing the correspondence between spectral variables and the multi-dimensional comprehensive state of freshness. Finally, a quantitative regression equation and machine learning prediction model are established based on the redundancy-removed spectral index to alleviate the multicollinearity problem in model training and improve the stability and generalization ability of the model. The three are sequential and mutually supportive, and are not independent parallel steps. Compared with a single technical path that only constructs a comprehensive index, only performs spectral dimensionality reduction, or only evaluates model performance, this solution has produced synergistic effects in terms of accuracy, robustness, and engineering deployability of non-destructive freshness detection that cannot be achieved by a single means. Attached Figure Description
[0021] Figure 1 This is a flowchart of the method described in this invention; Figure 2 This is a schematic diagram of the spectral data acquisition device described in this invention; Figure 3 This is a schematic diagram showing the verification results of the quantitative equation described in this invention at the spectral index T; Figure 4 This is a schematic diagram showing the verification results of the quantitative equation described in this invention at the spectral index DI. Figure 5 This is a schematic diagram showing the verification results of the quantitative equation described in this invention at the spectral index TBI-4. Detailed Implementation
[0022] The technical solution of the present invention will now be clearly and completely described with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0023] Example 1 This embodiment provides a method for constructing a freshness detection model for leafy vegetables, the flowchart of which is shown below. Figure 1 As shown, the method includes the following steps: S1. Determine the weight loss rate, SPAD value, and Fv / Fm of leafy vegetables; The relevant operations in step S1 will be introduced with specific examples: In this embodiment, 30 commercially available lettuce plants of relatively uniform size were selected as leafy vegetable samples. To avoid interference from aging, damage, and moisture evaporation of the outer leaves on the freshness test results and to ensure the accuracy and consistency of the experiment, the outermost 2-3 leaves were removed from each sample, and the freshness was tested at room temperature. The entire experimental period was 72 hours, with index measurements performed every 12 hours. To ensure that the leaves measured each time were the same leaves, the 30 lettuce plants were numbered.
[0024] The process for determining the SPAD value of leaves in this embodiment is as follows: The SPAD value of lettuce leaves is measured using a handheld chlorophyll meter (SPAD-502 Plus, Japan). The main vein is avoided during the measurement, and each leaf is measured 3 times. The average value is taken as the SPAD value of that leaf.
[0025] The procedure for determining the maximum photochemical efficiency Fv / Fm in this embodiment is as follows: The maximum photochemical efficiency Fv / Fm of lettuce leaves was measured using a Pocket PEA (Hansatech, UK) plant efficiency analyzer. Each leaf was measured three times, and the average value was taken as the maximum photochemical efficiency Fv / Fm of that leaf.
[0026] The formula for calculating the weight loss rate in this embodiment is: In the formula The percentage of weightlessness is expressed as % . This is the initial weight of the lettuce, in grams. for Weight at any given time, expressed in grams (g).
[0027] The initial weight of the whole lettuce head was determined using an electronic balance with an accuracy of 0.01 g. Calculate the weight loss rate, where the weight loss rate is the whole-plant weight loss rate of the corresponding numbered lettuce.
[0028] S2. Based on the indicators measured in step S1, conduct variable correlation and fitness tests; The relevant operations in step S2 will be introduced with specific examples: By analyzing the changes in SPAD value, Fv / Fm, and weight loss rate of lettuce leaves (selected in step S1) during storage, it was found that a single indicator cannot fully reflect the changes in lettuce freshness and cannot comprehensively evaluate lettuce freshness. Therefore, this invention considers three aspects: leaf color and nutritional status (SPAD), physiological state (Fv / Fm), and water loss (weight loss rate), and comprehensively processes the indicators by combining principal component analysis (PCA) and CRITIC weighting methods. PCA, based on data correlation, can extract principal components from the data, condense information, and simplify multidimensional data. Its advantage lies in effectively eliminating collinearity, reducing redundant information, and making the analysis results more robust. The CRITIC method comprehensively calculates the objective weights of each indicator based on the magnitude of variation and the conflict between indicators. The magnitude of variation of each indicator is measured by the standard deviation; the conflict between indicators is calculated by the correlation coefficient.
[0029] S3. Using the test results of step S2 as the judgment condition, construct an adaptive fusion freshness comprehensive evaluation mechanism based on principal component analysis and CRITIC method, and screen the construction method of freshness comprehensive index. The relevant operations in step S3 will be introduced with specific examples: This step, based on the results of the KMO test and Bartlett's test of sphericity in step S2, determines whether the data meets the applicable conditions for principal component analysis. The KMO statistic measures the strength of the correlation between variables and the suitability of the data for factor analysis; its value ranges from 0 to 1. Generally, a KMO value closer to 1 indicates a stronger correlation between variables, making it more suitable for factor or principal component analysis; conversely, a KMO value closer to 0 indicates a weaker correlation, making it unsuitable for dimensionality reduction analysis. Typically, a KMO value greater than 0.9 indicates very good suitability, 0.8-0.9 indicates suitable suitability, 0.7-0.8 indicates moderately suitable suitability, 0.6-0.7 indicates weak suitability, and less than 0.5 indicates unsuitability for factor analysis. The Bartlett's test of sphericity tests whether variables are independent; a significance level p ≤ 0.01 indicates that the data is suitable for factor or principal component analysis.
[0030] Therefore, when the test results (weights for constructing the comprehensive freshness index) meet the requirements, principal component analysis is used to construct the comprehensive evaluation index; when the test results do not meet the requirements, the CRITIC method is used for weight calculation. To improve the stability and adaptability of the comprehensive evaluation results, a fusion mechanism is introduced between the principal component analysis results and the CRITIC results. Specifically, the comprehensive freshness evaluation mechanism is as follows: ,in, A method for constructing a comprehensive index of freshness. Principal component analysis method, This is the CRITIC method.
[0031] The method for determining whether the weighting of the comprehensive freshness index meets the requirements is as follows:
[0032] in, Weights were constructed for the comprehensive freshness index, KMO represents the KMO test result, and p represents the Bartlett's sphericity test result. In this embodiment, the Bartlett's sphericity test p-value is 0, and the KMO value is 0.74. Therefore, principal component analysis is used to construct the comprehensive freshness index in this embodiment. Principal component analysis was performed on the SPAD value, Fv / Fm, and weight loss rate, and the results are shown in Table 1. Based on the principle that the eigenvalue is ≥1, the first principal component was extracted, with a cumulative variance contribution rate of 87.95%, indicating that the extracted first principal component contains 87.95% of the original data information.
[0033] Table 1
[0034] The principal component loading matrices for each experimental index are shown in Table 2. The loading coefficients of SPAD, weight loss rate, and Fv / Fm on principal component 1 are 0.920, 0.960, and 0.933, respectively, indicating that these three indices have large positive coefficient values. When the first principal component is large, the values of these three indices are also large. The communality (common factor variance) of the three is 0.846, 0.921, and 0.871, respectively, indicating that principal component 1 can effectively explain more than 84% of the variance of each index, demonstrating high information retention. Therefore, principal component 1 can serve as a core factor comprehensively reflecting the changes in freshness of lettuce during storage, providing a basis for constructing a comprehensive freshness evaluation index.
[0035] Table 2
[0036] S4. Based on the method selected in step S3, obtain the comprehensive freshness index value of leafy vegetables; The relevant operations in step S4 will be introduced with specific examples: In this embodiment, the process of obtaining the comprehensive freshness index value of leafy vegetables is as follows: Divide the principal component loadings of each test index by the square root of the corresponding principal component eigenvalues to obtain the principal component coefficients for each test index. Use these principal component coefficients as weights to establish the formula for calculating the principal component score. In the formula, F represents the principal component score, and X1, X2 and X3 represent the SPAD value, weight loss rate and Fv / Fm standardized values, respectively.
[0037] Taking the principal component coefficients of the SPAD value as an example, In this embodiment, the principal component coefficients are retained to 3 decimal places.
[0038] In this study, since only principal component 1 was extracted for the construction of the comprehensive index, its variance contribution rate was 87.95% ( Therefore, the overall score is equivalent to the score of principal component 1, and no further weighting is required. The comprehensive index for lettuce freshness is constructed as follows: .
[0039] In constructing a comprehensive evaluation index for the freshness of leafy vegetables, this invention does not rigidly employ Principal Component Analysis (PCA) or CRITIC weighting methods, nor does it simply superimpose the results of the two methods linearly. Instead, it establishes an adaptive construction mechanism based on data judgment: "data judgment - method matching - method determination." For three types of indicators—SPAD (reflecting chlorophyll and nutritional status), Fv / Fm (reflecting maximum photochemical efficiency and physiological status), and weight loss rate (reflecting water loss and tissue degradation)—which originate from different aspects and whose related structures change in stages during storage, this invention first uses KMO and Bartlett tests to determine the original indicators. When the determination conditions are met, PCA is used for information compression and principal component extraction. When the conditions are not met, the CRITIC method is used for objective weighting, quantifying the information entropy of the evaluation parameters from the dual perspectives of indicator dispersion and collinearity analysis. When the adaptability is insufficient, a fusion mechanism is further introduced to integrate the two types of results.
[0040] Existing technologies typically employ a single method or a simple linear combination of PCA and CRITIC results. However, these methods fail to consider the dynamic changes in the correlation structure of variables, easily leading to information redundancy under high correlation conditions and weight distortion under weak correlation conditions, thus making it difficult to guarantee the stability and consistency of the comprehensive evaluation index. This invention, through a technical approach of data structure determination and method matching, enables information compression and differentiation to achieve synergistic enhancement under different data structures, rather than simple superposition, thereby fundamentally avoiding the problems of redundant information amplification or weight allocation shift.
[0041] Therefore, the comprehensive freshness index constructed in this invention can simultaneously reflect the coupled evolution process of leaf color change, physiological activity decline, and water loss, exhibiting significant advantages in terms of consistency, stability, and batch adaptability in characterizing the overall freshness change trend. This technical effect is not achieved through simple splicing using conventional methods, but rather through a structurally adaptive matching mechanism for the coupled features of multidimensional physiological information. It possesses strong stability and operability, making it particularly suitable for evaluating the freshness of leafy vegetables with high water content, rapid aging, and easily changing index-related structures. It can provide a continuous, quantitative, and scalable unified evaluation standard for storage management and quality monitoring.
[0042] S5. Collect the raw spectral data of leafy vegetables and perform dimensionality reduction on the raw spectral data to obtain the dimensionality-reduced spectral data. The relevant operations in step S5 will be introduced with specific examples: like Figure 2As shown, this embodiment uses a fiber optic spectrometer to collect the visible-near-infrared reflectance spectrum of lettuce leaves. During data acquisition, the fiber optic cable is first connected to the spectrometer and the light source. Then, the fiber optic cable is fixed using a reflectance probe holder, ensuring a 45° angle between the cable and the sample. The spectrometer is preheated for 10 minutes before acquisition, followed by white board calibration. Calibration is considered successful when the white board's reflectance reaches 100%. White board calibration is performed every 30 minutes throughout the acquisition process. Three spectral curves are collected from each leaf, avoiding the main vein, and the average value is taken as the visible-near-infrared reflectance spectrum data for that leaf.
[0043] These indicators were chosen for detection in this embodiment because they can reflect the physiological state and quality changes of leafy vegetables from multiple perspectives, including moisture status, pigment content, and photosynthetic system function. Furthermore, these indicators can all be obtained through non-destructive measurement methods, allowing data collection without damaging leaf tissue. This ensures the integrity of the vegetables, provides a reliable data foundation for subsequent spectral detection, and meets the practical needs of rapid, online monitoring.
[0044] To address the challenges posed by high-dimensional nonlinear spectral data, which suffers from large data volume, noise, redundancy, and multicollinearity, this embodiment employs PCA to reduce the dimensionality of the original spectral data. This simplifies multiple correlated trait indicators into a few comprehensive indicators that reflect the original main trait indicators, thereby reducing data dimensionality and improving model accuracy and computational efficiency.
[0045] This embodiment employs principal component analysis (PCA) to reduce the dimensionality of the original spectrum, and selects 21 principal components based on the principle of eigenvalues ≥1 and cumulative contribution rates ≥85%. These 21 components, with a cumulative contribution rate of 97.10%, indicate that the selected principal components highly cover the effective information of the original data. Constructing spectral indices on this basis effectively reduces data dimensionality and computational burden, laying a reliable data foundation for subsequent modeling and analysis.
[0046] S6. Using the correlation matrix method, select the spectral index with the highest correlation coefficient with the comprehensive freshness index value of leafy vegetables from the dimensionality-reduced spectral data. The relevant operations in step S6 will be introduced with specific examples: To extract the principal component position combination with the highest correlation between the comprehensive freshness index and the spectral index, the correlation matrix method was used to extract one-dimensional, two-dimensional, and three-dimensional (1D, 2D, 3D) spectral indices, respectively. The calculation formulas are as follows: , , , , , , , In the formula , and It can be any principal component.
[0047] This embodiment performs principal component dimensionality reduction within the full spectral wavelength range of 400nm-950nm. Based on the dimensionality-reduced data, spectral indices are calculated for all combinations of principal components. Correlation analysis is then performed between the calculated spectral indices and the comprehensive freshness index to determine the optimal dimensionality-reduced spectral indices. The calculation formulas for the two-dimensional (2D) and three-dimensional (3D) spectral indices are selected based on traditional methods for constructing plant spectral indices, which to some extent reduces the interference of external lighting conditions and background noise. These spectral indices enhance the responsiveness to changes in the internal composition of the sample, facilitating the capture of subtle differences in complex systems, thereby improving the robustness and prediction accuracy of the model.
[0048] In this embodiment, the optimal principal component combination of the above-mentioned 1D, 2D, and 3D spectral indices is extracted using the correlation matrix method, with the combination having the highest correlation coefficient with the comprehensive freshness index value of leafy vegetables. , , The principal component positions were used as the optimal combination for calculating the dimensionality-reduced spectral indices, and the results are shown in Table 3.
[0049] Table 3
[0050] The proposed dimensionality-reduced spectral index construction scheme addresses the problems of large number of variables, high correlation between bands, severe multicollinearity, and noise superposition in the original high-dimensional spectral data through a collaborative mechanism of "PCA dimensionality reduction - low-dimensional feature space index screening." Directly constructing spectral indices based on the original data is susceptible to interference from redundant information, resulting in limited index stability and generalization ability. While PCA is conventionally used for dimensionality reduction to compress data, it does not address the subsequent optimization of the index expression. Furthermore, dimensionality reduction using PCA alone cannot directly yield a clearly defined mathematical expression. This scheme first uses PCA to reduce the dimensionality of the original spectral data, concentrating relevant information in the high-dimensional space into a few principal components, achieving information purification and compression. Then, index screening and construction are performed in the optimized low-dimensional feature space, ensuring that index calculation is based on information concentration and noise suppression, while also possessing a clear expression and application feasibility, thus achieving the construction of dimensionality-reduced spectral indices. Compared to directly constructing indices in the original bands or simple PCA modeling, this scheme establishes an inherent logical dependency in terms of sequence and function, enabling synergistic optimization of information compression and target response enhancement. This significantly improves the stability and cross-sample adaptability of the indices, while effectively reducing computational complexity and engineering implementation costs. This technical effect cannot be achieved by a single technique, nor can it be accomplished based on conventional dimensionality reduction or indices combination approaches. Rather, it arises from the synergistic effect of data dimensionality reduction and indices expression optimization, demonstrating promising application potential in research using spectral data to detect comprehensive evaluation indicators of leafy vegetable freshness.
[0051] S7. Construct several freshness detection models, using the spectral index selected in step S6 as input and the comprehensive freshness index value of leafy vegetables as output, and train the freshness detection models. The relevant operations in step S7 will be introduced with specific examples: The aforementioned freshness detection models are divided into two categories: one category contains several quantitative equations, and the other category contains several machine learning models.
[0052] Freshness detection model based on quantitative equations To further reveal the quantitative response relationship between the dimensionality reduction spectral index and the comprehensive freshness index, and to avoid subjective bias caused by human selection during data partitioning, thereby improving the stability and generalization ability of the model, the Kennard-Stone (KS) algorithm was used to partition the sample set (samples selected in step S1) into training and test sets at a 4:1 ratio before modeling. The KS method uses the Euclidean distance between samples in the dataset to select representative samples. By calculating the Euclidean distance between each pair of samples in the dataset, the sample pair with the largest distance is selected as the initial representative sample, and samples with the largest distance from the selected samples are gradually selected until the required number of representative samples is reached, thus ensuring that the training set has good representativeness and the test set has reasonable independence. In the model building stage, 80% of the sample data is selected to establish a quantitative prediction equation, using the optimal dimensionality reduction spectral index as the input variable and the comprehensive freshness index as the output variable, to train the freshness detection model.
[0053] In this embodiment, the fitting forms of several quantitative equations include: linear, quadratic, cubic, logarithmic, and exponential functions.
[0054] Machine learning-based freshness detection model To further explore the predictive effect of the optimal dimensionality reduction spectral index, the optimal 1D, 2D, and 3D spectral indices were used as inputs, and the overall freshness was used as the output. PSO-SVR, BP-NN, and ELM models were established as machine learning-based freshness detection models. The training and test sets were randomly divided in a 4:1 ratio to train and validate several machine learning models.
[0055] S8. Evaluate several freshness detection models and select the best freshness detection model as the freshness detection model for leafy vegetables.
[0056] The relevant operations in step S8 will be introduced with specific examples: S81. Evaluate the freshness detection models separately and select the first-stage freshness detection model; The first-stage freshness detection model includes: the optimal quantitative equation and the optimal machine learning model; This example uses various function forms, including linear, quadratic, cubic, logarithmic, and exponential functions, for fitting, and uses the coefficient of determination R0. 2 The model performance was compared and judged using the main evaluation indicators. The comparison results are shown in Table 4. In Table 4, the performance of each quantitative equation is... This indicates the input (the spectral index selected in step S6). This indicates the output (a comprehensive index value of the freshness of leafy vegetables).
[0057] Among the three quantitative equations established, the cubic equation established by the 1D dimensionality-reduced spectral index T has the best fitting effect. Therefore, only the cubic equation is shown in Table 4. 2 The F-value is 0.768, and the F-value is 181.176. The F-value is the statistic of the F-test, which can be used to help select the optimal quantitative equation. The larger the F-value, the greater the variance explained by the model compared to the random error, meaning the model is more significant overall.
[0058] Table 4
[0059] To evaluate the detection effectiveness of the quantitative equation, this invention validates the quantitative equation using the remaining 20% of the samples, such as... Figure 3 , 4 As shown in Figure 5, the verification results R of the three quantitative equations are... 2 All values were 0.80, but the RMSE of the quantitative equation established by the 1D dimensionality-reduced spectral index T was the smallest at 0.78. Therefore, based on the test results, the cubic fitting equation of the 1D dimensionality-reduced spectral index T was determined to be the best quantitative equation for preliminary diagnosis of freshness.
[0060] To evaluate the detection performance of the machine learning models, the trained PSO-SVR, BP-NN, and ELM models were validated using a test set. The trained PSO-SVR, BP-NN, and ELM models performed well in R... 2 The evaluation results on RMSE are shown in Table 5. Among them, the PSO-SVR model performed the best and is denoted as the best machine learning model. The test set R p 2 and RMSE p The values were 0.85 and 0.64, respectively. This indicates that visible-near-infrared reflectance spectroscopy can achieve rapid detection of the overall freshness of leafy vegetables.
[0061] Table 5
[0062] In this embodiment, R 2 The formula for calculating the root mean square error (RMSE) is as follows: , In the formula, N is the number of samples. For the first The actual value of each sample For the first The predicted value for each sample, This is the average of the actual values for all samples.
[0063] The data processing method is as follows: the acquired spectral data is exported using AvaSoft 8 spectral acquisition software, the exported basic data is input and analyzed using Excel 2010, the model is trained and tested using Matlab 2023b software, and principal component analysis and quantitative equation construction are performed using SPSS 23.
[0064] Machine learning methods include PSO-SVR, BP-NN, and ELM models. SVR, based on VC dimension theory and the principle of structural risk minimization, can fully utilize limited sample information to seek the optimal balance between model complexity and learning ability, thus achieving the best generalization ability. To prevent the model from getting trapped in local optima and to find the optimal SVR parameters, this invention uses the Particle Swarm Optimization (PSO) algorithm to optimize SVR. PSO is a bio-inspired method in the field of computational intelligence, possessing extremely strong parameter optimization capabilities. The PSO algorithm is simple, easy to implement, and has good optimization performance and convergence characteristics, making it particularly suitable for high-dimensional complex optimization problems. BPNN is a typical multi-layer feedforward network architecture that adjusts its internal parameters through an error backpropagation mechanism. This model is widely used in solving complex modeling problems such as pattern recognition, nonlinear regression, and classification. BPNN has powerful general function approximation capabilities, automatically learning and combining abstract features to fit highly nonlinear mapping functions, with the potential to achieve extremely high theoretical accuracy. Extreme Learning Machine (ELM) is a machine learning method based on feedforward neural networks, with advantages such as fast training speed, wide versatility, and small error.
[0065] This invention is not a simple superposition of three techniques: constructing a comprehensive freshness index, spectral dimensionality reduction and index screening, and model building. Instead, it forms a complete technical process with inherent logical dependencies. First, a comprehensive evaluation method (principal component, CRITIC, principal component + CRITIC) is determined through data analysis to construct a comprehensive freshness index, integrating weight loss rate, SPAD, and Fv / Fm in a weighted manner. These three indices correspond to water status, pigmentation, and photosynthetic function, respectively, reflecting the freshness of leafy vegetables from multiple perspectives. This transforms the target variable from multiple indicators into a comprehensive evaluation index with complete information, improving the consistency and anti-interference ability of the target variable. Based on this, spectral dimensionality reduction and multidimensional spectral index optimization are carried out to construct a dimensionality-reduced spectral index. Since the comprehensive index integrates multidimensional physiological information, spectral feature extraction no longer revolves around a single physiological parameter but rather around a multidimensional physiological state. This allows the constructed dimensionality-reduced spectral index to simultaneously respond to water absorption characteristics, chlorophyll absorption characteristics, etc., thereby enhancing the correlation between variables and changes in freshness. Finally, a detection model is established through quantitative regression equations and machine learning models. Since the input variables have undergone spectral redundancy removal, the multicollinearity problem during model training is alleviated, thereby improving model stability and generalization ability. These three aspects constitute a collaborative technical path of "comprehensive index construction - dimensionality reduction spectral index optimization - detection model establishment," rather than independent parallel technical steps.
[0066] Compared with constructing only a comprehensive freshness index, simple physiological indicators cannot achieve rapid and non-destructive detection; compared with only performing spectral dimensionality reduction and screening for the optimal dimensionality-reduced spectral index, it may lead to insufficient explanatory power of the model for physiological states; compared with only evaluating model performance, if there is a lack of comprehensive index construction and dimensionality-reduced spectral index construction, the model will lack reliable data input, resulting in limited model accuracy and insufficient robustness.
[0067] The changes in the freshness of leafy vegetables are essentially a synchronous process of water loss, chlorophyll degradation, and photosynthetic function decline. The comprehensive index constructed in this invention is highly consistent with the senescence mechanism of leafy vegetables. Furthermore, by combining spectral dimensionality reduction and index optimization, a rapid and non-destructive characterization of this comprehensive state is achieved, reducing redundant variables while ensuring information integrity and improving computational efficiency and robustness. The overall process is modular and easy to operate, applicable to different varieties, storage stages, and sampling conditions, and has strong scalability and engineering adaptability.
[0068] S82. Evaluate the first-stage freshness detection models (best quantitative equation and best machine learning model) respectively, and take the first-stage freshness detection model with the best evaluation result as the best freshness detection model.
[0069] Using the coefficient of determination R 2The root mean square error (RMSE) is used to evaluate the optimal quantitative equation and the optimal machine learning model, with R being the most significant factor in the evaluation results. 2 The detection result with the largest ratio of RMSE is the best detection result, and the first-stage freshness detection model corresponding to the best detection result is the best freshness detection model.
[0070] Quantitative equation models can intuitively reflect the relationship between spectral indices and comprehensive freshness indicators. They are characterized by simple model structure, low computational cost, and fast response speed, making them suitable for application scenarios where the variable relationship is relatively stable and real-time requirements are high. Machine learning models, on the other hand, fit complex data relationships through nonlinear mapping capabilities. They can effectively characterize the nonlinear variation characteristics between spectral indices and comprehensive freshness indicators, and usually have strong fitting ability and generalization performance. They are suitable for application scenarios with complex data structures or significant nonlinear characteristics.
[0071] Based on the above characteristics, this invention selects models according to actual application needs. When the application scenario has high requirements for computational efficiency and response speed or the device's computing resources are limited, a quantitative equation model is used for detection. When the application scenario is a complex environmental condition or has high requirements for prediction accuracy, both a quantitative equation model and a machine learning model are constructed, and the two types of models are compared. The model with the best performance is automatically selected as the final detection result, thereby achieving a balance between detection accuracy and computational efficiency under different application conditions.
[0072] Example 2 This embodiment further defines Embodiment 1, and demonstrates the construction of weights for the comprehensive freshness index. The method for constructing a comprehensive freshness index when the value is between 0 and 1.
[0073] For example: constructing weights for a comprehensive freshness index The weighting is set to 0.3, meaning that this embodiment employs a combined weighting strategy of 0.3 principal component analysis and 0.7 CRITIC method to construct a comprehensive index for the freshness of leafy vegetables. Essentially, this involves linearly fusing the comprehensive score obtained from principal component analysis with the weighted score determined by the CRITIC method according to a set ratio, thus balancing the advantages of both objective weighting methods. The specific implementation process is as follows: First, the three indicators measured during the storage of leafy vegetables—weight loss rate, SPAD value, and Fv / Fm—are standardized to eliminate dimensional differences. Then, principal component analysis and CRITIC weighting are performed respectively. In the principal component analysis path, principal components satisfying an eigenvalue greater than 1 are extracted, and the principal component score F is calculated. If only the first principal component is extracted, this score is the freshness evaluation value based on the principal component dimension. In the CRITIC path, an objective weight vector is calculated based on the contrast strength represented by the standard deviation of each indicator and the conflict represented by the correlation coefficient between indicators. The standardized data is then linearly weighted with the weights to obtain the CRITIC comprehensive score. Finally, after normalizing the principal component score F and the CRITIC composite score to the same dimension interval, they are weighted and summed at a ratio of 0.3 and 0.7, respectively. The resulting value is the comprehensive freshness index of leafy vegetables. This combined strategy retains the dimensionality reduction and compression ability of principal components on variable correlations, while also incorporating the CRITIC method's fine characterization of index dispersion and independence. It is particularly suitable for transitional situations where data characteristics are between strong and weak correlations, making the final evaluation results more robust to the sample data structure.
[0074] Example 3 This embodiment further defines Embodiment 1. This embodiment provides a system for constructing a freshness detection model for leafy vegetables. The system is used to implement the method described in Embodiment 1, and the system includes the following modules: Module 1 is used to determine the weight loss rate and SPAD of leafy vegetables. Values and Fv / Fm; Module 2 is used to conduct correlation and fitness tests on variables based on the indicators measured in Module 1. Module 3 is used to construct an adaptive fusion freshness comprehensive evaluation mechanism based on principal component analysis and the CRITIC method, using the test results of Module 2 as the judgment condition, and to screen the construction method of the comprehensive freshness index. Module 4 is used to obtain the comprehensive freshness index value of leafy vegetables based on the methods selected in Module 3; Module 5 is used to collect the raw spectral data of leafy vegetables and perform dimensionality reduction processing on the raw spectral data to obtain the dimensionality-reduced spectral data. Module 6 is used to select the spectral index with the highest correlation coefficient with the comprehensive freshness index value of leafy vegetables from the dimensionality-reduced spectral data using the correlation matrix method. Module 7 is used to construct several freshness detection models. It takes the spectral index selected in Module 6 as input and the comprehensive freshness index value of leafy vegetables as output to train the freshness detection models. Module 8 is used to evaluate several freshness detection models and select the best freshness detection model as the freshness detection model for leafy vegetables.
Claims
1. A method for constructing a freshness detection model for leafy vegetables, characterized in that, The method includes the following steps: S1. Determine the weight loss rate, SPAD value, and Fv / Fm of leafy vegetables; S2. Based on the indicators measured in step S1, conduct variable correlation and fitness tests; S3. Using the test results of step S2 as the judgment condition, construct an adaptive fusion freshness comprehensive evaluation mechanism based on principal component analysis and CRITIC method, and screen the construction method of freshness comprehensive index. S4. Based on the method selected in step S3, obtain the comprehensive freshness index value of leafy vegetables; S5. Collect the raw spectral data of leafy vegetables and perform dimensionality reduction on the raw spectral data to obtain the dimensionality-reduced spectral data. S6. Using the correlation matrix method, select the spectral index with the highest correlation coefficient with the comprehensive freshness index value of leafy vegetables from the dimensionality-reduced spectral data. S7. Construct several freshness detection models, using the spectral index selected in step S6 as input and the comprehensive freshness index value of leafy vegetables as output, and train the freshness detection models. S8. Evaluate several freshness detection models and select the best freshness detection model as the freshness detection model for leafy vegetables.
2. The method for constructing a freshness detection model for leafy vegetables according to claim 1, characterized in that, The tests for variable correlation and fitness include the KMO test and the Bartlett's test for sphericity.
3. The method for constructing a freshness detection model for leafy vegetables according to claim 2, characterized in that, The adaptive fusion freshness comprehensive evaluation mechanism based on principal component analysis and the CRITIC method is constructed as follows: in, Weights were constructed for the comprehensive freshness index, KMO represents the KMO test result, and p represents the Bartlett's sphericity test result. The comprehensive freshness evaluation mechanism is as follows: ,in, A method for constructing a comprehensive index of freshness. Principal component analysis method, This is the CRITIC method.
4. The method for constructing a freshness detection model for leafy vegetables according to claim 3, characterized in that, In step S4, the process of obtaining the comprehensive freshness index value of leafy vegetables is as follows: using the method selected in step S3, the index measured in step S1 is analyzed to obtain the comprehensive freshness index value of leafy vegetables.
5. The method for constructing a freshness detection model for leafy vegetables according to claim 4, characterized in that, In step S5, the original spectral data is dimensionality reduced using principal component analysis.
6. The method for constructing a freshness detection model for leafy vegetables according to claim 5, characterized in that, The spectral index includes at least one of a one-dimensional spectral index, a two-dimensional spectral index, and a three-dimensional spectral index; The aforementioned freshness detection models are divided into two categories: one category contains several quantitative equations, and the other category contains several machine learning models. The fitting forms of several quantitative equations include: linear, quadratic, cubic, logarithmic, and exponential functions; Several machine learning methods include: PSO-SVR, BP-NN, and ELM models.
7. The method for constructing a freshness detection model for leafy vegetables according to claim 6, characterized in that, The selection process for the optimal freshness detection model is as follows: S81. Evaluate the freshness detection models separately and select the first-stage freshness detection model; The first-stage freshness detection model includes: the optimal quantitative equation and the optimal machine learning model; S82. Evaluate the first-stage freshness detection models respectively, and take the first-stage freshness detection model with the best evaluation result as the best freshness detection model.
8. A system for constructing a freshness detection model for leafy vegetables, characterized in that, The system is used to implement the method according to any one of claims 1 to 7, and the system includes the following modules: Module 1 is used to determine the weight loss rate, SPAD value, and Fv / Fm of leafy vegetables; Module 2 is used to conduct correlation and fitness tests on variables based on the indicators measured in Module 1. Module 3 is used to construct an adaptive fusion freshness comprehensive evaluation mechanism based on principal component analysis and the CRITIC method, using the test results of Module 2 as the judgment condition, and to screen the construction method of the comprehensive freshness index. Module 4 is used to obtain the comprehensive freshness index value of leafy vegetables based on the methods selected in Module 3; Module 5 is used to collect the raw spectral data of leafy vegetables and perform dimensionality reduction processing on the raw spectral data to obtain the dimensionality-reduced spectral data. Module 6 is used to select the spectral index with the highest correlation coefficient with the comprehensive freshness index value of leafy vegetables from the dimensionality-reduced spectral data using the correlation matrix method. Module 7 is used to construct several freshness detection models. It takes the spectral index selected in Module 6 as input and the comprehensive freshness index value of leafy vegetables as output to train the freshness detection models. Module 8 is used to evaluate several freshness detection models and select the best freshness detection model as the freshness detection model for leafy vegetables.
9. An electronic device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1-7.
10. A computer-readable storage medium for storing computer instructions, characterized in that, When the computer instructions are executed by the processor, they implement the steps of the method according to any one of claims 1-7.