Special agricultural product quality improvement reasoning model construction and reasoning method based on PU learning
By constructing a reasoning model for improving the quality of agricultural products through PU learning, the problem of relying on experience and insufficient data for the quality control of agricultural products is solved. It enables effective modeling and quality improvement guidance under imbalanced data, and improves the generalization ability and data utilization of the model.
Patent Information
- Application Number
- CN202511664483.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-13
- Publication Date
- 2026-02-17
AI Technical Summary
Current agricultural product quality control relies too heavily on experience and data support, lacks systematic and data-driven methods, and traditional supervised learning methods struggle to achieve effective model generalization when sample distribution is uneven, making it difficult to improve quality in agricultural production.
A reasoning model for improving the quality of specialty agricultural products is constructed using the PU learning method. The random forest ensemble model and the neural network model are trained by PU-Bagging and nnPU algorithms. Feature patterns are mined using positive samples and unlabeled samples. The model is trained and reasoned by combining meteorological feature data.
It achieves effective modeling in the absence of negative samples, improves the generalization and sample utilization of the model, can automatically identify the most suitable and least suitable agricultural production areas, and generate suitability heat maps, providing accurate basis for quality improvement.
Smart Images

Figure CN121542693A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of agricultural informatization and intelligent decision-making technology, and in particular to a reasoning model for improving the quality of specialty agricultural products based on PU learning and a reasoning method. Background Technology
[0002] Specialty agricultural products refer to agricultural products produced in specific regions and possessing unique characteristics and qualities. In the central and western regions, rural specialty agricultural products such as grains, oils, fruits and vegetables, livestock and poultry, mushrooms, medicinal herbs, and teas generally suffer from problems such as poor standardization of production techniques, irrational resource utilization, and difficulty in guaranteeing quality stability. How to achieve controllability and quality improvement in the production process under different production conditions is a crucial issue for the high-quality development of rural industries. Currently, existing agricultural product quality control relies heavily on the subjective experience and manual judgment of agricultural producers, lacking systematic and data-driven support. On the other hand, agricultural production data collection is limited, typically obtaining only a small number of samples from "high-quality production areas" while struggling to acquire clear negative samples from "unsuitable production areas," making it difficult to establish effective quality improvement inference models using traditional supervised learning methods. This uneven sample distribution directly limits the model's ability to discriminate between different production conditions and its generalization performance, making it difficult to meet the needs of precise control and decision-making.
[0003] PU learning (Positive and Unlabeled Learning) is a machine learning method based on positive and unlabeled samples. It achieves robust classification and prediction when only a portion of the training data is labeled as positive, there are few explicitly negative samples, and the categories of the remaining samples are unknown (potentially positive or negative). Compared to traditional supervised learning methods, PU learning can uncover latent feature patterns even with incomplete data labels, thus providing a feasible intelligent modeling approach for quality control in scenarios where agricultural production data is scarce and negative samples are lacking. Summary of the Invention
[0004] This invention aims to address the problems existing in the production of specialty agricultural products in rural areas, such as reliance on experience for quality control, insufficient data support, and difficulty in model generalization. It proposes a method for constructing and reasoning a quality improvement inference model for specialty agricultural products based on Pu (Professional User Learning) learning. This invention constructs a generalizable quality improvement inference model for specialty agricultural products through Pu learning, and provides data-driven and intelligent support for quality control and improvement through model interpretability technology.
[0005] To achieve the above-mentioned objectives, the present invention adopts the following technical solution.
[0006] A method for constructing a reasoning model for improving the quality of specialty agricultural products based on PU learning includes the following steps:
[0007] Step 1: Collect major agricultural meteorological datasets nationwide, organize and preprocess the raw meteorological observation data in the datasets in a structured manner, and construct a meteorological feature dataset;
[0008] Step 2: Collect data from agricultural product samples, clean and standardize the names of characteristic qualities, establish a set of main characteristic qualities for each agricultural product variety, count the frequency of occurrence of characteristic qualities in different samples, screen out the main characteristic qualities with high frequency of occurrence, and construct an agricultural product sample dataset.
[0009] Step 3: Construct a positive sample set and an unlabeled sample set for each agricultural product variety. Specifically, this includes: for each agricultural product variety, extracting meteorological characteristics from samples from its place of origin, and defining the set of these characteristic samples as the positive sample set.
[0010] P={(x i ,y i )|y i =1}
[0011] Where, x i Let y represent the meteorological feature vector of the i-th sample. i =1 indicates that the sample belongs to the place of origin of the target agricultural product.
[0012] Meteorological features were extracted from all regions across the country, excluding the positive samples, to construct an unlabeled sample set.
[0013] U={(x i ,y i )|y i =0}
[0014] Where, x i Indicates the meteorological characteristics of other regions of the country, y i =0 indicates that the origin category of the sample is unknown or unmarked, and does not belong to the known origin of the current variety;
[0015] Step 4: Train and build a reasoning model for improving the quality of specialty agricultural products based on the PU learning algorithm.
[0016] In this invention, in step 1, the meteorological observation data in the agricultural meteorological dataset includes average high temperature, average low temperature, average wind speed, average visibility, extreme high temperature, extreme low temperature, and total rainfall; the original meteorological observation data is organized into a structure of "{origin name: [average high temperature, average low temperature, average wind speed, average visibility, extreme high temperature, extreme low temperature, total rainfall]}" for use as model input; preprocessing includes imputation and normalization of outliers and missing terms.
[0017] In this invention, in step 2, the agricultural product sample includes its place of origin, variety, and characteristic quality; the names of characteristic quality are standardized through keyword mapping.
[0018] In this invention, in step 4, the PU learning algorithm is the PU-Bagging algorithm, and the inference model for improving the quality of specialty agricultural products obtained after training is a random forest ensemble model; the specific training steps of PU-Bagging are as follows:
[0019] 1) Construct training samples for each sub-model. Each sub-model training set consists of a complete positive sample set P and a sampled negative sample set N:
[0020] T (k) =P∪N
[0021] Negative sample set N is an unlabeled sample set U = {(x i ,y i )|y i Random sampling is performed within the range 0, assuming that all unlabeled samples are negative samples:
[0022] N=RandomSample(U,size=negpercent·|P|)
[0023] 2) Each sub-model, i.e., random forest, has its corresponding training subset T (k) Independent training was performed on T; during the training process of the random forest, T was first trained independently. (k) Autosample the data to generate several subsets containing duplicate samples. Each subset is used to train a decision tree. During tree growth, each node randomly selects a subset of features from all features as candidate splitting features, thus introducing randomness at the feature level. For any candidate feature split, its information gain is defined as:
[0024]
[0025] Where I(·) represents the impurity of a node, and M j M represents the number of samples in the j-th child node. parent The number of samples in the current parent node; the algorithm selects the feature that maximizes ΔI and its splitting threshold at each node for splitting until the stopping condition is met, which is the maximum depth or the minimum number of samples;
[0026] After multiple sampling and training iterations, the random forest sub-model f (k) It consists of multiple independent decision trees with different structures;
[0027] 3) Integrate the trained K sub-models. The output of each sample sub-model is:
[0028]
[0029] Then, the majority voting method is used to obtain the number of times the sample was predicted as a positive example, which is denoted as the output of the ensemble model f:
[0030]
[0031] In this invention, in step 4, the PU learning algorithm is the nnPU algorithm, and the inference model for improving the quality of specialty agricultural products obtained after training is a neural network model; the specific training steps of nnPU are as follows:
[0032] 1) Construct a feedforward neural network model f θ :R d →R, including two hidden layers and residual connections:
[0033] h1=ReLU(BN(W1x+b1)),h2=ReLU(BN(W2h1+b2))+W s h1
[0034] logits = W o h2+b0
[0035] Among them, W1W2W s W o For network weights, b1b2b o The term is the bias term, BN stands for BatchNorm, and ReLU is the activation function;
[0036] 2) The nnPU loss function is based on risk estimation theory, and estimates the risk R of positive samples using the positive sample set P and the unlabeled sample set U respectively. pos Negative sample bias risk R unl Negative sample risk correction term R unl_pos :
[0037]
[0038] Where l(·) is the binary cross-entropy loss:
[0039]
[0040] Set the hyperparameter positive sample prior probability π p The weighted estimate of the nnPU risk function, which subtracts the positive sample risk from the negative class risk of unlabeled samples, is:
[0041] R(θ)=π p ·R pos (θ)+max(R unl (θ)-π p ·R unl_pos(θ),0)3) Set the learning rate η, use gradient descent to optimize R(θ), and iteratively update the neural network parameters θ:
[0042]
[0043] The training continues until the preset number of training rounds E is reached or the loss converges.
[0044] This invention also provides a method for suitability analysis of specialty agricultural products based on a reasoning model for improving the quality of specialty agricultural products. This method uses the aforementioned PU-based reasoning model to infer suitable production areas for characteristic qualities, and presents the results as a list of the most suitable and least suitable planting areas and a national regional suitability heatmap. The specific steps are as follows:
[0045] Step 1: Preparation of meteorological characteristic data and loading of the reasoning model for improving the quality of specialty agricultural products
[0046] For a given agricultural product variety, select and load a characteristic agricultural product quality improvement inference model f based on PU learning. This model can output the probability f(x) that a certain input meteorological feature x is suitable for the growth of the variety.
[0047] Step 2: Collect meteorological characteristics of all counties and cities across the country. i Input the model, perform model inference on the meteorological characteristics of various regions across the country, and obtain the probability f(x) that the meteorological characteristics of each county and city are suitable for the growth of this variety. i );
[0048] Step 3: Calculate the suitable growth probability f(x) for each county and city nationwide. i Sort the regions in descending order to generate recommendations for the most suitable and least suitable planting areas;
[0049] Step 4: Generate a national regional suitability heat map. The darker the color in the heat map, the more suitable the region is for planting.
[0050] 1) Set a threshold t to filter out samples with a predicted probability greater than the threshold f(x). i Counties and cities with a value greater than t are designated as suitable planting areas.
[0051] 2) Prepare national geographic information data, which includes the boundary coordinates of each city and the subordinate relationships between cities and counties and municipalities and districts, to provide spatial reference for the base map of the heat map;
[0052] 3) For each city, set the color intensity according to the number of suitable planting areas to construct a heat map.
[0053] Furthermore, this invention also provides a method for inferring the quality of specialty agricultural products based on a model for improving the quality of specialty agricultural products. This method achieves feature quality improvement inference based on the aforementioned PU-based inference model for improving the quality of specialty agricultural products. The specific steps are as follows:
[0054] Step 1: Preparation of meteorological characteristic data and loading of the reasoning model for improving the quality of specialty agricultural products
[0055] For a specific agricultural product variety, a characteristic agricultural product quality improvement inference model f based on PU learning is selected and loaded; the model outputs the probability value f(x) of the growth suitability of the variety under the environmental conditions based on the input meteorological feature x.
[0056] Step 2: Calculate the global feature importance and identify the key meteorological factors that determine the quality improvement of a certain feature at the overall scale. When the inference model for improving the quality of specialty agricultural products based on PU learning is a random forest ensemble model trained using PUbagging; Step 2 specifically involves:
[0057] 1) For each node in each decision tree of the ensemble model that is split by a feature, calculate the reduction in impurity resulting from the split;
[0058] 2) Sum the impurity decreases of the same feature in a single decision tree and normalize all features to obtain the importance of each feature in a single decision tree;
[0059] 3) The importance of each feature in the ensemble model is obtained by averaging the importance of the same features in all decision trees in the ensemble model;
[0060] When the inference model for improving the quality of specialty agricultural products based on PU learning is a neural network model trained using nnPU; step 2 specifically involves:
[0061] 1) Use the SHAP method to calculate the contribution weight of each climate feature to the model output; for each sample x i Each feature value The contributions are as follows:
[0062]
[0063] Where F: the complete feature set, S: a subset of features, Values based on feature subsets The model outputs the mean under certain conditions. feature The marginal contribution;
[0064] 2) For each feature, take the absolute value of the SHAP value of all samples and average it to obtain the global feature importance of each feature.
[0065] Step 3: Calculate the importance of local features and propose climate element adjustment plans to improve quality for the current climate conditions of individual planting areas.
[0066] When the inference model for improving the quality of specialty agricultural products based on PU learning is a random forest ensemble model trained using PUbagging; step 3 specifically involves:
[0067] 1) For each node in each decision tree of the ensemble model that is split by a feature, calculate the reduction in impurity resulting from the split;
[0068] 2) For a specified sample x i The decision path from the root node to the leaf node is obtained from each decision tree. The impurity decrease value of the corresponding feature of these split nodes is summed along the path to obtain the local importance of each feature in each decision tree.
[0069] 3) The local importance of each feature in the ensemble model is obtained by averaging the local importance of the same features in all decision trees in the ensemble model.
[0070] When the inference model for improving the quality of specialty agricultural products based on PU learning is a neural network model trained using nnPU; step 3 specifically involves:
[0071] 1) For a specified sample x i The forward propagation calculation model outputs the appropriate growth probability;
[0072] 2) Perform backpropagation on the suitable growth probability to obtain the value of each feature. The absolute value of the gradient is used as the local importance of each feature:
[0073]
[0074] Compared with the prior art, the present invention has the following beneficial effects:
[0075] 1. The method for constructing a reasoning model for improving the quality of specialty agricultural products based on PU learning proposed in this invention can achieve effective modeling even with only some positive samples and a lack of negative samples. This significantly reduces the dependence of the agricultural field on large-scale labeled data and improves the sample utilization rate and the generalizability of the model.
[0076] 2. The suitability analysis method for specialty agricultural products based on the reasoning model for improving the quality of specialty agricultural products proposed in this invention can automatically identify the most suitable and least suitable agricultural product production areas and generate a suitability heat map by reasoning from meteorological characteristic data across the country, thereby realizing an intuitive display and guidance for regional quality improvement.
[0077] 3. The inference method for improving the quality of specialty agricultural products proposed in this invention utilizes model interpretability technology to explain the causal mechanism of the model's appropriate probability prediction results, thereby identifying key meteorological factors that determine the quality of agricultural products, quantitatively assessing the degree of influence of each factor on quality indicators, revealing the causal relationship between different production conditions and quality results, and providing a precise basis for generating optimized operation plans to improve product quality. Attached Figure Description
[0078] Figure 1 This is a structural framework diagram of an embodiment of the present invention.
[0079] Figure 2 This is a flowchart illustrating the construction method of a reasoning model for improving the quality of specialty agricultural products based on PU learning, as described in an embodiment of the present invention.
[0080] Figure 3 This is a flowchart of the suitability analysis method for specialty agricultural products based on a reasoning model for improving the quality of specialty agricultural products, as described in an embodiment of the present invention.
[0081] Figure 4 This is a flowchart of the reasoning method for improving the quality of specialty agricultural products based on a reasoning model for improving the quality of specialty agricultural products, as described in an embodiment of the present invention. Detailed Implementation
[0082] The method of the present invention will be further described below with reference to the accompanying drawings and embodiments;
[0083] like Figure 1 As shown, a reasoning model for improving the quality of agricultural products based on PU learning is constructed and a reasoning method is proposed, providing three aspects: a method for constructing a reasoning model for improving the quality of specialty agricultural products based on PU learning, a method for suitability analysis of specialty agricultural products based on the reasoning model for improving the quality of specialty agricultural products, and a reasoning method for improving the quality of specialty agricultural products based on the reasoning model for improving the quality of specialty agricultural products. The specific steps of the three aspects are as follows:
[0084] Firstly, this invention provides a method for constructing a reasoning model for improving the quality of specialty agricultural products based on PU learning, used to construct such a reasoning model. Figure 2 The steps shown are as follows:
[0085] Step 1: Construct a meteorological feature dataset.
[0086] Step 2: Construct a dataset of agricultural product samples.
[0087] Step 3: Construct a positive sample set and an unlabeled sample set for each agricultural product variety.
[0088] Step 4: Train a reasoning model for improving the quality of specialty agricultural products based on the PU learning algorithm.
[0089] Step 1: The specific steps are as follows:
[0090] 1-1 Collect major agricultural meteorological datasets nationwide. The meteorological data includes meteorological elements such as average high temperature, average low temperature, average wind speed, average visibility, extreme high temperature, extreme low temperature, and total rainfall.
[0091] 1-2 The dataset is structured and organized, and the original meteorological observation data is organized into the structure "{origin name: [average high temperature, average low temperature, average wind speed, average visibility, extreme high temperature, extreme low temperature, total rainfall]}" for use as model input.
[0092] 1-3 Imputation and normalization are performed on outliers and missing items.
[0093] Step 2 is detailed below:
[0094] 2-1 Collect data from agricultural product samples. Each sample includes its place of origin, variety, and characteristic qualities (such as soluble solids, maximum hardness, sugar content, etc.).
[0095] 2-2 Cleaning and Standardization of Characteristic Quality Names. Characteristic quality names are standardized using a keyword mapping table (e.g., "soluble solids" is standardized to "soluble solids").
[0096] 2-3 Establish a set of main characteristic qualities for each agricultural product variety, count the frequency of occurrence of characteristic qualities in different samples, and screen out the main characteristic qualities with high frequency of occurrence.
[0097] Step 3 is detailed below:
[0098] 3-1 For each agricultural product variety, meteorological characteristics are extracted from samples from its place of origin, and the set of these characteristic samples is defined as the positive sample set:
[0099] P={(x i ,y i )|y i =1}
[0100] Where, x i Let y represent the meteorological feature vector of the i-th sample. i =1 indicates that the sample belongs to the place of origin of the target agricultural product.
[0101] 3-2 Extract meteorological features from all regions across the country except for the positive samples to construct an unlabeled sample set:
[0102] U={(x i ,y i )|y i =0}
[0103] Where, x i Indicates the meteorological characteristics of other regions of the country, y i =0 indicates that the origin category of the sample is unknown or unmarked, and does not belong to the known origin of the current variety.
[0104] Step 4 is detailed below:
[0105] 4-1 Select a PU learning algorithm, including PU-Bagging and nnPU.
[0106] The specific training steps for 4-2PU-Bagging are as follows:
[0107] 4-2-1 Constructing sub-model training samples: Each sub-model training set consists of a complete positive sample set P and a sampled negative sample set N.
[0108] T (k) =P∪N
[0109] Negative sample set N is an unlabeled sample set U = {(x i ,y i )|y i Random sampling is performed within the range 0, assuming that all unlabeled samples are negative samples:
[0110] N=RandomSample(U,size=negpercent·|P|)
[0111] 4-2-2 Each sub-model (random forest) on its corresponding training subset T (k) Independent training was performed on T. During the training process of the random forest, T was first... (k) Bootstrapping is performed to generate several subsets containing duplicate samples. Each subset is used to train a decision tree. During tree growth, each node randomly selects a subset of features from all features as candidate splitting features, thus introducing randomness at the feature level. For any candidate feature split, its information gain is defined as:
[0112]
[0113] Where I(·) represents the impurity of a node (such as entropy or Gini index), M j M represents the number of samples in the j-th child node. parent The number of samples in the current parent node. The algorithm selects the feature that maximizes ΔI and its splitting threshold at each node for splitting, until a stopping condition (such as maximum depth or minimum number of samples) is met.
[0114] After multiple sampling and training iterations, the random forest sub-model f (k) It consists of multiple independent decision trees with different structures.
[0115] 4-2-3 Integrate the trained K sub-models. The output of each sample sub-model is:
[0116]
[0117] Then, a majority voting method is used to obtain the number of times the model was predicted as a positive example, which is then used as the output of the ensemble model f.
[0118]
[0119] The specific training steps for 4-3nnPU are as follows:
[0120] 4-3-1 Constructing a feedforward neural network model f θ :R d →R, including two hidden layers and residual connections:
[0121] h1=ReLU(BN(W1x+b1)),h2=ReLU(BN(W2h1+b2))+W s h1
[0122] logits = W o h2+b0
[0123] Among them, W1W2W s W o For network weights, b1b2b o Here, BN stands for BatchNorm, and ReLU is the activation function.
[0124] The 4-3-2nnPU loss function is based on risk estimation theory, and estimates the positive sample risk R using the positive sample set P and the unlabeled sample set U, respectively. pos Negative sample bias risk R unl Negative sample risk correction term R unl_pos :
[0125]
[0126] Where l(·) is the binary cross-entropy loss:
[0127]
[0128] Set the hyperparameter positive sample prior probability π p The weighted estimate of the nnPU risk function, which subtracts the positive sample risk from the negative class risk of unlabeled samples, is:
[0129] R(θ)=π p ·R pos (θ)+max(R unl (θ)-πp ·R unl_pos (θ),0)4-3-3 Set the learning rate η, use gradient descent to optimize R(θ), and iteratively update the neural network parameters θ:
[0130]
[0131] The training continues until the preset number of training rounds E is reached or the loss converges.
[0132] Secondly, this invention provides a method for suitability analysis of specialty agricultural products based on a reasoning model for improving the quality of specialty agricultural products. This method enables reasoning about suitable production areas for characteristic qualities, and presents the results as a list of the most suitable and least suitable planting areas and a national regional suitability heat map. Figure 3 The steps shown are as follows:
[0133] Step 1: Preparation of meteorological characteristic data and loading of the reasoning model for improving the quality of specialty agricultural products;
[0134] Step 2: Perform model reasoning on the meteorological characteristics of various regions across the country;
[0135] Step 3: Generate recommendations for the most suitable and least suitable planting areas;
[0136] Step 4: Generate a national regional suitability heat map. The darker the color in the heat map, the more suitable the region is for planting.
[0137] Step 1: The specific steps are as follows:
[0138] 1-1 Collect major agricultural meteorological datasets from across the country, and organize the datasets into a structured format. The original meteorological observation data is organized into a structure of "{origin name: [average high temperature, average low temperature, average wind speed, average visibility, extreme high temperature, extreme low temperature, total rainfall]}" for use as model input.
[0139] 1-2 Select and load a characteristic agricultural product quality improvement inference model f based on PU learning for a specified agricultural product variety. The model can output the probability f(x) that a certain input meteorological feature x is suitable for the growth of the variety.
[0140] Step 2 is detailed below:
[0141] 2-1 Meteorological characteristics of counties and cities across the country x i Input the model to obtain the probability f(x) that the meteorological characteristics of each county and city are suitable for the growth of this variety. i ).
[0142] Step 3 is detailed below:
[0143] 3-1 Probability of suitable growth for each county and city in China f(x) i Sort in descending order.
[0144] 3-2 The top B counties and cities were selected as the most suitable planting areas for recommendation.
[0145] 3-3 After selection, B counties and cities were recommended as the least suitable planting areas.
[0146] Step 4 is detailed below:
[0147] 4-1 Set a threshold t to filter out samples with a predicted probability greater than the threshold f(x) i Counties and cities with a value greater than t are designated as suitable planting areas.
[0148] 4-2 Prepare national geographic information data, which includes the boundary coordinates of each city and the subordinate relationship between cities and counties (municipalities and districts), to provide spatial reference for the base map of the heat map.
[0149] 4-3 For each city (municipality), set the color intensity according to the number of suitable planting areas to construct a heat map.
[0150] Thirdly, this invention provides a method for reasoning about the quality improvement of specialty agricultural products based on a reasoning model for improving the quality of specialty agricultural products, so as to achieve reasoning for improving the quality of specialty agricultural products, such as... Figure 4 The steps shown are as follows:
[0151] Step 1: Preparation of meteorological characteristic data and loading of the reasoning model for improving the quality of specialty agricultural products
[0152] Step 2: Calculate the global feature importance and identify the key meteorological elements that determine the improvement of a certain feature quality at the overall scale.
[0153] Step 3: Calculate the importance of local features and propose climate element adjustment plans to improve quality for the current climate conditions of individual planting areas.
[0154] Step 1: The specific steps are as follows:
[0155] 1-1 Collect major agricultural meteorological datasets from across the country and structure them. Process the raw meteorological observation data into the following structure: "{Location Name: [Average Maximum Temperature, Average Minimum Temperature, Average Wind Speed, Average Visibility, Extreme Maximum Temperature, Extreme Minimum Temperature, Cumulative Precipitation]}", so that it can be used as input features for the model later.
[0156] 1-2 For specific agricultural product varieties, a characteristic agricultural product quality improvement inference model f based on PU learning is selected and loaded. This model can output the probability value f(x) of the growth suitability of the variety under the given environmental conditions based on the input meteorological feature x.
[0157] Step 2 is detailed below:
[0158] 2-1 The specific steps for training the random forest ensemble model using PUbagging are as follows:
[0159] 2-1-1 For each node in each decision tree of the ensemble model that is split by a feature, calculate the reduction in impurity resulting from that split:
[0160]
[0161] Where I(·) represents the impurity of a node (such as entropy or Gini index), M j Let j be the number of samples in the j-th child node.
[0162] M parent The number of samples in the current parent node. The algorithm selects the feature that maximizes ΔI and its splitting threshold at each node for splitting, until a stopping condition (such as maximum depth or minimum number of samples) is met.
[0163] 2-1-2 Summing the impurity decrease of the same feature in a single decision tree and normalizing all features, we can obtain the importance of each feature in a single decision tree.
[0164] 2-1-3 The importance of each feature in the ensemble model is obtained by averaging the importance of the same features in all decision trees in the ensemble model.
[0165] 2-2 The specific steps for training the neural network model obtained by nnPU are as follows:
[0166] 2-2-1 For the nnPU neural network model, the SHAP method is used to calculate the contribution weight of each climate feature to the model output. For each sample x... i Each feature value The contributions are as follows:
[0167]
[0168] Where F: the complete feature set, S: a subset of features, Values based on feature subsets The model outputs the mean under certain conditions. feature The marginal contribution.
[0169] 2-2-2 For each feature, the absolute value of the SHAP value of all samples is taken and averaged to obtain the global feature importance of each feature.
[0170] Step 3 is detailed below:
[0171] 3-1 The specific steps for training the random forest ensemble model using PUbagging are as follows:
[0172] 3-1-1 For each node in each decision tree of the ensemble model that is split by a feature, calculate the reduction in impurity resulting from that split:
[0173]
[0174] Where I(·) represents the impurity of a node (such as entropy or Gini index), M j M represents the number of samples in the j-th child node. parent The number of samples in the current parent node. The algorithm selects the feature that maximizes ΔI and its splitting threshold at each node for splitting, until a stopping condition (such as maximum depth or minimum number of samples) is met.
[0175] 3-1-2 For a specified sample x i The decision path from the root node to the leaf node is obtained from each decision tree. The impurity decrease value of the corresponding feature of these split nodes is summed along the path to obtain the local importance of each feature in each decision tree.
[0176] 3-1-3 The local importance of each feature in the ensemble model is obtained by averaging the local importance of the same features in all decision trees in the ensemble model.
[0177] 3-2 The specific steps for training the neural network model obtained by nnPU are as follows:
[0178] 3-2-1 For a specified sample x i The forward propagation calculation model outputs the appropriate growth probability.
[0179] 3-2-2 Backpropagation is performed on the suitable growth probability to obtain the value of each feature. The absolute value of the gradient is used as the local importance of each feature:
[0180]
[0181] Verify the effectiveness of the method of the present invention.
[0182] 1) Quantitatively validate the predictive performance of the inference model for improving the quality of specialty agricultural products based on PU learning:
[0183] 1.1) Prepare the standard dataset:
[0184] This invention uses a positive sample set and an unlabeled sample set of tomatoes as standard datasets to verify the inference model for improving the quality of specialty agricultural products based on PU learning. The positive sample set contains 70 samples, and the unlabeled sample set contains 3073 samples. All samples are used to verify the performance of the inference model for improving the quality of specialty agricultural products based on PU learning. For the 70 positive sample sets, 25% of the positive samples are labeled as unlabeled samples and merged into the unlabeled sample set, which are called mislabeled positive samples. The ultimate goal is to test whether the model can recover the correct labels.
[0185] 1.2) Evaluation Indicators:
[0186] The recall rate on positive samples and mislabeled positive samples is used as the evaluation metric for this example. The higher the recall rate, the better the predictive performance of the inference model for improving the quality of specialty agricultural products based on PU learning.
[0187] 1.3) Conduct experiments on the dataset:
[0188] For the three quality characteristics of tomatoes—soluble solids, lycopene, and vitamin C—a PU-based inference model for improving the quality of specialty agricultural products was trained on training samples using the PUBag and nnPU algorithms, and the recall rate was reported. The experimental results are shown in Table 1.
[0189] Table 1. Predictive performance results of the inference model for improving the quality of specialty agricultural products based on PUBAgging.
[0190]
[0191] Table 2. Predictive performance results of the inference model for improving the quality of specialty agricultural products based on nnPU.
[0192]
[0193] Table 1 shows that for the four quality characteristics of tomatoes, the recall rate for positive samples all reached over 84%, while the recall rate for mislabeled positive samples reached over 64%. This indicates that the PU learning-based model for improving the quality of specialty agricultural products performs well in identifying positive samples and can recognize positive samples that are incorrectly labeled as unlabeled.
[0194] 2) Qualitative experiments verify the effectiveness of the suitability analysis of specialty agricultural products based on the reasoning model for improving the quality of specialty agricultural products:
[0195] Suitability analysis was used to analyze potential suitable tomato growing areas outside the marked tomato producing areas. The model predicted that the top three most suitable areas were Shanhaiguan, Sishui, and Fuping, with suitable planting probabilities of 91.5%, 91.3%, and 90.3%, respectively. These areas were all verified as tomato demonstration producing areas. Wujiaqu City in Xinjiang, a tomato demonstration producing area in the central and western regions, was also predicted to be suitable for planting, with a suitable planting probability score of 79.8%.
[0196] 3) Qualitative experiments verify the effectiveness of the reasoning model for improving the quality of specialty agricultural products:
[0197] Using quality improvement reasoning, the importance of local features in the climate characteristics of counties and cities across the country was calculated, and distribution maps were drawn. For soluble solids, it was found that increasing the average high temperature, decreasing the average low temperature, and reducing the total rainfall in most areas could increase the probability of suitable planting. Manual verification showed that all of these were reasonable: on the one hand, increasing the average high temperature and decreasing the average low temperature are equivalent to increasing the diurnal temperature range, which will enhance photosynthesis during the day and reduce respiration at night, thereby increasing the accumulation of soluble solids in tomatoes; on the other hand, when the total rainfall is too high, the water content of tomatoes will be too high, at which point the soluble solids will be diluted, resulting in a decrease in the relative content. Therefore, reducing the total rainfall is beneficial to increasing the relative content of soluble solids in tomatoes.
Claims
1. A method for constructing a reasoning model for improving the quality of specialty agricultural products based on PU learning, characterized in that, Includes the following steps: Step 1: Collect major agricultural meteorological datasets nationwide, organize and preprocess the raw meteorological observation data in the datasets in a structured manner, and construct a meteorological feature dataset; Step 2: Collect data from agricultural product samples, clean and standardize the names of characteristic qualities, establish a set of main characteristic qualities for each agricultural product variety, count the frequency of occurrence of characteristic qualities in different samples, screen out the main characteristic qualities with high frequency of occurrence, and construct an agricultural product sample dataset. Step 3: Construct a positive sample set and an unlabeled sample set for each agricultural product variety. Specifically, this includes: for each agricultural product variety, extracting meteorological characteristics from samples from its place of origin, and defining the set of these characteristic samples as the positive sample set. P={(x i ,and i )|and i =1} Where, x i Let y represent the meteorological feature vector of the i-th sample. i =1 indicates that the sample belongs to the place of origin of the target agricultural product variety; Meteorological features were extracted from all regions across the country, excluding the positive samples, to construct an unlabeled sample set. U={(x i ,and i )|and i =0} Where, x i Indicates the meteorological characteristics of other regions of the country, y i =0 indicates that the origin category of the sample is unknown or unmarked, and does not belong to the known origin of the current variety; Step 4: Train and build a reasoning model for improving the quality of specialty agricultural products based on the PU learning algorithm.
2. The method for constructing the reasoning model for improving the quality of specialty agricultural products according to claim 1, characterized in that, In step 1, the meteorological observation data in the agricultural meteorological dataset includes average high temperature, average low temperature, average wind speed, average visibility, extreme high temperature, extreme low temperature, and total rainfall. The original meteorological observation data is organized into the structure "{origin name: [average high temperature, average low temperature, average wind speed, average visibility, extreme high temperature, extreme low temperature, total rainfall]}" for use as model input. Preprocessing includes imputation and normalization of outliers and missing terms.
3. The method for constructing the reasoning model for improving the quality of specialty agricultural products according to claim 1, characterized in that, In step 2, the agricultural product samples include their place of origin, variety, and characteristic qualities; the names of characteristic qualities are standardized through keyword mapping.
4. The method for constructing the reasoning model for improving the quality of specialty agricultural products according to claim 1, characterized in that, In step 4, the PU learning algorithm is the PU-Bagging algorithm, and the inference model for improving the quality of specialty agricultural products obtained after training is a random forest ensemble model; the specific training steps of PU-Bagging are as follows: 1) Construct training samples for each sub-model. Each sub-model training set consists of a complete positive sample set P and a sampled negative sample set N: T (k) =P∪N Negative sample set N is an unlabeled sample set U = {(x i ,y i )|y i Random sampling is performed within the range 0, assuming that all unlabeled samples are negative samples: N=RandomSample(U,size=negpercent·|P|) 2) Each sub-model, i.e., random forest, has its corresponding training subset T (k) Independent training was performed on T; during the training process of the random forest, T was first trained independently. (k) Autosample the data to generate several subsets containing duplicate samples. Each subset is used to train a decision tree. During tree growth, each node randomly selects a subset of features from all features as candidate splitting features, thus introducing randomness at the feature level. For any candidate feature split, its information gain is defined as: Where I(·) represents the impurity of a node, and M j M represents the number of samples in the j-th child node. parent The number of samples in the current parent node; the algorithm selects the feature that maximizes ΔI and its splitting threshold at each node for splitting until the stopping condition is met, which is the maximum depth or the minimum number of samples; After multiple sampling and training iterations, the random forest sub-model f (k) It consists of multiple independent decision trees with different structures; 3) Integrate the trained K sub-models. The output of each sample sub-model is: Then, the majority voting method is used to obtain the number of times the sample was predicted as a positive example, which is denoted as the output of the ensemble model f:
5. The method for constructing the reasoning model for improving the quality of specialty agricultural products according to claim 1, characterized in that, In step 4, the PU learning algorithm is the nnPU algorithm, and the resulting inference model for improving the quality of specialty agricultural products is a neural network model. The specific training steps of nnPU are as follows: 1) Construct a feedforward neural network model f θ :R d →R, including two hidden layers and residual connections: h1=ReLU(BN(W1x+b1)),h2=ReLU(BN(W2h1+b2))+W s h1 logits=W o h2+b0 Among them, W1W2W s W o For network weights, b1b2b o The term is the bias term, BN stands for BatchNorm, and ReLU is the activation function; 2) The nnPU loss function is based on risk estimation theory, and estimates the risk R of positive samples using the positive sample set P and the unlabeled sample set U, respectively. pos Negative sample bias risk R unl Negative sample risk correction term R unl_pos : in For binary cross-entropy loss: Set the hyperparameter positive sample prior probability π p The weighted estimate of the nnPU risk function, which subtracts the positive sample risk from the negative class risk of unlabeled samples, is: R(θ) = π p ·R pos (θ)+max(R unl (θ)-π p ·R unl_pos (θ),0)3) Set the learning rate η, use gradient descent to optimize R(θ), and iteratively update the neural network parameters θ: The training continues until the preset number of training rounds E is reached or the loss converges.
6. A method for suitability analysis of specialty agricultural products based on a reasoning model for improving the quality of specialty agricultural products, characterized in that, Based on the PU learning-based reasoning model for improving the quality of specialty agricultural products constructed according to claim 1, it achieves the reasoning of suitable production areas for characteristic qualities, and presents the results as a list of the most suitable and least suitable planting areas and a national regional suitability heat map; the specific steps are as follows: Step 1: Preparation of meteorological characteristic data and loading of the inference model for improving the quality of specialty agricultural products For a given agricultural product variety, select and load a characteristic agricultural product quality improvement inference model f based on PU learning. This model can output the probability f(x) that a certain input meteorological feature x is suitable for the growth of the variety. Step 2: Collect meteorological characteristics of all counties and cities across the country. i Input the model, perform model inference on the meteorological characteristics of various regions across the country, and obtain the probability f(x) that the meteorological characteristics of each county and city are suitable for the growth of this variety. i ); Step 3: Calculate the suitable growth probability f(x) for each county and city nationwide. i Sort the regions in descending order to generate recommendations for the most suitable and least suitable planting areas; Step 4: Generate a national regional suitability heat map. The darker the color of the heat map, the more suitable the region is for planting.
7. The method for suitability analysis of specialty agricultural products according to claim 6, characterized in that, Step 4 is detailed below: 1) Set a threshold t to filter out samples with a predicted probability greater than the threshold f(x). i Counties and cities with a value greater than t are designated as suitable planting areas; 2) Prepare national geographic information data, which includes the boundary coordinates of each city and the subordinate relationships between cities and counties and municipalities and districts, to provide spatial reference for the base map of the heat map; 3) For each city, set the color intensity according to the number of suitable planting areas to construct a heat map.
8. A reasoning method for improving the quality of specialty agricultural products based on a reasoning model for improving the quality of specialty agricultural products, characterized in that, Based on the PU learning-based inference model for improving the quality of specialty agricultural products constructed according to claim 1, it achieves feature quality improvement inference; the specific steps are as follows: Step 1: Preparation of meteorological characteristic data and loading of the inference model for improving the quality of specialty agricultural products For a specific agricultural product variety, a characteristic agricultural product quality improvement inference model f based on PU learning is selected and loaded; the model outputs the probability value f(x) of the growth suitability of the variety under the environmental conditions based on the input meteorological feature x. Step 2: Calculate the global feature importance and identify the key meteorological elements that determine the improvement of a certain feature quality at the overall scale; Step 3: Calculate the importance of local features and propose a climate element adjustment plan to improve the quality of a single planting site based on the current climate conditions.
9. The reasoning method for improving the quality of specialty agricultural products according to claim 8, characterized in that, The inference model for improving the quality of specialty agricultural products based on PU learning is the random forest ensemble model obtained by training based on PU bagging as described in claim 4. Step 2 is as follows: 1) For each node in each decision tree of the ensemble model that is split by a feature, calculate the reduction in impurity resulting from the split; 2) Sum the impurity decreases of the same feature in a single decision tree and normalize all features to obtain the importance of each feature in a single decision tree; 3) The importance of each feature in the ensemble model is obtained by averaging the importance of the same features in all decision trees in the ensemble model; Step 3 specifically involves: 1) For each node in each decision tree of the ensemble model that is split by a feature, calculate the reduction in impurity resulting from the split; 2) For a specified sample x i The decision path from the root node to the leaf node is obtained from each decision tree. The impurity decrease value of the corresponding feature of these split nodes is summed along the path to obtain the local importance of each feature in each decision tree. 3) The local importance of each feature in the ensemble model is obtained by averaging the local importance of the same features in all decision trees in the ensemble model.
10. The reasoning method for improving the quality of specialty agricultural products according to claim 8, characterized in that, The inference model for improving the quality of specialty agricultural products based on PU learning is the neural network model obtained by training nnPU as described in claim 5. Step 2 is as follows: 1) Use the SHAP method to calculate the contribution weight of each climate feature to the model output; for each sample x i Each feature value The contributions are as follows: Where F: the complete feature set, S: a subset of features, Values based on feature subsets The model outputs the mean under certain conditions. feature The marginal contribution; 2) For each feature, take the absolute value of the SHAP value of all samples and average it to obtain the global feature importance of each feature; Step 3 specifically involves: 1) For a specified sample x i The forward propagation calculation model outputs the appropriate growth probability; 2) Perform backpropagation on the appropriate growth probability to obtain the value of each feature. The absolute value of the gradient is used as the local importance of each feature: