Crop personalized planting recommendation method and system based on ensemble learning

By integrating multiple machine learning algorithms and collaborative filtering models, combining soil scoring and crop price information, personalized crop planting recommendations are provided, which solves the problem of relying on single machine learning and neglecting other soil information in the existing technology, and improves the accuracy and economicality of recommendations.

CN119831774APending Publication Date: 2025-04-15TIANJIN UNIVERSITY OF TECHNOLOGY
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411901609.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-23
Publication Date
2025-04-15

AI Technical Summary

Technical Problem

Existing crop planting recommendations rely mainly on farmers’ experience and single machine learning, neglecting other information in the soil, resulting in poor recommendation results.

Method used

Using an integrated learning-based method, the KNN classifier, a random forest classifier and a naive Bayes classifier were integrated to obtain crop prediction models through soft voting learning, combining soil scores and crop price information, and using a collaborative filtering model for personalized recommendations.

Benefits of technology

Improves the accuracy of soil scores and market orientation of planting recommendations, allowing farmers to make smarter planting decisions, improve crop yield and quality, and achieve sustainable agricultural development.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119831774A_ABST
    Figure CN119831774A_ABST
Patent Text Reader

Abstract

The invention discloses a crop personalized planting recommendation method and system based on ensemble learning, and the recommendation method comprises the following steps: 1) constructing a database, and obtaining a crop prediction model; 2) acquiring information of to-be-planted soil, and scoring each crop category corresponding to the to-be-planted soil; 3) scoring the crop categories corresponding to the soil samples, and generating a scoring matrix of the crop categories corresponding to the soil samples; 4) obtaining the price information of each crop category in the database, and generating a crop price score table; and 5) collaborative filtering is carried out, crop category personalized recommendation scores are calculated, and a crop recommendation list is generated. According to the method, the user can obtain more accurate soil scoring information and market-oriented planting suggestions, so that a more intelligent planting decision is made, the yield and quality of crops are improved, and the sustainable development of agriculture is finally realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to, and in particular to, a method and system for recommending personalized crop planting based on ensemble learning. Background Art

[0002] Recommendation algorithms are widely used in Internet companies, such as e-commerce platforms, portals, and entertainment platforms, improving user experience and bringing significant economic benefits to the platforms. In recent years, recommendation algorithms have gradually been applied to agriculture, providing farmers with more digital and scientific suggestions on planting techniques and seed selection, combining farmers' experience with scientific planting, and promoting the progress of agricultural production.

[0003] At present, crop planting recommendations mainly rely on farmers' long-term accumulated farming experience and expert advice. It is still relatively rare to provide farmers with scientific planting recommendations based on soil information. In addition, crop recommendation research mainly relies on single machine learning, and rarely conducts mixed recommendations. Most recommendations only consider the relationship between soil and crops, while ignoring other information about the soil. In response to the above problems, this application studies personalized crop planting recommendations based on ensemble learning. Crops are predicted through an ensemble model to obtain soil scoring information for crops. Based on the combination of this information and the market price information of crops, a collaborative filtering model is used to implement personalized recommendations for farmers to plant crops. Summary of the invention

[0004] In view of the above-mentioned defects or deficiencies in the prior art, it is desired to provide a personalized crop planting recommendation method and system based on ensemble learning, which can obtain more accurate soil scoring information and market-oriented planting suggestions, enabling users to make more informed planting decisions, improve crop yield and quality, and ultimately achieve sustainable development of agriculture.

[0005] The present invention provides a method for recommending personalized crop planting based on ensemble learning, comprising the following steps:

[0006] 1) Build a database containing soil sample information and a type of crop suitable for planting for each soil sample; integrate the KNN classifier, random forest classifier, and naive Bayes classifier, and obtain a crop prediction model through soft voting learning on the database;

[0007] 2) Obtaining information on the soil to be planted, predicting each crop category in the database corresponding to the soil to be planted using a crop prediction model, and obtaining the prediction probability of the soil to be planted corresponding to each crop category; and scoring each crop category corresponding to the soil to be planted according to the prediction probability;

[0008] 3) Using the crop prediction model, predict the correspondence of any soil sample in the database to each crop category in the database, and obtain the prediction probability of the soil sample corresponding to each crop category; score the soil sample corresponding to each crop category according to the prediction probability; complete the score of each soil sample corresponding to the crop category in the database one by one, and generate a score matrix of the soil sample corresponding to the crop category;

[0009] 4) Obtaining the price information of each crop category in the database, normalizing the prices of each crop respectively, scoring the crop prices according to the calculation results, and generating a crop price scoring table;

[0010] 5) Collaborative filtering: calculate the similarity between the soil to be planted and the soil samples in the database, and obtain g similar soil samples that are most similar to the soil to be planted; the crop categories suitable for planting in the g similar soil samples are used as the recommended crop categories for the soil to be planted, and the recommendation scores of each recommended crop category are calculated; the personalized recommendation scores of the crop categories are calculated to generate a crop recommendation list;

