Prediction model training method and prediction method for predicting agricultural product planting type
Through the preprocessing of high-resolution mass spectrometry data and the training of machine learning models, the problem of difficulty in identifying organic and conventionally grown agricultural products in the prior art is solved, and more efficient prediction of agricultural product cultivation types and food safety assessment are achieved.
Patent Information
- Application Number
- CN202510020485.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-07
- Publication Date
- 2025-02-11
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The difficulty in effectively identifying and distinguishing organic and conventionally grown agricultural products in the prior art has led to challenges in food safety and environmental sustainability assessment.
By obtaining high-resolution mass spectrometry data samples of organic and conventionally grown agricultural products, pre-processing and box partitioning, extracting mass spectrometry sample feature vectors, and using machine learning models for training and verification, we finally obtain target predictions for predicting agricultural product planting types. Model.
It improves the classification accuracy and efficiency of organic and conventionally grown agricultural products, and provides a more effective tool for assessing food sample quality and safety.
Smart Images

Figure CN119416069A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of safety assessment technology, and more specifically to a prediction model training method for predicting agricultural product planting types, and a prediction method and device for predicting agricultural product planting types. Background Art
[0002] The use of chemical fertilizers, pesticides, veterinary drugs, growth regulators and other chemicals in agricultural production has increased agricultural productivity and output, but has also caused a steady stream of health hazards and environmental pollution problems. In this context, organic agriculture, which does not use any synthetic agricultural chemicals and genetic engineering technology, has been proposed and has gradually developed into a huge industry. In recent years, due to the public's increasing concern about food safety, nutritional health, animal welfare and environmental sustainability, organic agricultural products have gradually become an important choice for consumers. Therefore, in order to ensure the authenticity of organic products, it is particularly important to identify and verify organic products. Summary of the invention
[0003] In view of the above problems, the present invention provides a prediction model training method for predicting the planting type of agricultural products, and a prediction method and device for predicting the planting type of agricultural products.
[0004] According to a first aspect of the present invention, there is provided a method for training a prediction model for predicting the planting type of agricultural products, comprising: obtaining high-resolution mass spectrometry data samples of organically grown agricultural products and conventionally grown agricultural products and classification labels corresponding to the high-resolution mass spectrometry data samples, wherein the classification labels characterize the planting type of agricultural products; preprocessing each high-resolution mass spectrometry data sample to obtain a standardized mass spectrometry data sample, and for each standardized mass spectrometry data sample, dividing the standardized mass spectrometry data sample into M box samples of equal length, wherein M is an integer greater than 1; based on the total ion abundance corresponding to each of the M box samples, obtaining a mass spectrometry sample feature vector corresponding to the standardized mass spectrometry data sample, wherein the total ion abundance is obtained by adding the ion abundances of all fragment peaks in the box sample; using a data set to verify multiple sets of hyperparameter combinations on an initial prediction model to obtain an optimal hyperparameter combination, wherein the data set includes the mass spectrometry sample feature vector and the classification label; training the initial prediction model based on the optimal hyperparameter combination to obtain a target prediction model.
[0005] The second aspect of the present invention provides a prediction method for predicting agricultural product planting types, including: obtaining high-resolution mass spectrometry data of the agricultural product to be predicted; preprocessing the high-resolution mass spectrometry data to obtain standardized mass spectrometry data, and dividing the standardized mass spectrometry data into M boxes of equal length; based on the total ion abundance corresponding to each of the M boxes, obtaining a mass spectrometry feature vector corresponding to the standardized mass spectrometry data; inputting the mass spectrometry feature vector into a target prediction model, outputting a classification value of the agricultural product planting type, and the target prediction model is used to predict the agricultural product planting type; comparing the classification value of the agricultural product planting type with the agricultural product classification judgment threshold to obtain a classification result of the agricultural product planting type to be predicted.
[0006] The third aspect of the present invention provides a training device for a prediction model for predicting the planting type of agricultural products, comprising: a first acquisition module, used to acquire high-resolution mass spectrometry data samples of organically grown agricultural products and conventionally grown agricultural products and classification labels corresponding to the high-resolution mass spectrometry data samples, wherein the classification labels characterize the planting type of agricultural products; a box division module, used to preprocess each high-resolution mass spectrometry data sample to obtain a standardized mass spectrometry data sample, and for each standardized mass spectrometry data sample, divide the standardized mass spectrometry data sample into M boxes of equal length, wherein M is an integer greater than 1; a mass spectrometry sample feature vector acquisition module, used to obtain a mass spectrometry sample feature vector corresponding to the standardized mass spectrometry data sample based on the total ion abundance corresponding to each of the M boxes, wherein the total ion abundance is obtained by adding the ion abundances of all fragment peaks in the box sample; an optimal hyperparameter combination acquisition module, used to use a data set to verify multiple sets of hyperparameter combinations on an initial prediction model to obtain an optimal hyperparameter combination, wherein the data set includes mass spectrometry sample feature vectors and classification labels; a target prediction model acquisition module, used to train the initial prediction model based on the optimal hyperparameter combination to obtain a target prediction model.
[0007] The fourth aspect of the present invention provides a prediction device for predicting agricultural product planting types, including: a second acquisition module, used to acquire high-resolution mass spectrometry data of the agricultural product to be predicted; a box sample division module, used to preprocess the high-resolution mass spectrometry data to obtain standardized mass spectrometry data, and divide the standardized mass spectrometry data into M boxes of equal length; a mass spectrometry feature vector acquisition module, used to obtain the mass spectrometry feature vector corresponding to the standardized mass spectrometry data based on the total ion abundance corresponding to each of the M boxes; an output module, used to input the mass spectrometry feature vector into a target prediction model, and output the classification value of the agricultural product planting type; a classification result acquisition module, used to compare the classification value of the agricultural product planting type with the agricultural product classification judgment threshold, and obtain the classification result of the agricultural product planting type to be predicted.
[0008] According to an embodiment of the present invention, high-resolution mass spectrometry data samples of organically grown agricultural products and conventionally grown agricultural products are obtained, each high-resolution mass spectrometry data sample is preprocessed to obtain a standardized mass spectrometry data sample, and for each standardized mass spectrometry data sample, the standardized mass spectrometry data sample can be divided into M box samples of equal length, and based on the total ion abundance corresponding to each of the M box samples, a mass spectrometry sample feature vector corresponding to the standardized mass spectrometry data sample can be obtained, so that useful information can be more effectively extracted from complex high-resolution mass spectrometry data samples, and multiple groups of hyperparameter combinations can be verified on the initial prediction model using the data set to obtain the optimal hyperparameter combination, and the performance of the prediction model and the accuracy of the prediction can be significantly improved based on the optimal hyperparameter combination, and the initial prediction model is trained using the optimal hyperparameter combination to obtain a target prediction model, and the obtained target prediction model can be used to quickly and efficiently predict the type of agricultural products, thereby improving the accuracy and efficiency of the classification of organically grown and conventionally grown agricultural products, and has important application prospects for the quality and safety assessment of complex food samples. BRIEF DESCRIPTION OF THE DRAWINGS
[0009] The above contents and other objects, features and advantages of the present invention will become more apparent through the following description of the embodiments of the present invention with reference to the accompanying drawings, in which:
[0010] Figure 1 A diagram showing an application scenario of a training method, a prediction method, and an apparatus for predicting a prediction model for predicting a planting type of agricultural products according to an embodiment of the present invention;
[0011] Figure 2 A flow chart showing a method for training a prediction model for predicting agricultural product planting types according to an embodiment of the present invention is shown;
[0012] Figure 3 A schematic diagram showing a method for obtaining a mass spectrum feature vector according to an embodiment of the present invention is shown;
[0013] Figure 4 A flowchart of a prediction method for predicting the planting type of agricultural products according to an embodiment of the present invention is shown;
[0014] Figure 5 A structural block diagram of a training device for a prediction model for predicting the planting type of agricultural products according to an embodiment of the present invention is shown;
[0015] Figure 6 It shows a structural block diagram of a prediction device for predicting the planting type of agricultural products according to an embodiment of the present invention;
[0016] Figure 7 A block diagram of an electronic device suitable for implementing a training method and a prediction method of a prediction model for predicting the planting type of agricultural products according to an embodiment of the present invention is shown. DETAILED DESCRIPTION
[0017] Below, embodiments of the present invention will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the present invention. In the following detailed description, for ease of explanation, many specific details are set forth to provide a comprehensive understanding of embodiments of the present invention. However, it is apparent that one or more embodiments may also be implemented without these specific details. In addition, in the following description, descriptions of known structures and technologies are omitted to avoid unnecessary confusion of concepts of the present invention.
[0018] The terms used herein are only for describing specific embodiments and are not intended to limit the present invention. The terms "comprise", "include", etc. used herein indicate the existence of the features, steps, operations and / or components, but do not exclude the existence or addition of one or more other features, steps, operations or components.
[0019] All terms (including technical and scientific terms) used herein have the meanings commonly understood by those skilled in the art unless otherwise defined. It should be noted that the terms used herein should be interpreted as having a meaning consistent with the context of this specification and should not be interpreted in an idealized or overly rigid manner.
[0020] When using expressions such as "at least one of A, B, and C, etc.", they should generally be interpreted according to the meaning of the expression commonly understood by those skilled in the art (for example, "a system having at least one of A, B, and C" should include but is not limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, C, etc.).
[0021] The identification and classification of organic and conventionally grown agricultural products is a complex issue in itself. Because there are differences in fertilizer use and agricultural practice management between organic and conventional agricultural planting modes, the differences in the content of macronutrients, bioactive substances, secondary metabolites, volatile organic compounds, pesticide residues, heavy metals, etc. are reflected in the composition. At present, a large number of studies are devoted to finding biomarkers between organic and conventionally grown agricultural products, and the content differences of markers in different planting modes have also been confirmed. For example, organic agricultural products contain higher levels of a series of antioxidant active substances such as polyphenols. At the same time, organic agricultural products have lower concentrations of harmful heavy metals and synthetic agricultural chemicals. However, due to the diversity and complexity of different crops, varieties, regions, climates and other factors, it is obviously unrealistic to classify organic products once and for all by a single marker. Therefore, it is very necessary to widely identify multiple components in organic products and consider the joint effects of multiple components.
[0022] Non-target analysis methods based on high-resolution mass spectrometry can comprehensively obtain the mass spectrometric characteristics of all component compounds in a sample due to its high sensitivity and unbiased data acquisition. In recent years, it has become a powerful tool for identifying the authenticity of organic agricultural products. The characteristic of non-target analysis is that it does not rely on preset target compounds, but uses high-throughput, high-resolution mass spectrometry technology to comprehensively screen and identify all detectable substances in the sample. Non-target analysis of complex samples can usually obtain mass-to-charge ratio and relative abundance information of thousands of molecular features, which makes data processing, statistical analysis and compound identification of non-target mass spectrometry data the key steps of non-target analysis. In the current research on the classification of organic agricultural products, the analysis of non-target mass spectrometry data mainly uses statistical analysis, especially multivariate analysis methods to analyze the differences between samples, so as to mine potential biomarkers for the next step of identification. For example, some studies use dimensionality reduction methods such as principal component analysis (PCA) and linear discriminant analysis to select features from raw data, thereby simplifying features. This type of method focuses on feature selection, and only analyzes and identifies a few significant features in mass spectrometry data, and does not fully exploit the potential of rich structural information contained in non-target mass spectrometry data. At the same time, traditional statistical analysis methods are somewhat incapable of classifying multidimensional mass spectrometry features.
[0023] In recent years, machine learning algorithms can fully learn the composition rules of mass spectrometry peaks of different types of samples due to their strong data processing capabilities and high efficiency, providing the possibility of establishing a classification prediction model based on the full spectrum. Although machine learning methods based on mass spectrometry data have been used in a small number of food classifications, such as the identification of different regional attributes of honey and organic agricultural products, these studies mainly adopt the method of first selecting features and then establishing a prediction model, which leads to a large degree of feature loss and cannot achieve comprehensive learning of global spectral features, resulting in poor performance in the identification of organic products. When analyzing complex food samples, the reliance on a single marker makes the classification process face limitations and cannot fully reflect the true characteristics of the sample. In addition, the currently used statistical analysis methods make it impossible to fully explore the rich structural information of non-target mass spectrometry data. According to the literature survey on the non-targeted method for evaluating the quality and safety risks of complex food samples, it can be seen that the methods or technologies involved have shortcomings. When analyzing complex food samples, the reliance on a single marker makes the classification process face limitations and cannot fully reflect the true characteristics of the sample. In addition, in the process of mining potential biomarkers, the focus is usually on feature selection, and only a few significant features in the mass spectrometry data are analyzed, failing to fully utilize the rich structural information contained in non-target mass spectrometry data.
[0024] In view of this, the present invention provides a training method for a prediction model for predicting the planting type of agricultural products, the method comprising:
[0025] High-resolution mass spectrometry data samples of organically grown agricultural products and conventionally grown agricultural products and classification labels corresponding to the high-resolution mass spectrometry data samples are obtained, wherein the classification labels characterize the types of agricultural products grown; each high-resolution mass spectrometry data sample is preprocessed to obtain a standardized mass spectrometry data sample, and for each standardized mass spectrometry data sample, the standardized mass spectrometry data sample is divided into M box samples of equal length, wherein M is an integer greater than 1; based on the total ion abundance corresponding to each of the M box samples, a mass spectrometry sample feature vector corresponding to the standardized mass spectrometry data sample is obtained, wherein the total ion abundance is obtained by adding the ion abundances of all fragment peaks in the box sample; multiple sets of hyperparameter combinations are verified on the initial prediction model using the data set to obtain the optimal hyperparameter combination, wherein the data set includes the mass spectrometry sample feature vector and the classification label; the initial prediction model is trained based on the optimal hyperparameter combination to obtain a target prediction model.
[0026] In the technical solution of the present invention, the user information (including but not limited to user personal information, user image information, user device information, such as location information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved are all information and data authorized by the user or fully authorized by all parties, and the collection, storage, use, processing, transmission, provision, disclosure and application of the relevant data comply with relevant laws, regulations and standards, take necessary confidentiality measures, do not violate public order and good morals, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0027] Figure 1 A diagram showing an application scenario of a training method, a prediction method, and an apparatus for predicting a prediction model for predicting the planting type of agricultural products according to an embodiment of the present invention.
[0028] like Figure 1 As shown, the application scenario 100 according to this embodiment may include a first terminal device 101, a second terminal device 102, a third terminal device 103, a network 104, and a server 105. The network 104 is used to provide a medium for a communication link between the first terminal device 101, the second terminal device 102, the third terminal device 103, and the server 105. The network 104 may include various connection types, such as wired, wireless communication links, or optical fiber cables, etc.
[0029] The user can use the first terminal device 101, the second terminal device 102, and the third terminal device 103 to interact with the server 105 through the network 104 to receive or send messages, etc. Various communication client applications can be installed on the first terminal device 101, the second terminal device 102, and the third terminal device 103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only for example).
[0030] The first terminal device 101, the second terminal device 102, and the third terminal device 103 may be various electronic devices having display screens and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, and the like.
[0031] The server 105 may be a server that provides various services, such as a background management server (only as an example) that provides support for websites browsed by users using the first terminal device 101, the second terminal device 102, and the third terminal device 103. The background management server may analyze and process the received data such as user requests, and feed back the processing results (such as web pages, information, or data obtained or generated according to user requests) to the terminal device.
[0032] It should be noted that the training method and prediction method of the prediction model for predicting the planting type of agricultural products provided in the embodiment of the present invention can generally be executed by the server 105. Accordingly, the prediction model training device for predicting the planting type of agricultural products and the prediction device for predicting the planting type of agricultural products provided in the embodiment of the present invention can generally be set in the server 105. The training method and prediction method of the prediction model for predicting the planting type of agricultural products provided in the embodiment of the present invention can also be executed by a server or server cluster that is different from the server 105 and can communicate with the first terminal device 101, the second terminal device 102, the third terminal device 103 and / or the server 105. Accordingly, the prediction model training device for predicting the planting type of agricultural products and the prediction method for predicting the planting type of agricultural products provided in the embodiment of the present invention can also be set in a server or server cluster that is different from the server 105 and can communicate with the first terminal device 101, the second terminal device 102, the third terminal device 103 and / or the server 105.
[0033] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0034] The following will be based on Figure 1 The scene described by Figures 2 to 4The training method and prediction method of the prediction model for predicting the planting type of agricultural products in the disclosed embodiment are described in detail.
[0035] Figure 2 A flow chart of a method for training a prediction model for predicting the planting type of agricultural products according to an embodiment of the present invention is shown.
[0036] like Figure 2 As shown, the training method of the prediction model for predicting the planting type of agricultural products in this embodiment includes operations S210 to S250.
[0037] In operation S210, high-resolution mass spectrum data samples of organically grown agricultural products and conventionally grown agricultural products and classification labels corresponding to the high-resolution mass spectrum data samples are acquired.
[0038] In operation S220, each high-resolution mass spectrum data sample is preprocessed to obtain a standardized mass spectrum data sample, and for each standardized mass spectrum data sample, the standardized mass spectrum data sample is divided into M box samples of equal length.
[0039] In operation S230 , a mass spectrum sample feature vector corresponding to the standardized mass spectrum data sample is obtained based on the total ion abundance corresponding to each of the M box samples.
[0040] In operation S240 , multiple sets of hyperparameter combinations are verified on the initial prediction model using the data set to obtain an optimal hyperparameter combination.
[0041] In operation S250, an initial prediction model is trained based on the optimal hyperparameter combination to obtain a target prediction model.
[0042] Optionally, high-resolution mass spectrometry data samples of organically grown agricultural products and conventionally grown agricultural products and classification labels corresponding to the high-resolution mass spectrometry data samples can be obtained from public data sets. The classification labels can characterize the agricultural product planting types, which can include conventional planting and organic planting.
[0043] Alternatively, data obtained from a high-resolution mass spectrometer using a non-targeted analysis method is high-resolution mass spectrometry data. High-resolution mass spectrometry (HRMS) is an analytical technique that can accurately measure the mass-to-charge ratio (m / z) of ions, and is mainly used to separate and identify complex compounds. The core principle is to form ions by ionizing the sample and separate them according to the mass-to-charge ratio under the action of electric and magnetic fields.
[0044] Optionally, each high-resolution mass spectrum data sample may be preprocessed to obtain a standardized mass spectrum data sample, and the high-resolution mass spectrum data sample may include information such as an accurate mass-to-charge ratio number and a mass spectrometer mass-to-charge ratio range.
[0045] Optionally, for each standardized mass spectrum data sample, the standardized mass spectrum data sample can first be divided into M box samples of equal length within the mass-to-charge ratio range. The ion abundances of all fragment peaks in the same box sample can be added to obtain the total ion abundance. Based on the total ion abundances corresponding to each of the M box samples, a mass spectrum sample feature vector with a length of M can be obtained. The data set can include the mass spectrum sample feature vector and the classification label.
[0046] Optionally, the data set may include a mass spectrometry sample feature vector and a label vector T. The length of the label vector T is N, and each element in T , indicating whether the i-th sample is an organic agricultural product or a conventional agricultural product. The label ‘0’ indicates that the agricultural product is conventionally grown, and the label ‘1’ indicates that the agricultural product is organically grown.
[0047] Optionally, for example, high-resolution mass spectrometry data samples corresponding to 80 organically grown agricultural product samples and 80 conventionally grown agricultural product samples can be obtained from a public data set, totaling 160 agricultural product samples. The 160 agricultural product samples can be detected using a mass spectrometer in positive ion mode, with a mass-to-charge ratio (m / z) ranging from 150 to 1700. Each sample can be subjected to 10 spectral acquisitions, and a total of 1600 high-resolution mass spectrometry data samples are obtained. The 1600 high-resolution mass spectrometry data samples are then subjected to preprocessing operations such as mass spectrum peak extraction, mass-to-charge ratio alignment, data normalization, and denoising. The preprocessed data contains a total of 16,227 m / z peaks, i.e., data features. The value on each feature represents the abundance of fragment ions of the standardized mass spectrometry data sample at the m / z peak. An abundance of 0 indicates that the high-resolution mass spectrometry sample has no fragment ion peak at the m / z. For each standardized mass spectrometry data sample, first divide M = 1000 boxes of equal length in the m / z range of 150 to 1700, then add the ion abundances of all fragment peaks in the same box sample to obtain the total ion abundance. Based on the total ion abundances corresponding to each of the M box samples, an M = 1000-dimensional mass spectrometry sample feature vector can be obtained. And the agricultural product sample corresponding to each mass spectrometry sample feature vector has a binary classification label of organic group or conventional group to form a label vector T. The length of label vector T is 1600, and each element in T , indicating whether the agricultural product sample corresponding to the i-th high-resolution mass spectrometry data sample is an organic agricultural product. The label '0' indicates that the agricultural product is conventionally grown, and the label '1' indicates that the agricultural product is organically grown. The final 1600×1000 feature matrix and the 1600-dimensional label vector T together constitute the data set for machine learning modeling. The size of the feature matrix D is N×M, where N is the number of standardized mass spectrometry data samples, M is the length of the mass spectrometry feature vector, and each element in D It represents the probability that the i-th sample corresponds to the mass spectrum peak feature j with a specific mass-to-charge ratio (m / z).
[0048] Optionally, the dataset can be used to verify multiple sets of hyperparameter combinations on the initial prediction model to obtain the optimal hyperparameter combination. The initial prediction model can be a model based on a weighted voting mechanism. The initial prediction model adopts an iterative weighting method, and its base models are all weak classifiers (usually decision stumps). Iterates n times in total, and each new model focuses on the data points that were misclassified in the previous round, and improves the accuracy of the model by adjusting the weights of the data points. The goal of the initial prediction model is to improve the performance of the overall model by weighted combination of the prediction results of all weak classifiers. The final prediction result is the result of weighted voting of all weak classifiers.
[0049] Optionally, the initial prediction model may be trained based on the optimal hyperparameter combination to obtain the target prediction model. The model trained when the optimal hyperparameter combination is obtained may also be determined as the target prediction model.
[0050] Optionally, for example, 20% of the 160 agricultural product samples are first taken from the total data set consisting of the above 1600×1000 feature matrix and the 1600-dimensional label vector T, and the corresponding mass spectrometry data constitute the test set data. Then the remaining agricultural product samples are randomly stratified and divided five times in a ratio of 3:1. In each division, the mass spectrometry data corresponding to the agricultural product samples with a ratio of 3:1 constitute the training set and the validation set respectively. The training set is used to train the machine learning model, and the five-divided training set and validation set are used for five repeated validations to find the optimal hyperparameters, and the test set is used to evaluate the generalization ability of the model.
[0051] Figure 3 A schematic diagram of a method for obtaining a mass spectrum sample feature vector according to an embodiment of the present invention is shown.
[0052] like Figure 3As shown, taking tomatoes as an example of agricultural products, multiple standardized mass spectrum data samples 310 of tomatoes can be obtained. For each standardized mass spectrum data sample, the standardized mass spectrum data sample is divided into M equal-length box samples 320, and the ion abundances of all fragment peaks in each box sample are added to obtain the total ion abundance 330 of the box sample. Based on the total ion abundances corresponding to each of the M box samples, a mass spectrum sample feature vector corresponding to the standardized mass spectrum data sample is obtained. Based on multiple standardized mass spectrum data samples, multiple mass spectrum sample feature vectors 340 can be obtained, and each mass spectrum sample feature vector has a corresponding classification label (i.e., organically grown tomatoes and conventionally grown tomatoes). The multiple data in the data set are classified using the initial prediction model to obtain a classification schematic diagram 350. According to the classification schematic diagram, organically grown tomatoes and conventionally grown tomatoes can be separated, as shown in 360.
[0053] According to an embodiment of the present invention, high-resolution mass spectrometry data samples of organically grown agricultural products and conventionally grown agricultural products are obtained, each high-resolution mass spectrometry data sample is preprocessed to obtain a standardized mass spectrometry data sample, and for each standardized mass spectrometry data sample, the standardized mass spectrometry data sample can be divided into M box samples of equal length, and based on the total ion abundance corresponding to each of the M box samples, a mass spectrometry sample feature vector corresponding to the standardized mass spectrometry data sample can be obtained, so that useful information can be more effectively extracted from complex high-resolution mass spectrometry data samples, and multiple groups of hyperparameter combinations can be verified on the initial prediction model using the data set to obtain the optimal hyperparameter combination, and the performance of the prediction model and the accuracy of the prediction can be significantly improved based on the optimal hyperparameter combination, and the initial prediction model is trained using the optimal hyperparameter combination to obtain a target prediction model, and the obtained target prediction model can be used to quickly and efficiently predict the type of agricultural products, thereby improving the accuracy and efficiency of the classification of organically grown and conventionally grown agricultural products, and has important application prospects for the quality and safety assessment of complex food samples.
[0054] Optionally, multiple sets of hyperparameter combinations are verified on the initial prediction model using the data set to obtain the optimal hyperparameter combination, including: using a grid search algorithm to process a preset shrinkage step range and a preset weak classifier number range to obtain multiple sets of hyperparameter combinations, wherein the hyperparameter combination includes the shrinkage step size and the number of weak classifiers; using A% of the data set as a test set, and repeatedly dividing the remaining data set N times based on a preset ratio to obtain N division results, wherein the division results include a training set and a validation set, A>0, and N is an integer greater than 1; for each set of hyperparameter combinations, using the initial prediction model to process the N division results separately to obtain N areas under the curve; determining the average area under the curve of the N areas under the curve; for multiple sets of hyperparameter combinations, among the multiple average areas under the curve, the hyperparameter combination corresponding to the maximum average area under the curve is determined as the optimal hyperparameter combination.
[0055] Optionally, a grid search algorithm can be used to process the preset shrinkage step range and the preset weak classifier number range to obtain multiple sets of hyperparameter combinations. Each set of hyperparameter combinations can include the shrinkage step size and the number of weak classifiers. From the data set including the mass spectrum feature vector and the label vector, A% of the samples can be first taken, and the corresponding mass spectrum data constitutes the test set data. Then, the remaining data set is randomly divided into layers N times according to the ratio of a:b. In each division, the ratio is The data corresponding to the samples constitute the training set and the validation set respectively. The training set is used to train the initial prediction model. The training set and validation set divided d times are used for d repeated validations to find the optimal hyperparameters. The test set is used to evaluate the generalization ability of the model to avoid repeated scanning data of the same sample being simultaneously divided into the training set, validation set and test set, resulting in abnormal test results. For example, there are 2 sets of hyperparameter combinations in total, and the remaining data set is divided 3 times based on the preset ratio, and 3 division results can be obtained. The 3 division results can be identified as A, B, and C. Each division result includes a training set and a test set.
[0056] Optionally, for each set of hyperparameter combinations, the initial prediction model can be used to process N partition results respectively, obtain N areas under the curve, and determine the average area under the curve of the N areas under the curve. For example, for each set of hyperparameter combinations, the initial prediction model can be used to process the partition results A, B, and C respectively, and three areas under the curve corresponding to the partition results A, B, and C can be obtained. The three areas under the curve are averaged to obtain the average area under the curve corresponding to the set of hyperparameter combinations. For two sets of hyperparameter combinations, two average areas under the curve can be obtained. Among the two average areas under the curve, the hyperparameter combination corresponding to the maximum average area under the curve can be determined as the optimal hyperparameter combination.
[0057] Optionally, for example, determine that the partition results are 5, determine the hyperparameter search space of the model (i.e., the preset shrinkage step range and the preset weak classifier number range), and tune the hyperparameters. Parameter tuning can be divided into four steps: The first step is to select the initial learning rate (i.e., the preset shrinkage step range, learning_rate) and the number of weak classifiers (n_estimators) as the search range. The range of learning rate is {0.1, 0.3, 0.5, 0.7, 1}, and the range of weak classifier number is {150, 200, 250}. The second step is to determine several sets of hyperparameter combinations, and for each set of hyperparameter combinations, perform five repeated validations on the five-partition training set and validation set to evaluate the model performance. The third step is to use the area under the curve of the receiver operating characteristic curve (AUROC) as the evaluation indicator of model performance. The following are some specific results: For learning_rate = 0.1, n_estimators = 250, the score is 0.979625. For learning_rate = 0.5, n_estimators = 250, the score is 0.9815703125. For learning_rate = 0.7, n_estimators = 250, the score is 0.9818125 (best score). Step 4. Find the best score and corresponding parameter combination among all the tested parameter combinations: the best score is 0.9818125, and the corresponding parameters are {'learning_rate': 0.7, 'n_estimators': 250}. By systematically evaluating the combinations of different learning rates and the number of weak classifiers, the best hyperparameter combination {'learning_rate': 0.7, 'n_estimators': 250} is finally selected.
[0058] Optionally, the initial prediction model is used to process N partitioning results separately to obtain N areas under the curves, including: for each partitioning result, the initial prediction model is trained based on the training set in the partitioning result to obtain a trained model; the validation set in the partitioning result is input into the trained model, and a set of classification prediction probability values is output; based on the classification prediction probability value set and the classification label corresponding to the validation set, the receiver operating characteristic curve is determined; and based on the receiver operating characteristic curve, the area under the curve is determined.
[0059] Optionally, for each partition result, the initial prediction model can be trained based on the training set in the partition result to obtain a trained model, and the validation set in the partition result is input into the trained model to output a set of classification prediction probability values.
[0060] Optionally, a receiver operating characteristic (ROC) curve is a statistical tool used to evaluate the performance of a classification model. The ROC curve is a curve drawn by the output of the classifier at different thresholds, with the horizontal axis being the false positive rate (FPR) and the vertical axis being the true positive rate (TPR). TPR is also known as recall, while FPR is 1 minus the true positive rate (Specificity). The ROC curve can show the performance of the classifier at all possible thresholds. Based on the set of classification prediction probability values and the classification labels corresponding to the validation set, the receiver operating characteristic curve can be determined. The area under the curve (Area Under Receiver Operating Characteristic Curve, AUROC) refers to the area surrounded by the ROC curve and the x-axis, (1, 0)-(1, 1). Based on the receiver operating characteristic curve, the area under the curve can be determined.
[0061] Optionally, based on the classification prediction probability value set and the classification label corresponding to the validation set, a receiver operating characteristic curve is determined, including: sorting multiple classification prediction probability values in the classification prediction probability value set from large to small to obtain a sorting result; for each classification prediction probability value, based on the classification label and the classification prediction probability value, determining the true positive rate and false positive rate corresponding to the classification prediction probability value; and determining the receiver operating characteristic curve according to the sorting result and the true positive rate and false positive rate corresponding to each of the multiple classification prediction probability values.
[0062] Optionally, multiple classification prediction probability values in the classification prediction probability value set can be sorted from large to small to obtain a sorting result. For each classification prediction probability value, based on the classification label and the classification prediction probability value, the true positive rate (True Positive Rate, TPR) and the false positive rate (False Positive Rate, FPR) corresponding to the classification prediction probability value can be determined, as shown in formulas (1) and (2).
[0063] (1);
[0064] (2);
[0065] Among them, TP is the number of positive samples predicted by the model as positive, TN is the number of negative samples predicted by the model as negative, FP is the number of negative samples predicted by the model as positive, and FN is the number of positive samples predicted by the model as negative.
[0066] Optionally, according to the sorting results, a receiver operating characteristic curve (ROC curve) can be drawn with FPR as the horizontal axis and TPR as the vertical axis.
[0067] Optionally, the training method of the prediction model for predicting the planting type of agricultural products also includes: inputting the target verification set into the target prediction model and outputting a target classification prediction probability value set; determining the target receiver operating characteristic curve based on the target classification prediction probability value set and the classification label corresponding to the target verification set; determining the target point from the target receiver operating characteristic curve, and determining the classification prediction probability value corresponding to the target point as the agricultural product classification determination threshold, wherein the target point represents the point with the largest geometric mean in the target receiver operating characteristic curve, and the geometric mean is obtained based on the true positive rate and false positive rate in the target receiver operating characteristic curve.
[0068] Optionally, the target validation set is input into the target prediction model, and a target classification prediction probability value set can be output. According to the target classification prediction probability value set and the classification label corresponding to the target validation set, the target receiver operating characteristic curve can be determined.
[0069] Optionally, the target point represents the point with the largest geometric mean in the target receiver operating characteristic curve, and the geometric mean is obtained based on the true positive rate and the false positive rate in the target receiver operating characteristic curve, as shown in formula (3). The target point is determined from the target receiver operating characteristic curve, and the classification prediction probability value corresponding to the target point can be determined as the agricultural product classification determination threshold, as shown in formula (4).
[0070] (3);
[0071] (4);
[0072] Among them, G-mean represents the geometric mean, Determine thresholds for agricultural product classification.
[0073] Optionally, use the optimal parameter combination and training set data to train, obtain the target prediction model, use the target prediction model to predict the test set data, and calculate the AUC value of the ROC curve. The obtained AUC value is compared with the AUC value of the XGBoost prediction model on the validation set. The results show that the AUC value of the initial prediction model on the test set is comparable to the AUC value on the validation set, indicating that the model has good generalization ability.
[0074] Optionally, each high-resolution mass spectrometry data sample is preprocessed to obtain a standardized mass spectrometry data sample, including: performing mass-to-charge ratio alignment on the high-resolution mass spectrometry data samples to obtain aligned mass spectrometry data samples; performing normalization processing on the aligned mass spectrometry data samples to obtain normalized mass spectrometry data samples; and performing denoising processing on the normalized mass spectrometry data samples to obtain standardized mass spectrometry data samples.
[0075] Optionally, the high-resolution mass spectrometry data samples are preprocessed. The preprocessing methods may include mass-to-charge ratio alignment, normalization, and denoising. These preprocessing methods help eliminate data bias and noise, making model training more robust and improving the model's predictive ability.
[0076] Figure 4 A flow chart of a prediction method for predicting the planting type of agricultural products according to an embodiment of the present invention is shown.
[0077] like Figure 4 As shown, the prediction method for predicting the planting type of agricultural products in this embodiment includes operations S410 to S450.
[0078] In operation S410, high-resolution mass spectrum data of the agricultural product to be predicted is acquired.
[0079] In operation S420, the high-resolution mass spectrum data is preprocessed to obtain standardized mass spectrum data, and the standardized mass spectrum data is divided into M boxes of equal length.
[0080] In operation S430, a mass spectrum feature vector corresponding to the standardized mass spectrum data is obtained based on the total ion abundances corresponding to each of the M bins.
[0081] In operation S440, the mass spectrum feature vector is input into a target prediction model, and a classification value of the agricultural product planting type is output.
[0082] In operation S450, the classification value of the agricultural product planting type is compared with the agricultural product classification determination threshold to obtain a classification result of the agricultural product planting type to be predicted.
[0083] Optionally, high-resolution mass spectrometry data of the agricultural product to be predicted is obtained, and the high-resolution mass spectrometry data can be preprocessed to obtain standardized mass spectrometry data, and the standardized mass spectrometry data can be divided into M boxes of equal length. Based on the total ion abundance corresponding to each of the M boxes, a mass spectrometry feature vector corresponding to the standardized mass spectrometry data can be obtained. For example, a high-resolution mass spectrometry data is obtained from a public mass spectrometry library, and the high-resolution mass spectrometry data is preprocessed by m / z alignment, data normalization, and denoising, and then divided into 1000 boxes of equal length in the range of 150 to 1700 m / z, and then the ion abundance of all fragment peaks in the same box is added to obtain a 1000-dimensional mass spectrometry feature vector.
[0084] Optionally, the mass spectrum feature vector is input into the target prediction model to output the classification value of the agricultural product planting type. The target prediction model can be used to predict the agricultural product planting type. The classification value of the agricultural product planting type is compared with the agricultural product classification judgment threshold to obtain the classification result of the agricultural product planting type to be predicted.
[0085] Optionally, the classification value of the agricultural product planting type is compared with the agricultural product classification determination threshold to obtain a classification result of the agricultural product planting type to be predicted, including: when the classification value of the agricultural product planting type is greater than or equal to the agricultural product classification determination threshold, the classification result is that the agricultural product to be predicted is an organically grown agricultural product; when the classification value of the agricultural product planting type is less than the agricultural product classification determination threshold, the classification result is that the agricultural product to be predicted is a conventionally grown agricultural product.
[0086] Optionally, when the classification value of the agricultural product planting type is greater than or equal to the agricultural product classification determination threshold, the classification result may be that the agricultural product to be predicted is an organically grown agricultural product. When the classification value of the agricultural product planting type is less than the agricultural product classification determination threshold, the classification result may be that the agricultural product to be predicted is a conventionally grown agricultural product. For example, the agricultural product classification determination threshold is 0.5, the sample mass spectrum feature vector is input into the target prediction model, and the classification value of the agricultural product planting type corresponding to the sample is output. If the classification value of the agricultural product planting type is greater than or equal to 0.5, the sample is considered to be an organic agricultural product, and if the classification value of the agricultural product planting type is less than 0.5, the sample is considered to be a conventional agricultural product.
[0087] Based on the above-mentioned training method for a prediction model for predicting the planting type of agricultural products, the present invention also provides a training device for a prediction model for predicting the planting type of agricultural products. Figure 5 The device is described in detail.
[0088] Figure 5 A structural block diagram of a training device for a prediction model for predicting planting types of agricultural products according to an embodiment of the present invention is shown.
[0089] like Figure 5 As shown, the training device 500 for the prediction model for predicting the planting type of agricultural products in this embodiment includes: a first acquisition module 510, a box division module 520, a mass spectrum sample feature vector acquisition module 530, an optimal hyperparameter combination acquisition module 540 and a target prediction model acquisition module 550.
[0090] The first acquisition module 510 is used to acquire high-resolution mass spectrum data samples of organically grown agricultural products and conventionally grown agricultural products and classification labels corresponding to the high-resolution mass spectrum data samples, wherein the classification labels represent the planting types of the agricultural products.
[0091] The box division module 520 is used to preprocess each high-resolution mass spectrum data sample to obtain a standardized mass spectrum data sample, and for each standardized mass spectrum data sample, divide the standardized mass spectrum data sample into M box samples of equal length, where M is an integer greater than 1.
[0092] The mass spectrum sample characteristic vector obtaining module 530 is used to obtain the mass spectrum sample characteristic vector corresponding to the standardized mass spectrum data sample based on the total ion abundance corresponding to each of the M box samples, wherein the total ion abundance is obtained by adding the ion abundances of all fragment peaks in the box sample.
[0093] The optimal hyperparameter combination obtaining module 540 is used to verify multiple sets of hyperparameter combinations on the initial prediction model using the data set to obtain the optimal hyperparameter combination, wherein the data set includes mass spectrometry sample feature vectors and classification labels.
[0094] The target prediction model obtaining module 550 is used to train the initial prediction model based on the optimal hyperparameter combination to obtain the target prediction model.
[0095] Optionally, by obtaining high-resolution mass spectrometry data samples of organically grown agricultural products and conventionally grown agricultural products, each high-resolution mass spectrometry data sample is preprocessed to obtain a standardized mass spectrometry data sample, and for each standardized mass spectrometry data sample, the standardized mass spectrometry data sample can be divided into M box samples of equal length, and based on the total ion abundance corresponding to each of the M box samples, a mass spectrometry sample feature vector corresponding to the standardized mass spectrometry data sample can be obtained, so that useful information can be more effectively extracted from complex high-resolution mass spectrometry data samples, and multiple groups of hyperparameter combinations can be verified on the initial prediction model using the data set to obtain the optimal hyperparameter combination. Based on the optimal hyperparameter combination, the performance of the prediction model and the accuracy of the prediction can be significantly improved, and the initial prediction model is trained using the optimal hyperparameter combination to obtain a target prediction model. Based on the obtained target prediction model, the type of agricultural product can be quickly and efficiently predicted, thereby improving the accuracy and efficiency of the classification of organically grown and conventionally grown agricultural products, and has important application prospects for the quality and safety assessment of complex food samples.
[0096] Optionally, the module for obtaining the optimal hyperparameter combination includes: a sub-module for obtaining a hyperparameter combination, a sub-module for obtaining a partition result, a sub-module for obtaining an area under the curve, a sub-module for determining an average area under the curve, and a sub-module for determining an optimal hyperparameter combination.
[0097] The hyperparameter combination obtains a submodule, which is used to process a preset shrinkage step size range and a preset weak classifier number range using a grid search algorithm to obtain multiple sets of hyperparameter combinations, wherein the hyperparameter combination includes a shrinkage step size and a weak classifier number.
[0098] The submodule obtained by the division result is used to take A% of the data set as the test set, and to repeatedly divide the remaining data set N times based on the preset ratio to obtain N division results, where the division results include a training set and a validation set, A>0, and N is an integer greater than 1.
[0099] The area under the curve obtaining submodule is used to process N partition results respectively with the initial prediction model for each set of hyperparameter combinations to obtain N areas under the curve.
[0100] The average area under the curve determination submodule is used to determine the average area under the curve of N areas under the curve.
[0101] The optimal hyperparameter combination determination submodule is used to determine, for multiple sets of hyperparameter combinations, a hyperparameter combination corresponding to a maximum average area under the curve among multiple average areas under the curve as the optimal hyperparameter combination.
[0102] Optionally, the area under the curve obtaining submodule includes: a trained model obtaining unit, a classification prediction probability value set output unit, a receiver operating characteristic curve determination unit and an area under the curve determination unit.
[0103] The trained model obtaining unit is used to train the initial prediction model based on the training set in the partition result for each partition result to obtain the trained model.
[0104] The classification prediction probability value set output unit is used to input the verification set in the division result into the trained model and output the classification prediction probability value set.
[0105] The receiver operating characteristic curve determination unit is used to determine the receiver operating characteristic curve based on the classification prediction probability value set and the classification label corresponding to the verification set.
[0106] The area under the curve determination unit is used to determine the area under the curve according to the receiver operating characteristic curve.
[0107] Optionally, the receiver operating characteristic curve determination unit includes: a sorting result obtaining subunit, a determination subunit and a receiver operating characteristic curve determination subunit.
[0108] The sorting result obtaining subunit is used to sort multiple classification prediction probability values in the classification prediction probability value set from large to small to obtain a sorting result.
[0109] The determination subunit is used to determine, for each classification prediction probability value, a true positive rate and a false positive rate corresponding to the classification prediction probability value based on the classification label and the classification prediction probability value.
[0110] The receiver operating characteristic curve determination subunit is used to determine the receiver operating characteristic curve according to the sorting result and the true positive rate and the false positive rate corresponding to each of the multiple classification prediction probability values.
[0111] Optionally, the training device 500 of this embodiment further includes: an output module, a target receiver operating characteristic curve determination module and a target point determination module.
[0112] The output module is used to input the target verification set into the target prediction model and output a set of target classification prediction probability values.
[0113] The target receiver operating characteristic curve determination module is used to determine the target receiver operating characteristic curve according to the target classification prediction probability value set and the classification label corresponding to the target verification set.
[0114] The target point determination module is used to determine the target point from the target receiver operating characteristic curve, and determine the classification prediction probability value corresponding to the target point as the agricultural product classification judgment threshold, wherein the target point represents the point with the largest geometric mean in the target receiver operating characteristic curve, and the geometric mean is obtained based on the true positive rate and false positive rate in the target receiver operating characteristic curve.
[0115] Optionally, the box division module 520 includes: an alignment mass spectrum data sample acquisition submodule, a normalization mass spectrum data sample acquisition submodule and a standardization mass spectrum data sample acquisition submodule.
[0116] The submodule for obtaining aligned mass spectrum data samples is used to align the mass-to-charge ratios of high-resolution mass spectrum data samples to obtain aligned mass spectrum data samples.
[0117] The normalized mass spectrum data sample obtaining submodule is used to perform normalization processing on the aligned mass spectrum data samples to obtain normalized mass spectrum data samples.
[0118] The standardized mass spectrum data sample obtaining submodule is used to perform noise removal on the normalized mass spectrum data sample to obtain a standardized mass spectrum data sample.
[0119] Based on the above-mentioned prediction method for predicting the planting type of agricultural products, the present invention also provides a prediction device for predicting the planting type of agricultural products. Figure 6 The device is described in detail.
[0120] Figure 6 A structural block diagram of a prediction device for predicting the planting type of agricultural products according to an embodiment of the present invention is shown.
[0121] like Figure 6 As shown, the prediction device 600 for predicting the planting type of agricultural products in this embodiment includes: a second acquisition module 610, a box sample division module 620, a mass spectrum feature vector acquisition module 630, an output module 640 and a classification result acquisition module 650.
[0122] The second acquisition module 610 is used to acquire high-resolution mass spectrum data of the agricultural product to be predicted.
[0123] The box sample division module 620 is used to pre-process the high-resolution mass spectrum data samples to obtain standardized mass spectrum data, and divide the standardized mass spectrum data samples into M boxes of equal length.
[0124] The mass spectrum feature vector obtaining module 630 is used to obtain the mass spectrum feature vector corresponding to the standardized mass spectrum data based on the total ion abundance corresponding to each of the M boxes.
[0125] The output module 640 is used to input the mass spectrum feature vector into the target prediction model and output the classification value of the agricultural product planting type.
[0126] The classification result obtaining module 650 is used to compare the classification value of the agricultural product planting type with the agricultural product classification determination threshold to obtain the classification result of the agricultural product planting type to be predicted.
[0127] Optionally, the classification result obtaining module 650 includes: an organically grown agricultural product determination submodule and a conventionally grown agricultural product determination submodule.
[0128] The organically grown agricultural product determination submodule is used to classify the agricultural product to be predicted as an organically grown agricultural product when the classification value of the agricultural product planting type is greater than or equal to the agricultural product classification determination threshold.
[0129] The conventionally grown agricultural product determination submodule is used to classify the agricultural product to be predicted as a conventionally grown agricultural product when the classification value of the agricultural product planting type is less than the agricultural product classification determination threshold.
[0130] Optionally, any multiple modules among the first acquisition module 510, the box division module 520, the mass spectrum sample feature vector acquisition module 530, the optimal hyperparameter combination acquisition module 540, the target prediction model acquisition module 550, the second acquisition module 610, the box sample division module 620, the mass spectrum feature vector acquisition module 630, the output module 640 and the classification result acquisition module 650 can be combined into one module for implementation, or any one of the modules can be split into multiple modules. Alternatively, at least part of the functions of one or more of these modules can be combined with at least part of the functions of other modules and implemented in one module. Optionally, at least one of the first acquisition module 510, the box division module 520, the mass spectrum sample feature vector acquisition module 530, the optimal hyperparameter combination acquisition module 540, the target prediction model acquisition module 550, the second acquisition module 610, the box sample division module 620, the mass spectrum feature vector acquisition module 630, the output module 640 and the classification result acquisition module 650 can be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on a chip, a system on a substrate, a system on a package, an application-specific integrated circuit (ASIC), or can be implemented by hardware or firmware such as any other reasonable way of integrating or packaging circuits, or can be implemented in any one of the three implementation methods of software, hardware and firmware or in an appropriate combination of any of them. Or at least one of the first acquisition module 510, the box division module 520, the mass spectrum sample feature vector acquisition module 530, the optimal hyperparameter combination acquisition module 540, the target prediction model acquisition module 550, the second acquisition module 610, the box sample division module 620, the mass spectrum feature vector acquisition module 630, the output module 640 and the classification result acquisition module 650 can be at least partially implemented as a computer program module, which can execute the corresponding function when the computer program module is executed.
[0131] Figure 7A block diagram of an electronic device suitable for implementing a training method and a prediction method of a prediction model for predicting the planting type of agricultural products according to an embodiment of the present invention is shown.
[0132] like Figure 7 As shown, the electronic device 700 according to an embodiment of the present invention includes a processor 701, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 702 or a program loaded from a storage part 708 to a random access memory (RAM) 703. The processor 701 may include, for example, a general-purpose microprocessor (such as a CPU), an instruction set processor and / or a related chipset and / or a special-purpose microprocessor (for example, an application-specific integrated circuit (ASIC)), etc. The processor 701 may also include an onboard memory for caching purposes. The processor 701 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of the present invention.
[0133] In RAM 703, various programs and data required for the operation of electronic device 700 are stored. Processor 701, ROM 702 and RAM 703 are connected to each other via bus 704. Processor 701 performs various operations of the method flow according to the embodiment of the present invention by executing the programs in ROM 702 and / or RAM 703. It should be noted that the program can also be stored in one or more memories other than ROM 702 and RAM 703. Processor 701 can also perform various operations of the method flow according to the embodiment of the present invention by executing the programs stored in the one or more memories.
[0134] Optionally, the electronic device 700 may further include an input / output (I / O) interface 705, which is also connected to the bus 704. The electronic device 700 may further include one or more of the following components connected to the I / O interface 705: an input portion 706 including a keyboard, a mouse, etc.; an output portion 707 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage portion 708 including a hard disk, etc.; and a communication portion 709 including a network interface card such as a LAN card, a modem, etc. The communication portion 709 performs communication processing via a network such as the Internet. A drive 710 is also connected to the I / O interface 705 as needed. A removable medium 711, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 710 as needed, so that a computer program read therefrom is installed into the storage portion 708 as needed.
[0135] The present invention also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiment; or may exist independently without being assembled into the device / apparatus / system. The above computer-readable storage medium carries one or more programs, and when the above one or more programs are executed, the method according to the embodiment of the present invention is implemented.
[0136] Optionally, the computer-readable storage medium may be a non-volatile computer-readable storage medium, for example, may include but is not limited to: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, an apparatus or a device. For example, optionally, the computer-readable storage medium may include the ROM 702 and / or RAM 703 described above and / or one or more memories other than ROM 702 and RAM 703.
[0137] The embodiment of the present invention also includes a computer program product, which includes a computer program, and the computer program includes a program code for executing the method shown in the flowchart. When the computer program product is run in a computer system, the program code is used to enable the computer system to implement the training method for the prediction model for predicting the planting type of agricultural products and the prediction method for predicting the planting type of agricultural products provided by the embodiment of the present invention.
[0138] The computer program executes the above functions defined in the system / device of the embodiment of the present invention when it is executed by the processor 701. Optionally, the system, device, module, unit, etc. described above can be implemented by a computer program module.
[0139] In one embodiment, the computer program may rely on tangible storage media such as optical storage devices, magnetic storage devices, etc. In another embodiment, the computer program may also be transmitted and distributed in the form of signals on a network medium, and downloaded and installed through the communication part 709, and / or installed from the removable medium 711. The program code contained in the computer program may be transmitted using any appropriate network medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.
[0140] In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 709, and / or installed from the removable medium 711. When the computer program is executed by the processor 701, the above functions defined in the system of the embodiment of the present invention are performed. Optionally, the system, device, apparatus, module, unit, etc. described above can be implemented by a computer program module.
[0141] Optionally, the program code for executing the computer program provided by the embodiment of the present invention can be written in any combination of one or more programming languages, specifically, these computing programs can be implemented using high-level process and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages include, but are not limited to, such as Java, C++, python, "C" language or similar programming languages. The program code can be executed entirely on the user computing device, partially on the user device, partially on the remote computing device, or entirely on the remote computing device or server. In the case of a remote computing device, the remote computing device can be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computing device (e.g., using an Internet service provider to connect through the Internet).
[0142] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0143] It will be appreciated by those skilled in the art that the features described in the various embodiments and / or claims of the present invention may be combined and / or combined in various ways, even if such combinations and / or combinations are not explicitly described in the present invention. In particular, the features described in the various embodiments and / or claims of the present invention may be combined and / or combined in various ways without departing from the spirit and teachings of the present invention. All of these combinations and / or combinations fall within the scope of the present invention.
[0144] The embodiments of the present invention are described above. However, these embodiments are only for the purpose of illustration, and are not intended to limit the scope of the present invention. Although each embodiment is described above, it does not mean that the measures in each embodiment cannot be used in combination advantageously. Without departing from the scope of the present invention, those skilled in the art may make various substitutions and modifications, which should all fall within the scope of the present invention.
Claims
1. A prediction model training method for predicting agricultural product planting types, characterized in that: The method comprises: Acquire high-resolution mass spectrometry data samples of organically grown agricultural products and conventionally grown agricultural products and classification labels corresponding to the high-resolution mass spectrometry data samples, wherein the classification labels characterize the planting types of the agricultural products; Preprocessing each of the high-resolution mass spectrum data samples to obtain a standardized mass spectrum data sample, and for each standardized mass spectrum data sample, dividing the standardized mass spectrum data sample into M box samples of equal length, wherein M is an integer greater than 1; Based on the total ion abundances corresponding to each of the M box samples, a mass spectrum sample feature vector corresponding to the standardized mass spectrum data sample is obtained, wherein the total ion abundance is obtained by adding the ion abundances of all fragment peaks in the box sample; Using a data set to verify multiple sets of hyperparameter combinations on an initial prediction model to obtain an optimal hyperparameter combination, wherein the data set includes the mass spectrometry sample feature vector and the classification label; The initial prediction model is trained based on the optimal hyperparameter combination to obtain a target prediction model.
2. The method according to claim 1, characterized in that The method of using the data set to verify multiple sets of hyperparameter combinations on the initial prediction model to obtain the optimal hyperparameter combination includes: Using a grid search algorithm to process a preset shrinkage step size range and a preset weak classifier number range, a plurality of sets of hyperparameter combinations are obtained, wherein the hyperparameter combinations include the shrinkage step size and the weak classifier number; A% of the data set is used as a test set, and the remaining data set is repeatedly divided N times based on a preset ratio to obtain N division results, wherein the division results include a training set and a validation set, A>0, and N is an integer greater than 1; For each set of hyperparameter combinations, the N division results are processed respectively using the initial prediction model to obtain N areas under the curve; Determining an average area under the curve of N areas under the curve; For multiple sets of hyperparameter combinations, among the multiple average areas under the curve, the hyperparameter combination corresponding to the maximum average area under the curve is determined as the optimal hyperparameter combination.
3. The method according to claim 2, characterized in that The using of the initial prediction model to process the N division results respectively to obtain N areas under the curves includes: For each division result, the initial prediction model is trained based on the training set in the division result to obtain a trained model; Inputting the validation set in the division result into the trained model, and outputting a set of classification prediction probability values; Determining a receiver operating characteristic curve based on the classification prediction probability value set and the classification label corresponding to the validation set; Based on the receiver operating characteristic curve, the area under the curve is determined.
4. The method according to claim 3, characterized in that The step of determining a receiver operating characteristic curve based on the classification prediction probability value set and the classification label corresponding to the validation set includes: Sorting the multiple classification prediction probability values in the classification prediction probability value set from large to small to obtain a sorting result; For each classification prediction probability value, based on the classification label and the classification prediction probability value, determine the true positive rate and the false positive rate corresponding to the classification prediction probability value; A receiver operating characteristic curve is determined according to the ranking result and the true positive rate and the false positive rate corresponding to each of the plurality of classification prediction probability values.
5. The method according to claim 1, characterized in that The method further comprises: Inputting the target verification set into the target prediction model, and outputting a set of target classification prediction probability values; Determining a target receiver operating characteristic curve according to the target classification prediction probability value set and the classification label corresponding to the target verification set; A target point is determined from the target receiver operating characteristic curve, and the classification prediction probability value corresponding to the target point is determined as the agricultural product classification judgment threshold, wherein the target point represents the point with the largest geometric mean in the target receiver operating characteristic curve, and the geometric mean is obtained based on the true positive rate and the false positive rate in the target receiver operating characteristic curve.
6. The method according to claim 1, characterized in that The preprocessing of each high-resolution mass spectrum data sample to obtain a standardized mass spectrum data sample includes: Performing mass-to-charge ratio alignment on the high-resolution mass spectrum data samples to obtain aligned mass spectrum data samples; Normalizing the aligned mass spectrum data samples to obtain normalized mass spectrum data samples; The normalized mass spectrum data sample is subjected to noise removal processing to obtain the standardized mass spectrum data sample.
7. A prediction method for predicting the planting type of agricultural products, characterized in that: The method comprises: Obtain high-resolution mass spectrometry data of agricultural products to be predicted; Preprocessing the high-resolution mass spectrum data to obtain standardized mass spectrum data, and dividing the standardized mass spectrum data into M boxes of equal length; Based on the total ion abundances corresponding to each of the M boxes, a mass spectrum feature vector corresponding to the standardized mass spectrum data is obtained; Inputting the mass spectrum feature vector into a target prediction model and outputting a classification value of the agricultural product planting type; The classification value of the agricultural product planting type is compared with the agricultural product classification judgment threshold to obtain the classification result of the agricultural product planting type to be predicted, wherein the target prediction model is used to predict the agricultural product planting type, and the target prediction model is obtained according to any one of claims 1 to 6.
8. The method according to claim 7, characterized in that The step of comparing the classification value of the agricultural product planting type with the agricultural product classification determination threshold to obtain the classification result of the agricultural product planting type to be predicted includes: In the case where the classification value of the agricultural product planting type is greater than or equal to the agricultural product classification determination threshold, the classification result is that the agricultural product planting type to be predicted is organic planting; In the case where the agricultural product planting type classification value is less than the agricultural product classification determination threshold, the classification result is that the agricultural product planting type to be predicted is conventional planting.
9. A prediction model training device for predicting agricultural product planting types, characterized in that: The training device comprises: A first acquisition module is used to acquire high-resolution mass spectrometry data samples of organically grown agricultural products and conventionally grown agricultural products and classification labels corresponding to the high-resolution mass spectrometry data samples, wherein the classification labels represent the planting types of the agricultural products; A box division module, used for preprocessing each of the high-resolution mass spectrum data samples to obtain a standardized mass spectrum data sample, and for each standardized mass spectrum data sample, dividing the standardized mass spectrum data sample into M box samples of equal length, wherein M is an integer greater than 1; A mass spectrum sample characteristic vector obtaining module, used for obtaining a mass spectrum sample characteristic vector corresponding to the standardized mass spectrum data sample based on the total ion abundance corresponding to each of the M box samples, wherein the total ion abundance is obtained by adding the ion abundances of all fragment peaks in the box sample; An optimal hyperparameter combination obtaining module is used to verify multiple sets of hyperparameter combinations on the initial prediction model using a data set to obtain an optimal hyperparameter combination, wherein the data set includes the mass spectrometry sample feature vector and the classification label; The target prediction model obtaining module is used to train the initial prediction model based on the optimal hyperparameter combination to obtain the target prediction model.
10. A prediction device for predicting the planting type of agricultural products, characterized in that: The prediction device comprises: The second acquisition module is used to acquire high-resolution mass spectrometry data of the agricultural product to be predicted; A box sample division module is used to pre-process the high-resolution mass spectrum data to obtain standardized mass spectrum data, and divide the standardized mass spectrum data into M boxes of equal length; A mass spectrum characteristic vector obtaining module, used for obtaining a mass spectrum characteristic vector corresponding to the standardized mass spectrum data based on the total ion abundance corresponding to each of the M boxes; An output module, used for inputting the mass spectrum feature vector into a target prediction model and outputting a classification value of the agricultural product planting type; The classification result obtaining module is used to compare the classification value of the agricultural product planting type with the agricultural product classification determination threshold to obtain the classification result of the agricultural product planting type to be predicted.
Citation Information
Patent Citations
Toxicity prediction method based on compound secondary mass spectrum data
CN117409871A
Method and system for constructing organophosphate high-resolution mass spectrum database
CN118366570A
Methods and systems for classifying mass spectra
US7228239B1