Potato yield classification method, device and system and storage medium
By adopting the method of layered K-fold cross-validation and CART decision tree in potato yield classification prediction, combined with preprocessing and feature coding technology, the problem of poor yield classification prediction accuracy in traditional methods is solved, and the prediction accuracy and model stability are significantly improved.
Patent Information
- Application Number
- CN202411957288.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-30
- Publication Date
- 2025-04-25
AI Technical Summary
The traditional potato yield classification prediction method has the problems of strong subjectivity and poor accuracy, especially when the sample number at different yield levels is unbalanced, which affects the training effect and prediction accuracy of the model.
A stratified K-fold cross-validation method and a CART-based decision tree were used to obtain experimental data on the entire growth cycle of potatoes in the mine repair area to construct a classification model for classification of potato yields. By preprocessing the feature values and target values, dictionary feature extraction and label encoding are used to convert categorical variables into numerical features.
It significantly improves the prediction accuracy of potato yield classification and the generalization ability of the model, ensures that the model can fully learn different categories of data characteristics during the training process, and improves the stability and reliability of the model.
Smart Images

Figure CN119884948A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of machine learning, and in particular relates to a potato yield classification method and device, a system, and a storage medium. Background Art
[0002] Traditional potato yield classification prediction mainly relies on empirical judgment and simple statistical methods, which often have problems such as strong subjectivity and poor accuracy. With the rapid development of information technology, machine learning technology is increasingly used in the agricultural field, providing new ideas and methods for crop yield prediction. However, when applying machine learning technology to potato yield classification prediction, the number of potato samples of different yield levels in actual production is often unbalanced, which will affect the training effect and prediction accuracy of the model. Summary of the invention
[0003] The technical problem to be solved by the present invention is to provide a potato yield classification method and device, system, and storage medium to improve the accuracy and efficiency of potato yield classification.
[0004] To achieve the above object, the present invention adopts the following technical solution:
[0005] A potato yield classification method comprising:
[0006] S1. Obtain potato test data in the mine restoration area as feature values and target values for building a classification model;
[0007] S2, preprocessing the characteristic value and the target value;
[0008] S3. According to the preprocessed feature values and target values, a stratified K-fold cross-validation method and a CART-based decision tree were used to construct a classification model for classifying potato yield.
[0009] Preferably, in S1, by obtaining test data of the entire potato growth cycle in the mine restoration area, the tailings ratio, bacterial fertilizer application, potato variety and soil moisture content in the test data are used as characteristic values of the model, and the classification of yield is used as the target.
[0010] Preferably, in S2, the preprocessing is performed as follows: converting the categorical variables into numerical features using dictionary feature extraction and label encoding.
[0011] The present invention also provides a potato yield classification device, comprising:
[0012] An acquisition module is used to obtain potato test data in the mine restoration area as feature values and target values for building a classification model;
[0013] A preprocessing module is used to preprocess the characteristic values and target values;
[0014] The classification module is used to construct a classification model for classifying potato yield based on the preprocessed feature values and target values using a stratified K-fold cross-validation method and a CART-based decision tree.
[0015] Preferably, the acquisition module obtains test data of the entire potato growth cycle in the mine restoration area, uses the tailings ratio, bacterial fertilizer application, potato variety and soil moisture content in the test data as characteristic values of the model, and uses the classification of yield as the target.
[0016] Preferably, the preprocessing module converts categorical variables into numerical features using dictionary feature extraction and label encoding.
[0017] An embodiment of the present invention further provides a potato yield classification system, comprising: a memory and a processor, wherein the memory stores a computer program executed by the processor, and the computer program executes a potato yield classification method when executed by the processor.
[0018] An embodiment of the present invention further provides a storage medium, on which a computer program is stored, and when the computer program is run, the potato yield classification method is executed.
[0019] Compared with the prior art, the present invention has the following technical effects:
[0020] 1. Improve prediction accuracy: By integrating the CART decision tree algorithm with agricultural data features, accurate classification prediction of potato yield is achieved, which significantly improves the prediction accuracy compared with traditional methods.
[0021] 2. Enhance model generalization ability: The Stratified K-Fold cross-validation method is used to ensure that the model can fully learn the data features of different categories during the training process, thereby improving the generalization ability and stability of the model. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, 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 embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.
[0023] Figure 1 This is a flow chart of a potato yield classification method according to an embodiment of the present invention;
[0024] Figure 2 The CART decision tree flow chart is an example;
[0025] Figure 3 CART decision tree visualization graph for the embodiment;
[0026] Figure 4 The following is an ROC curve diagram of the CART decision tree. DETAILED DESCRIPTION
[0027] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0028] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.
[0029] Embodiment 1:
[0030] like Figure 1 As shown, an embodiment of the present invention provides a potato yield classification method, comprising:
[0031] S1. Obtain potato test data in the mine restoration area as feature values and target values for building a classification model;
[0032] S2, preprocessing the characteristic value and the target value;
[0033] S3. According to the preprocessed feature values and target values, a CART-based decision tree is constructed for the classification model, which adopts the Stratified K-Fold cross-validation method.
[0034] S4. Conduct a preliminary evaluation of the decision tree classification model. The classification evaluation report analyzes the model's accuracy, recall rate, F1 score and other indicators in detail, verifying the model's effectiveness and reliability.
[0035] S5. Draw and calculate the receiver operating characteristic curve (ROC) and area under the curve (AUC) of each classification to further measure the overall performance and classification ability of the model.
[0036] As an implementation method of the present invention, in step S1, potato test data (as shown in Table 1) in the mine restoration area is obtained as the characteristic value and target value for constructing the classification model. Specifically, by obtaining the test data of the entire growth cycle of potatoes in the mine restoration area, the tailings ratio, bacterial fertilizer application, potato variety and soil moisture content in the test data are used as the characteristic value of the model, and the classification of the yield is used as the target value.
[0037] Table 1
[0038] Tailings Proportion Fertilizer application Potato varieties Soil moisture content Production 95% laterite + 5% phosphate tailings have Green potato No.9 18% high yield 95% laterite + 5% phosphate tailings none Green potato No.9 20% high yield 95% laterite + 5% phosphate tailings have Cooperation 88 14% Middle class 95% laterite + 5% phosphate tailings none Cooperation 88 16% Middle class 90% laterite + 10% phosphate tailings have Cooperation 88 14% Low yield 90% laterite + 10% phosphate tailings none Cooperation 88 14% Low yield 90% laterite + 10% phosphate tailings have Green potato No.9 17% high yield 90% laterite + 10% phosphate tailings none Green potato No.9 16% Middle class 85% laterite + 15% phosphate tailings have Green potato No.9 15% high yield 85% laterite + 15% phosphate tailings none Green potato No.9 16% Low yield 85% laterite + 15% phosphate tailings have Cooperation 88 13% Low yield 85% laterite + 15% phosphate tailings none Cooperation 88 17% Middle class 90% laterite + 5% phosphate tailings + 5% phosphogypsum have Green potato No.9 14% high yield 90% laterite + 5% phosphate tailings + 5% phosphogypsum none Green potato No.9 15% high yield 90% laterite + 5% phosphate tailings + 5% phosphogypsum have Cooperation 88 13% Low yield 90% laterite + 5% phosphate tailings + 5% phosphogypsum none Cooperation 88 16% Middle class
[0039] As an implementation method of an embodiment of the present invention, in step S2, the eigenvalues and the target values are preprocessed, including feature selection and encoding conversion, and the categorical variables are converted into numerical features using a dictionary feature extraction method and a label encoding method. Specifically, the eigenvalues of the test data are feature extracted and converted into digital features (two-dimensional matrices) that can be used for machine learning through the DictVectorizer class. This process uses "one-hot" encoding, and at the same time, the target value is converted from a categorical type to a numerical type through the LabelEncoding class, and the potato yield conditions such as "low yield", "medium yield" and "high yield" are converted into 0, 1, and 2, forming a label dictionary {'low yield': 0, 'medium yield': 1, 'high yield': 2}.
[0040] As an implementation method of an embodiment of the present invention, in step S3, a classification model for feature values and target values is constructed by a decision tree based on CART, and the model adopts a stratified K-fold cross-validation method. Specifically, the decision tree model is trained by taking the preprocessed feature values and target values as input. The basic principle of the classification model based on the CART decision tree is: the source of the decision tree idea is very simple, and the conditional branch structure in program design is the if-else structure. The earliest decision tree is a classification learning method that uses this type of structure to segment data. A decision tree is a tree structure in which each internal node represents a judgment on an attribute, each branch represents the output of a judgment result, and finally each leaf node represents a classification result. It is essentially a tree composed of multiple judgment nodes. The CART decision tree is one of them, and the "Gini index" is used to select the partition attributes. CART is the abbreviation of Classification and Regression Tree. This is a well-known decision tree learning algorithm that can be used for classification and regression tasks. The flowchart and visualization graphics of the CART decision tree are as follows. Figure 2 and Figure 3 shown.
[0041] Gini(D): The probability that two samples are randomly selected from data set D and their category labels are inconsistent. Therefore, the smaller the Gini(D) value, the higher the purity of data set D.
[0042] The purity of the data set D can be measured by the Gini value:
[0043]
[0044] Where: D is the total number of samples, C k is the number of samples in the kth class.
[0045] Gini index Gini_index (D): Generally, the attribute that minimizes the Gini index coefficient after partitioning is selected as the optimal partition attribute.
[0046]
[0047] Where: D v Indicates the number of samples contained in the vth branch node in the a attribute.
[0048] The basic principle of the Stratified K-Fold method is: "CrossValidation" divides the data set D into k mutually exclusive subsets of similar size, that is, D = D1∪D2∪...∪D k ,D i ∩D j ≠Φ(i≠j). Each subset D i The consistency of data distribution is maintained as much as possible, that is, it is obtained from D through stratified sampling. Then the union of k-1 subsets is used as the training set, and the remaining subset is used as the test set; in this way, k sets of training sets and test sets can be obtained. Stratified K-Fold is a method in cross-validation that uses stratified sampling to ensure that the proportion of samples of each category in the training set and test set is consistent with that in the original data set.
[0049] As an implementation method of an embodiment of the present invention, a preliminary evaluation of the decision tree classification model is performed in step S4, and the classification evaluation report (as shown in Table 2) analyzes the model's accuracy, recall rate, F1 score and other indicators in detail, verifying the effectiveness and reliability of the model.
[0050] Table 2
[0051]
[0052] Table 3 is used to form a confusion matrix between the classification prediction value of the CART decision tree and the true value of the test set, where: This is the confusion matrix for the binary classification problem.
[0053] Table 3
[0054]
[0055] After obtaining the corresponding confusion matrix, we can calculate the accuracy, recall rate, F1 score and other indicators of the classification model.
[0056]
[0057] As an implementation manner of an embodiment of the present invention, in step S5, the receiver operating characteristic curve (ROC) and the area under the curve (AUC) of each classification are plotted and calculated to further measure the overall performance and classification ability of the model. Specifically, by first calculating the abscissa (FPR) and ordinate (TPR) of the ROC, the meaning of FPR in a binary classification problem is the proportion of samples with a predicted class of positive among all samples with a true class of negative, and the meaning of TPR is the proportion of samples with a predicted class of positive among all samples with a true class of positive.
[0058]
[0059] After calculating the corresponding FPR and TPR, the ROC curve can be drawn, as Figure 4 shown. When FPR = TPR, the meaning is that for samples with a true class of either positive or negative, the probability that the classifier predicts a positive class is equal. The corresponding ROC curve is the random guessing line, which is a diagonal line; and the meaning of AUC is the probability that a randomly selected pair of positive and negative samples has a positive sample score greater than the negative sample score. The value of AUC is the integral of the ROC curve, that is, the area under the curve. The range of AUC is between [0, 1], and the closer it is to 1, the better. The AUC of the random guessing line is equal to 0.5. When AUC = 1, it is a perfect classifier. When using this prediction model, no matter what the threshold is set, the result can be perfectly predicted, which belongs to an ideal classifier. In most prediction scenarios, there is no perfect classifier. When 0.5 < AUC < 1, it is better than random guessing. By setting an appropriate threshold for this classifier (model), it can have predictive value.
[0060] Embodiment 2:
[0061] The embodiment of the present invention further provides a potato yield classification device, including:
[0062] An acquisition module, configured to acquire potato test data in a mine restoration area as eigenvalue and target value for constructing a classification model;
[0063] A preprocessing module, configured to preprocess the eigenvalue and target value;
[0064] A classification module, configured to construct a classification model for classifying potato yield according to the preprocessed eigenvalue and target value by using the hierarchical K-fold cross-validation method and a decision tree based on CART.
[0065] As an implementation manner of an embodiment of the present invention, the acquisition module acquires test data of the entire growth period of potatoes in a mine restoration area, uses the tailings ratio, fertilizer application, potato variety, and soil moisture content in the test data as the eigenvalue of the model, and uses the classification of the yield as the target.
[0066] As an implementation method of the embodiment of the present invention, the preprocessing module converts the categorical variables into numerical features by using dictionary feature extraction and label encoding.
[0067] Embodiment 3:
[0068] An embodiment of the present invention further provides a potato yield classification system, comprising: a memory and a processor, wherein the memory stores a computer program executed by the processor, and the computer program executes a potato yield classification method when executed by the processor.
[0069] Embodiment 4:
[0070] An embodiment of the present invention further provides a storage medium, on which a computer program is stored, and when the computer program is run, the potato yield classification method is executed.
[0071] The embodiments described above are only descriptions of the preferred embodiments of the present invention and are not intended to limit the scope of the present invention. Without departing from the design spirit of the present invention, various modifications and improvements made to the technical solutions of the present invention by ordinary technicians in this field should all fall within the protection scope determined by the claims of the present invention.
Claims
1. A potato yield classification method, characterized in that: include: S1. Obtain potato test data in the mine restoration area as feature values and target values for building a classification model; S2, preprocessing the characteristic value and the target value; S3. According to the preprocessed feature values and target values, a stratified K-fold cross-validation method and a CART-based decision tree were used to construct a classification model for classifying potato yield.
2. The potato yield classification method according to claim 1, characterized in that: In S1, by obtaining the test data of the entire potato growth cycle in the mine restoration area, the tailings ratio, bacterial fertilizer application, potato variety and soil moisture content in the test data were used as the characteristic values of the model, and the classification of yield was used as the target.
3. The potato yield classification method according to claim 2, characterized in that: In S2, the preprocessing is to convert categorical variables into numerical features using dictionary feature extraction and label encoding.
4. A potato yield classification device, characterized in that: include: An acquisition module is used to obtain potato test data in the mine restoration area as feature values and target values for building a classification model; A preprocessing module is used to preprocess the characteristic values and target values; The classification module is used to construct a classification model for classifying potato yield based on the preprocessed feature values and target values using a stratified K-fold cross-validation method and a CART-based decision tree.
5. The potato yield classification device according to claim 4, characterized in that: The acquisition module obtains the test data of the entire potato growth cycle in the mine restoration area, takes the tailings ratio, bacterial fertilizer application, potato variety and soil moisture content in the test data as the characteristic values of the model, and takes the classification of yield as the target.
6. The potato yield classification method according to claim 5, characterized in that: The preprocessing module converts categorical variables into numerical features using dictionary feature extraction and label encoding.
7. A potato yield classification system, characterized in that: include: A memory and a processor, wherein the memory stores a computer program to be executed by the processor, and when the computer program is executed by the processor, the potato yield classification method according to any one of claims 1 to 3 is executed.
8. A storage medium, characterized in that: The storage medium stores a computer program, which executes the potato yield classification method according to any one of claims 1 to 3 when running.