[0011] O = h%*Y+(1-h%)*Z;

[0012] Among them, O is the personalized recommendation score of the crop category;

[0013] Y is the recommendation score of the recommended crop category;

[0014] Z is the price score of the recommended crop category;

[0015] h% is the weight of the recommendation score, and (1-h%) is the weight of the price score.

[0016] Furthermore, in step 1), the soft voting learning includes the following steps:

[0017] 11) Determine whether the data in the database is balanced. If it is not balanced, perform smoothing oversampling on it;

[0018] 12) Perform multicollinearity diagnosis on each characteristic value of soil samples; use variance inflation factor VIF as a multicollinearity discrimination index:

[0019]

[0020] Among them, R i 2 It indicates the goodness of fit of the model obtained by linear regression of the remaining eigenvalues ​​on the i-th eigenvalue for planting;

[0021] Eigenvalues ​​with VIF less than 10 indicate that there is no multicollinearity between the eigenvalues, and these eigenvalues ​​are selected as valid eigenvalues ​​for training the model;

[0022] 13) Standardize the effective characteristic values ​​of soil samples;

[0023]

[0024] Among them, X is the standardized effective eigenvalue, μ is the mean of the effective eigenvalue, and σ is the standard deviation of the effective eigenvalue;

[0025] 14) Model ensemble training;

[0026] 141) KNN classifier, using 65%-75% of the data in the database as the training set and the remaining data as the test set; measuring the Euclidean distance L(x,y) between the target soil sample in the test set and the soil sample in the training set;

[0027]

[0028] Where x is the target soil sample; y is the soil sample in the training set; n is the number of valid eigenvalues ​​of the soil sample;

[0029] The K soil samples with the closest Euclidean distance to the target soil sample in the training set are counted as neighbors, the number of times each crop category in the database appears in the K neighbors is counted, and the predicted probability of each crop category is calculated:

[0030]

[0031] Where x is the target soil sample;

[0032] C i is one of all the crop categories in the database;

[0033] n i For crop category C i The number of times it appears in K neighbors;

[0034] 142) A random forest classifier, wherein multiple sub-sample data sets are obtained from a database by random sampling with replacement; each sub-sample data set is used to train a decision tree, and finally a random forest consisting of multiple decision trees is obtained; when constructing each decision tree, a portion of valid feature values ​​of soil samples are randomly selected from the sub-sample data set as split decision tree nodes; each decision tree is trained independently until the maximum depth or the minimum number of samples for splitting the decision tree nodes is reached;

[0035] Each decision tree classifies the target soil sample and outputs a crop category. The number of crop categories in all decision trees is counted, and the random forest performs a majority vote on the classification results of each decision tree to obtain the predicted probability of each crop category:

[0036]

[0037] Where T is the number of decision trees;

[0038] C i is one of all the crop categories in the database;

[0039] n i is the number of times the crop category Ci appears in the classification results output by all decision trees;

[0040] 143) Naive Bayes classifier, assume that the features of soil samples in the database are independent of each other; calculate the conditional probability F(X) of each valid feature value when the soil sample is known to be suitable for the type of crop to be planted. j |C b );

[0041]

[0042] Among them, C b The type of crops that the soil sample is suitable for planting;

[0043] X j is the effective characteristic value of the soil sample;

[0044] μ jb Suitable for growing crops Category C b X of each soil sample j The mean of

[0045] σ jb Suitable for growing crops Category C b X of each soil sample j The standard deviation of

[0046] Calculate the posterior probability of each crop category using the formula:

[0047]

[0048] Among them, C a is one of all the crop categories in the database;

[0049] f is the total number of all crop categories in the database;

[0050] m is the number of effective characteristics of the soil sample;

[0051] F(C a ) represents the crop category C a The prior probability of I is the category C of crops suitable for planting in the training set. a The number of soil samples in the training set is L.

[0052] F(X i |C a ) is related to crop category C a Characteristic value X under soil sample conditions suitable for planting i The characteristic conditional probability of

[0053] The posterior probability of each crop category is divided by the sum of the probabilities of all crop categories as the predicted probability of the crop:

[0054]

[0055] Among them, C a is one of all the crop categories in the database;

[0056] f is the total number of all crop categories in the database;

[0057] 144) The crop prediction model calculates the prediction probability of each crop category in the database corresponding to the soil sample in the database through an integrated algorithm:

[0058]

[0059] Among them, c is the weight of the predicted probability output by the KNN classifier;

[0060] d is the weight of the predicted probability output by the random forest classifier;

[0061] e is the weight of the predicted probability output by the naive Bayes classifier.

[0062] Furthermore, in step 141), multiple k values ​​are selected, and the test set is tested using the formula of Euclidean distance L(x, y), and the optimal k value is 2.

[0063] Furthermore, in step 144), the weight ratio of the prediction probabilities output by the KNN classifier, the random forest classifier, and the naive Bayes classifier is c:d:e=2:5:3.

