Method for predicting solution concentration model by combining selectable algorithm with spectrophotometric method

By combining spectrophotometry and multiple algorithms, selecting the most suitable algorithm for solution concentration prediction, the problem of improper algorithm selection in the existing technology is solved, the accuracy and efficiency of prediction are improved, and the self-optimization and robustness of the model are achieved. .

CN118918977APending Publication Date: 2024-11-08HUAIYIN INSTITUTE OF TECHNOLOGY
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410960657.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-17
Publication Date
2024-11-08

AI Technical Summary

Technical Problem

When predicting different solution concentrations in the prior art, improper algorithm selection will affect the reliability of experimental results and will not meet the experimental needs.

Method used

By combining spectrophotometry and multiple algorithms, the applicability of different algorithms in different sample solutions is compared, and the most suitable algorithm is selected for concentration prediction, using support vector machine algorithm, support vector regression algorithm and cuckoo based on genetic algorithm optimization The algorithm-optimized support vector machine algorithm automatically selects the most suitable algorithm for concentration prediction.

Benefits of technology

It significantly improves the accuracy and efficiency of prediction, can self-adjust key parameters according to the absorption spectral information of the solution, optimize the model structure, improve the generalization ability and prediction accuracy of the model, and reduce the error of the prediction of a single algorithm.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118918977A_ABST
    Figure CN118918977A_ABST
Patent Text Reader

Abstract

The invention relates to a method for predicting a solution concentration model by combining a selectable algorithm with a spectrophotometric method, which comprises the following steps of: firstly, acquiring spectral data through a precise instrument, and preprocessing the data by using a self-made system; carrying out spectrum regression modeling analysis by using a support vector machine algorithm optimized based on a genetic algorithm; carrying out spectrum regression modeling analysis by using a support vector regression algorithm; performing spectrum regression modeling analysis by using a support vector machine algorithm optimized based on a cuckoo algorithm; and finally, comparing differences of modeling of the three algorithms to obtain prediction algorithms most suitable for different solutions. Different results can be generated by using different algorithms for different types of samples, the concentration of different solutions can be quickly and accurately predicted, and the algorithm most suitable for the solutions can be automatically selected; the model integrates a plurality of algorithms, so that the algorithm most suitable for a specific sample solution can be effectively identified; the model can improve the prediction accuracy and efficiency, and provides more reliable data support for scientific research and experimental work.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the technical field of spectral information processing, and in particular to a method for predicting a solution concentration model by combining a selectable algorithm with a spectrophotometer. Background Art

[0002] Spectrophotometry is a commonly used chemical analysis method that determines the concentration of a substance by measuring its absorbance to light of a specific wavelength. It has the advantages of simple operation, high accuracy, and high sensitivity, and is widely used in the fields of pharmaceuticals, environmental monitoring, and food safety. The method of predicting the concentration of different solutions by spectrophotometry involves conventional techniques that use optical absorption properties to measure the concentration of substances. In this process, machine learning algorithms play a key role. Spectrophotometry data can be modeled and predicted through algorithms such as linear regression, support vector machines, random forests, and neural networks.

[0003] Conclusions When predicting different solution concentrations, data preprocessing is crucial, including denoising and normalization to ensure data quality and stability. The model training and optimization phases involve adjusting parameters and hyperparameters to achieve optimal performance, while cross-validation is used to evaluate the generalization ability and prediction accuracy of the model. Further analysis of the model prediction results, interpretation of solution concentration predictions, and exploration of possible application areas such as environmental monitoring, food safety, and medical diagnosis will provide important support for research and practice in related fields.

[0004] However, the existing technology has the problem of improper algorithm selection when predicting the concentration of different solutions. Due to the limitations of the selected algorithm, it cannot meet the experimental needs, resulting in the reliability of the experimental results being affected. Summary of the invention

[0005] In response to the technical problem of improper algorithm selection mentioned above, the present technical solution provides a method for predicting a solution concentration model by combining a selectable algorithm with spectrophotometry. By combining spectrophotometry and multiple algorithms, the applicability of different algorithms in different sample solutions is compared, and the most suitable algorithm is selected for concentration prediction, thereby improving the accuracy and efficiency of the prediction. This method of integrating multiple algorithms can better adapt to the characteristics of different samples and can effectively solve the above problems.

[0006] The present invention is achieved through the following technical solutions:

[0007] A method for predicting a solution concentration model by combining a selectable algorithm with spectrophotometry comprises the following steps:

[0008] Step 1: Collect spectral data through precision instruments and pre-process the data using a self-made system; the self-made system is a self-made GUI system, which includes the following steps:

[0009] Step 1.1: Choose a suitable GUI framework to build the system interface. You can choose PyQt5;

[0010] Step 1.2: Design the GUI system interface in Python's QT Designer, including the data import button, data visualization module, and data preprocessing module;

