Agricultural product traceability method and system based on source data verification mechanism

By employing a non-prior probability posterior probability update mechanism, MICV, MDMC, cloud model, and SVM model in the agricultural product traceability system, combined with a reputation value mechanism, the problems of deviation of the scale cloud digital features from the actual situation and false customer evaluations have been solved, resulting in more accurate and reliable traceability results.

CN118485451BActive Publication Date: 2024-11-22HAINAN TIANDI SHENNONG TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410652301.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-05-24
Publication Date
2024-11-22
Estimated Expiration
2044-05-24

AI Technical Summary

Technical Problem

In existing agricultural product traceability technologies, the digital feature correction of the scale cloud is prone to deviating from the actual situation, resulting in poor traceability effect, and the problem of false customer evaluation data has not been fully resolved.

Method used

A posterior probability update mechanism, which is not based on prior probability, is adopted. It combines multidimensional information cross-validation (MICV) and multi-source data matching computation (MDMC), uses cloud models and complex dynamic weighting algorithms to filter valid data, and corrects the scale cloud digital features through support vector machine (SVM) models. A reputation value mechanism is introduced to curb data fraud.

Benefits of technology

It improves the accuracy and reliability of agricultural product traceability data, reduces the influence of subjectivity, enhances the system's adaptability and robustness, effectively curbs data fraud, and improves the credibility of traceability results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118485451B_ABST
    Figure CN118485451B_ABST
Patent Text Reader

Abstract

The present invention discloses a method and system for tracing the source of agricultural products based on a source data verification mechanism; the present invention relates to the technical field of online sales of agricultural products; a cloud model is used to process raw data, generate cloud droplets, calculate digital features (expected E x 、Entropy E n and super entropy H e ). Remove abnormal cloud droplets according to the trust region 1‑α. Reduce the excess entropy H e , and use the new super entropy H e ' and the original E x 、E n Regenerate cloud droplets. Merge new cloud droplets and original cloud droplets to form data set D. Add labels to data set D to distinguish new cloud droplets from original cloud droplets. The technical solution of the present invention significantly reduces the subjectivity brought by artificially set prior probabilities by adopting data-driven SVM models and algorithms, making the traceability results more objective and accurate; at the same time, the technical solution of the present invention learns actual data through machine learning models, which can more accurately identify data features and make corrections, thereby improving the accuracy and reliability of data correction.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of online sales of agricultural products, and in particular to a multidimensional information cross-verification (MICV) and a multi-source data matching calculation (MDMC) mechanism in blockchain technology, and to the technical field of information tracing in combination with a credit-proof of stake (CPOS) mechanism, and in particular to a method and system for tracing the source of agricultural products based on a source data verification mechanism. Background Art

[0002] In recent years, blockchain technology has demonstrated strong application potential in many fields with its unique characteristics of decentralization, data immutability, and information traceability. In particular, in the fields of logistics information management and food safety information traceability, blockchain technology has become a key tool to improve transparency and trust. However, the effectiveness of blockchain technology is highly dependent on the authenticity and accuracy of the stored data. If there is a problem with the source data, even if blockchain technology can ensure that the data has not been tampered with, it cannot guarantee the authenticity of the information. [1] .

[0003] In the agricultural product traceability system, the data sources mainly include data from IoT information collection devices and customer feedback evaluation data. The former may cause inconsistent data formats, errors or tampering due to equipment differences, operational errors, etc.; the latter may be affected by false and malicious evaluations. Although the standardization of IoT data is relatively easy to solve, dealing with false data in customer feedback is more complicated and requires more advanced traceability technology to deal with it. There are currently some studies trying to solve these problems. For example:

[0004] A technology that uses zero-knowledge proofs and a trusted execution environment to process sensor data to ensure data integrity [2] However, this method mainly focuses on the correction of IoT sensor data and does not involve comprehensive source data verification. Another technology proposes a multi-dimensional certificate of origin data traceability framework based on a penalty mechanism to filter false data, but it lacks verification of sales link data and fails to fundamentally solve the problem of false data. [3] .

[0005] In view of the defects of these traditional technical problems, there is currently a blockchain source verification mechanism for the traceability system. [4]The mechanism automatically processes uploaded data through smart contracts, and specifically designs an evaluation algorithm based on cloud models and complex dynamic weighting for customer evaluation data in transactions. This algorithm can effectively eliminate false data and generate more objective evaluation data. [4-5] At the same time, combined with the reputation-based consensus mechanism (CPOS), this solution can more comprehensively solve the problem of data source authenticity in all aspects of the traceability system. [6] .

[0006] Based on the above guiding ideology, a recent study proposed a source data verification mechanism for agricultural product traceability blockchain, which verifies and filters valid data through multi-dimensional information cross-validation (MICV) and multi-source data matching calculation (MDMC), introduces cloud models and complex dynamic empowerment mechanisms to process customer evaluation data, and effectively solves the problem of false and malicious evaluations. [7] . However, when dealing with the problem of large discreteness of scale cloud droplets (mainly caused by differences in standard evaluation of the same agricultural product by different merchants), this method uses the Bayesian feedback method for correction. However, the effectiveness of the Bayesian method depends largely on the accuracy of the prior probability. Since the choice of prior probability is subjective and may contain errors, this method may cause the corrected digital features of the scale cloud to deviate from the actual situation. In order to overcome this limitation, this latest agricultural product traceability technology needs to explore more objective and accurate correction methods to ensure the authenticity and reliability of data in the agricultural product traceability system.

[0007] To this end, the present invention proposes an agricultural product traceability method and system based on a source data verification mechanism. Summary of the invention

[0008] In view of this, the embodiment of the present invention hopes to provide an agricultural product traceability method and system based on a source data verification mechanism to solve or alleviate the technical problem existing in the prior art, that is, it is easy to cause the corrected scale cloud digital features to deviate from the actual situation, resulting in poor traceability effect, and at least provide a beneficial option for this; the technical solution of the present invention is implemented as follows:

[0009] First, agricultural product traceability method based on source data verification mechanism:

[0010] 1. Overview:

[0011] Based on the traditional credibility consensus mechanism, multi-dimensional information cross-validation and multi-source data matching calculation, a mechanism that is not based on prior probability to update the posterior probability is adopted to avoid technical defects that may cause the corrected digital features of the ruler cloud to deviate from the actual situation due to the subjectivity and errors in the selection of prior probability, and to meet the traceability requirements of agricultural products.

[0012] (II) Multidimensional Information Cross Validation (MICV) and Multi-Source Data Matching Computation (MDMC):

[0013] MICV and MDMC are used to evaluate the consistency of multi-source data, and the consistency of multi-source data in agricultural product traceability is evaluated. Valid data is screened out based on the consistency of the data to ensure the accuracy and credibility of the data uploaded to the blockchain. If the data is completely consistent, it is directly uploaded to the blockchain for storage. Otherwise, MDMC is used to calculate the consistency. When the data consistency is greater than the set threshold, it is uploaded to the blockchain for storage. The process is as follows: Figure 2 and Figure 4 shown.

[0014] 2.1 Algorithm content:

[0015] References [7] Based on the MICV mechanism, the data from multiple data sources are first verified. MICV evaluates the consistency of data by comparing the same transaction data provided by different data sources. Suppose there are n data providing nodes P, data sets S from multiple data providing nodes, and transaction set A with unique code j:

[0016] P={p1,p2,...,p n};

[0017] S={s1,...,s i ,...,s n};

[0018] A={a1,...,a j ,...,a m};

[0019] Among them, p i represents the i-th data providing node; represents different participants or links in the agricultural product supply chain, such as farms, processing plants, logistics companies, retailers, etc. Each node records and provides information related to its operations; i Indicates data provider node p i The data provided; for example, for a farm node, s i Contains planting information (such as sowing date, fertilization records, and pesticide usage); for processing plant nodes, s i Including processing date, processing method, raw material source, quality inspection results; a jRepresents transaction number j; a "transaction" can be understood as an event or activity related to the production, processing, transportation or sale of a specific agricultural product. For example, a batch of agricultural products is picked from the farm (a1), then transported to the processing plant for processing (a2), then distributed to various retail outlets (a3), and finally sold to consumers at the retail outlets (a4). Each such event can be regarded as an independent transaction a and is assigned a unique code j. Furthermore, the definition Indicates data provider node p i Provides data for transaction number j.

[0020] When the verification data is provided by node p i When transaction data number j is provided, MICV calculates its data consistency:

[0021] ;