[0064] Furthermore, in step 2) and step 3), the predicted probability of the crop category is recorded as 1 point if it is between 0-0.2, 2 points if it is between 0.2-0.4, 3 points if it is between 0.4-0.6, 4 points if it is between 0.6-0.8, and 5 points if it is between 0.8-1.

[0065] Furthermore, in step 4), the crop prices are normalized using Min-Max and scaled to the interval [0,1]. The specific method is as follows:

[0066]

[0067] Among them, X normalized is the normalized crop price;

[0068] X is the current crop price;

[0069] X max The highest price among all the crop categories suitable for planting in the database for all soil samples;

[0070] X min The lowest price among the crop categories suitable for planting for all soil samples in the database;

[0071] The normalized crop price is recorded as 1 point if it is between 0-0.2, 2 points if it is between 0.2-0.4, 3 points if it is between 0.4-0.6, 4 points if it is between 0.6-0.8, and 5 points if it is between 0.8-1.

[0072] Furthermore, in step 5), the similarity is:

[0073]

[0074] Among them, A is the score vector of the soil to be planted for all crop categories, that is, the scores of all crop categories in the database corresponding to the soil to be planted;

[0075] B is the score vector of a soil sample in the database for all crop categories, that is, the scores of all crop categories in the database corresponding to the soil sample;

[0076] A·B is the dot product of A and B, calculated as:

[0077] f is the total number of all crop categories in the database;

[0078] ||A|| is the norm of the rating vector A, and the calculation formula is:

[0079] f is the total number of all crop categories in the database;

[0080] ||B|| is the norm of the rating vector B, and the calculation formula is:

[0081] f is the total number of all crop categories in the database.

[0082] Furthermore, in step 5), the recommendation score r UI for:

[0083]

[0084] Among them, rUI is the recommended score of the crop category I corresponding to the soil U to be planted;

[0085] N(U) is a set of similar soil samples of the soil to be planted U;

[0086] S(U,u) is the similarity between the soil to be planted U and the similar soil sample u;

[0087] r uI is the score of similar soil sample u for crop category I.

[0088] Furthermore, in the step 5), g is 8-10; h is 70-80.

[0089] In addition, the present invention also provides a system for the above-mentioned personalized crop planting recommendation method based on ensemble learning, comprising an ensemble learning module, a classification result scoring module, a crop market information statistics module and a collaborative filtering module;

[0090] The integrated learning module includes a crop prediction model, which is used to predict the crop category corresponding to the soil to be planted, and obtain the prediction probability of each crop category in the database corresponding to the soil to be planted;

[0091] The classification result scoring module is used to score each crop category in the database corresponding to the soil to be planted according to the predicted probability;

[0092] The crop market information statistics module is used to perform normalized calculations on the prices of various crops according to the price information of the crop categories, score the crop prices according to the calculation results, and generate a crop price score table;

[0093] The collaborative filtering module is used to calculate the similarity between the soil to be planted and each soil sample in the database, obtain the most similar a similar soil samples, and use the a similar soil samples as the recommended crop categories for the soil to be planted, and calculate the recommendation score of each recommended crop category; calculate the personalized recommendation score of the crop category through the recommendation score and the price score, and generate a crop recommendation list.

[0094] Compared with the prior art, the beneficial effects of the present invention are:

[0095] (1) The present invention performs soft voting ensemble learning on three weak classifiers, namely, KNN classifier, random forest classifier and naive Bayes classifier, to form a new strong classifier, and performs weighted average of the prediction probabilities of the three weak classifiers to obtain the final prediction result. This not only reduces the possible misjudgment of a single classifier, but also improves the performance of the strong classifier by utilizing the advantages of each weak classifier on different data subsets. By combining the prediction results of multiple weak classifiers, the sensitivity of the model to outliers and noise is reduced, and the robustness of the strong classifier is improved. Each weak classifier itself has the characteristic of reducing overfitting, and the performance of each weak classifier is further balanced through soft voting ensemble, greatly reducing the risk of overfitting of the strong classifier. By combining the prediction probabilities of different classifiers, the strong classifier can more accurately capture the patterns in the data, thereby improving the accuracy of the prediction. The strong classifier can adapt to different data distributions and feature types, so that it maintains high adaptability and accuracy in the variable soil scoring information, providing strong data support for accurate crop recommendation.

[0096] (2) The present invention integrates the soil-corresponding crop score and the crop price score. The soil-corresponding crop score can provide key data on soil quality, fertility, and the types of crops suitable for planting, while the crop price score reflects the economic value and market demand of different crops. Combining the soil-corresponding crop score and the crop price score, the collaborative filtering model can generate a personalized recommended planting score sheet. This score sheet will recommend the most suitable crops for each farmer based on their specific conditions and market trends, thereby increasing crop yields and economic benefits. Farmers can obtain more accurate planting recommendations, thereby making more informed planting decisions, increasing crop yields and quality, and ultimately achieving sustainable agricultural development.