[0011] Step 1.3: Design a data import module, use the Pandas library in Python to implement data reading and processing, and support users to import spectral data files of different solutions through the interface, such as csv format;

[0012] Step 1.4: Design a data preprocessing module, including standardization and outlier processing operations; add corresponding buttons on the interface for users to select preprocessing methods; use the NumPy library in Python to implement data preprocessing;

[0013] Step 2: Apply the support vector machine algorithm based on genetic algorithm optimization to perform spectral regression modeling analysis;

[0014] Step 3: Apply support vector regression algorithm to perform spectral regression modeling analysis;

[0015] Step 4: Apply the support vector machine algorithm based on cuckoo algorithm optimization to perform spectral regression modeling analysis;

[0016] Step 5: Compare the differences in modeling of the three algorithms and derive the most suitable prediction algorithm for different solutions.

[0017] Furthermore, the support vector machine algorithm based on genetic algorithm optimization described in step 2 is to optimize the support vector regression algorithm using a genetic algorithm, and the optimization process includes: initializing GA parameters, encoding, defining fitness functions, genetic operations and model updating steps, optimizing the parameters of the SVR model, and obtaining optimized hyperparameters; importing processed spectral data to establish a mathematical model, and drawing a graph to display the relationship between absorbance and concentration; after training and verifying the model, optimizing and adjusting the model according to the experimental results, such as parameter adjustment and cross-validation, to improve the generalization ability and prediction accuracy of the model.

[0018] Furthermore, the imported processed spectral data is used to establish a mathematical model, wherein the algorithm modeling part includes the following steps:

[0019] Step 2.1: Define the population size, number of iterations, crossover rate, and mutation rate related parameters of the genetic algorithm; randomly generate an initial population, where each individual in the population represents a set of SVM parameter configurations;

[0020] Step 2.2: Define the fitness function according to the actual problem, and use the prediction error of SVM as the fitness function. The smaller the error, the higher the fitness.

[0021] Step 2.3: Apply the selection operator to the population, and directly pass the optimized individuals to the next generation or generate new individuals through pairing and crossover and then pass them to the next generation. In this model, the selection factor adopts the roulette selection method.

[0022] Furthermore, the basic idea of ​​the roulette wheel selection method for the factors is that the probability of each individual being selected is proportional to its fitness; specifically:

[0023] Step 2.3.1: Calculate the fitness of each individual in the population:

[0024] f(i=1,2,…,M),

[0025] In the above formula, f is the fitness function value of the individual; i is the serial number of the individual in the group; M is the size of the group;

[0026] Step 2.3.2: Calculate the probability of each individual being inherited into the next generation, that is:

[0027]

[0028] In the above formula, P(x i ) is the probability that an individual will be inherited into the next generation; f(x i ) represents the fitness of the ith individual; f(x j ) represents the fitness of the jth individual; j is the serial number of the individual in the population; N represents the total number of individuals in the population;

[0029] Step 2.3.3: Calculate the cumulative probability of each individual, that is

[0030]

[0031] In the above formula, q i represents the cumulative probability of the ith individual; P(x j ) represents the probability that the jth individual is inherited into the next generation population;

[0032] Step 2.3.4: Generate a uniformly distributed pseudo-random number r in the interval [0, 1]. If r < q[1], select individual 1. Otherwise, select individual k, so that: q[k-1] < r ≤ q[k] holds. Repeat the operation M times.

[0033] Step 2.3.5: Apply the crossover operator to the population, and then apply the mutation operator to the population, which is to change the gene values ​​at certain loci of the individual strings in the population;

[0034] Step 2.3.6: After selection, crossover and mutation operations, the population P(t) is used to obtain the next generation population P(t+1);

[0035] Step 2.3.7: Check whether the evolutionary algebraic counter t = T, then take the individual with the maximum fitness obtained in the evolution process as the optimal solution output and terminate the calculation.

[0036] Furthermore, the application of the support vector regression algorithm for spectral regression modeling analysis in step 3 is to directly establish a mathematical model for the imported processed spectral data through the support vector regression algorithm, and draw a graph to show the relationship between absorbance and concentration. The data set is divided into a training set and a test set, and the training set is trained using the support vector regression SVR algorithm. The appropriate kernel function RBF kernel function is selected to map the input features to a high-dimensional feature space; and parameters such as the penalty parameter C are adjusted to optimize the model performance. After the training is completed, the test set is used to verify the model, and the mean square error MSE and the determination coefficient R are calculated. 2 Indicators are used to evaluate the model fitting effect; finally, the model prediction results are analyzed, and the comparison between the predicted value and the true value is displayed through visualization to evaluate the accuracy and generalization ability of the model; the SVR model layer maps the input to a high-dimensional space through a kernel function and finds the optimal regression function.

[0037] Furthermore, the goal of the SVR model is to minimize the sum of squares of the distances from the training data points to the optimal hyperplane, while considering the regularization term to prevent the model from overfitting; assuming that the training set is:

[0038] D={(x1,y1),(x2,y2),…,(x n ,y n )};

[0039] Among them, x i is the feature vector of the i-th sample, y i ∈R is the true value of the i-th sample, R represents a real number, i is the serial number of the individual in the group, which is a natural number from 1 to n; D is the training set; the objective function of SVR can be expressed as:

[0040]

[0041] Among them, i ranges from 1 to n, w is the normal vector of the hyperplane, b is the bias term, ζ and ζ * is a slack variable used to deal with inseparable situations; C is a regularization parameter used to balance the weights of maximizing the interval and minimizing the error; T represents the transposed matrix; L2 regularization is used here;

[0042] In order to make the SVR prediction more accurate, it is necessary to introduce constraints in the objective function; for each sample (x i ,y i ), the following constraints need to be met:

[0043] y i -w T φ(x i )-b≤ε+ζ i ;

[0044]

[0045] Among them, ε is a positive value, indicating the tolerance to error; ζ i and is a non-negative slack variable used to handle the inseparable case; at the same time, for all ζ i and The following constraints also need to be met:

[0046]

[0047] The SVR model is then trained using the selected kernel function and parameters. The training process uses the training data set, with the goal of making the SVR model fit the data as closely as possible. The performance of the model is then evaluated using the test data set, with a mean square error of 0.0080.

[0048] Furthermore, the support vector machine algorithm based on cuckoo algorithm optimization described in step 4 is to optimize the support vector regression algorithm by cuckoo algorithm, obtain optimized hyperparameters, import the processed spectral data to establish a mathematical model, and draw a graph to show the relationship between absorbance and concentration; it is mainly through the application of cuckoo algorithm to optimize the key parameters of SVR, such as penalty parameter C, kernel function parameters, and find the optimal solution by simulating the nest parasitic behavior of birds; after the parameter optimization, use the training data set to train the support vector regression machine, and adjust the model parameters to minimize the prediction error; after the model is established, the stability and generalization ability of the model are ensured through cross-validation and test set verification.

[0049] Furthermore, the spectral regression modeling analysis is performed by applying the support vector machine algorithm optimized by the cuckoo algorithm as described in step 4, and the specific operation steps include:

[0050] Step 4.1: Determine the objective function, initialize the population, and randomly generate the initial positions of n bird nests;

[0051] Step 4.2: Set the algorithm parameters: population size N, dimension D, discovery probability, threshold value L, maximum number of iterations MaxN, optimal nest location and optimal solution;

[0052] Step 4.3: Then compare the current bird's nest position with the previous generation of bird's nest position, and use the bird's nest position with a better fitness value: Replace the bird's nest position with poor fitness value: Among them, P t-1 Indicates the location vector of the bird's nest with better fitness value in the contemporary era, g t Indicates the location vector of the bird's nest with poor fitness value in the previous generation, It represents the position of the i-th bird's nest in the t-th generation, i is a natural number from 1 to n; T is the transposed matrix.

[0053] Among them, the following formula is used to update the position of the next generation bird's nest:

[0054]

[0055] Where: represents the position of the i-th (i=1,2,…,n) bird's nest in the t-th generation; Represents point-to-point multiplication; α represents the step size control amount, which is used to control the step size. Usually, α=1; Levy(λ) is the Levy random search path, which belongs to random walk and adopts the Levy flight mechanism. The step size of its walk satisfies a heavy-tailed stable distribution, and the random step size is Levy distribution:

[0056] Levy:μ=t -λ ,1≤λ≤3;

[0057] Step 4.4: Use the random number R as the probability that the nest owner will find the foreign egg, and compare it with the probability that the bird will be eliminated P a Compare; if R>P a Then randomly change the position of the bird's nest to get a new set of bird's nest positions;

[0058] Step 4.5: Update the bird's nest position to get a set of better bird's nest positions: Update the optimal bird nest location and the optimal solution f min ;

[0059] Step 4.6: Determine whether the algorithm meets the set maximum number of iterations: If it does, end the search process and output the global optimal value f min Otherwise, repeat the second step for iterative optimization. Finally, we can get the optimal penalty factor c = 7.8325, kernel function parameter gamma = 0.7155, slack variable epsilon = 0.0262, and mean square error MSE = 0.0016.

[0060] Beneficial Effects

[0061] The method of predicting solution concentration model by combining a selectable algorithm with spectrophotometry proposed in the present invention has the following beneficial effects compared with the prior art:

[0062] (1) The present invention combines an efficient algorithm with spectrophotometry, and combines spectrophotometry with a machine learning algorithm, and can automatically select the most suitable algorithm from a variety of algorithms to predict the concentration of a solution, significantly improving the accuracy and efficiency of the prediction. The model proposed in the present invention integrates the existing support vector machine algorithm model, the support vector machine algorithm optimized by a genetic algorithm, and the support vector machine algorithm model optimized by a cuckoo algorithm. The model can select the most suitable algorithm for concentration prediction based on the absorption spectrum information of the solution. They can improve the accuracy and robustness of the prediction by self-adjusting key parameters and optimizing the model structure. Specifically, the model in the present invention first collects the absorption spectrum data of the solution using spectrophotometry, and then obtains the best hyperparameter combination by selecting a support vector regression (SVR) algorithm optimized by a genetic algorithm or a cuckoo algorithm. The selection of these algorithms and parameters is based on the optimization capability of the algorithm itself, which improves the generalization capability of the model.

[0063] (2) The spectral data prediction and analysis system implemented by the present invention based on the python language first selects a suitable Python library such as pyqt5, then imports data, followed by feature extraction, model training, prediction analysis and visualization. These steps cover the entire process from data processing to model training to result display. Through these steps, a fully functional spectral data prediction and analysis system can be constructed to process and analyze spectral data, realize prediction and visualization display. In practical applications, different types of solutions may be more suitable for using a specific prediction algorithm. The present invention allows the user to import the solution data file according to actual needs, and automatically selects the algorithm that is more suitable for the current solution, thereby further improving the accuracy of the prediction. The three prediction algorithms are integrated through python, thereby reducing the error of selecting a single algorithm for prediction and improving the accuracy of the prediction.

[0064] (3) The present invention combines the existing genetic algorithm optimized support vector machine algorithm model, support vector regression algorithm model and cuckoo algorithm optimized support vector machine algorithm model by combining spectrophotometry and multiple algorithms. The model can quickly and accurately predict the concentrations of different solutions, thereby automatically selecting the algorithm that is most suitable for the solution. Different types of samples will produce different results using different algorithms, and the present invention integrates multiple algorithms to effectively identify the algorithm that is most suitable for a specific sample solution. In this way, the model can improve the accuracy and efficiency of predictions, provide more reliable data support for scientific research and experimental work, and solve the technical problem in the prior art of not knowing how to select the algorithm that is most suitable for predicting the concentration of a specific solution. BRIEF DESCRIPTION OF THE DRAWINGS

[0065] Figure 1 It is a schematic diagram of the overall process of the present invention.

[0066] Figure 2 This is a flow chart of the support vector machine algorithm based on genetic algorithm optimization in the present invention.

[0067] Figure 3 This is a flow chart of the support vector regression algorithm in the present invention.

[0068] Figure 4 This is a flow chart of the support vector machine algorithm optimized based on the cuckoo algorithm in the present invention.

[0069] Figure 5 This is a schematic diagram of the results of algorithm prediction using the support vector machine algorithm optimized by genetic algorithm after importing data using the spectral analysis system, taking the food additive carmine pigment measured by precision instruments as an example.

[0070] Figure 6 This is a schematic diagram of the results of algorithm prediction using the support vector machine algorithm after importing data using the spectral analysis system, taking the food additive carmine pigment measured by precision instruments as an example.

[0071] Figure 7 This is a schematic diagram of the results of algorithm prediction using the support vector machine algorithm optimized by the cuckoo algorithm after importing data using the spectral analysis system, taking the food additive carmine pigment measured by precision instruments as an example. DETAILED DESCRIPTION

[0072] The following will be combined with the accompanying drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. The described embodiments are only part of the embodiments of the present invention, rather than all the embodiments. Under the premise of not departing from the design concept of the present invention, various modifications and improvements made by ordinary persons in the art to the technical solutions of the present invention should all fall within the protection scope of the present invention.

[0073] Embodiment 1:

[0074] like Figure 1 As shown, a method for predicting a solution concentration model by combining a selectable algorithm with a spectrophotometer comprises the following steps:

[0075] Step 1: Collect spectral data through precision instruments and pre-process the data using a self-made system to improve the accuracy of model prediction; the self-made system is a self-made GUI system, which includes the following steps:

[0076] Step 1.1: Select a suitable GUI framework to build the system interface. In this embodiment, PyQt5 is selected.

[0077] Step 1.2: Design the GUI system interface in Python's QT Designer, including data import button, data visualization module, data preprocessing module, etc.

[0078] Step 1.3: Design a data import module, use the Pandas library in Python to implement data reading and processing, and support users to import spectral data files of different solutions through the interface, such as csv format.

[0079] Step 1.4: Design a data preprocessing module, including standardization and outlier processing operations; add corresponding buttons on the interface for users to select preprocessing methods; use the NumPy library in Python to implement data preprocessing.

[0080] Step 2: Apply the support vector machine algorithm optimized by genetic algorithm for spectral regression modeling analysis; first import the preprocessed file in the self-made GUI system, select the GA-SVR algorithm, and then click the concentration prediction button to call the support vector regression algorithm optimized by genetic algorithm to establish the model drawing display.

[0081] Figure 2 This is the algorithm flow chart of the support vector machine algorithm based on genetic algorithm optimization. The support vector machine algorithm based on genetic algorithm optimization uses genetic algorithm to optimize the support vector regression algorithm. The optimization process includes: initializing GA parameters, encoding, defining fitness function, genetic operation and model update steps, optimizing the parameters of the SVR model, and obtaining the optimized hyperparameters; importing the processed spectral data to establish a mathematical model, and drawing a graph to show the relationship between absorbance and concentration; after training and verifying the model, optimize and adjust the model according to the experimental results, such as parameter adjustment and cross-validation, to improve the generalization ability and prediction accuracy of the model. Import the processed spectral data to establish a mathematical model, and the algorithm modeling part includes the following steps:

[0082] Step 2.1: Define the population size, number of iterations, crossover rate, and mutation rate related parameters of the genetic algorithm; randomly generate an initial population, where each individual in the population represents a set of SVM parameter configurations.

[0083] Step 2.2: Define the fitness function according to the actual problem, and use the prediction error of SVM as the fitness function. The smaller the error, the higher the fitness.

[0084] Step 2.3: Apply the selection operator to the population, and directly pass the optimized individuals to the next generation or generate new individuals through pairing and crossover and then pass them to the next generation. In this model, the selection factor adopts the roulette selection method.

[0085] The basic idea of ​​the roulette wheel selection method is that the probability of each individual being selected is proportional to its fitness; specifically:

[0086] Step 2.3.1: Calculate the fitness of each individual in the population:

[0087] f(i=1,2,…,M),

[0088] In the above formula, f is the fitness function value of the individual; i is the sequence number of the individual in the group; M is the size of the group.

[0089] Step 2.3.2: Calculate the probability of each individual being inherited into the next generation, that is:

[0090]

[0091] In the above formula, P(x i ) is the probability that an individual will be inherited into the next generation; f(x i ) represents the fitness of the ith individual; f(x j ) represents the fitness of the jth individual; j is the serial number of the individual in the population; N represents the total number of individuals in the population;

[0092] Step 2.3.3: Calculate the cumulative probability of each individual, that is

[0093]

[0094] In the above formula, q i represents the cumulative probability of the ith individual; P(x j ) represents the probability that the jth individual will be inherited into the next generation population.

[0095] Step 2.3.4: Generate a uniformly distributed pseudo-random number r in the interval [0, 1]. If r<q[1], select individual 1, otherwise, select individual k, so that: q[k-1]<r≤q[k] holds, and then repeat the operation M times.

[0096] Step 2.3.5: Apply the crossover operator to the population, and then apply the mutation operator to the population, which is to change the gene values ​​at certain loci of the individual strings in the population.

[0097] Step 2.3.6: After selection, crossover and mutation operations, the population P(t) obtains the next generation population P(t+1).

[0098] Step 2.3.7: Check whether the evolutionary algebraic counter t = T, then take the individual with the maximum fitness obtained in the evolution process as the optimal solution output and terminate the calculation.

[0099] Finally, we get the optimal penalty factor c = 2.0908, kernel function parameter gamma = 0.2409, and slack variable epsilon = 0.1469. Substituting into the model for calculation, we get the mean square error MSE = 0.0067.

[0100] Step 3: Figure 3 This is the flow chart of support vector regression algorithm; support vector regression algorithm is used for spectral regression modeling analysis.

[0101] The application of support vector regression algorithm for spectral regression modeling analysis is to directly establish a mathematical model for the imported processed spectral data through the support vector regression algorithm, and draw a graph to show the relationship between absorbance and concentration. The data set is divided into a training set and a test set, and the support vector regression SVR algorithm is used to train the model on the training set, and the appropriate kernel function RBF kernel function is selected to map the input features to a high-dimensional feature space; and the parameters such as the penalty parameter C are adjusted to optimize the model performance; after the training is completed, the test set is used to verify the model, and the mean square error MSE and the determination coefficient R are calculated. 2 Indicators are used to evaluate the model fitting effect; finally, the model prediction results are analyzed, and the comparison between the predicted value and the true value is displayed through visualization to evaluate the accuracy and generalization ability of the model; the SVR model layer maps the input to a high-dimensional space through a kernel function and finds the optimal regression function.

[0102] First, we need to determine a kernel function RBF kernel function to map the input features to a high-dimensional feature space. Then we build the SVR model. The goal of the SVR model is to minimize the sum of the squares of the distances from the training data points to the optimal hyperplane, while considering the regularization term to prevent the model from overfitting; assuming that the training set is:

[0103] D={(x1,y1),(x2,y2),…,(x n ,y n )};

[0104] Among them, x i is the feature vector of the i-th sample, y i ∈R is the true value of the i-th sample, R represents a real number; i is the sequence number of the individual in the group, which is a natural number from 1 to n; D is the training set; the objective function of SVR can be expressed as:

[0105]

[0106] Among them, i ranges from 1 to n, w is the normal vector of the hyperplane, b is the bias term, ζ and ζ * is a slack variable used to deal with inseparable situations; C is a regularization parameter used to balance the weights of maximizing the interval and minimizing the error; T represents the transposed matrix; L2 regularization is used here;