[0022] Among them, Boolean is a Boolean function, and its results are only two: true or false. Boolean function is used to compare whether two data are equal. If the two data are exactly the same, it returns true; if they are different, it returns false; o is a variable used as the index of the node that provides other data except i.

[0023] B in the formula ij according to The transaction data with number j provided by the remaining n-1 data providing nodes Whether it is consistent, it returns true or false. If the data is completely consistent through MICV verification, that is, it reaches absolute consistency, it returns true and directly uploads the data to the blockchain for storage. If the data does not reach absolute consistency, it returns false and enters the next step of MDMC calculation to calculate the consistency degree D ij :

[0024] ;

[0025] Set a consistency threshold. The above MDMC quantifies the consistency between data by counting and matching data from different data sources. When the consistency calculated by MDMC is higher than this threshold, the corresponding data will be regarded as valid data and uploaded to the blockchain for storage. If the consistency is lower than the set threshold, the data will be regarded as invalid data and will not be uploaded.

[0026] The pseudocode form of the algorithm in this section is as follows Figure 3 shown.

[0027] 2.2 Complex dynamic weighted customer evaluation mechanism:

[0028] In order to accurately evaluate customer reviews, cloud models and complex dynamic weighting algorithms are introduced to identify and eliminate malicious and false review data, while marking nodes that provide abnormal data.

[0029] 2.2.1 Cloud model construction:

[0030] ;

[0031] ;

[0032] Among them, F X is a dataset of agricultural product x containing m customer reviews; Q X is a data set containing m standard reviews of the product. The customer review data contains three types of data: normal data, (high-scoring) cheating data, and (low-scoring) malicious data. In the first stage, the K-means clustering algorithm is used to divide the customer data into three types of data: D1, D2, and D3. Subsequently, the inverse cloud algorithm without certainty information (such as the literature [7] The three types of data are processed as described above to obtain the digital characteristics of their respective cloud models: expected value E x 、Entropy E n and super entropy H e , realizing the transformation of quantitative data into qualitative concepts.

[0033] When identifying qualified customer evaluation data, first compare the expected values ​​E of various types of data. x The closest category is considered as qualified customer evaluation data. If the expected values ​​are the same, the entropy E is further compared. n , select the data with the smallest difference as qualified data. Thus, qualified data Y X and malicious / cheating data N X Nodes that provide abnormal data will be marked as malicious nodes.

[0034] The second stage uses principal component analysis (PCA) for complex dynamic weighting. When there are too many abnormal data and only a small amount of normal data remains, PCA will use the merchant standard evaluation as the main component, thereby increasing the difficulty and cost of cheating. The variance contribution rate of the principal component is used to determine the coefficient of the comprehensive score model, and then the indicator weights are normalized to finally calculate the objective comprehensive customer evaluation data A: X ={a1,...,a i ,...,a p}.

[0035] 2.2.2 Judgment and its revision:

[0036] The cloud droplets of the initial scale cloud usually have a large dispersion, which reflects the difference in the evaluation standards of different merchants for the same agricultural product. In order to make a more accurate assessment, it is necessary to judge and possibly correct the scale cloud:

[0037] The ruler is so obedient The normal distribution of is obtained according to the central limit theorem when the following conditions are met:

[0038] ;

[0039] but The degree of certainty of qualitative concepts can reach 1-α; is the two-sided percentile point of the standard normal distribution;

[0040] Then calculate the mean value X of the cloud droplet points of the following two equations L and mean X H :

[0041] ;

[0042] And judge:

[0043] ;

[0044] Among them, α is the significance level factor. In the cloud model, α represents the error rate or uncertainty level that is willing to be accepted, which is used to determine the confidence interval of the cloud droplet (data point) distribution. d represents the difference between the means of two specific cloud droplets, which is the difference between the means of cloud droplets at the two ends of the distribution (outside and inside the confidence interval defined by α). This difference is used to measure the degree of dispersion or concentration of the cloud droplet distribution. d0 is the range of 1-α for the confidence domain of the qualitative concept when α is given. When the above formula is satisfied, it means that the dispersion of cloud droplets is small, and the difference in merchant standard evaluation data is within an acceptable range, and no correction is required; otherwise, the scale cloud needs to be corrected.

[0045] (III) Technical solution:

[0046] If the discreteness of the cloud droplets in formula 2.2.2 above is large, it needs to be corrected. The technical solution adopted by the present invention is the SVM model (support vector machine). The SVM model does not directly rely on the calculation of prior probability or posterior probability during classification. On the contrary, it focuses on finding an optimal decision boundary in the feature space to maximize the margin between the two categories. Use the forward cloud generator to regenerate an equal amount of cloud droplets, and then use the above-mentioned "not based on prior probability to update the posterior probability" mechanism to correct the digital features of the scale cloud with the new cloud droplets and the old cloud droplets through the SVM model, and trace the agricultural product information based on the new scale cloud. The steps include the following S1~S5.

[0047] 3.1 Step S1, cloud model processing:

[0048] Use the cloud model to process raw data, generate cloud droplets, and calculate digital features (expected E x 、Entropy E n and super entropy H e ). Remove abnormal cloud droplets according to the confidence region 1-α. Reduce the excess entropy H e , and use the new super entropy H e ' and the original E x 、E n Regenerate cloud droplets.

[0049] 3.1.1 Step S100, removing abnormal cloud droplets:

[0050] For any cloud droplet sample, the abnormal cloud droplets are removed according to the confidence region 1-α, because the mean or median of the cloud droplets conforms to the normal distribution. [7] , then a confidence interval can be determined based on the distribution and the given confidence level 1-α, and cloud droplets outside the interval are regarded as outliers and removed:

[0051] ;

[0052] in, is the cloud droplet sample mean, s is the cloud droplet sample standard deviation, n is the cloud droplet sample size, z α / 2 It is the critical value of the standard normal distribution when the confidence level is 1-α, where α is the significance level factor.

[0053] 3.1.2 Step S101, reducing the super entropy H e And use the new super entropy H e 'Regenerate cloud droplets:

[0054] The reduced super entropy can be expressed as the original super entropy H e Multiply by a reduction factor between [0,1] (such as 0.9) to get the new super entropy H e ':

[0055] H e ' = 0.9*H e ;

[0056] Using the new hyperentropy H e '、Original expectations x and entropy E n , cloud droplets are regenerated through the generation algorithm of the cloud model.

[0057] 3.2 Step S2, constructing and reading data set D:

[0058] The new cloud droplets and the original cloud droplets are merged to form a dataset D. Labels are added to the dataset D to distinguish between the new cloud droplets and the original cloud droplets.

[0059] 3.2.1 Step S200, merging the newly generated cloud droplets and the original cloud droplets:

[0060] Let the original cloud droplet set be C original , the newly generated cloud droplet set is C new . Combining these two sets to form the dataset D can be expressed as:

[0061] ;

[0062] 3.2.2 Step S201, add labels to data set D:

[0063] In order to distinguish new cloud droplets from original cloud droplets, a label is added to each cloud droplet. Let the label set be {0,1}, where 0 represents the original cloud droplet and 1 represents the newly generated cloud droplet. Then the label adding process can be formally expressed as:

[0064] ;

[0065] Among them, D labeled It is a labeled dataset, where each element is a tuple (x, l), x is the data stored in the cloud droplet, and l is the corresponding label.

[0066] 3.3 Step S3, SVM model:

[0067] Define the objective function F(X) to learn and identify the rules of cloud droplet digital features, use the RBF kernel function to drive the objective function, and read the model parameters of the SVM model;

[0068] 3.3.1 Step S300, objective function F(X):

[0069] The objective function F(X) aims to find a hyperplane in a high-dimensional space to maximize the interval between two categories. Its standard form of objective function F(X) is expressed as:

[0070] ;

[0071] Among them, the output of the objective function F(X) is y pred , is the predicted category of new cloud droplets; sign is the sign function used to convert The outputs calculated by the term are classified into three different preset ranges: high HighQuality, medium MediumQuality and low LowQuality; w is the normal vector of the hyperplane, b is the bias term, ξ and ξ i is a slack variable (used to handle nonlinear separability), C is a penalty coefficient (used to control the degree of penalty for misclassification), and y iis the label l of the i-th tuple (x, l), x i is the feature vector of the cloud droplet sample, and N is the number of tuples (x, l).

[0072] 3.3.1 Step S301, RBF (Radial Basis Function) kernel function:

[0073] The RBF kernel is a commonly used SVM kernel function used to map data to a higher-dimensional space for better classification. i ,x j ) is:

[0074] ;