[0097] It should be understood that the contents described in the summary of the invention are not intended to limit the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0098] Other features, objects and advantages of the present invention will become more apparent from the detailed description of non-limiting embodiments made with reference to the following drawings:

[0099] Figure 1 Flowchart of the personalized crop planting recommendation method based on ensemble learning. DETAILED DESCRIPTION

[0100] The present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the relevant invention, rather than to limit the invention. It should also be noted that, for ease of description, only the parts related to the invention are shown in the accompanying drawings.

[0101] It should be noted that, in the absence of conflict, the embodiments of the present invention and the features in the embodiments can be combined with each other. The present invention will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.

[0102] Please refer to Figure 1 The embodiment of the present invention provides a method for recommending personalized crop planting based on ensemble learning, comprising the following steps:

[0103] 1) Build a database containing soil sample information and a type of crop suitable for planting for each soil sample; integrate the KNN classifier, random forest classifier, and naive Bayes classifier, and obtain a crop prediction model through soft voting learning on the database;

[0104] 2) Obtaining information on the soil to be planted, predicting each crop category in the database corresponding to the soil to be planted using a crop prediction model, and obtaining the prediction probability of the soil to be planted corresponding to each crop category; and scoring each crop category corresponding to the soil to be planted according to the prediction probability;

[0105] 3) Using the crop prediction model, predict the correspondence between any soil sample in the database and each crop category in the database, and obtain the prediction probability of the soil sample corresponding to each crop category; score the soil sample corresponding to each crop category according to the prediction probability; complete the score of each soil sample corresponding to the crop category in the database one by one, and generate a score matrix of the soil sample corresponding to the crop category;

[0106] 4) Obtaining the price information of each crop category in the database, normalizing the prices of each crop respectively, scoring the crop prices according to the calculation results, and generating a crop price scoring table;

[0107] 5) Collaborative filtering: calculate the similarity between the soil to be planted and the soil samples in the database, and obtain g similar soil samples that are most similar to the soil to be planted; the crop categories suitable for planting in the g similar soil samples are used as the recommended crop categories for the soil to be planted, and the recommendation scores of each recommended crop category are calculated; the personalized recommendation scores of the crop categories are calculated to generate a crop recommendation list;

[0108] O = h%*Y+(1-h%)*Z;

[0109] Among them, O is the personalized recommendation score of the crop category;

[0110] Y is the recommendation score of the recommended crop category;

[0111] Z is the price score of the recommended crop category;

[0112] h% is the weight of the recommendation score, and (1-h%) is the weight of the price score.

[0113] In this embodiment, the soil-corresponding crop score and the crop price score are integrated. The soil-corresponding crop score can provide key data on soil quality, fertility, and the types of crops suitable for planting, while the crop price score reflects the economic value and market demand of different crops. Combining the soil-corresponding crop score and the crop price score, the collaborative filtering model can generate a personalized recommended planting score sheet. This score sheet will recommend the most suitable crops for each farmer to plant based on their specific conditions and market trends, thereby increasing crop yields and economic benefits. Farmers can get more accurate planting advice, make more informed planting decisions, increase crop yields and quality, and ultimately achieve sustainable agricultural development.

[0114] In a preferred embodiment, in step 1), soft voting learning includes the following steps:

[0115] 11) Determine whether the data in the database is balanced. If it is not balanced, perform smoothing oversampling on it;

[0116] 12) Perform multicollinearity diagnosis on each characteristic value of soil samples; use variance inflation factor VIF as a multicollinearity discrimination index:

[0117]

[0118] Among them, R i 2 It indicates the goodness of fit of the model obtained by linear regression of the remaining eigenvalues ​​on the i-th eigenvalue for planting;

[0119] Eigenvalues ​​with VIF less than 10 indicate that there is no multicollinearity between the eigenvalues, and these eigenvalues ​​are selected as valid eigenvalues ​​for training the model;

[0120] 13) Standardize the effective characteristic values ​​of soil samples;

[0121]

[0122] Among them, X is the standardized effective eigenvalue, μ is the mean of the effective eigenvalue, and σ is the standard deviation of the effective eigenvalue;

[0123] 14) Model ensemble training;

[0124] 141) KNN classifier, using 65%-75% of the data in the database as the training set and the remaining data as the test set; measuring the Euclidean distance L(x,y) between the target soil sample in the test set and the soil sample in the training set;

[0125]

[0126] Where x is the target soil sample; y is the soil sample in the training set; n is the number of valid eigenvalues ​​of the soil sample;

[0127] The K soil samples with the closest Euclidean distance to the target soil sample in the training set are counted as neighbors, the number of times each crop category in the database appears in the K neighbors is counted, and the predicted probability of each crop category is calculated:

[0128]

[0129] Where x is the target soil sample;

[0130] C i is one of all the crop categories in the database;

[0131] n i For crop category C i The number of times it appears in K neighbors;

[0132] 142) A random forest classifier, wherein multiple sub-sample data sets are obtained from a database by random sampling with replacement; each sub-sample data set is used to train a decision tree, and finally a random forest consisting of multiple decision trees is obtained; when constructing each decision tree, a portion of valid feature values ​​of soil samples are randomly selected from the sub-sample data set as split decision tree nodes; each decision tree is trained independently until the maximum depth or the minimum number of samples for splitting the decision tree nodes is reached;

[0133] Each decision tree classifies the target soil sample and outputs a crop category. The number of crop categories in all decision trees is counted, and the random forest performs a majority vote on the classification results of each decision tree to obtain the predicted probability of each crop category:

[0134]

[0135] Where T is the number of decision trees;

[0136] C i is one of all the crop categories in the database;

[0137] n i is the number of times the crop category Ci appears in the classification results output by all decision trees;

[0138] 143) Naive Bayes classifier, assume that the features of soil samples in the database are independent of each other; calculate the conditional probability F(X) of each valid feature value when the soil sample is known to be suitable for the type of crop to be planted. j |C b );

[0139]

[0140] Among them, C b The type of crops that the soil sample is suitable for planting;

[0141] X j is the effective characteristic value of the soil sample;

[0142] μ jb Suitable for growing crops Category C b X of each soil sample j The mean of

[0143] σ jb Suitable for growing crops Category C b X of each soil sample j The standard deviation of

[0144] Calculate the posterior probability of each crop category using the formula:

[0145]

[0146] Among them, C a is one of all the crop categories in the database;

[0147] f is the total number of all crop categories in the database;

[0148] m is the number of effective characteristics of the soil sample;

[0149] F(C a ) represents the crop category C a The prior probability of I is the category C of crops suitable for planting in the training set. a The number of soil samples in the training set is L.

[0150] F(X i |C a ) is related to crop category C a Characteristic value X under soil sample conditions suitable for planting i The characteristic conditional probability of

[0151] The posterior probability of each crop category is divided by the sum of the probabilities of all crop categories as the predicted probability of the crop:

[0152]

[0153] Among them, C a is one of all the crop categories in the database;

[0154] f is the total number of all crop categories in the database;

[0155] 144) The crop prediction model calculates the prediction probability of each crop category in the database corresponding to the soil sample in the database through an integrated algorithm:

[0156]

[0157] Among them, c is the weight of the predicted probability output by the KNN classifier;

[0158] d is the weight of the predicted probability output by the random forest classifier;

[0159] e is the weight of the predicted probability output by the naive Bayes classifier.

[0160] In this embodiment, when designing the crop recommendation system, each soil sample is first regarded as an independent "user". There is no need to worry about the imbalance of data categories, because each "user" is unique and focuses on the differences between individuals. In order to avoid result deviations due to inconsistent dimensions in subsequent calculations, the characteristic values ​​of the soil samples are standardized. This ensures that all characteristic values ​​are on the same scale, making the calculation of similarity more accurate and meaningful.

[0161] This application uses soft voting to integrate and learn three weak classifiers, namely, KNN classifier, random forest classifier and naive Bayes classifier, into a new strong classifier, and weighted averages the prediction probabilities of these three weak classifiers to obtain the final prediction result. It not only reduces the possible misjudgment of a single classifier, but also can utilize the advantages of each weak classifier on different data subsets to improve the performance of the strong classifier. By combining the prediction results of multiple weak classifiers, the sensitivity of the model to outliers and noise is reduced, and the robustness of the strong classifier is improved. Each weak classifier itself has the characteristic of reducing overfitting, and the performance of each weak classifier is further balanced by soft voting integration, which greatly reduces the risk of overfitting of the strong classifier. By combining the prediction probabilities of different classifiers, the strong classifier can more accurately capture the pattern in the data, thereby improving the accuracy of the prediction. The strong classifier can adapt to different data distributions and feature types, so that it maintains high adaptability and accuracy in the variable soil scoring information, and provides strong data support for accurate crop recommendation.

[0162] Cross-validation is a powerful model evaluation technique that evaluates the generalization ability of a model by dividing a dataset into multiple subsets, using one of the subsets as a test set and the rest as a training set in turn. By calculating the average score of the model training results on each subset, we can get a more robust performance indicator. K-fold cross-validation was performed on the KNN classifier, random forest classifier, naive Bayes classifier, and crop prediction model. The KNN classifier scored 0.9764, the random forest classifier scored 0.9952, the naive Bayes classifier scored 0.9948, and the crop prediction model scored the highest at 0.9956. The results show that through the soft voting ensemble method, we have successfully improved the generalization ability of the model, thereby enhancing the accuracy of the model recommendation results.