[0107] In order to make the SVR prediction more accurate, it is necessary to introduce constraints in the objective function; for each sample (x i ,y i ), the following constraints need to be met:

[0108] y i -w T φ(x i )-b≤ε+ζ i ;

[0109]

[0110] Among them, ε is a positive value, indicating the tolerance to error; ζ i and is a non-negative slack variable used to handle the inseparable case; at the same time, for all ζ i and The following constraints also need to be met:

[0111]

[0112] The SVR model is then trained using the selected kernel function and parameters. The training process uses the training data set, with the goal of making the SVR model fit the data as closely as possible. The performance of the model is then evaluated using the test data set, with a mean square error of 0.0080.

[0113] Step 4: Apply the support vector machine algorithm based on cuckoo algorithm optimization to perform spectral regression modeling analysis; Figure 4 This is the flowchart of the support vector machine algorithm optimized based on the cuckoo algorithm.

[0114] The support vector machine algorithm based on cuckoo algorithm optimization optimizes the support vector regression algorithm with the cuckoo algorithm to obtain the optimized hyperparameters, imports the processed spectral data to establish a mathematical model, and draws a graph to show the relationship between absorbance and concentration; it mainly optimizes the key parameters of SVR, such as penalty parameter C and kernel function parameters, by applying the cuckoo algorithm, and finds the optimal solution by simulating the nest parasitic behavior of birds; after parameter optimization, the support vector regression machine is trained using the training data set, and the model parameters are adjusted to minimize the prediction error; after the model is established, the stability and generalization ability of the model are ensured through cross-validation and test set verification.

[0115] The support vector machine algorithm based on cuckoo algorithm optimization is used for spectral regression modeling analysis. The specific operation steps include:

[0116] Step 4.1: Determine the objective function, initialize the population, and randomly generate the initial positions of n bird nests;

[0117] Step 4.2: Set the algorithm parameters: population size N, dimension D, discovery probability, threshold value L, maximum number of iterations MaxN, optimal nest location and optimal solution;

[0118] Step 4.3: Then compare the current bird's nest position with the previous generation of bird's nest position, and use the bird's nest position with a better fitness value: Replace the bird's nest position with poor fitness value: Among them, P t-1 Indicates the location vector of the bird's nest with better fitness value in the contemporary era, g t Indicates the location vector of the bird's nest with poor fitness value in the previous generation, It represents the position of the i-th bird's nest in the t-th generation, i is a natural number from 1 to n; T is the transposed matrix.

[0119] Among them, the following formula is used to update the position of the next generation bird's nest:

[0120]

[0121] Where: represents the position of the i-th (i=1,2,…,n) bird's nest in the t-th generation; Represents point-to-point multiplication; α represents the step size control amount, which is used to control the step size. Usually, α=1; Levy(λ) is the Levy random search path, which belongs to random walk and adopts the Levy flight mechanism. The step size of its walk satisfies a heavy-tailed stable distribution, and the random step size is Levy distribution:

[0122] Levy:μ=t -λ ,1≤λ≤3;

[0123] Step 4.4: Use the random number R as the probability that the nest owner will find the foreign egg, and compare it with the probability that the bird will be eliminated P a Compare; if R>P a Then randomly change the position of the bird's nest to get a new set of bird's nest positions;

[0124] Step 4.5: Update the bird's nest position to get a set of better bird's nest positions: Update the optimal bird nest location and the optimal solution f min ;

[0125] Step 4.6: Determine whether the algorithm meets the set maximum number of iterations: If it does, end the search process and output the global optimal value f minOtherwise, repeat the second step for iterative optimization. Finally, we can get the optimal penalty factor c = 7.8325, kernel function parameter gamma = 0.7155, slack variable epsilon = 0.0262, and mean square error MSE = 0.0016.

[0126] Step 5: Compare the differences in modeling of the three algorithms and derive the most suitable prediction algorithm for different solutions.

[0127] Compare Figure 5 , Figure 6 , Figure 7 The determination coefficient of the training set and test set of the support vector machine algorithm optimized by the genetic algorithm is about 0.9852, the determination coefficient of the training set and test set of the support vector machine algorithm is about 0.9828, and the determination coefficient of the training set and test set of the support vector regression algorithm optimized by the cuckoo algorithm is about 0.9966. Finally, it can be obtained that for the food additive carmine, the support vector regression algorithm optimized by the cuckoo algorithm has the best regression performance among the three algorithms, so the most suitable algorithm for the food additive carmine is the support vector regression algorithm based on cuckoo optimization.

[0128] The above embodiments are only for illustrating the technical concept and features of the present invention, and their purpose is to enable people familiar with the technology to understand the content of the present invention and implement it accordingly, and they cannot be used to limit the protection scope of the present invention. Any equivalent transformation or modification made according to the spirit of the present invention should be included in the present invention.