[0075] Among them, γ is the hyperparameter of the RBF kernel, which controls the similarity measure of the data points. After the SVM model is trained, the dot product (w·x i ) will be replaced by the kernel function K(x i ,x j ).

[0076] 3.4 SVM model training:

[0077] 3.4.1 The first step, initialization:

[0078] Set the initial values ​​of the parameters of the SVM model. Prepare training data (divide the training set D from the data set D train ).

[0079] 3.4.2 The second step is to train the SVM model:

[0080] Set the optimization problem to solve the objective function F(X), that is, regard the objective function F(X) as the training function; then use the training set D train Train the SVM model. Use the cross-validation method to adjust the model penalty coefficient C and hyperparameter γ to achieve the best performance (i.e., obtain their optimal values). The steps of the cross-validation technique include:

[0081] 3.4.3 The third step is evaluation and verification:

[0082] Divide the validation set D from the dataset D val And evaluate the performance of the SVM model. Determine the optimal normal vector w and bias term b based on the evaluation results, and automatically determine the relaxation variables ξ and ξ i The key formula in the evaluation and validation step is the decision function of the SVM model, which predicts each sample in the validation set and compares it with the true label to evaluate the performance of the model. The mean square error (MSE) is selected as the evaluation indicator;

[0083] Decision function f(X): For each sample x in the validation set (i.e. each tuple (x, l)), the decision function f(x) of SVM is:

[0084] ;

[0085] Among them, α i is the Lagrange multiplier, N SV is the number of support vectors, and K(·,·) is the kernel function (such as the RBF kernel above).

[0086] Mean Square Error (MSE): used to evaluate regression problems. If it is a classification problem, indicators such as accuracy are usually used. MSE is defined as:

[0087] ;

[0088] Among them, n val is the validation set D val The normal vector w and bias term b that minimize the MSE value are used as the optimal values, and the relaxation variables ξ and ξ are automatically determined. i ;

[0089] 3.4.4 Step 4: Iteration and Optimization:

[0090] The model is iterated and optimized according to the test results, including adjusting the model parameters (normal vector w, bias term b, penalty coefficient C, hyperparameter γ and slack variables ξ and ξ i ). Repeat the above steps until satisfactory prediction performance is achieved or the maximum number of training iterations is reached.

[0091] 3.5 Step S4, digital feature correction:

[0092] The trained SVM model is applied to the cloud droplets generated by the newly collected agricultural product data. The SVM model will use the objective function F(X) to predict the expected value E of the new cloud droplets based on the learned rules. x and entropy E n Corrections are made to more accurately reflect the actual situation of agricultural products.

[0093] 3.5.1 Correction function:

[0094] Introducing the correction function M(E x , E n , y pred ), where y pred is the predicted category of new cloud droplets by the SVM model. The correction function M(E x , E n , y pred ) Adjust the expected E according to the predicted category x and entropy En :

[0095] ;

[0096] Among them, E x ' and E n ' are the adjusted expectation and entropy respectively;

[0097] ;

[0098] Among them, the prediction results of the SVM model for new cloud droplets are divided into three possible categories: high Quality, medium Quality and low Quality.

[0099] 3.5.2 Adjustment rules:

[0100] The correction function M adjusts the expected E according to the predicted category x and entropy E n Make the following adjustments:

[0101] (1) If the predicted category is HighQuality, increase the expected E x A fixed value θ, and reduce the entropy E n A fixed value of β reflects a higher confidence that the cloud droplet represents high-quality agricultural product, so expectation increases and uncertainty (i.e., entropy) decreases.

[0102] (2) If the predicted category is MediumQuality, then the expected E x and entropy E n Remains unchanged. That is, there is no additional information about the mass of the cloud droplet, so no correction is made.

[0103] (3) If the predicted category is LowQuality, reduce the expected E x A fixed value θ, and increasing entropy E n A fixed value of β reflects lower confidence that the cloud droplet represents low-quality agricultural product, so expectation decreases and uncertainty (i.e., entropy) increases.

[0104] Among them, α and β are two adjustable parameters, which can be adjusted according to actual conditions.

[0105] 3.6 Step S5, traceability information output:

[0106] According to the revised expectation E x ' and entropy E n ', rebuild the ruler cloud.

[0107] Let P = {p1,p2,...,p n} is the set of user nodes, any node p i The reputation value C(p i ) The evaluation rules are as follows: Initial reputation value C i (p i ) is set to 50, the minimum value min is set to 0, and the maximum value max is set to 100. In the traceability data upload job, if the node p i If the uploaded data is judged as unqualified by the data verification algorithm, then node p i In this round of operations, it is marked as a dishonest node, and its reputation value is deducted according to the reputation penalty rules. When the reputation value is lower than the minimum value, the node’s certification qualification in the agricultural product traceability system is cancelled; otherwise, it is marked as a trustworthy node, and its reputation value is increased according to the reputation penalty rules.

[0108] 1) If node p i If the uploaded data is judged as unqualified (set as event B), the credit value will be deducted:

[0109] C(p i )=max(C(p i )−ΔC p ,C min );

[0110] Where, ΔC p It is the credit value deduction amount determined according to the credit penalty rules.

[0111] 2) If node p i If the uploaded data is judged as qualified (set as event ¬B), the reputation value is increased:

[0112] C(p i )=min(C(p i )+ΔC r ,C max );

[0113] Where, ΔC r It is the amount of credit value increase determined according to the credit reward rules.

[0114] 4. Mechanisms for solving technical problems:

[0115] 4.1 Data-driven cloud model processing:

[0116] In step S1, cloud model processing is adopted, which does not rely on prior probability, but constructs the cloud model by analyzing actual data, thereby avoiding the problem of subjectively setting prior probability.

[0117] 4.2 Removal of abnormal cloud droplets and adjustment of excess entropy:

[0118] In the cloud model processing, the noise and outliers in the data are reduced by removing abnormal cloud droplets, which helps to improve the data quality. e And use the new super entropy H e 'Regenerating cloud droplets can more accurately describe the distribution characteristics of the data and further reduce the dependence on prior knowledge.

[0119] 4.3 Application of SVM model based on machine learning:

[0120] The SVM model recognizes the regularity of cloud droplet digital features by learning data with known labels. It can automatically learn and adjust based on actual data without relying on subjectively set prior probabilities.

[0121] 4.4 Correction of the objective function F(X) to the expectation Ex and entropy En:

[0122] Use the objective function F(X) of the SVM model to correct the expectation E of the new cloud droplets x and entropy E n This method is data-driven and automatically adjusts the digital features of cloud droplets according to the rules learned by the model, thus avoiding the bias caused by improper selection of prior probabilities.

[0123] 4.5 Introduction of reputation value mechanism:

[0124] In step S5, a reputation value mechanism is also introduced to curb data falsification. This mechanism dynamically adjusts the user's reputation value based on the user's behavior to ensure the authenticity and reliability of the data. This also further reduces the reliance on subjective correction of data.

[0125] Second, agricultural product traceability systems based on source data verification mechanisms, such as Figure 5 As shown, including:

[0126] The first transceiver module is used to send the traceability information to the PaaS platform layer through the IaaS service layer;

[0127] The second transceiver module is used to transmit the traceability information in the PaaS platform layer to the SaaS software layer; and is also used to retrieve the agricultural product supply chain data source so that the IaaS service layer can find the corresponding data;

[0128] A third transceiver module is used to transmit the delivery request sent by the channel party in the SaaS software layer to the IaaS service layer through the PaaS platform layer;

[0129] The IaaS service layer is connected to a processor and a memory connected to the processor. The memory stores program instructions. When the program instructions are executed by the processor, the IaaS service layer executes the agricultural product traceability method as described above under the control of the processor.

[0130] Compared with the prior art, the present invention has the following beneficial effects:

[0131] 1. Reduce subjective influence: When using the Bayesian method in traditional traceability technology, the selection of prior probability is often affected by subjective judgment, which may cause the result to deviate from the actual situation. The technical solution of the present invention significantly reduces the subjectivity brought by the artificially set prior probability by adopting the data-driven SVM model and algorithm, making the traceability result more objective and accurate.

[0132] 2. Improve the accuracy of data correction: In traditional methods, data correction may not be accurate enough due to errors in prior probability. The technical solution of the present invention uses a machine learning model to learn actual data, which can more accurately identify data features and make corrections, thereby improving the accuracy and reliability of data correction.

[0133] 3. Enhanced model adaptability: Compared with traditional methods, the machine learning model (such as SVM) used in the technical solution of the present invention has stronger adaptability. When the data environment changes, the model can automatically adjust and learn new data features without the need to manually reset parameters or adjust the model, thereby maintaining the continued effectiveness and accuracy of the traceability system.

