Dependent fruit freshness prediction method and system based on smell information
By optimizing the extreme learning machine (ELM) structure and odor feature selection through an improved chaotic sparrow search algorithm and binary black wolf optimization algorithm, the instability and local optimality problems of the multi-fruit freshness prediction model were solved, and higher prediction accuracy and stability were achieved.
Patent Information
- Application Number
- CN202510733653.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-04
- Publication Date
- 2025-09-16
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The prediction accuracy of the multi-fruit freshness prediction model in the existing technology is unstable, easily affected by random initialization, the number of hidden layer nodes is difficult to determine, and the odor feature selection method is prone to fall into local optimality, resulting in insufficient model generalization ability.
An improved chaotic sparrow search algorithm is used to optimize the extreme learning machine (ELM) structure. The simulated annealing method is combined to adjust the acceptance probability of individual sparrows. A variety of chaotic mapping strategies are used to enhance population diversity and local mining capabilities. The binary black wolf optimization algorithm is combined to select odor features and construct the optimal prediction model.
The stability and accuracy of the Duoyiguo freshness prediction model are improved, the generalization ability of the model is enhanced, local optimality is avoided, and the accuracy and consistency of the prediction are improved.
Smart Images

Figure CN120654112A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of odor recognition, and in particular to a method and system for predicting the freshness of multi-fruits based on odor information. Background Art
[0002] The freshness of doyigo is a key indicator for evaluating its quality, remaining shelf life, and commercial value. Currently, the freshness assessment of doyigo mainly relies on manual sensory scoring, which has problems such as inconsistent evaluation standards and susceptibility to subjective factors, making it difficult to achieve quantitative quality traceability between the place of production and the place of sale. In recent years, non-destructive testing technologies represented by computer vision, electronic noses, and hyperspectral imaging have been widely used in the field of fruit quality assessment, providing new ideas for objectively and accurately predicting the freshness of doyigo. Studies have shown that the odor of the fruit is closely related to the freshness of doyigo. The content and composition of volatile components in doyigo at different storage stages vary significantly, and freshness can be determined by analyzing odor changes. However, existing research mainly focuses on odor feature extraction and classification model construction, while research on prediction model optimization and continuous freshness prediction is relatively lacking, and the prediction accuracy and stability need to be further improved.
[0003] In terms of prediction models, the Extreme Learning Machine (ELM) has become a research hotspot for fruit quality prediction due to its advantages, such as rapid learning speed and strong generalization. However, the structural parameters of the ELM model are typically determined through random generation, which is susceptible to initialization effects and leads to unstable prediction accuracy. Furthermore, the number of nodes in the ELM hidden layer is often set empirically, making it difficult to determine the optimal network structure. This can easily lead to underfitting or overfitting, reducing the model's generalization ability. To improve the prediction performance of the ELM, some researchers have adopted swarm intelligence optimization algorithms, such as genetic algorithms and particle swarm optimization, to select its structural parameters, achieving some results. However, these algorithms are prone to falling into local optima, and their optimization efficiency and search accuracy need to be improved. The Sparrow Search Algorithm (SSA), a new swarm intelligence optimization algorithm, features good population diversity and rapid convergence, but its exploration capability and optimization accuracy still need further improvement. Summary of the Invention
[0004] In response to the problem of unstable multi-fruit freshness prediction in the existing technology, the present application provides a multi-fruit freshness prediction method and system based on odor information. The extreme learning machine (ELM) structure is optimized by an improved chaotic sparrow search algorithm. On the one hand, chaotic sequences generated by multiple chaotic mapping strategies are introduced to enhance population diversity and improve the algorithm's ability to escape local optimality. On the other hand, the acceptance probability of individual sparrows is adjusted by combining the simulated annealing idea, and the local mining capability is strengthened in the later stage of the search, thereby improving the stability of the model while ensuring prediction accuracy.
[0005] The purpose of this application is achieved through the following technical solutions.
[0006] One aspect of the present application provides a method for predicting the freshness of doyigo fruit based on odor information, including: S1, collecting doyigo fruit samples of different maturity and origin, and obtaining odor data of the corresponding samples; constructing a doyigo fruit odor dictionary based on the doyigo fruit odor components, and performing feature extraction on the sample odor data according to the doyigo fruit odor dictionary to obtain the doyigo fruit odor feature; S2, calculating the correlation coefficient between the doyigo fruit odor feature and the doyigo fruit freshness, and performing combined optimization using a binary black wolf optimization algorithm based on the correlation coefficient to obtain the optimal odor feature; S3, using the optimal odor feature as the input layer and the doyigo fruit freshness as the output layer node to construct a single hidden layer extreme learning machine ELM structure; S4, using an improved chaotic sparrow search algorithm to optimize the hidden layer connection weights and thresholds of the extreme learning machine ELM structure to obtain a doyigo fruit freshness prediction model; wherein, the improved chaotic sparrow search algorithm updates the position of sparrow individuals during the iterative optimization process by using a chaotic sequence generated by alternately using logistic mapping, Chebyshev mapping, and Tent mapping. S5, inputting the collected odor data of the to-be-predicted Duoyiguo sample into the Duoyiguo freshness prediction model to obtain the Duoyiguo freshness prediction result of the corresponding sample.
[0007] Furthermore, S4 uses an improved chaotic sparrow search algorithm to optimize the hidden layer connection weights and thresholds of the extreme learning machine ELM structure to obtain a multi-fruit freshness prediction model, including: S41, initializing the sparrow population, encoding each sparrow individual as a set of hidden layer connection weights and thresholds, and the population size is N; initializing the maximum flight speed V of the sparrow individual max , maximum number of iterations T max, inertia weight w, acceleration constants c1 and c2, as well as the initial temperature T0 and cooling coefficient α of simulated annealing; S42, randomly generate three different chaotic sequences, namely Logistic mapping sequence, Chebyshev mapping sequence and Tent mapping sequence, each with a length of N; let t = 1, select the Logistic mapping sequence as the initial chaotic sequence; S43, according to the hidden layer connection weights and thresholds encoded by each sparrow individual in S41, construct the corresponding ELM structure, and use the training samples to calculate the hidden layer output matrix H; use the ELM structure corresponding to each sparrow individual to predict the freshness of the multi-fruit; calculate the mean square error MSE between the predicted freshness and the expected output, and take -MSE as the fitness value of the corresponding individual.
[0008] S44, divide the sparrow individuals into explorers, followers and vigilant individuals according to the fitness values of S43; S45, use the current chaotic sequence to update the position and speed of the explorer individuals; S46, update the position of the follower individuals according to the optimal position of the explorer individuals; S47, randomly select an explorer individual as the center, and randomly fly within the preset range of the center to obtain the updated position of the vigilant individuals; S48, calculate the average fitness value of the sparrow population after update. If the improvement of the average fitness value of several consecutive iterations is less than the set threshold, switch to the next chaotic sequence in the order of Logistic mapping sequence, Chebyshev mapping sequence and Tent mapping sequence, and set t=t+1.
[0009] S49, calculate the fitness value corresponding to the new position of the explorer individual. If the fitness of the new position is better than the original position, the new position is accepted; otherwise, the new position is accepted with probability exp(-ΔE / T), where ΔE is the fitness difference between the new and old positions, T is the current temperature, and the update formula is T(t+1)=αT(t); S410, when the maximum number of iterations T is reached, max Or when the improvement of the optimal fitness value after several consecutive iterations is less than the set threshold, stop the iteration and output the hidden layer connection weights and thresholds corresponding to the current global optimal position as the optimal parameters of ELM; otherwise, return to S43; S411, use the optimal hidden layer connection weights and thresholds obtained in S410 to construct the corresponding ELM structure, and use the training samples to train the ELM to obtain a multi-fruit freshness prediction model.
[0010] Among them, in the extreme learning machine (ELM) model, the hidden layer connection weight and threshold are two important parameters that determine the network structure and mapping ability of the ELM. The hidden layer connection weight refers to the connection weight matrix between the input layer nodes and the hidden layer nodes, represented by W; the threshold refers to the bias term of the hidden layer node, represented by b. In the ELM model, the hidden layer connection weight W and the threshold b are usually randomly generated and do not need to be adjusted through iterative training like traditional neural networks. However, the values of W and b will directly affect the generalization performance of ELM, so optimization selection is required. In the scheme of the present application, W and b are used as the encoding of the sparrow individual, and the chaotic sparrow search algorithm is used for optimization search to find the optimal W and b combination, thereby constructing the ELM freshness prediction model with the best performance. Each sparrow individual corresponds to a set of candidate W and b values, and the fitness value (the negative of the prediction error) is used to evaluate the quality of the individual.
[0011] Explorers are individuals within a sparrow population, primarily responsible for global exploration and finding promising new areas during the search process. Their search strategies typically exhibit strong randomness and diversity, enabling them to search extensively across the solution space, escape local optima, and discover better solutions. In this application's solution, the position updates of individual explorers follow the velocity-position update formula of the classic particle swarm optimization (PSO) algorithm, while also introducing a chaotic sequence to generate random numbers to enhance the randomness and diversity of the search.
[0012] Followers are another type of individual within a sparrow population, primarily responsible for local search and solution refinement. Followers typically search around high-quality solutions, continuously improving their position by learning from them. In this application's solution, follower individuals search under the guidance of explorers, drawn simultaneously to the global optimal position and the local optimal position of their subpopulation.
[0013] Vigilants are a third type of individual in a sparrow population, primarily responsible for maintaining population diversity and preventing premature convergence during the search process. Vigilants typically search in a random manner, randomly generating new positions within a certain range around an explorer. In this application's solution, a vigilant individual randomly selects an explorer as the center and randomly generates new positions within a warning radius around it.
[0014] Explorers, followers, and vigilants collaborate during the search process, pushing the population toward the optimal solution. Explorers are responsible for global exploration, followers for local exploitation, and vigilants for maintaining diversity. Their optimization mechanisms complement each other, forming an effective swarm intelligence search model.
[0015] Furthermore, in S45, the position and velocity of the explorer individual are updated using the current chaotic sequence, including:
[0016] X1(t+1)=X1(t)+V(t+1),
[0017] V(t+1)=w(t)V(t)+c1(t)r1[X pbest (t)-X1(t)]+c2(t)r2[X gbest (t)-X1(t)], where X1(t) and
[0018] V(t) is the position and velocity of the explorer at time t, X1(t+1) and V(t+1) are the position and velocity of the explorer at time t+1; X pbest (t) is the historical optimal position of the explorer at time t, X gbest (t) is the global optimal position of the population at time t; r1 and r2 are random numbers in the current chaotic sequence; w(t) is the inertia weight, c1(t) and c2(t) are acceleration constants, and w(t), c1(t) and c2(t) are adaptively changing parameters.
[0019] Furthermore, in S46, the position of the follower individual is updated according to the optimal position of the explorer individual, including:
[0020] X2(t+1)=X2(t)+r3[X pbest (t)-X2(t)]+r4[X gbest (t)-X2(t)]+r5[X lbest (t)-X2(t)], where X2(t) and X2(t+1) are the positions of the follower individuals at time t and time t+1 respectively; X pbest (t) is the historical optimal position of the explorer at time t, X gbest (t) is the global optimal position of the population at time t, X lbest (t) is the local optimal position of the subpopulation where the follower individual is located at time t; r3, r4 and r5 are random numbers of corresponding dimensions in the current chaotic sequence, and r3, r4, r5∈(0,1), r3+r4+r5=1, which is used to balance the contribution of the explorer individual, the global optimal individual and the local optimal individual to the update of the follower individual position.
[0021] Further, S47, randomly select an explorer individual as the center, and randomly fly within the preset range of the center to obtain the updated position of the vigilant individual, including: X3(t+1)=X pbest (t)+r6×R, where X3(t+1) is the position of the vigilant individual at time t+1, X pbest (t) is the historical optimal position of the explorer randomly selected at time t, and R ... pbest(t) is the warning radius centered, and r6 is a random number in the current chaotic sequence.
[0022] Furthermore, S44, based on the fitness values of S43, the sparrow individuals are divided into explorers, followers, and vigilants, including: sorting N individuals in the sparrow population in descending order according to the fitness values; selecting the sparrow individuals with the top N×20% fitness values after sorting as explorers, denoted as N e ; Among them, N is the population size; among the remaining N×80% sparrow individuals, the sparrow individuals with the top N×50% fitness values after sorting are selected as followers, recorded as N f ; The remaining N×30% of sparrows are regarded as vigilant individuals, recorded as N w ; Use K-means clustering algorithm to cluster N f The follower individuals are divided into K sub-populations, the position of the follower individuals is used as the clustering feature, and the Euclidean distance is used as the similarity metric; for each follower sub-population, the individual with the best fitness value is selected as the local optimal individual of the sub-population, denoted by X lbest (t).
[0023] Furthermore, S2 calculates the correlation coefficient between the odor feature of Duoyiguo and the freshness of Duoyiguo, and performs combined optimization based on the correlation coefficient through the binary black wolf optimization algorithm to obtain the optimal odor feature, including: S21, according to the odor feature of Duoyiguo and the freshness of the corresponding sample, calculating the Spearman rank correlation coefficient ρ and the Kendall rank correlation coefficient τ between each odor feature and the freshness; S22, based on the Spearman rank correlation coefficient ρ and the Kendall rank correlation coefficient τ calculated in S21, using the recursive feature elimination (RFE) method to select the odor feature, and obtain K candidate odor feature subsets, denoted as {S1, S2,....., S K}; S23, for each candidate odor feature subset S i , calculate the Spearman rank correlation coefficient ρ between it and freshness Si and Kendall rank correlation coefficient τ Si , and the Spearman rank correlation coefficient ρ between the two odor features within the subset ij and Kendall rank correlation coefficient τ ij , set the evaluation function J(S i ); S24, the candidate odor feature subset {S1, S2, ....., S K} as the initial population of the Binary Black Wolf Optimization (BBWO) algorithm, where each black wolf individual corresponds to a candidate feature subset S i ; Each black wolf individual is encoded into a binary vector, each bit of the vector indicates whether the corresponding odor feature is selected; the evaluation function J(S23 defined i ) as the fitness function, through the cooperative hunting and population update strategy among black wolf individuals, the global optimal solution is iteratively searched to obtain the optimal odor feature; S25, the optimal odor feature obtained in S24 is used as the input feature of S3 to construct the ELM structure.
[0024] Traditional odor feature selection methods usually use correlation analysis, such as Spearman rank correlation coefficient or Kendall rank correlation coefficient, which directly sorts the correlation between individual odor features and freshness, and selects the top N features with the highest correlation as model input. However, feature selection is a combinatorial optimization problem, which requires searching for the optimal subset among all possible feature combinations. Traditional methods use a greedy strategy and are prone to falling into local optimality. On the one hand, this application introduces the evaluation function J(S i ), not only the correlation between the candidate feature subset and freshness is considered, but also the redundancy of the odor features within the subset. This helps to select the optimal feature combination with high correlation and low redundancy. On the other hand, the feature selection problem is transformed into a binary optimization problem. The intelligent search capability of the black wolf algorithm is utilized. Through mechanisms such as cooperative hunting and population renewal among black wolf individuals, an efficient global search is performed in the feature combination space, breaking out of the local optimum and converging to the global optimal feature subset. The Spearman rank correlation coefficient and the Kendall rank correlation coefficient are used as correlation metrics. They are more sensitive to nonlinear relationships and insensitive to outliers, making them more suitable for odor feature data.
[0025] By introducing the Spearman rank correlation coefficient and the Kendall rank correlation coefficient, this application can more comprehensively evaluate the correlation between odor characteristics and freshness, while taking into account the redundancy within the feature subset; the BBWO algorithm with global search capability is used for feature combination optimization, which can effectively avoid greedy search falling into local optimality and obtain the globally optimal odor feature subset.
[0026] Furthermore, set the feature subset S i The evaluation function J(S i )for:
[0027] in, Represents the i-th candidate odor feature subset S i The Spearman rank correlation coefficient between and freshness, Represents the i-th candidate odor feature subset S i Kendall rank correlation coefficient between ρ and freshness, ρ ij Represents the i-th candidate odor feature subset S i The Spearman rank correlation coefficient between the jth odor feature and other odor features, τ ij Represents the i-th candidate odor feature subset S i Kendall rank correlation coefficient between the jth internal odor feature and other odor features, |S i | represents the i-th candidate odor feature subset S i The number of odor features included; α and β are weight coefficients that balance relevance and redundancy, and satisfy α+β=1.
[0028] Furthermore, the formula for the Spearman rank correlation coefficient ρ is: Among them, d i is the difference between the two ranks of the i-th sample, and n is the number of samples.
[0029] The formula for Kendall's rank correlation coefficient τ is: Among them, n c is the number of consistent pairs, n d is the number of discordant pairs, and n is the number of samples.
[0030] Another aspect of the present application also provides a multi-fruit freshness prediction system based on odor information, which is used to execute a multi-fruit freshness prediction method based on odor information of the present application.
[0031] Compared with the existing technology, the advantages of this application are:
[0032] To address issues such as ELM's susceptibility to random initialization and difficulty determining the number of hidden layer nodes, this application optimizes the ELM using an improved chaotic sparrow search algorithm. During the iterative process of the sparrow search algorithm, the positions of individual sparrows are updated using chaotic sequences generated by the logistic mapping, Chebyshev mapping, and Tent mapping. Because different chaotic maps have different dynamic characteristics, alternating between multiple mapping strategies can introduce greater diversity and randomness into the population, expanding the search range, enhancing the algorithm's ability to escape local optima, and improving global search performance.
[0033] After each iteration, the position of each sparrow is updated, and the fitness of the new position is calculated and compared with the original. For each explorer, if the new position's fitness is better than the original, the new position is unconditionally accepted. Otherwise, using simulated annealing, a new position worse than the current one is accepted with a certain probability, decreasing with increasing iterations. By dynamically adjusting the position acceptance probability of each explorer, the algorithm maintains strong random exploration capabilities in the early stages of the search while focusing more on refined searches of local areas in the later stages. This balance between exploration and exploitation improves the algorithm's convergence speed and search accuracy.
[0034] The traditional position update of follower individuals is completely dependent on the optimal position of the explorer individual, lacks its own exploration ability, and is prone to falling into local optimality; the position update of follower individuals only considers the optimal position of the explorer individual, but does not fully utilize the position information of other excellent individuals in the population. The update method is relatively simple, which is not conducive to maintaining population diversity; in the position update of follower individuals, the random number r3 in the chaotic sequence uses the same value for all dimensions, lacks the ability to differentiate and adjust the search intensity in different dimensions, and affects the optimization performance of the algorithm. In this application, Xgbest(t) is the global optimal position of the population at time t; Xlbest(t) is the local optimal position of the subpopulation where the follower individual is located at time t; r3, r4, r5 are random numbers of corresponding dimensions in the chaotic sequence, and r3, r4, r5∈(0, 1), r3+r4+r5=1, which is used to balance the contribution of the explorer individual, the global optimal individual and the local optimal individual to the position update; this update method takes into account the learning of the global optimal position and the local optimal position while learning the explorer individual, and adjusts the learning intensity through random numbers of different dimensions in the chaotic sequence, thereby enhancing the exploration ability of the follower individual, helping to escape the local optimum, and improving the population diversity and optimization performance of the algorithm.
[0035] The present application uses the Spearman rank correlation coefficient and the Kendall rank correlation coefficient to evaluate the correlation between odor features and freshness, fully considering the nonlinear monotonic correlation and consistency relationship between the two. Unlike the mutual information metric in the maximum information coefficient MIC and mRMR methods that only reflects linear correlation, the rank correlation coefficient can capture the complex nonlinear relationship between odor features and freshness, has stronger descriptive ability and robustness, and provides a more reliable correlation metric for subsequent feature selection. In the feature subset evaluation function, the present application not only considers the correlation between the subset and freshness, but also introduces the Spearman rank correlation coefficient and the Kendall rank correlation coefficient between the odor features within the subset to measure the redundancy between features. Unlike the maximum information coefficient MIC that only considers the correlation between a single feature and freshness, the evaluation function of the present application not only optimizes the correlation between the feature subset and freshness, but also minimizes the redundancy within the subset as much as possible, so that the correlation between the selected odor features is low, thereby improving the generalization ability of the subsequent prediction model.
[0036] This application first uses a recursive feature elimination method to coarsely screen the initial odor features, obtaining a set of candidate feature subsets. This is then used as the encoding for the binary Black Wolf optimization algorithm, which searches for the global optimal solution by optimizing the feature subset evaluation function. Unlike the mRMR method, which uses a greedy incremental search strategy, this application's feature selection strategy reduces the search space while introducing a swarm intelligence optimization algorithm to perform a global search at the feature subset level. This effectively avoids the risk of falling into a local optimum, improves the global optimality of the resulting feature subset, and thus enhances the accuracy and robustness of the prediction model. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] The present application will be further described in the form of exemplary embodiments, which will be described in detail with reference to the accompanying drawings. These embodiments are not limiting, and in these embodiments, the same numbers represent the same structures, wherein:
[0038] Figure 1 is an exemplary flow chart of a method for predicting the freshness of multifruits based on odor information according to some embodiments of the present application;
[0039] Figure 2 is an exemplary flow chart for generating optimal odor characteristics according to some embodiments of the present application;
[0040] Figure 3 This is an exemplary flow chart for generating a multi-fruit freshness prediction model according to some embodiments of the present application. DETAILED DESCRIPTION
[0041] The method and system provided in the embodiments of the present application are described in detail below with reference to the accompanying drawings.
[0042] like Figure 1 As shown, samples of duoyiguo fruit of different maturity and origin are collected to obtain odor data of the corresponding samples. A duoyiguo odor dictionary is constructed based on the odor components of duoyiguo fruit. Feature extraction of the sample odor data is performed based on the odor dictionary to obtain a duoyiguo odor signature. The correlation coefficient between the odor signature and the duoyiguo freshness is calculated. Combinatorial optimization is performed using the binary black wolf optimization algorithm based on the correlation coefficient to obtain the optimal odor signature. A single-hidden-layer extreme learning machine (ELM) structure is constructed using the optimal odor signature as the input layer and the duoyiguo freshness as the output layer node. An improved chaotic sparrow search algorithm is used to optimize the hidden layer connection weights and thresholds of the extreme learning machine (ELM) structure to obtain a duoyiguo freshness prediction model. The improved chaotic sparrow search algorithm updates the position of individual sparrows during the iterative optimization process by alternately using a chaotic sequence generated by logistic mapping, Chebyshev mapping, and Tent mapping. The odor data of the duoyiguo fruit samples to be predicted are input into the duoyiguo freshness prediction model to obtain a duoyiguo freshness prediction result for the corresponding samples.
[0043] Specifically, S1 collects samples of doyi fruit of different maturity and origin, and obtains the odor data of the corresponding samples. In order to improve the representativeness and coverage of the samples, typical plantations are selected in the main doyi fruit producing areas, and doyi fruit samples are collected according to maturity (such as unripe, nearly mature, mature, overripe, etc.) and origin (such as Hainan, Yunnan, etc.). Pay attention to randomness and uniformity during collection, and collect at least 30 samples for each maturity and origin. The collected samples are transported to the laboratory within 24 hours, and the odor data is collected after equilibration at 25°C for 2 hours. The odor data of doyi fruit samples is obtained using solid phase microextraction-gas chromatography-mass spectrometry (HS-SPME-GC-MS) technology.
[0044] A Duoyiguo odor dictionary was constructed based on Duoyiguo odor components. GC-MS results were analyzed to identify Duoyiguo odor components. The chemical structure of each component was determined by referring to the NIST spectral library and literature, combined with the retention index (RI) value. A Duoyiguo odor dictionary was constructed based on the identified odor components. Considering that some odor components may not be highly correlated with freshness, and to reduce the computational complexity of subsequent feature selection, the variable importance projection (VIP) method was used to screen the odor components, and components with a VIP value greater than 1 were included in the odor dictionary. Each component in the odor dictionary corresponds to an odor feature and is assigned a unique feature ID.
[0045] The sample odor data is feature extracted based on the Duoyiguo odor dictionary to obtain Duoyiguo odor signatures. For each sample's GC-MS results, the chromatographic peaks are identified and the content of each component is quantitatively analyzed. The identified components are matched with the features in the odor dictionary to extract the corresponding odor signatures. For odor signatures included in the dictionary but not detected in the sample, their content is recorded as 0. The result is an N×M dimensional odor signature matrix, where N is the number of samples and M is the number of odor signatures. Each sample corresponds to an M-dimensional odor signature vector, representing the quantified value of each odor signature for that sample.
[0046] like Figure 2 As shown, S2, calculates the correlation coefficient between the odor characteristics of Duoyiguo and the freshness of Duoyiguo, and performs combined optimization based on the correlation coefficient through the binary black wolf optimization algorithm to obtain the optimal odor characteristics, including: S21, based on the odor characteristics of Duoyiguo and the freshness of the corresponding samples, calculates the Spearman rank correlation coefficient ρ and the Kendall rank correlation coefficient τ between each odor characteristic and the freshness. Suppose there are N Duoyiguo samples, and M odor characteristics are extracted from each sample. Let x ij represents the jth odor feature value of the i-th sample, y i represents the freshness value of the i-th sample, where i=1, 2, ..., N, j=1, 2, ..., M.
[0047] For the jth odor feature and freshness, according to the feature value x ij and freshness value y i The size of the rank is numbered respectively, and two groups of ranks r are obtained. ij and q i , calculate the rank difference d ij =r ij -q i According to the definition of Spearman rank correlation coefficient, calculate the Spearman rank correlation coefficient ρ between the jth odor feature and freshness j : Similarly, for the jth odor feature, according to its characteristic value x ij With freshness value y i The size comparison of the statistical consistency (i.e. x ij >x kj And y i >y k or x ij <x kj And y i <y k ) cj and inconsistent pairs (i.e. x ij >x kj And y i <y kor x ij <x kj and y i >y k ) the quantity n dj , where 1 ≤ i < k ≤ N. According to the definition formula of Kendall rank correlation coefficient, calculate the Kendall rank correlation coefficient τ between the j - th odor feature and freshness j : Repeat the above calculation process to obtain the Spearman rank correlation coefficient vector ρ = [ρ1, ρ2,....., ρ M and Kendall rank correlation coefficient vector τ = [τ1, τ2,....., τ M . The value ranges of ρ and τ are both [-1, 1]. The larger the absolute value, the higher the degree of monotonic correlation and consistency between the odor feature and freshness
[0048] S22. Based on the Spearman rank correlation coefficient ρ and Kendall rank correlation coefficient τ calculated in step S21, use the recursive feature elimination (RFE) method to select odor features. RFE recursively constructs a model, eliminating a certain number of the least important features from the feature set each time until the preset number of features is reached. Here, the weighted average of ρ and τ is used as the feature importance score, and the weights are both 0.5. Then the importance score s j of the j - th odor feature is j = 0.5×ρ j + 0.5×τ j . Set a series of candidate feature subset quantities K, and decrease from M to 1 according to a preset step size (such as 5 or 10). In each iteration, sort according to the importance scores s k of each odor feature from high to low, and select the top k odor features with the highest scores to form the feature subset S K , k = 1, 2,....., K. After the iteration ends, K candidate odor feature subsets {S1, S2,....., S K} are obtained, where S1 contains the most important features and S [[ID=-37]]
[0049] contains the least important features. These candidate feature subsets will be used in the subsequent combinatorial optimization process. Use the Spearman rank correlation coefficient and Kendall rank correlation coefficient to measure the non - linear correlation between odor features and freshness from different angles, and quantitatively evaluate the importance of odor features based on the weighted average of the two. Combining with the RFE method, by recursively selecting different numbers of the most important features, a series of candidate feature subsets are obtained, providing an initial solution space for the subsequent feature combination optimization, which can effectively narrow the search range and improve the optimization efficiencyS23. For each candidate odor feature subset S i , i = 1, 2,....., K, calculate the Spearman rank correlation coefficient between it and freshness and the Kendall rank correlation coefficient Let the feature subset S i contain m i odor features, and the corresponding sample feature matrix is X i ={x pq}, where p = 1, 2,......, N represents the sample number, and q = 1, 2,....., m i represents the feature number. Rank each feature vector x i in X q and the freshness vector y respectively, and then calculate according to the definition formulas of the Spearman rank correlation coefficient and the Kendall rank correlation coefficient to obtain and used to measure the overall correlation between the feature subset S i and freshness.
[0050] Calculate the Spearman rank correlation coefficient ρ i and the Kendall rank correlation coefficient τ ij between the odor features pairwise within the candidate odor feature subset S ij , where i is the feature subset number and j is the number of pairwise feature combinations within the subset. For any two odor feature vectors x i and x p and x q (1 ≤ p < q ≤ m_i) within S i , rank them and calculate ρ ij and τ ij according to the definition formula to measure the redundancy within the feature subset.
[0051] Set the evaluation function J(S i ) of the feature subset S i to balance the correlation between the feature subset and freshness and the redundancy of the internal features. The function is defined as follows: where α and β are weight coefficients for balancing correlation and redundancy, and satisfy α + β = 1.
[0052] The evaluation function J(S i ) consists of two parts: The first part represents the correlation between the feature subset S i and freshness. and range from [-1, 1], and the larger the value, the stronger the correlation. Therefore, a plus sign is taken for this part, and the larger the value of the coefficient α, the more importance is attached to the correlation; The second part Represents the feature subset S i Internal redundancy, ρ ij and τ ij The absolute value of |ρ ij | and |τ ij The larger the |, the higher the redundancy between features, so this part takes a minus sign, and the larger the coefficient β, the more attention is paid to redundancy.
[0053] According to the evaluation function J(S i ) Calculate each candidate feature subset S i The higher the score, the higher the correlation between the subset and freshness, the lower the internal redundancy, and the better the overall performance.
[0054] An evaluation function was designed that balances the correlation between feature subsets and freshness and internal feature redundancy. This balance was quantitatively achieved through a weighted average approach. Candidate feature subsets were then ranked based on the evaluation function, providing an evaluation criterion for subsequent optimization searches. This evaluation function leverages the complementary properties of the Spearman rank correlation coefficient and the Kendall rank correlation coefficient, measuring the overall correlation and internal redundancy of feature subsets from different perspectives. Weight coefficients were introduced to adjust the importance of correlation and redundancy, enhancing the flexibility and applicability of the evaluation function. In the subsequent black wolf optimization algorithm, this evaluation function was used as the fitness function to effectively guide the black wolf population in its search for the optimal feature combination, improving the accuracy and efficiency of feature selection. To identify the optimal feature combination from the candidate odor feature subsets, a global optimization algorithm, the Binary Black Wolf Optimization (BBWO) algorithm, was employed. BBWO is a swarm intelligence-based heuristic search algorithm that simulates wolf hunting behavior to achieve optimized search.
[0055] S24, K candidate odor feature subsets {S1, S2, ....., S K As the initial population of the BBWO algorithm, each black wolf individual corresponds to a candidate feature subset S i . Assume that the complete odor feature set is F = {f1,f2,.....,f M}, then each candidate feature subset S i It can be expressed as a binary subset of F, namely S i ∈{0,1} M .
[0056] Each black wolf individual is encoded into an M-dimensional binary vector, where each bit of the vector indicates whether the corresponding odor feature is selected. For example, for the feature subset S i , if it contains the jth odor feature f j, then the jth bit of the binary vector takes the value of 1, otherwise it takes the value of 0. Through this encoding method, a one-to-one correspondence is formed between the black wolf individual and the candidate feature subset.
[0057] The evaluation function J(S i ) is used as the fitness function of the BBWO algorithm to evaluate the quality of each black wolf individual (candidate feature subset). i ) comprehensively considers the correlation between the feature subset and freshness and the redundancy of internal features. A larger value indicates better overall performance of the feature subset. The BBWO algorithm iteratively searches for the global optimal solution through cooperative hunting among individual black wolves and a population update strategy. The BBWO algorithm is divided into three phases: roundup, hunting, and attack. In each iteration, the position of individual black wolves (i.e., the corresponding binary code) is updated by simulating the behavior of the black wolf population. In the roundup phase, the roundup center is determined by calculating the distance between individual black wolves. The black wolves are ranked according to their fitness values, with the top three individuals labeled α, β, and δ, respectively, and the remaining individuals labeled ω. In the hunting phase, ω adjusts its position based on the distance between itself and α, β, and δ, and updates its binary code based on the transition probability matrix. In the attack phase, a set of random positions is generated by simulating the wolf pack's attack behavior on prey, and the positions of individual black wolves are updated based on the fitness value and the probability of successful attack. These three phases are repeated until the maximum number of iterations is met or the fitness value converges. After the iteration, the binary code corresponding to the black wolf individual with the highest fitness value is the optimal odor feature combination.
[0058] S25 uses the optimal odor signature obtained in S24 as the input feature for constructing the ELM structure in S3. The BBWO algorithm is used to perform combinatorial optimization on the candidate feature subsets, and a global search is achieved through the cooperative hunting behavior of individual black wolves. The optimization search direction is guided by the evaluation function, effectively avoiding the local optimum and searching for the globally optimal feature combination. This scheme fully utilizes the excellent global search capabilities of the BBWO algorithm and the reasonable feature subset evaluation indicators of the evaluation function to significantly improve the accuracy and efficiency of feature selection. Using the optimal odor signature obtained by optimization as the input feature of the ELM can reduce feature redundancy while maximizing the relevance and discriminability of the features.
[0059] like Figure 3 As shown in S3, the optimal odor feature is used as the input layer, and the multi-fruit freshness is used as the output layer node to construct a single hidden layer extreme learning machine ELM structure; specifically, the optimal odor feature obtained in step S2 is used as the input layer of ELM. Assuming that the number of optimal odor features selected is m, the number of input layer nodes of ELM is m. The multi-fruit freshness is used as the output layer node of ELM. Since freshness is a continuous variable, the number of output layer nodes is 1. Set the number of hidden layer nodes of ELM to h, according to the empirical formula Determine, where a is a constant between [1, 10]. Construct a single hidden layer ELM structure, whose connection weight matrix is W∈R m×h , the hidden layer threshold vector is b∈R h , the output layer connection weight matrix is β∈R h×1 The mathematical model of ELM is as follows: Where x∈R m is the input odor feature vector, f(x) is the output freshness prediction value, g(*) is the hidden layer activation function, and the Sigmoid function is commonly used.
[0060] S4, using the improved chaotic sparrow search algorithm to optimize the hidden layer connection weights and thresholds of the extreme learning machine ELM structure, to obtain a multi-fruit freshness prediction model, including: S41, initializing the sparrow population, the population size is N. The hidden layer connection weight matrix W of the ELM and the threshold vector b are combined into an optimization variable vector, denoted as [W(:); b]∈R m×h+h , whose dimension is m×h+h. Each sparrow individual corresponds to a set of ELM parameters, which are encoded by optimizing the variable vector. Initialize the maximum flight speed V of the sparrow individual max , maximum number of iterations T max , inertia weight w, acceleration constants c1 and c2, and the initial temperature T0 and cooling coefficient α of simulated annealing.
[0061] Three different chaotic sequences are randomly generated, namely Logistic mapping sequence, Chebyshev mapping sequence and Tent mapping sequence, each with a length of N. Let the number of iterations t = 1, and select the Logistic mapping sequence as the initial chaotic sequence C(t). The iterative formulas of these three chaotic mappings are as follows: Logistic mapping: C i (t+1)=μC i (t)[1-C i (t)], Chebyshev mapping: C i (t+1)=cos(karccos(C i (t))), Tent mapping: C i (t+1)=μ[1-2|C i (t)-0.5|], where μ and k are the control parameters of the chaotic map. By properly setting them, a chaotic sequence that traverses the interval (0, 1) and is uniformly distributed can be generated. The introduction of chaotic sequences is to enhance the diversity of the sparrow search algorithm and its ability to escape local optima.
[0062] The position and velocity of the sparrow population are initialized using the chaotic sequence C(t). According to the value of the chaotic sequence, it is mapped to the value range of the ELM parameter as the initial position of each sparrow individual. For example, for the jth optimization variable x of the i-th sparrow individual ij , its initial position is: x ij (1) = LB j +C i (1)(UB j -LB j ), where LB j and UB j are the lower and upper bounds of the jth optimization variable, respectively. Similarly, the chaotic sequence can be used to initialize the flight speed of individual sparrows.
[0063] In each iteration, the fitness value of each sparrow individual is evaluated, that is, the prediction performance of the model corresponding to the set of ELM parameters on the validation set (such as root mean square error RMSE) is used as the fitness function. The global optimal position g of the sparrow population is updated according to the fitness value. best and each individual's historical optimal position p best . Then, the speed and position of the individual sparrow are updated in combination with the chaotic sequence C(t). Taking advantage of the fast learning ability and powerful nonlinear fitting ability of ELM, a mapping model between odor characteristics and freshness is constructed. The improved chaotic sparrow search algorithm is used to optimize the hidden layer parameters of ELM, and the chaotic sequence is introduced to enhance population diversity. The simulated annealing strategy is used to jump out of the local optimum, and the optimal ELM parameter combination can be searched globally to construct a freshness prediction model with excellent performance. Compared with traditional parameter tuning methods, this algorithm has stronger global search capabilities and convergence speed, which can significantly improve the learning performance and generalization ability of the prediction model, and provide strong model support for the accurate prediction of the freshness of multi-fruit.
[0064] S42, set the number of iterations t = 1, select the Logistic mapping sequence as the initial chaotic sequence C(t). During the iteration process, the chaotic sequence is switched in sequence according to the search state of the algorithm to enhance the population diversity.
[0065] S43, calculate the fitness value. Assume that the number of input layer nodes of the ELM is m, and the number of hidden layer nodes is h. Then the dimension of the hidden layer connection weight matrix W is m×h, and the dimension of the threshold vector b is h×1. W and b are expanded by column and concatenated into a vector of length m×h+h, which serves as the encoding of the sparrow individual. That is, each sparrow individual corresponds to a set of candidate ELM hidden layer parameters. During the fitness value calculation process, the sparrow individual needs to be decoded into the ELM parameter matrix. Specifically, the first m×h elements of the individual encoding vector are split by column and reshaped into an m×h matrix W, and the remaining h elements constitute the threshold vector b. Based on the decoded hidden layer connection weight matrix W and threshold vector b, the ELM structure corresponding to the current sparrow individual is constructed. Assume the number of training samples is n. The m-dimensional odor feature vectors of n samples are sequentially input into the ELM. The hidden layer output matrix H is obtained through hidden layer mapping: H = g(XW + b), where X is the n × m training sample matrix, g(*) is the hidden layer activation function, usually the Sigmoid function. H is the n × h hidden layer output matrix, with each row corresponding to the hidden layer output of a sample.
[0066] Using the ELM structure corresponding to the current sparrow individual, the multi-fruit freshness of the training sample is predicted. Assuming the connection weight vector from the hidden layer to the output layer is β, the output f(X) of ELM can be expressed as: f(X) = Hβ, where β can be solved by the least squares method: β = H Ψ T, where H Ψ is the Moore-Penrose generalized inverse of H, and T is the n×1 training sample freshness vector. The output f(X) of ELM is compared with the expected input Take T for comparison and calculate the mean square error MSE: In order to maximize the optimization goal, the negative MSE is used as the fitness value of the current sparrow individual: fitness = -MSE. The larger the fitness value, the better the ELM performance corresponding to the current individual.
[0067] S44: Divide the sparrow population and sort it in descending order based on the fitness of the individual sparrows. Individuals are divided into three groups according to a certain ratio: the top 20% of individuals by fitness are considered explorers, the top 50% of the remaining 80% are considered followers, and the remaining 30% are considered vigilant. This division method balances the population's exploration and exploitation capabilities. Assuming the population size is N, the number of explorers Ne = N × 20%, the number of followers Nf = N × 80% × 50% = N × 40%, and the number of vigilant individuals Nw = N × 80% × 50% = N × 40%. To promote information sharing and cooperation among follower individuals, a K-means clustering algorithm is used to divide the follower individuals into K subpopulations. The clustering process uses individual positions (i.e., encoding vectors) as features and Euclidean distance as a similarity metric. By minimizing the sum of squared intra-class distances, the follower individuals are divided into K compact subpopulations.
[0068] Let the position matrix of the follower individual be X f , then the objective function of K-means clustering is: Among them, x i is the position vector of the i-th follower individual, μ j is the jth cluster center, and ||*|| represents the Euclidean distance. The clustering result can be expressed as K mutually exclusive subsets: Among them, C i is the ith subpopulation, containing a set of follower individual indices. For each follower subpopulation C i , select the individual with the largest fitness value as the local optimal individual X of the subpopulation lbesti : Here, fitness(x) represents the fitness value of individual x. The selection of local optimal individuals helps maintain high-quality solutions within the subpopulation and provides valuable search directions for follower individuals. Explorer individuals are responsible for extensive exploration of the solution space, discovering new promising areas; follower individuals, guided by the local optimal individuals, conduct in-depth searches to accelerate convergence; and vigilant individuals avoid being trapped in local optima through random flight. These three types of individuals collaborate to continuously advance the population toward the optimal solution. Furthermore, the division of subpopulations and the introduction of local optimal individuals further facilitate information exchange and sharing among follower individuals, improving the algorithm's optimization efficiency.
[0069] S45, explorer individual position update. The explorer individual is responsible for extensively searching the solution space to discover new promising areas. Its position update follows the speed-position update formula of the classic particle swarm optimization (PSO) algorithm, while introducing a chaotic sequence to generate random numbers to enhance the randomness and diversity of the search. The speed update formula of the explorer individual is:
[0070] V(t+1)=w(t)V(t)+c1(t)r1[X pbest (t)-X1(t)]+c2(t)r2[X gbest (t)-X1(t)], where V(t) and V(t+1) are the velocity vectors of the explorer at time t and time t+1 respectively; X1(t) is the position vector of the explorer at time t; X pbest (t) is the historical optimal position vector of the explorer at time t; X gbest (t) is the global optimal position vector of the population at time t. w(t) is the inertia weight, which controls the tendency of the individual to maintain its current speed; c1(t) and c2(t) are acceleration constants, which control the degree to which the individual learns from its own historical optimal position and the global optimal position, respectively. In order to balance global exploration and local utilization, w(t), c1(t), and c2(t) adopt an adaptive adjustment strategy:
[0071] Among them, w max and w min are the maximum and minimum values of w(t) respectively; c 1,max and c 1,min are the maximum and minimum values of c1(t) respectively; c 2,max and c 2,min are the maximum and minimum values of c2(t) respectively; T max is the maximum number of iterations. As the number of iterations t increases, w(t) and c1(t) decrease linearly, while c2(t) increases linearly, causing the algorithm to focus on global exploration in the early stages and local utilization in the later stages. r1 and r2 are random numbers in the interval (0, 1), generated by the current chaotic sequence C(t): r1 = C(t)[i], r2 = C(t)[j], where i and j are random indices of the chaotic sequence. Introducing a chaotic sequence can increase random perturbations and escape local optima. Position update: The position update formula for the explorer individual is: X1(t+1) = X1(t) + V(t+1). The explorer individual's current position X1(t) is added to the updated velocity V(t+1) to obtain the position X1(t+1) at the next moment.
[0072] S46, follower individual position update: The follower individual searches under the guidance of the explorer individual, and is attracted by the global optimal position and the local optimal position of the sub-population. Its position update formula is:
[0073] X2(t+1)=X2(t)+r3[X pbest (t)-X2(t)]+r4[X gbest (t)-X2(t)]+r5[X lbest(t)-X2(t)], where X2(t) and X2(t+1) are the position vectors of the follower individual at time t and time t+1 respectively; X pbest (t) is the historical optimal position vector of the explorer at time t; X gbest (t) is the global optimal position vector of the population at time t; X lbest (t) is the local optimal position vector of the follower's subpopulation at time t. r3, r4, and r5 ∈ (0, 1) are random numbers generated from the corresponding dimensions of the current chaotic sequence C(t), satisfying r3 + r4 + r5 = 1: r3 = C(t)[i], r4 = C(t)[j], and r5 = 1 - r3 - r4, where i and j are random indices of the chaotic sequence. r3, r4, and r5 control the contribution of the explorer, global optimal, and local optimal individuals to the follower's position update. When r3 is large, the follower is more likely to learn from the explorer; when r4 is large, the follower is more likely to learn from the global optimal; and when r5 is large, the follower is more likely to learn from the local optimal.
[0074] S47, the position of the vigilant individual is updated. The vigilant individual performs random search with the explorer individual as the center to avoid falling into the local optimum. The position update formula is: X3(t+1)=X pbest (t)+r6×R, where X3(t+1) is the position vector of the vigilant individual at time t+1; X pbest (t) is the historical optimal position vector of the explorer randomly selected at time t; R is the vector of the optimal position of the explorer randomly selected at time t; pbest (t) is the alert radius centered on the chaotic sequence. r6 is a random number in the interval (0, 1) and is generated by the current chaotic sequence C(t): r6 = C(t)[i], where i is the random index of the chaotic sequence. pbest A new position is randomly generated within a hypersphere with (t) as the center and a radius of R. The size of R controls the search range of the vigilant individual.
[0075] Through the collaborative optimization of explorers, followers, and vigilant individuals, the improved chaotic sparrow search algorithm can efficiently search for the optimal ELM parameter combination in the solution space. Explorers are responsible for global exploration, using their historical and global optimal positions to guide the search direction. Followers, building on the explorers' foundation, conduct local searches, attracted by both the global optimal position and the local optimal position of their subpopulation, accelerating convergence. Vigilant individuals increase population diversity through random search to avoid premature convergence. The position update strategies of these three types of individuals work together to form a search mechanism that balances global exploration with local utilization and achieves collaborative optimization. Furthermore, by introducing a chaotic sequence to generate random numbers, the algorithm's randomness and ability to escape local optima are further enhanced. An adaptive adjustment strategy enables the algorithm to maintain dynamic equilibrium during iteration, improving search flexibility and efficiency.
[0076] To further enhance the algorithm's global search capabilities and ability to escape local optima, the improved chaotic sparrow search algorithm incorporates a chaotic sequence switching mechanism and a simulated annealing strategy. Furthermore, appropriate iteration termination conditions are set to balance search quality and computational efficiency. Finally, the optimal ELM parameters obtained through the search are used to construct and train the ELM, resulting in the final freshness prediction model.
[0077] S48, chaotic sequence switching mechanism. In order to maintain population diversity and escape local optimality, multiple chaotic sequences are introduced in the iterative process and adaptively switched according to the search state of the algorithm. After each iteration, the average fitness value of the updated sparrow population is calculated. If the improvement in the average fitness value for several consecutive iterations (such as 5 times) is less than a set threshold (such as 0.1%), it is considered that the current chaotic sequence has lost its search capability and needs to be switched to the next chaotic sequence. The switching order of the chaotic sequences is: Logistic mapping sequence → Chebyshev mapping sequence → Tent mapping sequence → Logistic mapping sequence → ... After switching the chaotic sequence, set the number of iterations t = t + 1 and continue the search process.
[0078] S49, in order to further enhance the ability of the algorithm to escape from the local optimum, a simulated annealing strategy is introduced in the position update of the explorer individual. For each new position of the explorer individual, its corresponding fitness value is calculated. If the fitness value of the new position is better than the original position, the new position is accepted unconditionally; otherwise, the new position is accepted with a certain probability. The acceptance probability P depends on the fitness difference ΔE between the new and old positions and the current temperature T: P = exp(-ΔE / T), where ΔE = fitness(X new )-fitness(X old ), where X new Represents the new position vector, X oldRepresents the old position vector, and fitness(*) represents the fitness function. The larger ΔE is, the worse the fitness value of the new position is, and the smaller the acceptance probability is; conversely, the smaller ΔE is, the greater the acceptance probability is.
[0079] The initial temperature, T0, is set to a high value to ensure a sufficiently high acceptance probability in the early stages, facilitating escape from local optima. During the iteration process, the temperature, T, decays exponentially at a constant rate: T(t+1) = αT(t), where α is the temperature decay coefficient, ranging from (0, 1) and typically ranging from 0.9 to 0.99. As the number of iterations, t, increases, the temperature, T, gradually decreases, and the probability of accepting inferior solutions decreases, leading to the algorithm becoming stable. By introducing a simulated annealing strategy, the improved chaotic sparrow search algorithm can accept solutions slightly inferior to the current one with a higher probability in the early stages, helping to escape from local optima and enhance global search capabilities. In the later stages, it is more inclined to accept high-quality solutions, accelerating local search and improving convergence. This strategy achieves a balance between global exploration and local exploitation, thereby improving the performance of the algorithm's extreme learning machine optimization.
[0080] S410, set appropriate iteration termination conditions to balance search quality and computational efficiency. Common iteration termination conditions include: reaching the preset maximum number of iterations T max ; If the improvement of the optimal fitness value for several consecutive iterations (such as 20 times) is less than the set threshold (such as 0.01%), the algorithm is considered to have converged to the optimal solution. When any of the above conditions is met, the iteration is stopped and the hidden layer connection weight matrix W corresponding to the current global optimal position is output best and threshold vector b best , as the optimal parameter of ELM.
[0081] S411, using the optimal hidden layer parameter W obtained in S410 best and b best , construct the corresponding ELM structure. Then, use the training samples to train the ELM and obtain the final Duoyiguo freshness prediction model. The construction of ELM is based on the optimal hidden layer connection weight matrix W best and threshold vector b best , construct a single hidden layer ELM network. Assuming the number of nodes in the input layer of ELM is m, the number of nodes in the hidden layer is h, and the number of nodes in the output layer is 1, the mathematical model of ELM is:
[0082] Where x∈R m is the input feature vector, f(x) is the output freshness prediction value, w j ∈R m is the connection weight vector of the jth hidden layer node, b j is the threshold of the jth hidden layer node, β jis the connection weight from the jth hidden layer node to the output layer, g(*) is the hidden layer activation function, usually the Sigmoid function is selected. ELM training uses the training samples to train the constructed ELM and obtain the output layer connection weight vector β. Suppose the training sample set is {(x i ,t i )|i=1,2,....,n}, where x i ∈R m is the input feature vector of the i-th sample, t i is the expected output (freshness value) of the i-th sample, and n is the number of training samples.
[0083] Input the training samples into ELM in sequence to obtain the hidden layer output matrix H: H = [g(W best ×X+b best )], where X=[x1,x2,......x n ] T is the n×m training sample input matrix. According to ELM theory, the output layer weight vector β can be solved by the least squares method: β = H Ψ T, where H Ψ is the Moore-Penrose generalized inverse of H, T=[t1,t2,......t n ] T is the n×1 expected output vector. At this point, the ELM training is complete, and the multi-fruit freshness prediction model f(x) is obtained. This model can be used to predict the freshness of new multi-fruit samples. By introducing a chaotic sequence switching mechanism and a simulated annealing strategy, the improved chaotic sparrow search algorithm can adaptively adjust the search strategy during the iteration process, effectively enhancing the algorithm's global search capability and ability to escape local optima. Properly setting the iteration termination condition can improve computational efficiency while maintaining search quality. Using the optimal ELM parameters obtained through search to construct and train the ELM, an excellent freshness prediction model can be obtained. This model fully utilizes the ELM's fast learning speed and powerful nonlinear fitting capabilities. Through a nonlinear mapping between odor characteristics and freshness, it achieves accurate prediction of multi-fruit freshness. Compared with traditional modeling methods, this solution has stronger learning ability and generalization performance, providing strong technical support for intelligent assessment of fruit freshness.
[0084] In step S5, the collected odor data of the Duoyiguo sample to be predicted is input into the Duoyiguo freshness prediction model to obtain the Duoyiguo freshness prediction result of the corresponding sample. The Duoyiguo odor dictionary constructed in step S1 is used to perform feature extraction on the preprocessed odor data. The optimal odor feature obtained in step S24 is extracted to generate an odor feature vector for the sample to be predicted. Feature extraction methods can include non-negative matrix factorization for target detection. The extracted odor feature vector is input into the Duoyiguo freshness prediction model (optimized ELM) constructed in step S4. The ELM model receives odor features from the input layer, and through hidden layer transformation, gives the freshness prediction value of the sample to be predicted at the output layer. The output value of the ELM model is the freshness prediction result of the sample to be predicted. The freshness prediction value can be discretized into several levels as needed, such as "very fresh", "generally fresh", "not fresh", etc. The prediction result is associated with information such as the sample number, and a prediction report is generated and presented intuitively to the user.
Claims
1. A method for predicting the freshness of multifruit based on odor information, characterized in that: include: S1, collect samples of doyi fruit with different maturity and origin, and obtain the odor data of the corresponding samples; Constructing a Duoyiguo odor dictionary based on Duoyiguo odor components, performing feature extraction on sample odor data according to the Duoyiguo odor dictionary to obtain Duoyiguo odor features; S2, calculate the correlation coefficient between the odor characteristics of Duoyiguo and the freshness of Duoyiguo, and perform combination optimization based on the correlation coefficient through the binary black wolf optimization algorithm to obtain the optimal odor characteristics; S3, takes the optimal odor feature as the input layer and the multi-fruit freshness as the output layer node to construct a single hidden layer extreme learning machine ELM structure; S4, using an improved chaotic sparrow search algorithm to optimize the hidden layer connection weights and thresholds of the extreme learning machine (ELM) structure to obtain a multi-fruit freshness prediction model; wherein the improved chaotic sparrow search algorithm updates the positions of individual sparrows during the iterative optimization process by alternately using a chaotic sequence generated by a logistic map, a Chebyshev map, and a Tent map; S5, inputting the collected odor data of the to-be-predicted Duoyiguo sample into the Duoyiguo freshness prediction model to obtain the Duoyiguo freshness prediction result of the corresponding sample.
2. The method for predicting the freshness of multi-fruits based on odor information according to claim 1, characterized in that: S4, using the improved chaotic sparrow search algorithm to optimize the hidden layer connection weights and thresholds of the extreme learning machine (ELM) structure, to obtain the multi-fruit freshness prediction model, including: S41, initialize the sparrow population, encode each sparrow individual as a set of hidden layer connection weights and thresholds, and the population size is N; Initialize the maximum flight speed V of the sparrow individual max , maximum number of iterations T max , inertia weight w, acceleration constants c1 and c2, and the initial temperature T0 and cooling coefficient α of simulated annealing; S42, randomly generate three different chaotic sequences, namely Logistic mapping sequence, Chebyshev mapping sequence and Tent mapping sequence, each sequence length is N; Let t = 1, select the Logistic mapping sequence as the initial chaotic sequence; S43, constructing the corresponding ELM structure according to the hidden layer connection weights and thresholds encoded for each sparrow individual in S41, and calculating the hidden layer output matrix H using the training samples; The ELM structure corresponding to each sparrow individual is used to predict the freshness of the multi-fruit; Calculate the mean square error (MSE) between the predicted freshness and the expected output, and use the negative MSE as the fitness value of the corresponding individual; S44, classify sparrow individuals into explorers, followers, and vigilant individuals based on the fitness values of S43; S45, using the current chaotic sequence to update the position and velocity of the explorer individual; S46, updating the position of the follower individual according to the optimal position of the explorer individual; S47, randomly select an explorer individual as the center, and randomly fly within the preset range of the center to obtain the updated position of the vigilant individual; S48, calculating the average fitness value of the updated sparrow population. If the improvement of the average fitness value after several consecutive iterations is less than the set threshold, switching to the next chaotic sequence in the order of the Logistic mapping sequence, Chebyshev mapping sequence, and Tent mapping sequence, and setting t = t + 1; S49, calculate the fitness value corresponding to the new position of the explorer individual. If the fitness of the new position is better than the original position, the new position is accepted; otherwise, the new position is accepted with probability exp(-ΔE / T), where ΔE is the fitness difference between the new and old positions, T is the current temperature, and the update formula is T(t+1)=αT(t); S410, when the maximum number of iterations T is reached max Or when the improvement of the optimal fitness value after several consecutive iterations is less than the set threshold, the iteration is stopped, and the hidden layer connection weights and thresholds corresponding to the current global optimal position are output as the optimal parameters of the ELM; otherwise, return to S43; S411, using the optimal hidden layer connection weights and thresholds obtained in S410, constructing a corresponding ELM structure, and using the training samples to train the ELM to obtain a multi-fruit freshness prediction model.
3. The method for predicting the freshness of multi-fruits based on odor information according to claim 2, characterized in that: S45, using the current chaotic sequence to update the position and velocity of the explorer individual, including: X1(t+1)=X1(t)+V(t+1) V(t+1)=w(t)V(t)+c1(t)r1[X pbest (t)-X1(t)]+c2(t)r2[X gbest (t)-X1(t)] Among them, X1(t) and V(t) are the position and velocity of the explorer at time t, X1(t+1) and V(t+1) are the position and velocity of the explorer at time t+1; X pbest (t) is the historical optimal position of the explorer at time t, X gbest (t) is the global optimal position of the population at time t; r1 and r2 are random numbers in the current chaotic sequence; w(t) is the inertia weight, c1(t) and c2(t) are acceleration constants, and w(t), c1(t) and c2(t) are adaptively changing parameters.
4. The method for predicting the freshness of multi-fruits based on odor information according to claim 2, characterized in that: S46, updating the position of the follower individual according to the optimal position of the explorer individual, including: X2(t+1)=X2(t)+r3[X pbest (t)-X2(t)]+r4[X gbest (t)-X2(t)]+r5[X lbest (t)-X2(t)] Among them, X2(t) and X2(t+1) are the positions of the follower individuals at time t and time t+1 respectively; X pbest (t) is the historical optimal position of the explorer at time t, X gbest (t) is the global optimal position of the population at time t, X lbest (t) is the local optimal position of the subpopulation where the follower individual is located at time t; r3, r4 and r5 are random numbers of corresponding dimensions in the current chaotic sequence, and r3, r4, r5∈(0,1), r3+r4+r5=1, which is used to balance the contribution of the explorer individual, the global optimal individual and the local optimal individual to the update of the follower individual position.
5. The method for predicting the freshness of multi-fruits based on odor information according to claim 2, characterized in that: S47, randomly select an explorer individual as the center, and randomly fly within the preset range of the center to obtain the updated position of the vigilant individual, including: X3(t+1)=X pbest (t)+r6×R Among them, X3(t+1) is the position of the vigilant individual at time t+1, X pbest (t) is the historical optimal position of the explorer randomly selected at time t, and R ... pbest (t) is the warning radius centered, and r6 is a random number in the current chaotic sequence.
6. The method for predicting the freshness of multi-fruits based on odor information according to claim 4, characterized in that: S44, based on the fitness values of S43, classifies sparrow individuals into explorers, followers, and vigilant individuals, including: Sort N individuals in the sparrow population in descending order according to their fitness values; Select the sparrow individuals with the top N×20% fitness values after sorting as explorers, denoted as N e ; Where N is the population size; Among the remaining N×80% sparrow individuals, select the sparrow individuals with the top N×50% fitness values after sorting as followers, denoted as N f ; The remaining N×30% of sparrows are regarded as vigilant individuals, denoted as N w ; K-means clustering algorithm is used to cluster N f The follower individuals are divided into K sub-populations, the position of the follower individuals is used as the clustering feature, and the Euclidean distance is used as the similarity measure; For each follower subpopulation, the individual with the best fitness value is selected as the local optimal individual of the subpopulation, denoted as X lbest (t).
7. The method for predicting the freshness of multi-fruits based on odor information according to any one of claims 2 to 6, characterized in that: S2, calculates the correlation coefficient between the odor characteristics of Duoyiguo and the freshness of Duoyiguo, and performs combined optimization based on the correlation coefficient using the binary black wolf optimization algorithm to obtain the optimal odor characteristics, including: S21, based on the odor characteristics of the doy fruit and the freshness of the corresponding samples, calculate the Spearman rank correlation coefficient ρ and the Kendall rank correlation coefficient τ between each odor characteristic and the freshness; S22, based on the Spearman rank correlation coefficient ρ and Kendall rank correlation coefficient τ calculated in S21, uses the recursive feature elimination (RFE) method to select the odor features and obtain K candidate odor feature subsets, denoted as {S1, S2, ....., S K }; S23, for each candidate odor feature subset S i , calculate the Spearman rank correlation coefficient between it and freshness and Kendall rank correlation coefficient And the Spearman rank correlation coefficient ρ between the two odor features within the subset ij and Kendall rank correlation coefficient τ ij , set the evaluation function J(S i ); S24, the candidate odor feature subset {S1, S2, ....., S K } as the initial population of the Binary Black Wolf Optimization (BBWO) algorithm, where each black wolf individual corresponds to a candidate feature subset S i ; Each black wolf individual is encoded into a binary vector, each bit of the vector indicates whether the corresponding odor feature is selected; the evaluation function J(S23 defined i ) as the fitness function, through the cooperative hunting and population renewal strategy among black wolves, the global optimal solution is searched iteratively to obtain the optimal odor characteristics; S25, uses the optimal odor feature obtained in S24 as the input feature of S3 to construct the ELM structure.
8. The method for predicting the freshness of multi-fruits based on odor information according to claim 7, characterized in that: Set feature subset S i The evaluation function J(S i )for: in, Represents the i-th candidate odor feature subset S i The Spearman rank correlation coefficient between and freshness, Represents the i-th candidate odor feature subset S i Kendall rank correlation coefficient between ρ and freshness, ρ ij Represents the i-th candidate odor feature subset S i The Spearman rank correlation coefficient between the jth odor feature and other odor features, τ ij Represents the i-th candidate odor feature subset S i Kendall rank correlation coefficient between the jth internal odor feature and other odor features, |S i | represents the i-th candidate odor feature subset S i The number of odor features included; α and β are weight coefficients that balance relevance and redundancy, and satisfy α+β=1.
9. The method for predicting the freshness of multi-fruits based on odor information according to claim 8, characterized in that: The formula for the Spearman rank correlation coefficient ρ is: Among them, d i is the difference between the two ranks of the i-th sample, and n is the number of samples; The formula for Kendall's rank correlation coefficient τ is: Among them, n c is the number of consistent pairs, n d is the number of discordant pairs, and n is the number of samples.
10. A multi-fruit freshness prediction system based on odor information, characterized in that: include: At least one processing unit; used to execute instructions to implement the multi-fruit freshness prediction method based on odor information as described in any one of claims 1 to 9.