Claims

1. A method for predicting solution concentration model by combining a selectable algorithm with spectrophotometry, Features: The following steps are involved: Step 1: Collect spectral data through precision instruments and pre-process the data using a self-made system; the self-made system is a self-made GUI system, which includes the following steps: Step 1.1: Choose a suitable GUI framework to build the system interface. You can choose PyQt5; Step 1.2: Design the GUI system interface in Python's QT Designer, including the data import button, data visualization module, and data preprocessing module; Step 1.3: Design a data import module, use the Pandas library in Python to implement data reading and processing, and support users to import spectral data files of different solutions through the interface, such as csv format; Step 1.4: Design a data preprocessing module, including standardization and outlier processing operations; add corresponding buttons on the interface for users to select preprocessing methods; use the NumPy library in Python to implement data preprocessing; Step 2: Apply the support vector machine algorithm based on genetic algorithm optimization to perform spectral regression modeling analysis; Step 3: Apply support vector regression algorithm to perform spectral regression modeling analysis; Step 4: Apply the support vector machine algorithm based on cuckoo algorithm optimization to perform spectral regression modeling analysis; Step 5: Compare the differences in modeling of the three algorithms and derive the most suitable prediction algorithm for different solutions.

2. The method of predicting solution concentration model by combining a selectable algorithm with spectrophotometry according to claim 1, Features: The support vector machine algorithm based on genetic algorithm optimization described in step 2 is to optimize the support vector regression algorithm using a genetic algorithm. The optimization process includes: initializing GA parameters, encoding, defining fitness functions, genetic operations and model updating steps, optimizing the parameters of the SVR model, and obtaining optimized hyperparameters; importing processed spectral data to establish a mathematical model, and drawing a graph to display the relationship between absorbance and concentration; after training and verifying the model, optimizing and adjusting the model according to the experimental results, such as parameter adjustment and cross-validation, to improve the generalization ability and prediction accuracy of the model.

3. The method of predicting solution concentration model by combining a selectable algorithm with spectrophotometry according to claim 2, Features: The imported processed spectral data is used to establish a mathematical model, wherein the algorithm modeling part includes the following steps: Step 2.1: Define the population size, number of iterations, crossover rate, and mutation rate related parameters of the genetic algorithm; randomly generate an initial population, where each individual in the population represents a set of SVM parameter configurations; Step 2.2: Define the fitness function according to the actual problem, and use the prediction error of SVM as the fitness function. The smaller the error, the higher the fitness. Step 2.3: Apply the selection operator to the population, and directly pass the optimized individuals to the next generation or generate new individuals through pairing and crossover and then pass them to the next generation. In this model, the selection factor adopts the roulette selection method.

4. The method of predicting solution concentration model by combining a selectable algorithm with spectrophotometry according to claim 3, Features: The basic idea of ​​the roulette wheel selection method for the factors is that the probability of each individual being selected is proportional to its fitness; specifically: Step 2.3.1: Calculate the fitness of each individual in the population: f(i=1,2,…,M), In the above formula, f is the fitness function value of the individual; i is the serial number of the individual in the group; M is the size of the group; Step 2.3.2: Calculate the probability of each individual being inherited into the next generation, that is: In the above formula, P(x i ) is the probability that an individual is inherited into the next generation; f(x i ) represents the fitness of the ith individual; f(x j ) represents the fitness of the jth individual; j is the serial number of the individual in the population; N represents the total number of individuals in the population; Step 2.3.3: Calculate the cumulative probability of each individual, that is In the above formula, q i represents the cumulative probability of the ith individual; P(x j ) represents the probability that the jth individual is inherited into the next generation population; Step 2.3.4: Generate a uniformly distributed pseudo-random number r in the interval [0, 1]. If r < q[1], select individual 1. Otherwise, select individual k, so that: q[k-1] < r ≤ q[k] holds. Repeat the operation M times. Step 2.3.5: Apply the crossover operator to the population, and then apply the mutation operator to the population, which is to change the gene values ​​at certain loci of the individual strings in the population; Step 2.3.6: After selection, crossover and mutation operations, the population P(t) is used to obtain the next generation population P(t+1); Step 2.3.7: Check whether the evolutionary algebraic counter t = T, then take the individual with the maximum fitness obtained in the evolution process as the optimal solution output and terminate the calculation.

5. The method of predicting solution concentration model by combining a selectable algorithm with spectrophotometry according to claim 1, Features: The application of support vector regression algorithm for spectral regression modeling analysis in step 3 is to directly establish a mathematical model for the imported processed spectral data through the support vector regression algorithm, and draw a graph to display the relationship between absorbance and concentration. The data set is divided into a training set and a test set, and the training set is trained by the support vector regression SVR algorithm. The appropriate kernel function RBF kernel function is selected to map the input features to a high-dimensional feature space; And adjust parameters such as penalty parameter C to optimize model performance; after training, use the test set to verify the model and calculate the mean square error MSE and determination coefficient R 2 Indicators are used to evaluate the model fitting effect; finally, the model prediction results are analyzed, and the comparison between the predicted value and the true value is displayed through visualization to evaluate the accuracy and generalization ability of the model; the SVR model layer maps the input to a high-dimensional space through a kernel function and finds the optimal regression function.