[0134] 4. Improve system robustness: By reducing the reliance on traditional prior knowledge and introducing data-driven methods and machine learning techniques, the technical solution of the present invention enhances the robustness of the traceability system. The system can better cope with noise, outliers and changes in the data, and provide stable and reliable traceability results.

[0135] 5. Effectively curb data falsification: By introducing a reputation value mechanism, the technical solution of the present invention can effectively identify and curb data falsification. This not only improves the authenticity of the data, but also enhances the credibility of the traceability results, further overcoming the traceability result deviation caused by untrue data in traditional methods. BRIEF DESCRIPTION OF THE DRAWINGS

[0136] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0137] Figure 1 It is a schematic diagram of the method flow of the present invention;

[0138] Figure 2 A schematic diagram of the interaction mechanism between MICV and MDMC of the present invention;

[0139] Figure 3 Schematic diagram of the training method of the SVM model of the present invention;

[0140] Figure 4 It is a schematic diagram of the data source composition of the present invention;

[0141] Figure 5 It is a schematic diagram of the system composition of the present invention;

[0142] Figure 6 It is a schematic diagram of the training effect of the SVM model of the present invention;

[0143] Figure 7 This is a schematic diagram of cloud model classification distribution after the correction function of the present invention is adjusted;

[0144] Figure 8 A visual schematic diagram of the predicted category distribution of the present invention;

[0145] Figure 9~Figure 10 It is a C++ execution program diagram of step S1 of the present invention;

[0146] Fig.11 It is a C++ execution program diagram of step S2 of the present invention;

[0147] Figure 12~Figure 13 The SVM model of step S3 of the present invention and the C++ program diagram of its training;

[0148] Fig.14 It is the C++ execution program diagram of step S4 of the present invention;

[0149] Fig.15 This is a C++ execution program diagram of step S5 of the present invention. DETAILED DESCRIPTION

[0150] In order to make the above-mentioned purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are described in detail below in conjunction with the accompanying drawings. In the following description, many specific details are set forth to facilitate a full understanding of the present invention. However, the present invention can be implemented in many other ways different from those described herein, and those skilled in the art can make similar improvements without violating the connotation of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed below;

[0151] It should be noted that the various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments, and the same or similar parts between the various embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description.

[0152] Embodiment 1: Figure 1 As shown in the figure, when implementing the agricultural product traceability method based on the source data verification mechanism, it is necessary to first build a cloud model:

[0153] ;

[0154] ;

[0155] Among them, F X is a dataset of agricultural product x containing m customer reviews; Q X It is a data set containing standard reviews of m merchants for this product.

[0156] The customer evaluation data contains three types of data: normal data, (high-scoring) cheating data, and (low-scoring) malicious data. First, the K-means clustering algorithm (an unsupervised learning algorithm that can divide data into K clusters. In this embodiment, K is set to 3 to distinguish between normal data, cheating data, and malicious data) is used to divide the customer data into three types of data: D1, D2, and D3. Then, the inverse cloud algorithm without certainty information (such as the literature [7] The above technology) processes these three types of data to obtain the digital characteristics of their respective cloud models: expected value E x 、Entropy E n and super entropy H e , realizing the conversion of quantitative data into qualitative concepts. Similarly, the merchant standard data is also processed by the reverse cloud algorithm to obtain the corresponding cloud model digital features, and the cloud model is generated through the forward cloud generator. Among them:

[0157] (1) Expected E x : The expectation of the distribution of cloud droplets in the domain space, that is, the point that best represents the qualitative concept, can be regarded as the central value of the cloud.

[0158] (2) Entropy E n : An uncertainty measure representing a qualitative concept, that is, the degree of discreteness of cloud droplets. The greater the entropy, the wider the distribution of cloud droplets.

[0159] (3) Super entropy H e : is the entropy E n It is an uncertainty measure that reflects the degree of condensation of cloud droplets. The larger the super entropy, the thicker the cloud layer and the greater the randomness of the cloud droplets.

[0160] In this embodiment, when identifying qualified customer evaluation data, a concept of a ruler cloud needs to be introduced. The ruler cloud is a preset cloud model, and its expected value E x 、Entropy E n and super entropy H e represents the standard characteristics of qualified customer evaluation data. x Compare with the expected value of the Ruler Cloud. The data that is closest to the expected value of the Ruler Cloud is considered as qualified customer evaluation data. The logic of this step is that the expected value is the point that best represents the trend in the data set, so by comparing the expected value, you can quickly filter out the data category that is closest to the standard.

[0161] If after comparing the expected values, it is found that the expected values ​​of multiple categories of data are the same or very close, then it is necessary to further compare the entropy E of these categories. n . Select entropy E n The data with the smallest entropy difference with the ruler cloud is qualified data. Entropy represents the degree of data dispersion, and the smallest difference means that the data has the highest similarity with the ruler cloud in data distribution.

[0162] After the above steps, we can determine the qualified data Y X and malicious / cheating data N X At the same time, the node that provides abnormal data (i.e., the source of malicious or cheating data) will be marked as a malicious node for subsequent monitoring or processing. However, for the traceability of agricultural product information, the existing cloud model has the problem of excessive discreteness. In order to correct this problem and improve the accuracy of traceability, the following steps S1~S5 need to be performed for correction.

[0163] In this embodiment, regarding step S1, cloud model processing: using the cloud model to process the original data, generate cloud droplets, and calculate the digital features of the cloud droplets, including the expected E x 、Entropy E n and super entropy H e According to the set trust region 1-α, cloud droplets outside the trust region are removed to reduce the influence of outliers. e 90% of the original value to adjust the dispersion of cloud droplets. x 、Entropy E n And the new super entropy H e ', regenerate an equal amount of cloud droplets through a forward cloud generator.

[0164] Specifically, step S100, removing abnormal cloud droplets: the generation of cloud droplets is based on the processing of the original data by the cloud model, and these cloud droplets reflect the distribution characteristics of the data. However, in the actual data, there may be some abnormal values, which may be caused by measurement errors, data entry errors or other reasons. These abnormal values ​​will interfere with the results of data analysis, so they need to be processed.

[0165] Therefore, the embodiment sets a confidence region 1-α and removes cloud droplets outside the confidence interval according to the confidence region. The confidence region here is a statistical concept, which indicates the degree of confidence in the data analysis results. By setting a suitable confidence region, outliers that are obviously deviated from the normal range can be removed, thereby improving the accuracy of data analysis:

[0166] ;

[0167] in, is the cloud droplet sample mean, s is the cloud droplet sample standard deviation, n is the cloud droplet sample size, z α / 2 It is the critical value of the standard normal distribution when the confidence level is 1-α, where α is the significance level factor.

[0168] For example, Figure 7 As shown in the figure, after setting the corresponding parameters, the scatter distribution of the two types of cloud droplets inside and outside the confidence interval is quite different, and the cloud droplets outside the confidence interval can be easily removed.

[0169] Preferably, in statistics, the commonly used significance level factor α values ​​are 0.10, 0.05 and 0.01. These values ​​correspond to different significance levels:

[0170] 1) α = 0.10: indicates a "moderately significant" level, usually used in situations where the consequences of rejecting the null hypothesis are not very serious;

[0171] 2) α=0.05: indicates the "significant" level, which is the most commonly used significance level in statistics;

[0172] 3) α=0.01: indicates the "highly significant" level, which is used in situations where the null hypothesis is of great significance and the consequences of rejection are serious.

[0173] Furthermore, in hypothesis testing, α is used as a critical threshold for judging statistical significance. For example, in a one-sided test, if the value of the test statistic exceeds the critical value (determined by α), the null hypothesis is rejected. Taking the Z test as an example, if the absolute value of the Z value (test statistic) is greater than Z (1-α) (critical value under standard normal distribution), then reject the null hypothesis. (1-α) It is determined by α.

[0174] Specifically, step S101, reducing the super entropy H e And use the new super entropy H e 'Regenerate cloud droplets: The reduction of super entropy can be expressed as the original super entropy H e Multiply by a reduction factor between [0,1] (such as 0.9) to get the new super entropy H e ':H e ' =0.9*H e Then use the new super entropy H e '、Original expectations x and entropy E n , cloud droplets are regenerated through the cloud model generation algorithm. The advantage of this is that a more concentrated and accurate cloud droplet distribution can be obtained, thereby improving the accuracy of subsequent data analysis.

[0175] Furthermore, the C++ program of step S1 is as follows Figure 9~Figure 10 As shown in the figure, the CloudDrop structure represents the cloud droplet, and the CloudModel structure represents the cloud model, including its digital features and cloud droplet collection. The initializeCloudModel function is used to initialize the cloud model and generate normally distributed cloud droplets. The removeOutliers function removes abnormal cloud droplets according to the given significance level factor alpha. The regenerateDropsWithReducedHe function is used to reduce the hyperentropy and regenerate cloud droplets. Finally, the getNewCloudModel function combines these steps and returns a new cloud model. In the main function, the initial digital features, number of cloud droplets, significance level factor, and reduction factor of the cloud model are set, and then the getNewCloudModel function is called to obtain the new cloud model and print its digital features and cloud droplet values.

[0176] In this embodiment, regarding step S2, the data set D is constructed and read: the new cloud droplets are merged with the original cloud droplets to form a data set D. Labels are added to the data set to distinguish the new cloud droplets from the original cloud droplets so that the SVM model can learn how to distinguish and correct digital features.

[0177] Specifically, step S200 is to merge the newly generated cloud droplets with the original cloud droplets: In this step, firstly, the original cloud droplet set is set to C original , represents the existing and verified data points in the agricultural product traceability system. At the same time, the newly generated cloud droplet set is set to C new , these new cloud droplets come from the results of new agricultural product data sampling. By performing a union operation on these two sets:

[0178] ;

[0179] A more comprehensive dataset D is obtained, which includes both historical data and the latest collected or processed data. The benefit of merging cloud droplet collections is that it can provide a richer and more diverse data foundation for subsequent machine learning models. In the scenario of agricultural product traceability, this is equivalent to the model being able to learn based on a wider range of data, thereby improving the accuracy of judgment on the origin and quality of agricultural products.

[0180] Specifically, step S201, adding labels to the data set D: In order to distinguish new cloud droplets from original cloud droplets and provide a learning basis for the subsequent SVM model, we add a label to each cloud droplet. The label set used here is {0,1}, where 0 represents the original cloud droplet, that is, the verified data that already exists in the system; and 1 represents the newly generated cloud droplet, which is the data point newly added to the system. The label adding process can be formally expressed as:

[0181] ;

[0182] Among them, D labeled is a labeled dataset, where each element is a tuple (x, l), x is the data stored in Cloud Droplet, and l is the corresponding label. By adding labels to the dataset, we provide an important learning tool for the SVM model. The model can learn how to distinguish new data from old data by analyzing these labels, and then accurately classify and predict based on the characteristics of these data points. In the context of agricultural product traceability, this is equivalent to the model being able to more effectively identify which data is reliable and which data needs further verification, thereby improving the accuracy and efficiency of the entire traceability system.

[0183] Further, the C++ execution program of step S2 is as follows Fig.11 As shown in the figure, the principle is to read the tuple vector of the original cloud droplet set originalDrops (containing cloud droplet data and corresponding labels, 0 represents the original cloud droplet). Call the getNewCloudModel function in the step S1 program to read the desired cloud model and access its Ex, En, He attributes and drops collection to obtain the expected, entropy, super entropy and new cloud droplet instances. The function returns the CloudModel structure containing the newly generated cloud droplets and other cloud model parameters. Then create a new vector labeledDrops and copy the contents of the original cloud droplet set into it. Then traverse the cloud droplets in the newly generated cloud model and add each new cloud droplet to the labeledDrops vector together with the label 1 (representing the newly generated cloud droplet). Finally, the program traverses the labeledDrops vector and outputs the value and corresponding label of each cloud droplet to verify the correctness of the merge and label addition.

[0184] In this embodiment, regarding step S3, the SVM model is constructed and read: the objective function F(X) is defined to learn and identify the law of cloud droplet digital features, the RBF kernel function is used to drive the objective function, and the model parameters of the SVM model are read. That is, the SVM model is used to learn and identify the law of cloud droplet digital features, thereby achieving accurate judgment of the source and quality of agricultural products.

[0185] Specifically, step S300, objective function F(X): The goal is to find a hyperplane in the high-dimensional space to maximize the interval between two categories (such as HighQuality, MediumQuality, and LowQuality described later). Its standard form of objective function F(X) is expressed as:

[0186] ;

[0187] Among them, the output of the objective function F(X) is y pred , is the predicted category of new cloud droplets; sign is the sign function used to convert The outputs calculated by the term are classified into three different preset ranges: high HighQuality, medium MediumQuality and low LowQuality; w is the normal vector of the hyperplane, b is the bias term, ξ and ξ i is a slack variable (used to handle nonlinear separability), C is a penalty coefficient (used to control the degree of penalty for misclassification), and y i is the label l of the i-th tuple (x, l), x i is the feature vector (i.e., digital feature) of the i-th cloud droplet sample, and N is the number of tuples (x, l).

[0188] Specifically, step S301, RBF (Radial Basis Function) kernel function: RBF kernel function is used to map data to a higher dimensional space for better classification. RBF kernel function K(x i ,x j ) is:

[0189] ;

[0190] Among them, the RBF kernel function plays the role of mapping data from the original space to the high-dimensional space in SVM. This mapping can make the data that was originally linearly inseparable in the original space become linearly separable. The γ parameter in the expression of the RBF kernel function controls the similarity measure of the data points, that is, it determines the distribution of the data points in the high-dimensional space. By adjusting the γ value, the complexity of the model and its ability to fit the data can be changed. After the SVM model is trained, the dot product (w·xi ) will be replaced by the RBF kernel function K(x i ,x j ), that is, when the trained SVM model is actually classified, it does not operate directly on the original data, but in the high-dimensional space after the kernel function mapping. This method can handle more complex data distribution and improve the accuracy of classification.

[0191] In this embodiment, regarding step S4, digital feature correction: the SVM model is applied to the cloud droplets generated by the newly collected agricultural product data. By learning the data of known categories (i.e., training data), an optimal decision boundary is found so that the new data can be classified. In this technical solution, the SVM model has mastered the quality of agricultural products by learning historical agricultural product data; the trained SVM model is applied to the cloud droplets generated by the newly collected agricultural product data. The SVM model will use the objective function F(X) to predict the expected value E of the new cloud droplets according to the learned rules. x and entropy E n Make corrections.

[0192] Specifically, the correction function M(E x , E n , y pred ), where y pred is the predicted category of new cloud droplets by the SVM model. The correction function M(E x , E n , y pred ) Adjust the expected E according to the predicted category x and entropy E n :

[0193] ;

[0194] Among them, E x ' and E n 'are the adjusted expectation and entropy respectively;

[0195] ;

[0196] Among them, the prediction results of the SVM model for new cloud droplets are divided into three possible categories: high Quality, medium Quality and low Quality.

[0197] It can be understood that the correction function M works as follows: it first receives the expected value E of the new cloud droplet x 、Entropy E n And the category y predicted by the SVM model pred Then, according to the different predicted categories, the correction function M(E x, E n , y pred ) is to adjust the rule based on the expected value E of the scale cloud according to the predicted category. x and entropy E n The following adjustments are made (the adjusted expectation and entropy are expressed as E x ' and E n ' indicates); because the predicted category y pred The SVM model has processed the difference between the expected x and entropy E n The nonlinear relationship between them, so at this time, regardless of the expected E x and entropy E n How does it change, the corresponding predicted category y pred It can also be output accordingly, and its exemplary visual distribution form is as follows Figure 8 shown.

[0198] (1) If the predicted category is HighQuality, increase the expected E x A fixed value θ, and reduce the entropy E n A fixed value β. It reflects a higher confidence that the cloud droplet represents high-quality agricultural products, so the expectation increases and the uncertainty (i.e., entropy) decreases. That is, increasing expectation means that the model believes that the quality of the agricultural product is higher, while decreasing entropy means that the model is less uncertain about this judgment.

[0199] (2) If the predicted category is MediumQuality, then the expected E x and entropy E n Remains unchanged. That is, there is no additional information about the mass of the cloud droplet, so no correction is made.

[0200] (3) If the predicted category is LowQuality, reduce the expected E x A fixed value θ, and increasing entropy E n A fixed value β. It reflects the lower confidence that the cloud droplet represents low-quality agricultural products, so the expectation decreases and the uncertainty (i.e., entropy) increases. That is, a decrease in expectation means that the model believes that the quality of the agricultural product is lower, while an increase in entropy means that the model's uncertainty about this judgment increases.

[0201] In the above adjustment process, θ and β are two adjustable fixed values, which can be adjusted according to actual conditions to optimize the correction effect of the model. This flexibility enables the correction function to adapt to different agricultural product traceability scenarios and needs.

[0202] Further, the C++ program of step S4 is as follows Fig.14As shown, the principle is that the svmPredict function is responsible for calling the SVM library function (as shown in Example 2), which returns the predicted quality category based on the input cloud droplet data. The M function corrects the expectation and entropy of the cloud droplets according to the prediction results of the SVM model. The correction rules are as described above, and the values ​​of expectation and entropy are increased or decreased according to the predicted quality category. A cloud droplet instance is created in the main function, and the svmPredict function is used to predict it. Then, the correction function M is called according to the prediction results to update the expectation and entropy of the cloud droplets. Finally, the corrected cloud droplet properties are output.

[0203] In this embodiment, regarding step S5, the traceability information output is: according to the revised expected E x ' and entropy E n ', reconstruct the scale cloud. Then perform principal component analysis (PCA) for complex dynamic weighting. When there are too many abnormal data and only a small amount of normal data remains, PCA will use the merchant standard evaluation as the main component, thereby increasing the difficulty and cost of cheating. Randomly select the qualified data Y from the merchant standard evaluation data set X The same amount of evaluation data Q X , and then use PCA to linearly combine these two types of data to form a comprehensive index. According to the size of the variance, define the first, second, third, and fourth principal components in turn, and determine the coefficients of each indicator in the linear combination of the principal components. Use the variance contribution rate of the principal component to determine the coefficient of the comprehensive score model, and then normalize the indicator weights to finally calculate the objective comprehensive customer evaluation data A X ; The method flow is:

[0204] S500, data standardization: n samples, each sample has p features (i.e., the corrected expected E x ' and entropy E n '). The data needs to be standardized, that is, the mean of each feature is 0 and the variance is 1. The standardization formula is as follows:

[0205] ;

[0206] Among them, x ij is the jth eigenvalue of the ith sample, is the average value of the jth feature of all samples, s j is the standard deviation of the jth feature of all samples.

[0207] S501, let the standardized data matrix be X, where each row represents a sample and each column represents a feature (corrected expected E x ' and entropy E n '). The elements C of the covariance matrix C ijRepresents the covariance between the i-th feature and the j-th feature, and the calculation formula is:

[0208] ;

[0209] Since the data has been standardized, the mean of each feature and are all 0, so the formula can be simplified accordingly. The entire covariance matrix C can be calculated using the above formula.

[0210] S502, calculate the eigenvalues ​​and eigenvectors of the covariance matrix C: C v = λ v ;

[0211] Among them, λ is the eigenvalue and v is the corresponding eigenvector. All eigenvalues ​​and corresponding eigenvectors can be solved by numerical methods (such as power method, QR algorithm, etc.).

[0212] S503, select principal components and transform data: Arrange the solved eigenvalues ​​in descending order, and select the eigenvectors corresponding to the first k largest eigenvalues ​​to form the projection matrix P. The original data X can be projected onto these k principal components by the following formula to obtain a new low-dimensional data representation PC: PC = XP; and PC is a comprehensive index obtained by PCA transformation based on the corrected expected Ex' and entropy En'. These comprehensive indicators can more comprehensively reflect the quality of agricultural products and achieve data dimensionality reduction, so that we can more clearly observe the main change trends in the data.

[0213] S504, in order to obtain comprehensive customer evaluation data A X , we can normalize the comprehensive indicators after PCA conversion so that the weight of each indicator is between 0 and 1:

[0214] ;

[0215] Among them, PC i is the value of the i-th principal component (i.e., the value of the comprehensive index), and k is the number of principal components selected. Through such processing, the comprehensive customer evaluation data A is obtained. X :

[0216] A X ={a1,...,a i ,...,a p};

[0217] Where p is the number of original features (including the modified expected Ex' and entropy En', etc.). It should be noted that p here is different from the number of principal components k selected. Because each element a in the comprehensive customer evaluation data Ai They all represent the importance weight of the corresponding features in the comprehensive evaluation.

[0218] Further, the C++ execution program of step S5 is as follows Fig.15 As shown in the figure, the principle is to use the Eigen library (a powerful C++ mathematical library) to handle matrix operations. The main steps of the program include:

[0219] 1) Data standardization: convert the original data into a distribution with a mean of 0 and a standard deviation of 1;

[0220] 2) Calculate the covariance matrix: Calculate the covariance matrix using the standardized data;

[0221] 3) Calculate the principal components: find the principal components by solving the eigenvalues ​​and eigenvectors of the covariance matrix and sort them according to the size of the eigenvalues;

[0222] 4) Projection data: Project the original data onto the selected principal components to obtain the data representation after dimensionality reduction.

[0223] It is understandable that the comprehensive customer evaluation data A X The initial state is the customer evaluation data set F X , the comprehensive customer evaluation data A at this time X Based on cloud model elimination, SVM model prediction type, correction of correction function and analysis by principal component analysis, malicious and cost evaluation data have been eliminated, and effective information traceability of agricultural products has been completed.

[0224] Embodiment 2: Based on the SVM model constructed in step S3 of embodiment 1, this embodiment further provides a method for training the SVM model, and a complete set of construction and training procedures for the SVM model.

[0225] In this example, see Figure 3 The method for training the SVM model and the method for optimally selecting model parameters include the following steps:

[0226] The first step is initialization: set the initial values ​​of the parameters of the SVM model. Prepare training data (divide the training set D from the data set D train ).

[0227] The second step is to train the SVM model: set the optimization problem to solve the objective function F(X), that is, regard the objective function F(X) as the training function; then use the training set D train Train the SVM model. Use the cross-validation method to adjust the model penalty coefficient C and hyperparameter γ to achieve the best performance (i.e., obtain their optimal values). The steps of the cross-validation technique include:

[0228] P1. Use k-fold cross validation to divide the data set into k subsets (k values ​​can be 5, 10, etc.). Each time, select one subset as the validation set, and the remaining k-1 subsets are combined as the training set.

[0229] P2. Set parameter range: Set a reasonable range for C and γ. For example, C can take a range of values, such as [0.1, 1, 10, 100], and γ can take a similar range.

[0230] P3, training and validation: For each pair of combinations of C and γ, use the training set to train the SVM model. Then evaluate the performance of the model on the validation set and record the evaluation results.

[0231] P4. Select the best parameters: Compare the performance of all parameter combinations on the validation set. Select the pair of C and γ with the best performance as the best parameters.

[0232] The third step is evaluation and verification: divide the verification set D from the data set D val And evaluate the performance of the SVM model. Determine the optimal normal vector w and bias term b based on the evaluation results, and automatically determine the relaxation variables ξ and ξ i The key formula in the evaluation and validation step is the decision function of the SVM model, which predicts each sample in the validation set and compares it with the true label to evaluate the performance of the model. The mean square error (MSE) is selected as the evaluation indicator;

[0233] Decision function f(x): For each sample x in the validation set (i.e. each tuple (x, l)), the decision function f(x) of SVM is:

[0234] ;

[0235] Among them, α i is the Lagrange multiplier, N SV is the number of support vectors (referring to the number of tuples selected as "support vectors" in the trained SVM model. These support vectors are automatically selected by the model during the training process, and they have an important impact on the prediction performance of the model), y i is a sample x i ’s label; K(·,·) is the kernel function (such as the RBF kernel above).

[0236] Mean Square Error (MSE): used to evaluate regression problems. If it is a classification problem, indicators such as accuracy are usually used. MSE is defined as:

[0237] ;

[0238] Among them, n val is the validation set Dval The normal vector w and bias term b that minimize the MSE value are used as the optimal values, and the relaxation variables ξ and ξ are automatically determined. i ;

[0239] Step 4: Iteration and optimization: Iterate and optimize the model according to the test results, including adjusting the model parameters (normal vector w, bias term b, penalty coefficient C, hyperparameter γ and slack variables ξ and ξ i ). Repeat the above steps until satisfactory prediction performance is achieved or the maximum number of training iterations is reached.