[0163] The F1 score, as the harmonic mean of precision and recall, provides a performance metric that takes both metrics into account. It not only measures the accuracy of the model's predictions, but also measures the model's ability to identify all positive samples, thus providing a balanced performance metric. The F1 scores of the KNN classifier, random forest classifier, naive Bayes classifier, and crop prediction model were calculated respectively. The F1 score of the KNN classifier was 0.9712, the F1 score of the random forest classifier was 0.9924, the F1 score of the naive Bayes classifier was 0.9939, and the F1 score of the crop prediction model was 0.9924. These data reveal that the crop prediction model performs well in precision and recall, with little difference, showing a good balance.

[0164] In summary, we can conclude that the crop prediction model outperforms other single classifiers and provides more reliable prediction results.

[0165] In a preferred embodiment, in step 141), multiple k values ​​are selected, and the test set is tested using the formula of Euclidean distance L(x, y), and the optimal k value is 2.

[0166] In a preferred embodiment, in step 144), the weight ratio of the prediction probabilities output by the KNN classifier, the random forest classifier, and the naive Bayes classifier is c:d:e=2:5:3, which ensures the reliability of the integrated crop prediction model.

[0167] In a preferred embodiment, in step 2) and step 3), the predicted probability of the crop category is scored as 1 point if it is between 0-0.2, 2 points if it is between 0.2-0.4, 3 points if it is between 0.4-0.6, 4 points if it is between 0.6-0.8, and 5 points if it is between 0.8-1. By assigning points to the predicted probability of the crop category corresponding to the soil to be planted, the result of crop recommendation is more intuitive.

[0168] In a preferred embodiment, in step 4), the crop prices are normalized using Min-Max to scale them to the interval [0,1], and the specific method is as follows:

[0169]

[0170] Among them, X normalized is the normalized crop price;

[0171] X is the current crop price;

[0172] X max The highest price among all the crop categories suitable for planting in the database for all soil samples;

[0173] X min The lowest price among all the crop categories suitable for planting soil samples in the database;

[0174] The normalized crop prices between 0-0.2 are scored as 1, between 0.2-0.4 as 2, between 0.4-0.6 as 3, between 0.6-0.8 as 4, and between 0.8-1 as 5. The scoring of crop prices makes the crop recommendation results more intuitive.

[0175] In a preferred embodiment, in step 5), the similarity is:

[0176]

[0177] Among them, A is the score vector of the soil to be planted for all crop categories, that is, the scores of all crop categories in the database corresponding to the soil to be planted;

[0178] B is the score vector of a soil sample in the database for all crop categories, that is, the scores of all crop categories in the database corresponding to the soil sample;

[0179] A·B is the dot product of A and B, calculated as:

[0180] f is the total number of all crop categories in the database;

[0181] ||A|| is the norm of the rating vector A, and the calculation formula is:

[0182] f is the total number of all crop categories in the database;

[0183] ||B|| is the norm of the rating vector B, and the calculation formula is:

[0184] f is the total number of all crop categories in the database.

[0185] In this embodiment, the recommended crop category of the soil to be planted is obtained through similarity, which ensures the reliability of the recommendation result.

[0186] In a preferred embodiment, in step 5), the recommendation score r UI for:

[0187]

[0188] Among them, r UI is the recommended score of the crop category I corresponding to the soil U to be planted;

[0189] N(U) is a set of similar soil samples of the soil to be planted U;

[0190] S(U,u) is the similarity between the soil to be planted U and the similar soil sample u;

[0191] r uI is the score of similar soil sample u for crop category I.

[0192] In this embodiment, the recommendation score of each recommended crop category is used as an important parameter for personalized crop planting recommendation, thereby ensuring the reliability of the recommendation result.

[0193] In a preferred embodiment, in step 5), g is 8-10, and 8-10 similar soil samples are selected; h is 70-80, the weight of the recommendation score is 70-80%, and the weight of the corresponding price score is 30-20%; thereby obtaining a highly reliable personalized recommendation score for the crop category.

[0194] In addition, an embodiment of the present invention further provides a system for the above-mentioned personalized crop planting recommendation method based on ensemble learning, comprising an ensemble learning module, a classification result scoring module, a crop market information statistics module and a collaborative filtering module;

[0195] The integrated learning module includes a crop prediction model, which is used to predict the crop category corresponding to the soil to be planted, and obtain the prediction probability of each crop category in the database corresponding to the soil to be planted;

[0196] The classification result scoring module is used to score each crop category in the database corresponding to the soil to be planted according to the predicted probability;

[0197] The crop market information statistics module is used to perform normalized calculations on the prices of various crops according to the price information of the crop categories, score the crop prices according to the calculation results, and generate a crop price score table;

[0198] The collaborative filtering module is used to calculate the similarity between the soil to be planted and each soil sample in the database, obtain the most similar a similar soil samples, and use the a similar soil samples as the recommended crop categories for the soil to be planted, and calculate the recommendation score of each recommended crop category; calculate the personalized recommendation score of the crop category through the recommendation score and the price score, and generate a crop recommendation list.

