System for predicting insect pest types of rice based on electronic nose
Through an electronic nose-based system, rice volatile organic matter is collected and pest species is predicted using the XGBoost model, which solves the problem of timely and inefficient pest monitoring in rice, and achieves efficient and accurate pest identification.
Patent Information
- Application Number
- CN202411769897.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-04
- Publication Date
- 2025-05-02
AI Technical Summary
The timeliness and efficiency of rice pest monitoring is reduced, and the existing technology relies on traditional lighting trapping and field system investigations, resulting in monitoring delays and inefficiency.
Using an electronic nose-based system, the volatile organic matter released by rice is collected through the headspace collection device, and the electronic nose generates a feature parameter set. The processor uses a double-layer feature selection method to screen the feature subset and inputs the XGBoost model to predict pest species.
It realizes efficient and accurate identification of rice pests, improves the timeliness and efficiency of monitoring, and can quickly identify the types of pests that rice is affected by.
Smart Images

Figure CN119917949A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the technical field of agricultural monitoring and plant protection, and in particular to a system for predicting rice pest types based on an electronic nose. Background Art
[0002] As one of the world's major food crops, rice is widely grown around the world. Rice planthoppers are one of the important pests in rice production, among which rice pests caused by brown planthoppers and white-backed planthoppers seriously affect the growth and yield of rice.
[0003] In the related art, the monitoring method of rice pests mainly relies on professional plant protection personnel at regional pest and disease monitoring stations to use traditional methods such as light trapping and field system investigation. However, the above methods will cause the problem of reduced timeliness and efficiency of rice pest monitoring. Summary of the invention
[0004] The embodiments of the present application provide a system for predicting rice pest types based on an electronic nose, an optimization method for an XGBoost model, a terminal device, and a storage medium, which can solve the problem of reduced timeliness and efficiency in rice pest monitoring.
[0005] In a first aspect, an embodiment of the present application provides a system for predicting rice pest types based on an electronic nose, characterized in that the system includes a headspace collection device, an electronic nose and a processor; the headspace collection device is used to collect volatile organic compounds released by rice and transmit the volatile organic compounds to the electronic nose; the electronic nose is used to generate a feature parameter set based on the volatile organic compounds; the processor is used to filter out a feature subset that meets preset requirements from the feature parameter set according to a double-layer feature selection method, and input the feature subset that meets the preset requirements into an XGBoost model to output a prediction result of the pest type.
[0006] In a possible implementation of the first aspect, the head space collection device is composed of an activated carbon tube, a molecular sieve tube, a flow meter, a gas pump, a gas generating device and a gas sampling bag, and the various components of the head space collection device are connected in sequence using silicone tubes.
[0007] Optionally, in another possible implementation of the first aspect, the electronic nose is composed of a gas sensor array, a gas filter and a data collector;
[0008] A gas sensor array, used to react with volatile organic compounds to generate multiple response signals;
[0009] A data collector, used for collecting peak values, peak areas, average values and maximum slope values of multiple response signals as a characteristic parameter set;
[0010] Gas filter, used to clean volatile organic matter after reaction.
[0011] Optionally, in another possible implementation manner of the first aspect, the processor is used to filter out a feature subset that meets preset requirements from a feature parameter set according to a double-layer feature selection method, including:
[0012] According to the Boruta feature selection method, a first feature subset that meets the preset requirements is selected from the feature parameter set, and the random seed in the Boruta feature selection method is set to 123;
[0013] According to the mutual information value calculation and the support vector machine recursive feature elimination algorithm, a feature subset that meets the preset requirements is screened out from the first feature subset.
[0014] Optionally, in another possible implementation manner of the first aspect, the method of selecting a first feature subset that meets preset requirements from a feature parameter set according to the Boruta feature selection method includes:
[0015] Create a shadow feature for each feature parameter in the feature parameter set;
[0016] Calculate the Z-sore of each feature parameter and the Z-sore of the shadow feature corresponding to each feature parameter;
[0017] Compare the Z-sore of each feature parameter with the Z-sore of the shadow feature corresponding to each feature parameter to obtain a comparison result;
[0018] Repeat the above steps N times, where N is a positive integer;
[0019] A first feature subset is screened out from the feature parameter set according to the comparison result.
[0020] Optionally, in another possible implementation manner of the first aspect, selecting a first feature subset from the feature parameter set according to the comparison result includes:
[0021] When the comparison result is that the Z-sore of the shadow feature corresponding to the feature parameter is greater than the Z-sore of the feature parameter, the feature parameter is determined as a subset in the first feature subset;
[0022] When the comparison result shows that the Z-sore of the shadow feature corresponding to the feature parameter is less than the Z-sore of the feature parameter, the feature parameter is discarded;
[0023] When the comparison result is that the absolute value of the difference between the Z-sore of the shadow feature corresponding to the feature parameter and the Z-sore of the feature parameter is within a preset interval, the feature parameter is discarded.
[0024] Optionally, in another possible implementation of the first aspect, the method of calculating the mutual information value and the support vector machine recursive feature elimination algorithm is used to select a feature subset that meets preset requirements from the first feature subset, including:
[0025] According to the dependency relationship between each feature parameter and the classification label in the first feature subset, the mutual information value is calculated, and the feature parameters with a mutual information value of 0 in the first feature subset are discarded;
[0026] According to the preset linear support vector machine model, the weight corresponding to each feature parameter in the first feature subset is obtained, and the feature parameter with the smallest weight is discarded in the first feature subset, and the preset linear support vector machine model is retrained according to the first feature subset after discarding the feature parameter with the smallest weight, and the above steps are repeated until the number of feature parameters in the first feature subset reaches the preset number, so as to obtain a feature subset that meets the preset requirements.
[0027] In a second aspect, an embodiment of the present application provides an optimization method for an XGBoost model, comprising: determining a hyperparameter space of the XGBoost model, the hyperparameter space comprising multiple hyperparameters, the value range of each hyperparameter being a preset range, and the hyperparameter space comprising multiple hyperparameter combinations; creating an objective function so that the objective function outputs the negative value of the accuracy of the XGBoost model on a test set after receiving the hyperparameter combination; according to a Bayesian optimization algorithm, arbitrarily extracting multiple hyperparameter combinations in the hyperparameter space, and calculating the negative values of the accuracy corresponding to the multiple hyperparameter combinations in combination with the objective function; constructing a proxy model according to the negative values of the accuracy corresponding to the multiple hyperparameter combinations, and obtaining target values corresponding to the multiple hyperparameter combinations according to the proxy model; selecting a hyperparameter combination with the largest target value from the target values corresponding to the multiple hyperparameter combinations, and determining the hyperparameter combination as the current optimal hyperparameter combination; updating the proxy model according to the current optimal hyperparameter combination; repeating the above steps M times to obtain the optimal hyperparameter combination, where M is a positive integer; and optimizing the XGBoost model according to the optimal hyperparameter combination.
[0028] In a third aspect, an embodiment of the present application provides a terminal device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the aforementioned XGBoost model optimization method when executing the computer program.
[0029] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the optimization method of the XGBoost model as described above.
[0030] The embodiment of the present application provides a system for predicting the types of rice pests based on an electronic nose, comprising a headspace collection device, an electronic nose, and a processor, wherein the headspace collection device is used to collect volatile organic compounds released by rice and transmit the volatile organic compounds to the electronic nose; the electronic nose is used to generate a feature parameter set based on the volatile organic compounds; the processor is used to select a feature subset that meets the preset requirements from the feature parameter set according to a double-layer feature selection method, and input the feature subset that meets the preset requirements into an XGBoost model to output the prediction result of the pest type. In this way, the types of rice pests can be identified efficiently and accurately. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0032] Figure 1 This is a schematic diagram of the structure of a system for predicting rice pest types based on an electronic nose provided in an embodiment of the present application;
[0033] Figure 2 It is an electronic nose signal diagram of a healthy rice plant, rice damaged by brown planthoppers, and rice damaged by white-backed planthoppers provided in an embodiment of the present application;
[0034] Figure 3 This is a schematic diagram of feature selection results based on the Boruta algorithm provided in one embodiment of the present application;
[0035] Figure 4 is a schematic diagram of mutual information values of characteristic parameters provided in an embodiment of the present application;
[0036] Figure 5 is a schematic diagram of the error rate of cross-validation provided in an embodiment of the present application;
[0037] Figure 6 It is a schematic diagram of the accuracy of cross-validation provided by an embodiment of the present application;
[0038] Figure 7 This is a schematic diagram of the optimization method flow of the XGBoost model provided in one embodiment of the present application;
[0039] Figure 8 It is a structural diagram of a terminal device provided in one embodiment of the present application. DETAILED DESCRIPTION
[0040] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0041] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or combinations thereof.
[0042] It should also be understood that the term “and / or” used in the specification and appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.
[0043] As used in the specification and appended claims of this application, the term "if" can be interpreted as "when" or "uponce" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" can be interpreted as meaning "uponce it is determined" or "in response to determining" or "uponce [described condition or event] is detected" or "in response to detecting [described condition or event]", depending on the context.
[0044] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.
[0045] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.
[0046] The following describes in detail the system for predicting rice pest types based on an electronic nose, the optimization method of the XGBoost model, the terminal device and the storage medium provided by the present application with reference to the accompanying drawings.
[0047] Figure 1 The schematic diagram of the structure of a system for predicting rice pest types based on an electronic nose provided in an embodiment of the present application is shown. Figure 1 As shown, the system 100 for predicting rice pest types based on electronic nose includes: a head space collection device 110 , an electronic nose 120 and a processor 130 , wherein the head space collection device 110 is connected to the electronic nose 120 , and the electronic nose 120 is connected to the processor 130 .
[0048] The headspace collection device 110 is used to collect volatile organic compounds released by rice and transmit the volatile organic compounds to the electronic nose 120 .
[0049] It should be noted that when rice is infested by insects, the plants will release specific volatile organic compounds. The production and release patterns of these volatile organic compounds can serve as biomarkers of the degree of damage to the rice.
[0050] Furthermore, in one embodiment of the present application, the head space collection device 110 is composed of an activated carbon tube, a molecular sieve tube, a flow meter, a gas pump, a gas generating device and a gas sampling bag, and the various components of the head space collection device are connected in sequence using silicone tubes.
[0051] Preferably, as a possible implementation, the working conditions of the head space collection device 110 are: the gas flow rate is controlled to be 400 mL / min by a flow meter, and the collection time is 5 min. This application does not limit this.
[0052] The electronic nose 120 is used to generate a characteristic parameter set according to volatile organic compounds.
[0053] Preferably, as a possible implementation method, the collection parameters of the electronic nose 120 are set as follows: detection temperature is 40°C, collection time is 140s, cleaning time is 180s, detection and flushing flow rates are 0.6L / min and 2L / min respectively, ensuring the accuracy of collection and the stability of the system.
[0054] Furthermore, in an embodiment of the present application, the electronic nose 120 is composed of a gas filter 121 , a gas sensor array 122 , and a data collector 123 .
[0055] The gas filter 121 is used to clean volatile organic compounds.
[0056] The gas sensor array 122 is used to react with the cleaned volatile organic compounds to generate a plurality of response signals.
[0057] The data collector 123 is used to collect the peak values, peak areas, average values and maximum slope values of multiple response signals as a characteristic parameter set.
[0058] In an embodiment of the present application, the gas sensor array 122 may include 14 sensors, respectively named S1, S2, S3, ..., S14. The specific properties of each sensor are shown in Table 1.
[0059] Table 1
[0060] Sensor No. Sensor Name Sensor properties S1 TGS-826 Ammonia S2 MQ-138 Alcohols, ketones, aldehydes, aromatic compounds S3 MQ-136 Hydrogen sulfide, sulfide S4 MQ-4 Methane, biogas, natural gas S5 MQ-5 Liquefied gas, natural gas, coal gas S6 TGS-821 hydrogen S7 TGS-822 Alcohol, organic solvents S8 TGS2611 Methane, gas S9 MQ-2 Alkanes, alcohol, natural gas, spray S10 TGS-813 Ammonia, LPG, Methane, Propane S11 TGS2602 Organic gas S12 TGS2610 Liquefied gas, combustible gas S13 TGS2620 Alcohol, organic solvents S14 TGS2600 Smoke, cooking odor
[0061] It should be noted that the typical response signals of the 14 sensors of the electronic nose to healthy rice plants, rice plants infested by white-backed planthoppers, and rice plants infested by brown planthoppers are as follows: Figure 2 shown. Figure 2 (a) shows a healthy rice plant. Figure 2 (b) shows rice plants infested by white-backed planthoppers. Figure 2 (c) shows rice plants damaged by brown planthoppers. It can be seen from the figure that sensors S2, S3, S5, and S11 have almost no response to different types of rice plants, so sensors S2, S3, S5, and S11 are removed. The remaining 10 sensors all have obvious responses to different types of rice plants, so the remaining 10 sensors are selected to form the initial array.
[0062] After collecting the response signals of 10 sensors, the data collector 123 extracts the peak value, peak area, average value and maximum slope value of each response signal as a feature parameter set, and extracts 10×4 feature parameters in total to form a 40-dimensional feature matrix. The 40 feature parameters of each test sample are marked as Pi, Ai, Mi, Si, respectively, where i=1, 4, 6, 7, 8, 9, 10, 12, 13, 14, and Pi, Ai, Mi, Si represent the peak value, peak area, average value and maximum slope value of the response signal emitted by the i-th sensor, respectively. The corresponding relationship between the feature number and the sensor number is shown in Table 2.
[0063] Table 2
[0064] Characteristic parameters Feature Number Sensor No. Peak P1, P4, P6...P14 1,4,6,7,8,9,10,12,13,14 Peak area A1, A4, A6...A14 1,4,6,7,8,9,10,12,13,14 average value M1, M4, M6...M14 1,4,6,7,8,9,10,12,13,14 Maximum slope S1, S4, S6...S14 1,4,6,7,8,9,10,12,13,14
[0065] As a possible implementation method, after the data collector 123 collects the response signals of 10 sensors and extracts the peak value, peak area, average value and maximum slope value of each response signal as a feature parameter set, a normalization method can be used to preprocess the feature parameter set so that the data in the feature parameter set is converted into a comparable scale.
[0066] The processor 130 is used to select a feature subset that meets the requirements. The feature selection includes two layers. The first layer uses the Bortua algorithm to select the initial feature matrix, and the second layer further selects feature parameters through mutual information value (MI) and support vector machine recursive feature elimination (SVM-RFE). The feature subset that meets the preset requirements is input into the XGBoost model to output the prediction results of the pest species.
[0067] Among them, the Boruta feature selection method can refer to a feature selection method based on random forests, which aims to evaluate the importance of features through repeated randomness tests. It is suitable for high-dimensional data analysis, especially for determining the most useful input features in machine learning models.
[0068] It should be noted that the Boruta algorithm can effectively filter out irrelevant or minor features and only retain features with strong predictive power for the target variable. Therefore, in the embodiment of the present application, the preset requirement can be the importance of the feature parameter, which can be expressed in the form of a percentage as a possible implementation method, and the present application does not limit this.
[0069] In one embodiment of the present application, Figure 3 As shown in the schematic diagram of the feature selection results based on the Boruta algorithm, it can be seen that after several iterations of feature selection based on the Bortua algorithm, the 22 most closely related feature subsets are confirmed to be P7, P9, S4, M6, P8, S14, S10, S12, M10, M1, P1, M9, P12, A8, P13, P4, S13, M14, M12, M8, M13, M4. Then, according to the dependency between each feature parameter and the classification label, the mutual information value was calculated, and it was found that the mutual information value of a feature parameter M9 was 0, which means that this feature parameter is independent of the classification label and has almost no relationship. Its MI is as follows Figure 4 As shown. The SVM-RFE algorithm screened 18 feature parameters. When the number of feature parameters is 18, the error rate of 5-fold cross validation is ( Figure 5 ) and accuracy ( Figure 6 ) all achieved the most suitable. Finally, according to the above steps, the intersection of the feature parameters selected by the above machine learning algorithms was calculated, and 18 key feature subsets were obtained: M4, S14, S13, M13, M12, S12, P12, M14, P13, S4, P4, M10, S10, P7, M8, M6, M9, and A8.
[0070] Among them, the XGBoost model can refer to a type of Gradient Boosted Trees (GBT) model, which optimizes model performance by iteratively training multiple decision trees. Each tree is based on the previous tree and "corrects" the error of the previous tree by minimizing the loss function. XGBoost is an efficient, flexible and powerful machine learning algorithm, especially suitable for dealing with complex regression and classification problems. Its core advantages include efficient computing power, built-in regularization mechanism and powerful parallel processing capabilities. Through proper hyperparameter adjustment, XGBoost can provide excellent prediction performance for a variety of problems.
[0071] In the embodiment of the present application, by screening out a feature subset that meets preset requirements and inputting it into the XGBoost model for classification prediction, the prediction results of the pest types can be output more accurately.
[0072] Further, in an embodiment of the present application, the processor 130 is used to select a feature subset that meets preset requirements from a feature parameter set according to the Boruta feature selection method, and further includes:
[0073] Create a shadow feature for each feature parameter in the feature parameter set;
[0074] Calculate the Z-sore of each feature parameter and the Z-sore of the shadow feature corresponding to each feature parameter;
[0075] Compare the Z-sore of each feature parameter with the Z-sore of the shadow feature corresponding to each feature parameter to obtain a comparison result;
[0076] Repeat the above steps N times, where N is a positive integer;
[0077] According to the comparison results, a feature subset that meets the preset requirements is selected from the feature parameter set.
[0078] In the embodiment of the present application, the Boruta algorithm is used to generate shadow features and compare Z-scores to evaluate the importance of feature parameters, thereby determining the most relevant feature parameters.
[0079] It should be noted that setting the random seed to 123 means using a fixed initial value (seed) to control the process of random number generation when performing calculations involving random processes. Specifically, the random number generator generates a series of random numbers based on the seed value, and the same seed always generates the same sequence of random numbers. By setting the random seed, you can ensure that each time the program is executed, the results are still repeatable even if the algorithm involves randomness. This can help debug, reproduce experimental results, or compare different models and algorithms.
[0080] It should be noted that the shadow feature is generated by randomly scrambling the values of the feature parameters. For each feature parameter and its corresponding shadow feature, the Z-score is calculated and compared to reflect the importance of the feature parameter.
[0081] It should be noted that the Boruta algorithm automatically performs multiple iterations, regenerating shadow features and updating their Z-scores in each iteration, and repeatedly comparing importance. This iterative process can more stably screen out important features, because under different random shadow feature conditions, only truly important features can continuously show high Z-scores.
[0082] In the embodiment of the present application, the feature subset that meets the preset requirements is screened out from the feature parameter set according to the comparison result, including:
[0083] When the comparison result is that the Z-sore of the shadow feature corresponding to the feature parameter is greater than the Z-sore of the feature parameter, the feature parameter is determined as a subset of the feature subsets that meet the preset requirements;
[0084] When the comparison result shows that the Z-sore of the shadow feature corresponding to the feature parameter is less than the Z-sore of the feature parameter, the feature parameter is discarded;
[0085] When the comparison result is that the absolute value of the difference between the Z-sore of the shadow feature corresponding to the feature parameter and the Z-sore of the feature parameter is within a preset interval, the feature parameter is discarded.
[0086] In one embodiment, if the Z-sore of the shadow feature is greater than the Z-sore of the feature parameter, the feature parameter is marked as "important", otherwise it is marked as "unimportant", and it is not excluded that the situation of similarity is marked as "to be investigated". Based on this process, the Boruta algorithm can effectively screen out irrelevant or minor features and only retain features with strong predictive power for the target variable.
[0087] In the embodiment of the present application, the processor 130 uses the Bortua algorithm to screen the initial feature matrix, and then further screens the feature parameters through SVM-RFE and mutual information value. The following code execution steps can be used:
[0088]
[0089]
[0090]
[0091]
[0092]
[0093] Further, in the embodiment of the present application, the processor 130 is used to filter out a feature subset that meets preset requirements from the first feature subset according to the mutual information value calculation and the support vector machine recursive feature elimination algorithm, including:
[0094] According to the dependency relationship between each feature parameter and the classification label in the first feature subset, the mutual information value is calculated, and the feature parameters with a mutual information value of 0 in the first feature subset are discarded;
[0095] According to the preset linear support vector machine model, the weight corresponding to each feature parameter in the first feature subset is obtained, and the feature parameter with the smallest weight is discarded in the first feature subset, and the preset linear support vector machine model is retrained according to the first feature subset after discarding the feature parameter with the smallest weight, and the above steps are repeated until the number of feature parameters in the first feature subset reaches the preset number, so as to obtain a feature subset that meets the preset requirements.
[0096] The electronic nose-based system for predicting rice pest types provided in the embodiment of the present application includes a headspace collection device, an electronic nose, and a processor, wherein the headspace collection device is used to collect volatile organic compounds released by rice and transmit the volatile organic compounds to the electronic nose, the electronic nose is used to generate a feature parameter set according to the volatile organic compounds, and the processor is used to select a feature subset that meets the preset requirements from the feature parameter set according to a double-layer feature selection method, and input the feature subset that meets the preset requirements into an XGBoost model to output the prediction result of the pest type. In this way, the types of pests suffered by rice can be identified efficiently and accurately.
[0097] In an embodiment of the present application, before the feature subset that meets the preset requirements is input to the XGBoost model and the prediction result of the output pest species is output, it is also necessary to use the Bayesian optimization method to perform hyperparameter tuning for six common machine learning, such as RF model, KNN model, SVM model, LR model, XGBoost model and LightGBM model, to maximize the accuracy on the test set and determine the best hyperparameter combination. In the Bayesian optimization process, the hyperparameter space of each model is defined, the objective function is used to create and evaluate the model, and the negative value of the accuracy of the test set is used as the optimization target. After evaluation, the best hyperparameter combination is obtained. Based on this hyperparameter combination, the model is retrained to calculate the classification performance and evaluation index of the model. Finally, the XGBoost model is determined as the final classification prediction model by evaluation, and the method of optimizing the model by the Bayesian optimization method will be described below using the XGBoost model as an example.
[0098] Figure 7A schematic diagram of an optimization method for an XGBoost model provided in an embodiment of the present application is shown below. Figure 7 , the optimization method of the XGBoost model provided in the embodiments of the present application is further explained.
[0099] Step 701, determine the hyperparameter space of the XGBoost model, the hyperparameter space includes multiple hyperparameters, the value range of each hyperparameter is a preset range, and the hyperparameter space includes multiple hyperparameter combinations;
[0100] Step 702, creating an objective function so that the objective function outputs the negative value of the accuracy of the XGBoost model on the test set after receiving the hyperparameter combination;
[0101] Step 703, according to the Bayesian optimization algorithm, arbitrarily extract multiple hyperparameter combinations in the hyperparameter space, and calculate the negative values of the accuracy rates corresponding to the multiple hyperparameter combinations in combination with the objective function;
[0102] Step 704, constructing a proxy model according to the negative values of the accuracy rates corresponding to the multiple hyperparameter combinations, and obtaining target values corresponding to the multiple hyperparameter combinations according to the proxy model;
[0103] Step 705, selecting a hyperparameter combination with a maximum target value from target values corresponding to multiple hyperparameter combinations, and determining the hyperparameter combination as the current optimal hyperparameter combination;
[0104] Step 706, updating the proxy model according to the current optimal hyperparameter combination;
[0105] Step 707, repeat the above steps M times to obtain the best hyperparameter combination, where M is a positive integer;
[0106] Step 708, optimize the XGBoost model according to the optimal hyperparameter combination.
[0107] In one embodiment, the hyperparameter space may be as follows:
[0108] colsample_bytree: between 0.5 and 1;
[0109] gamma: between 0 and 5;
[0110] learning_rate: between 0.01 and 0.3;
[0111] max_depth: between 1 and 10;
[0112] n_estimators: between 50 and 500;
[0113] reg_alpha and reg_lambda: between 0 and 1;
[0114] subsample: Between 0.5 and 1.
[0115] In the embodiment of the present application, the above steps can be executed using the following code:
[0116]
[0117]
[0118]
[0119]
[0120] The optimization method of the XGBoost model provided in the embodiment of the present application determines the optimal hyperparameter combination through a Bayesian optimization method, and optimizes the XGBoost model according to the optimal hyperparameter combination, thereby improving the accuracy of classification prediction of the XGBoost model.
[0121] In one embodiment, Table 3 shows the optimal hyperparameter configurations of several models obtained by the Bayesian optimization algorithm.
[0122] Table 3
[0123]
[0124]
[0125] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0126] In order to implement the above embodiments, the present application also proposes a terminal device.
[0127] Figure 8 A schematic diagram of the structure of a terminal device according to an embodiment of the present application.
[0128] like Figure 8 As shown, the terminal device 200 includes:
[0129] A memory 210 and at least one processor 220, a bus 230 connecting different components (including the memory 210 and the processor 220), the memory 210 stores a computer program, and when the processor 220 executes the program, the optimization method of the XGBoost model described in the embodiment of the present application is implemented.
[0130] Bus 230 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor or a local bus using any of a variety of bus architectures. For example, these architectures include but are not limited to Industry Standard Architecture (ISA) bus, Micro Channel Architecture (MAC) bus, Enhanced ISA bus, Video Electronics Standards Association (VESA) local bus and Peripheral Component Interconnect (PCI) bus.
[0131] The terminal device 200 typically includes a variety of electronic device readable media, which can be any available media that can be accessed by the terminal device 200, including volatile and non-volatile media, removable and non-removable media.
[0132] The memory 210 may also include computer system readable media in the form of volatile memory, such as random access memory (RAM) 240 and / or cache memory 250. The terminal device 200 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the storage system 260 may be used to read and write non-removable, non-volatile magnetic media ( Figure 8 not shown, usually called a "hard drive"). Although Figure 8 Not shown, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk"), and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical medium) may be provided. In these cases, each drive may be connected to bus 230 via one or more data medium interfaces. Memory 210 may include at least one program product having a set (e.g., at least one) of program modules that are configured to perform the functions of the various embodiments of the present application.
[0133] A program / utility 280 having a set (at least one) of program modules 270 may be stored, for example, in the memory 210, such program modules 270 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment. The program modules 270 generally perform the functions and / or methods of the embodiments described herein.
[0134] The terminal device 200 can also communicate with one or more external devices 290 (e.g., keyboard, pointing device, display 291, etc.), and can also communicate with one or more devices that enable users to interact with the terminal device 200, and / or communicate with any device that enables the terminal device 200 to communicate with one or more other computing devices (e.g., network card, modem, etc.). This communication can be carried out through an input / output (I / O) interface 292. In addition, the terminal device 200 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN) and / or public network, such as the Internet) through a network adapter 293. As shown in the figure, the network adapter 293 communicates with other modules of the terminal device 200 through a bus 230. It should be understood that, although not shown in the figure, other hardware and / or software modules can be used in conjunction with the terminal device 200, including but not limited to: microcode, device driver, redundant processing unit, external disk drive array, RAID system, tape drive, and data backup storage system, etc.
[0135] The processor 220 executes various functional applications and data processing by running the programs stored in the memory 210 .
[0136] It should be noted that the implementation process and technical principles of the terminal device of this embodiment refer to the aforementioned explanation of the optimization method of the XGBoost model of the embodiment of the present application, which will not be repeated here.
[0137] An embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in the above-mentioned method embodiments can be implemented.
[0138] An embodiment of the present application provides a computer program product. When the computer program product runs on a terminal device, the terminal device can implement the steps in the above-mentioned method embodiments when executing the computer program product.
[0139] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may at least include: any entity or device that can carry the computer program code to the camera / terminal device, a recording medium, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electric carrier signal, a telecommunication signal, and a software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk or an optical disk. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electric carrier signals and telecommunication signals.
[0140] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0141] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0142] In the embodiments provided in the present application, it should be understood that the disclosed devices / terminal equipment and methods can be implemented in other ways. For example, the device / terminal equipment embodiments described above are only schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0143] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0144] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. A system for predicting rice pest types based on electronic nose, characterized in that: The system includes a headspace collection device, an electronic nose, and a processor; The headspace collection device is used to collect volatile organic compounds released by rice and transmit the volatile organic compounds to the electronic nose; The electronic nose is used to generate a characteristic parameter set according to the volatile organic compound; The processor is used to select a feature subset that meets preset requirements from the feature parameter set according to a double-layer feature selection method, and input the feature subset that meets the preset requirements into the XGBoost model to output a prediction result of the pest type.
2. The system according to claim 1, characterized in that The head space collection device is composed of an activated carbon tube, a molecular sieve tube, a flow meter, a gas pump, a gas generating device and a gas sampling bag, and the various components of the head space collection device are connected in sequence using silicone tubes.
3. The system according to claim 1, characterized in that The electronic nose is composed of a gas sensor array, a gas filter and a data collector; The gas sensor array is used to react with the volatile organic compounds to generate a plurality of response signals; The data collector is used to collect peak values, peak areas, average values and maximum slope values of a plurality of the response signals as the characteristic parameter set; The gas filter is used to clean the volatile organic matter after the reaction.
4. The system according to claim 3, characterized in that The processor is used to select a feature subset that meets preset requirements from the feature parameter set according to a double-layer feature selection method, including: According to the Boruta feature selection method, a first feature subset meeting the preset requirements is selected from the feature parameter set, wherein the random seed in the Boruta feature selection method is set to 123; According to the mutual information value calculation and the support vector machine recursive feature elimination algorithm, the feature subset that meets the preset requirements is screened out from the first feature subset.
5. The system according to claim 4, characterized in that The method of selecting a first feature subset that meets preset requirements from the feature parameter set according to the Boruta feature selection method includes: Creating a shadow feature for each feature parameter in the feature parameter set; Calculating the Z-sore of each of the feature parameters and the Z-sore of the shadow feature corresponding to each of the feature parameters; Comparing the Z-sore of each of the feature parameters with the Z-sore of the shadow feature corresponding to each of the feature parameters to obtain a comparison result; Repeat the above steps N times, where N is a positive integer; The first feature subset is screened out from the feature parameter set according to the comparison result.
6. The system according to claim 5, characterized in that The step of selecting the first feature subset from the feature parameter set according to the comparison result includes: When the comparison result is that the Z-sore of the shadow feature corresponding to the feature parameter is greater than the Z-sore of the feature parameter, determining the feature parameter as a subset in the first feature subset; When the comparison result is that the Z-sore of the shadow feature corresponding to the feature parameter is less than the Z-sore of the feature parameter, discarding the feature parameter; When the comparison result is that the absolute value of the difference between the Z-sore of the shadow feature corresponding to the feature parameter and the Z-sore of the feature parameter is within a preset interval, the feature parameter is discarded.
7. The system according to claim 4, characterized in that The method of calculating the mutual information value and the support vector machine recursive feature elimination algorithm to select the feature subset that meets the preset requirements from the first feature subset includes: Calculate the mutual information value according to the dependency relationship between each feature parameter and the classification label in the first feature subset, and discard the feature parameters in the first feature subset whose mutual information value is 0; According to the preset linear support vector machine model, the weight corresponding to each feature parameter in the first feature subset is obtained, and the feature parameter with the smallest weight in the first feature subset is discarded, and the preset linear support vector machine model is retrained according to the first feature subset after discarding the feature parameter with the smallest weight, and the above steps are repeated until the number of feature parameters in the first feature subset reaches the preset number, so as to obtain the feature subset that meets the preset requirements.
8. An optimization method for an XGBoost model, characterized in that: include: Determine a hyperparameter space of the XGBoost model, wherein the hyperparameter space includes multiple hyperparameters, each hyperparameter has a value range of a preset range, and the hyperparameter space includes multiple hyperparameter combinations; Creating an objective function so that the objective function outputs a negative value of the accuracy of the XGBoost model on the test set after receiving the hyperparameter combination; According to the Bayesian optimization algorithm, a plurality of the hyperparameter combinations are randomly selected in the hyperparameter space, and the negative values of the accuracy rates corresponding to the plurality of the hyperparameter combinations are calculated in combination with the objective function; Building a proxy model according to the negative values of the accuracy rates corresponding to the multiple hyperparameter combinations, and obtaining target values corresponding to the multiple hyperparameter combinations according to the proxy model; Selecting the hyperparameter combination with the largest target value from the target values corresponding to the multiple hyperparameter combinations, and determining the hyperparameter combination as the current optimal hyperparameter combination; Update the proxy model according to the current optimal hyperparameter combination; Repeat the above steps M times to obtain the best hyperparameter combination, where M is a positive integer; The XGBoost model is optimized according to the optimal hyperparameter combination.
9. A terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method according to claim 6 is implemented.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to claim 6 is implemented.