[0240] Further, the C++ program of the SVM model in Example 1 and the training method of this embodiment is as follows: Figures 12-13 As shown, the curve of loss rate and recall rate output after iteration is as follows Figure 6 As shown in the figure, the principle is that the program first needs to load the training data set and the validation data set. Before starting training, the SVM model needs to be initialized, including setting the initial parameters of the model, such as the penalty coefficient C, the hyperparameter γ, etc. Then the SVM model is trained using the training data set. During the training process, the model will try to find an optimal hyperplane to divide the data points of different categories. This hyperplane is determined by the normal vector w and the bias term b. The goal of training is to maximize the boundary (i.e., the interval) between the two categories while ensuring that as many data points as possible are correctly classified. The sequential minimum optimization algorithm SMO is used in the training process to solve the optimal normal vector w and bias term b. After the training is completed, the model is evaluated using the validation data set, where the recall rate measures the model's ability to find true positive examples, that is, the proportion of true positive examples to all actual positive examples, and the loss rate reflects the classification error rate of the model on the validation set. By adjusting the parameters of the model (such as C and γ) and repeating the training and evaluation process, a set of optimal parameter configurations can be found so that the model performs best on the validation set. After multiple training and evaluations, the best performing model and its corresponding parameters are selected as the final result, including the optimal normal vector w, bias term b, penalty coefficient C and hyperparameter γ. These parameters determine the final SVM model, which can be used to classify and trace new agricultural product data.

[0241] It should be noted that the Lagrange multiplier α i Follow the steps below to construct a quadratic programming problem, then use an existing SVM library (such as LibSVM, Scikit-learn, etc.) to solve this problem and obtain the Lagrange multiplier α i :

[0242] (1) Constructing the Lagrangian function: First, we construct the Lagrangian function for the original SVM problem, which contains the original objective function, constraints, and the Lagrangian multiplier αi .

[0243] (2) Transformation into a dual problem: By taking the partial derivative of the Lagrangian function and setting it equal to 0, the original problem is transformed into a dual problem. We obtain a solution that only contains the Lagrangian multiplier α i The quadratic programming problem.

[0244] (3) Solving quadratic programming problems: such as the sequential minimal optimization (SMO) algorithm, interior point method, etc.

[0245] (4) Application of KKT conditions: Karush-Kuhn-Tucker (KKT) conditions are used in the solution process to ensure that the solution found is the global optimal one. KKT conditions include primal feasibility, dual feasibility, complementary slackness, and zero gradient constraints.

[0246] (5) Obtaining α i :After solving the quadratic programming problem and satisfying the KKT condition, the optimal α can be obtained i value.

[0247] Embodiment 3: Based on step S4 of embodiment 1, this embodiment further provides a technical solution for dynamically assigning values ​​to θ and β. Since the assignment solution of embodiment 1 is fixed, and this embodiment is a dynamic assignment solution, θ and β will be named "adjustment factors" in the technical solution of this embodiment:

[0248] The first step is to define the loss function: define a loss function that contains θ and β as parameters, which can reflect the accuracy of the model prediction:

[0249] Loss = f(θ, β, X, y);

[0250] Where X is the input data (the input of the correction function) and y is the target output (the predicted category y pred ). The optimization algorithm adjusts θ and β to minimize the loss value Loss.

[0251] Preferably, the function f is preferably a cross entropy loss function:

[0252] ;

[0253] Among them, y i is the true label (0 or 1), p i is the probability that the SVM model predicts the positive class.

[0254] The second step is to use the gradient descent method to minimize the loss value Loss to find the optimal θ and β values:

[0255] 2.1) Initialization parameters: Set initial values ​​for θ and β, which can be random.

[0256] 2.2) Calculate the gradient of the loss function: Calculate the partial derivatives of the loss function with respect to the parameter. These partial derivatives constitute the gradient of the loss function. For θ and β, the gradient is:

[0257] ;

[0258] ;

[0259] These partial derivatives need to be calculated analytically or automatically using automatic differentiation tools (such as TensorFlow, PyTorch, etc.).

[0260] 2.3) Update parameters: Use the calculated gradient to update θ new and β new The update formula is as follows:

[0261] ;

[0262] ;

[0263] Where η is the learning rate, which is a positive decimal number that controls the step size of the parameter update.

[0264] 2.4) Iteration process: Repeat 2.2 to 2.3 above until the stopping condition is met (such as reaching the preset number of iterations, the loss function value converges, or the gradient is small enough, etc.).

[0265] 2.5) Convergence judgment: If the value of the loss function changes very little in several consecutive iterations or the gradient is close to zero, the algorithm can be considered to have converged. At this time, the obtained θ new and β new This is the approximate optimal solution.

[0266] It should be noted that the adjustment factor θ provided in this embodiment is new and β new The dynamic assignment method is based on the input of the correction function and the output of the SVM model. new and β new It is dynamically adjusted through gradient descent, and the correction function can be more flexible to adapt to different data distributions or specific scenarios. Dynamically adjusted adjustment factor θ new and β new These factors can be better weighed. And through dynamic optimization adjustment factor θ new and β new, the correction function can reduce the impact of these unfavorable factors on the final prediction to a certain extent, thereby enhancing the robustness of the model. At the same time, by dynamically improving the adjustment factor θ new and β new ,The correction function can be closer to the actual needs of users and provide personalized prediction services.

[0267] Embodiment 4: In this embodiment, in step S5 of embodiment 1, the traceability information of agricultural products is obtained, that is, the comprehensive customer evaluation data A X On this basis, a credit penalty rule will be further provided:

[0268] Let P = {p1,p2,...,p n} is the set of user nodes, any node p i The reputation value C(p i ) The evaluation rules are as follows: Initial reputation value C i (p i ) is set to 50, the minimum value min is set to 0, and the maximum value max is set to 100. In the traceability data upload job, determine whether the data is qualified; the judgment method is:

[0269] Compare each node p i The expected value of the ruler cloud is E x '. The closest category is regarded as qualified customer evaluation data. If the expected values ​​are the same, the entropy of the two is further compared, and the data with the smallest difference is selected as qualified data. Thus, qualified data Y X and malicious / cheating data N X Nodes that provide abnormal data will be marked as malicious nodes. Then the reputation reward and punishment mechanism is activated:

[0270] If the node p i If the uploaded data is judged as unqualified, the corresponding node p i In this round of operations, it is marked as a dishonest node, and its reputation value is deducted according to the reputation penalty rules. When the reputation value is lower than the minimum value, the node’s certification qualification in the agricultural product traceability system is cancelled; otherwise, it is marked as a trustworthy node, and its reputation value is increased according to the reputation penalty rules.

[0271] 1) If node p i If the uploaded data is judged as unqualified (set as event B), the credit value will be deducted:

[0272] C(p i )=max(C(p i )−ΔC p ,C min );

[0273] Where, ΔC pIt is the credit value deduction amount determined according to the credit penalty rules.

[0274] 2) If node p i If the uploaded data is judged as qualified (set as event ¬B), the reputation value is increased:

[0275] C(p i )=min(C(p i )+ΔC r ,C max );

[0276] Where, ΔC r It is the amount of credit value increase determined according to the credit reward rules.

[0277] ΔC p and ΔC r The specific values ​​need to be set according to system requirements and actual conditions. They can be fixed values ​​or dynamically calculated based on certain factors.

[0278] Understandably, the beneficial effect of this reputation reward and punishment mechanism is that it can effectively motivate user nodes to upload true and accurate traceability data, and punish those nodes that upload malicious or cheating data. In this way, we can improve the data quality and reliability of the agricultural product traceability system, thereby enhancing consumers' trust in agricultural products. At the same time, this mechanism can also help the system identify and exclude malicious nodes, thereby maintaining the security and stability of the entire traceability system. Moreover, this agricultural product traceability method based on the source data verification mechanism combined with the reputation reward and punishment mechanism can significantly improve the performance and credibility of the agricultural product traceability system, and provide consumers with more reliable and safer agricultural product information.

[0279] Embodiment 5: Figure 5 As shown, based on all the above embodiments, this embodiment will further provide an agricultural product traceability system based on a source data verification mechanism, as an implementation carrier of the agricultural product traceability method based on a source data verification mechanism disclosed in all the above embodiments:

[0280] The system mainly includes three transceiver modules (first transceiver module, second transceiver module, third transceiver module), IaaS service layer, PaaS platform layer and SaaS software layer. These components work together to achieve comprehensive traceability of agricultural products.

[0281] The main function of the first transceiver module is to send the traceability information to the PaaS platform layer through the IaaS service layer. When the agricultural product traceability method generates or updates the traceability information, the first transceiver module will package the information and send it to the PaaS platform layer through the secure channel of the IaaS service layer. In this process, the security and integrity of the traceability information are ensured.

[0282] The second transceiver module has two main tasks. First, it transfers the traceability information in the PaaS platform layer to the SaaS software layer, so that the channel party and other relevant personnel can easily view and manage the traceability information through the SaaS software layer. Secondly, the second transceiver module is also responsible for retrieving the agricultural product supply chain data source so that the IaaS service layer can find the corresponding data. In turn, it ensures that the system can obtain all key data of agricultural products from production to sales.