[0199] In this embodiment, a crop recommendation list is finally generated through the personalized crop planting recommendation system, which not only includes the scores of crop categories through collaborative filtering, but also integrates the market price scores of crops. While ensuring the scientific nature of crop planting, economic efficiency is also taken into account, providing farmers with a personalized recommendation that combines soil quality and market value. This not only helps farmers choose crops that are suitable for their soil conditions, but also takes into account the market prospects of crops, thereby maximizing profits.

[0200] In the description of this specification, the description of the terms "one embodiment", "some embodiments", etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any one or more embodiments or examples in a suitable manner.

[0201] The above are only preferred embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.

Claims

1. A personalized crop planting recommendation method based on ensemble learning, characterized in that: The steps include: 1) Build a database containing soil sample information and a type of crop suitable for planting for each soil sample; integrate the KNN classifier, random forest classifier, and naive Bayes classifier, and obtain a crop prediction model through soft voting learning on the database; 2) Obtaining information on the soil to be planted, predicting each crop category in the database corresponding to the soil to be planted using a crop prediction model, and obtaining the prediction probability of the soil to be planted corresponding to each crop category; and scoring each crop category corresponding to the soil to be planted according to the prediction probability; 3) Using the crop prediction model, predict the correspondence between any soil sample in the database and each crop category in the database, and obtain the prediction probability of the soil sample corresponding to each crop category; score the soil sample corresponding to each crop category according to the prediction probability; complete the score of each soil sample corresponding to the crop category in the database one by one, and generate a score matrix of the soil sample corresponding to the crop category; 4) Obtaining the price information of each crop category in the database, normalizing the prices of each crop respectively, scoring the crop prices according to the calculation results, and generating a crop price scoring table; 5) Collaborative filtering: calculate the similarity between the soil to be planted and the soil samples in the database, and obtain g similar soil samples that are most similar to the soil to be planted; the crop categories suitable for planting in the g similar soil samples are used as the recommended crop categories for the soil to be planted, and the recommendation scores of each recommended crop category are calculated; the personalized recommendation scores of the crop categories are calculated to generate a crop recommendation list; O = h%*Y+(1-h%)*Z; Among them, O is the personalized recommendation score of the crop category; Y is the recommendation score of the recommended crop category; Z is the price score of the recommended crop category; h% is the weight of the recommendation score, and (1-h%) is the weight of the price score.

2. The method for personalized crop planting recommendation based on ensemble learning according to claim 1, characterized in that: In step 1), soft voting learning includes the following steps: 11) Determine whether the data in the database is balanced. If it is not balanced, perform smoothing oversampling on it; 12) Perform multicollinearity diagnosis on each characteristic value of soil samples; use variance inflation factor VIF as a multicollinearity discrimination index: Among them, R i 2 It indicates the goodness of fit of the model obtained by linear regression of the remaining eigenvalues ​​on the i-th eigenvalue for planting; Eigenvalues ​​with VIF less than 10 indicate that there is no multicollinearity between the eigenvalues, and these eigenvalues ​​are selected as valid eigenvalues ​​for training the model; 13) Standardize the effective characteristic values ​​of soil samples; Among them, X is the standardized effective eigenvalue, μ is the mean of the effective eigenvalue, and σ is the standard deviation of the effective eigenvalue; 14) Model ensemble training; 141) KNN classifier, using 65%-75% of the data in the database as the training set and the remaining data as the test set; measuring the Euclidean distance L(x,y) between the target soil sample in the test set and the soil sample in the training set; Where x is the target soil sample; y is the soil sample in the training set; n is the number of valid eigenvalues ​​of the soil sample; The K soil samples with the closest Euclidean distance to the target soil sample in the training set are counted as neighbors, the number of times each crop category in the database appears in the K neighbors is counted, and the predicted probability of each crop category is calculated: Where x is the target soil sample; C i is one of all the crop categories in the database; n i For crop category C i The number of times it appears in K neighbors; 142) A random forest classifier, wherein multiple sub-sample data sets are obtained from a database by random sampling with replacement; each sub-sample data set is used to train a decision tree, and finally a random forest consisting of multiple decision trees is obtained; when constructing each decision tree, a portion of valid feature values ​​of soil samples are randomly selected from the sub-sample data set as split decision tree nodes; each decision tree is trained independently until the maximum depth or the minimum number of samples for splitting the decision tree nodes is reached; Each decision tree classifies the target soil sample and outputs a crop category. The number of crop categories in all decision trees is counted, and the random forest performs a majority vote on the classification results of each decision tree to obtain the predicted probability of each crop category: Where T is the number of decision trees; C i is one of all the crop categories in the database; n i is the number of times the crop category Ci appears in the classification results output by all decision trees; 143) Naive Bayes classifier, assume that the features of soil samples in the database are independent of each other; calculate the conditional probability F(X) of each valid feature value when the soil sample is known to be suitable for the type of crop to be planted. j |C b ); Among them, C b The type of crops that the soil sample is suitable for planting; X j is the effective characteristic value of the soil sample; μ jb Suitable for growing crops Category C b X of each soil sample j The mean of σ jb Suitable for growing crops Category C b X of each soil sample j The standard deviation of Calculate the posterior probability of each crop category using the formula: Among them, C a is one of all the crop categories in the database; f is the total number of all crop categories in the database; m is the number of effective characteristics of the soil sample; F(C a ) represents the crop category C a The prior probability of I is the category C of crops suitable for planting in the training set. a The number of soil samples in the training set is L. F(X i |C a ) is related to crop category C a Characteristic value X under soil sample conditions suitable for planting i The characteristic conditional probability of The posterior probability of each crop category is divided by the sum of the probabilities of all crop categories as the predicted probability of the crop: Among them, C a is one of all the crop categories in the database; f is the total number of all crop categories in the database; 144) The crop prediction model calculates the prediction probability of each crop category in the database corresponding to the soil sample in the database through an integrated algorithm: Among them, c is the weight of the predicted probability output by the KNN classifier; d is the weight of the predicted probability output by the random forest classifier; e is the weight of the predicted probability output by the naive Bayes classifier.