6. The method of predicting solution concentration model by combining a selectable algorithm with spectrophotometry according to claim 5, Features: The goal of the SVR model is to minimize the sum of squares of the distances from the training data points to the optimal hyperplane, while taking into account the regularization term to prevent the model from overfitting; assuming that the training set is: D={(x 1 ,and 1 ),(x 2 ,and 2 ),…,(x n ,and n )}; Among them, x i is the feature vector of the i-th sample, y i ∈R is the true value of the i-th sample, R represents a real number, i is the sequence number of the individual in the group, which is a natural number from 1 to n; D is the training set; the objective function of SVR can be expressed as: Among them, i ranges from 1 to n, w is the normal vector of the hyperplane, b is the bias term, ζ and ζ * is a slack variable used to deal with inseparable situations; C is a regularization parameter used to balance the weights of maximizing the interval and minimizing the error; T represents the transposed matrix; In order to make the SVR prediction more accurate, it is necessary to introduce constraints in the objective function; for each sample (x i ,y i ), the following constraints need to be met: y i -w T φ(x i )-b≤e+z i ; Among them, ε is a positive value, indicating the tolerance to error; ζ i and is a non-negative slack variable used to handle the inseparable case; at the same time, for all ζ i and The following constraints also need to be met: g i ≥0, The SVR model is then trained using the selected kernel function and parameters. The training process will use the training data set, with the goal of making the SVR model fit the data as closely as possible. The performance of the model is then evaluated using the test data set to obtain the mean square error.

7. The method of predicting solution concentration model by combining a selectable algorithm with spectrophotometry according to claim 1, Features: The support vector machine algorithm based on cuckoo algorithm optimization described in step 4 is to optimize the support vector regression algorithm with the cuckoo algorithm to obtain the optimized hyperparameters, import the processed spectral data to establish a mathematical model, and draw a graph to show the relationship between absorbance and concentration; it is mainly through the application of the cuckoo algorithm to optimize the key parameters of SVR, such as the penalty parameter C and the kernel function parameter, and to find the optimal solution by simulating the nest parasitic behavior of birds; after the parameter optimization, the support vector regression machine is trained using the training data set, and the model parameters are adjusted to minimize the prediction error; after the model is established, the stability and generalization ability of the model are ensured through cross-validation and test set verification.

8. The method of predicting solution concentration model by combining a selectable algorithm with spectrophotometry according to claim 1, Features: Step 4 uses the support vector machine algorithm optimized by the cuckoo algorithm to perform spectral regression modeling analysis, and its specific operation steps include: Step 4.1: Determine the objective function, initialize the population, and randomly generate the initial positions of n bird nests; Step 4.2: Set the algorithm parameters: population size N, dimension D, discovery probability, threshold value L, maximum number of iterations MaxN, optimal nest location and optimal solution; Step 4.3: Then compare the current bird's nest position with the previous generation of bird's nest position, and use the bird's nest position with a better fitness value: Replace the bird's nest position with poor fitness value: Among them, P t-1 Indicates the location vector of the bird's nest with better fitness value in the contemporary era; g t The position vector of the bird nests with poor fitness values ​​in the previous generation; It represents the position of the i-th bird's nest in the t-th generation, i is a natural number from 1 to n; T is the transposed matrix. Among them, the following formula is used to update the position of the next generation bird's nest: Where: represents the position of the i-th (i=1,2,…,n) bird's nest in the t-th generation; Represents point-to-point multiplication; α represents the step size control amount, which is used to control the step size. Usually, α=1; Levy(λ) is the Levy random search path, which belongs to random walk and adopts the Levy flight mechanism. The step size of its walk satisfies a heavy-tailed stable distribution, and the random step size is Levy distribution: Lions:μ=t -λ ,1≤λ≤3; Step 4.4: Use the random number R as the probability that the nest owner will find the foreign egg, and compare it with the probability that the bird will be eliminated P a Compare; if R>P a Then randomly change the position of the bird's nest to get a new set of bird's nest positions; Step 4.5: Update the bird's nest position to get a set of better bird's nest positions: Update the optimal bird nest location and the optimal solution f min ; Step 4.6: Determine whether the algorithm meets the set maximum number of iterations: If it does, end the search process and output the global optimal value f min , otherwise, repeat the second step for iterative optimization.

Citation Information

Patent Citations

  • Aquaculture dissolved oxygen prediction method

    CN110598895A

  • Method for selecting near infrared spectrum characteristic wavelength of black vinegar solution based on combinatorial algorithm

    CN116525018A