[0283] The third transceiver module is mainly responsible for passing the delivery request sent by the channel party in the SaaS software layer to the IaaS service layer through the PaaS platform layer. When the channel party needs to deliver agricultural products or perform other related operations, they will send delivery requests through the SaaS software layer. After receiving these requests, the third transceiver module will pass them through the PaaS platform layer to the IaaS service layer for processing. In this way, the system can respond quickly according to the needs of the channel party.

[0284] The IaaS service layer is a key component that connects the processor and the memory. It provides infrastructure services such as computing, storage, and networking. When the processor executes the program instructions stored in the memory, it controls the IaaS service layer to execute the agricultural product traceability method mentioned above. This is equivalent to the processor processing traceability information, receiving and sending data, and other tasks according to the program instructions, thereby achieving comprehensive traceability of agricultural products.

[0285] All the above embodiments only express the implementation methods of the relevant practical applications of the present invention, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for ordinary technicians in this field, several variations and improvements can be made without departing from the concept of the present invention, which all belong to the protection scope of the present invention. Therefore, the protection scope of the patent of the present invention shall be based on the attached claims.

[0286] The cited documents in the present invention are:

[0287] [1] Sun Zhiguo, Li Xiufeng, Wang Wensheng. Prospects of blockchain technology application in food safety[J]. Agricultural Network Information, 2016(12):30-31.

[0288] [2]JONATHAN HEISS,ANSELM BUSSE.STEFAN TAI.Trustworthy pre-processingof sensor data in data on-chai-ning workflows for blockchain-based iotapplications[C] / / Service-0riented Computing: 19th InternationalConference,ICS0C 2021, Virtual Event, November 22-25,2021,Proceedings. :Springer,2021 :133 -149.

[0289] [3]WANG YILEI, WANG ZHAOJIE, YANG GUOYU, et al. On-chain is not enough: Ensuring pre-data on the chaincredit for blockchain-based source-tracingsystems [J]. Digital Communications and Networks, 2021.

[0290] [4] Ye Qiong, Li Shaowen, Zhang Youhua, et al. A review of cloud models and applications[J]. Computer Engineering and Design, 2011, 32(12): 4198-4201

[0291] [5] Yan Zhiqiang, Yang Hanzi, Cheng Guanjie, et al. Comprehensive evaluation framework and algorithm of service quality based on blockchain[J]. Computer Integrated Manufacturing Systems, 2021, 27(9): 2708-2720.

[0292] [6] Zhang Youzhi. Research on consensus mechanism and transaction retrieval method of Chinese herbal medicine traceability blockchain[D]. Lanzhou: Northwest Normal University, 2021.

[0293] [7] Zhao Longhai, Zhao Jinhui, Zou Hui. Research on source data verification mechanism of agricultural product traceability blockchain[J]. Journal of Chongqing University of Technology (Natural Science), 2024, 38(2): 246-256.

Claims

1. The agricultural product traceability method based on the source data verification mechanism includes generating digital features of agricultural products, and at the same time, the merchant standard data is processed by reverse cloud to obtain the corresponding cloud model, and the cloud model is generated by the forward cloud generator to obtain the scale cloud, which is characterized by: The cloud model is implemented with the following steps to achieve agricultural product traceability: S1, cloud model processing: using the cloud model to calculate digital features; removing abnormal cloud droplets according to the trust region, reducing the digital features and regenerating new cloud droplets; S2, read the data set D: merge the new cloud droplets and the original cloud droplets to form the data set D, and add labels to the data set D to distinguish the new cloud droplets from the original cloud droplets; S3, using the SVM model: including learning and identifying the target function F(X) with the digital feature law, and driving the RBF kernel function with the target function F(X) ; In S3, the objective function F(X) and the RBF kernel function for: ; ; Among them, the output of the objective function F(X) is y pred , is the predicted category of new cloud droplets; sign is the symbol function used to convert The outputs calculated by the term are classified into three different preset ranges: high HighQuality, medium MediumQuality and low LowQuality; w is the normal vector of the hyperplane, b is the bias term, ξ and ξ i is the slack variable; C is the penalty coefficient, y i is the label l of the i-th tuple (x, l), x is the data stored in the cloud droplet, x i is the feature vector of the i-th cloud droplet sample, and N is the number of tuples (x, l); γ is a hyperparameter of the RBF kernel. After the SVM model is trained, the dot product (w·x i ) will be replaced by the RBF kernel function; The decision function f(x) is: ; Among them, α i is the Lagrange multiplier, N SV is the number of support vectors; The evaluation criterion is the mean square error (MSE). The normal vector w and the bias term b that minimize the mean square error (MSE) are used as the optimal values, and the relaxation variables ξ and ξ are automatically determined. i ; S4, using the trained SVM model to modify the digital features of the new cloud droplets; The expected value E of the new cloud droplet using the objective function F(X) x and entropy E n Make corrections, the correction method is: By modifying the function M(E x , E n , y pred ) to adjust the expected E x and entropy E n : ; Among them, E x ' and E n 'are the adjusted expectation and entropy respectively; ; In S4, the adjusted expected value E is obtained. x ' and entropy E n 'After that, the following adjustment rules are introduced: If the predicted category is the high quality, then increase the expected E x A fixed value θ, and reduce the entropy E n A fixed value β; If the predicted category is the medium quality, then the expected E x and the entropy E n remain unchanged; If the predicted category is the low quality, then reduce the expected E x A fixed value θ, and increase the entropy E n A fixed value β; The method for assigning the fixed value θ and the fixed value β is: The first step is to define the loss function with θ and β as parameters: Loss = f(θ, β, X, y); ; Among them, X is the input data, y is the target output; y i is the true label; p i is the probability that the SVM model predicts the positive class; The second step is to use the gradient descent method to minimize the loss value Loss to find the optimal θ and β values: ; ; Use the calculated gradient to update θ new and β new : ; ; Where η is the learning rate; Repeat the second step until the gradient converges, and the obtained θ new and β new as the fixed value θ and the fixed value β; S5, reconstructing the scale cloud according to the corrected digital features to obtain the traceability information of the agricultural products.

2. The agricultural product traceability method according to claim 1, characterized in that: The digital features include the expected E x 、Entropy E n and super entropy H e ; In the S1, the removal and the reduction are respectively achieved by the following two steps: S100, for any cloud droplet sample, remove abnormal cloud droplets according to the confidence region 1-α: ; in, is the cloud droplet sample mean, s is the cloud droplet sample standard deviation, n is the cloud droplet sample size, z α / 2 is the critical value of the standard normal distribution when the confidence level is 1-α, where α is the significance level factor; S101, the original super entropy H e Multiply by a reduction factor between [0,1] to get the new super entropy H e '; Using the new super entropy H e ', the original expectation E x and the entropy E n , generating the new cloud droplets.

3. The agricultural product traceability method according to claim 1, characterized in that: In S2, the above merging and the above differentiation are respectively achieved through the following two steps: S200, ; Among them, the original cloud droplet set is C original , the set of new cloud droplets is C new ; S201, the set of labels is {0,1}, where 0 represents the original cloud droplet and 1 represents the newly generated cloud droplet: ; Among them, D labeled is a labeled dataset, where each element is a tuple (x, l), where l is the corresponding label.

4. The agricultural product traceability method according to claim 3, characterized in that: Before executing S4, the SVM model needs to be trained and parameters updated; The training steps include: The first step is to determine the training set D train ; The second step is to optimize the objective function F(X) using the training set D train The SVM model is trained to adjust the optimal penalty coefficient C and the hyperparameter γ through a cross-validation method; The third step is to divide the validation set D from the data set D val The performance of the SVM model is evaluated, and then the optimal normal vector w and the bias term b are determined, and the relaxation variables ξ and ξ are automatically determined. i ; Step 4: Repeat steps 2 to 3 until the predetermined number of iterations is reached.

5. The agricultural product traceability system based on source data verification mechanism is characterized by: include: The first transceiver module is used to send the traceability information to the PaaS platform layer through the IaaS service layer; A second transceiver module is used to transmit the traceability information in the PaaS platform layer to the SaaS software layer; A third transceiver module is used to transmit the delivery request sent by the channel party in the SaaS software layer to the IaaS service layer through the PaaS platform layer; The IaaS service layer is connected to a processor and a memory connected to the processor, wherein program instructions are stored in the memory. When the program instructions are executed by the processor, the IaaS service layer, under the control of the processor, executes the agricultural product traceability method as described in any one of claims 1 to 4.