3. The method for personalized crop planting recommendation based on ensemble learning according to claim 2, characterized in that: In the step 141), multiple k values ​​are selected, and the test set is tested using the formula of Euclidean distance L(x, y), and the optimal k value is 2.

4. The method for personalized crop planting recommendation based on ensemble learning according to claim 3 is characterized in that: In the step 144), the weight ratio of the predicted probabilities output by the KNN classifier, the random forest classifier and the naive Bayes classifier is c:d:e=2:5:

3.

5. The method for personalized crop planting recommendation based on ensemble learning according to claim 1, characterized in that: In step 2) and step 3), the predicted probability of the crop category is recorded as 1 point if it is between 0-0.2, 2 points if it is between 0.2-0.4, 3 points if it is between 0.4-0.6, 4 points if it is between 0.6-0.8, and 5 points if it is between 0.8-1.

6. The method for personalized crop planting recommendation based on ensemble learning according to claim 5, characterized in that: In step 4), the crop prices are normalized using Min-Max and scaled to the interval [0,1]. The specific method is as follows: Among them, X normalized is the normalized crop price; X is the current crop price; X max The highest price among all the crop categories suitable for planting in the database for all soil samples; X min The lowest price among all the crop categories suitable for planting soil samples in the database; The normalized crop price is recorded as 1 point if it is between 0-0.2, 2 points if it is between 0.2-0.4, 3 points if it is between 0.4-0.6, 4 points if it is between 0.6-0.8, and 5 points if it is between 0.8-1.

7. The method for personalized crop planting recommendation based on ensemble learning according to claim 1, characterized in that: In step 5), the similarity is: Among them, A is the score vector of the soil to be planted for all crop categories, that is, the scores of all crop categories in the database corresponding to the soil to be planted; B is the score vector of a soil sample in the database for all crop categories, that is, the scores of all crop categories in the database corresponding to the soil sample; A·B is the dot product of A and B, calculated as: f is the total number of all crop categories in the database; ||A|| is the norm of the rating vector A, and the calculation formula is: f is the total number of all crop categories in the database; ||B|| is the norm of the rating vector B, and the calculation formula is: f is the total number of all crop categories in the database.

8. The method for personalized crop planting recommendation based on ensemble learning according to claim 7, characterized in that: In step 5), the recommendation score r UI for: Among them, r UI is the recommended score of the crop category I corresponding to the soil U to be planted; N(U) is a set of similar soil samples of the soil to be planted U; S(U,u) is the similarity between the soil to be planted U and the similar soil sample u; r uI is the score of similar soil sample u for crop category I.

9. The method for personalized crop planting recommendation based on ensemble learning according to claim 8, characterized in that: In the step 5), g is 8-10; h is 70-80.

10. A system for the method for recommending personalized crop planting based on ensemble learning according to any one of claims 1 to 9, characterized in that: It includes integrated learning module, classification result scoring module, crop market information statistics module and collaborative filtering module; The integrated learning module includes a crop prediction model, which is used to predict the crop category corresponding to the soil to be planted, and obtain the prediction probability of each crop category in the database corresponding to the soil to be planted; The classification result scoring module is used to score each crop category in the database corresponding to the soil to be planted according to the predicted probability; The crop market information statistics module is used to perform normalized calculations on the prices of various crops according to the price information of the crop categories, score the crop prices according to the calculation results, and generate a crop price score table; The collaborative filtering module is used to calculate the similarity between the soil to be planted and each soil sample in the database, obtain the most similar a similar soil samples, and use the a similar soil samples as the recommended crop categories for the soil to be planted, and calculate the recommendation score of each recommended crop category; calculate the personalized recommendation score of the crop category through the recommendation score and the price score, and generate a crop recommendation list.

Citation Information

Cited By

  • Crop intelligent recommendation system based on neural network

    CN120782586A