A food safety data traceability method
By building a hierarchical clustering tree and an adaptive support FP tree, the accuracy problem in food traceability due to the low frequency of key data is solved, the accuracy and safety of food traceability are achieved, and the integrity and consistency of traceability information is ensured.
Patent Information
- Application Number
- CN202510622951.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-15
- Publication Date
- 2025-07-25
- Estimated Expiration
- 2045-05-15
AI Technical Summary
In the food traceability process, the existing technology has poor accuracy when tracing the source with frequent mode trees, resulting in distortion of traceability information.
Build a hierarchical clustering tree, and through the bottom-up clustering method, determine the centrality of the matter and the similarity of the production chain, combine the frequency, build an adaptive support FP tree, and adjust the position of the leaf nodes in the tree structure.
It improves the accuracy and safety of food traceability, ensures the integrity and consistency of traceability information, and can correct errors by approaching data, and enhances the tracking ability of the food production chain.
Smart Images

Figure CN120146875B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data processing, and particularly to a method for tracing food safety data. Background Art
[0002] The application of the labeling method in food safety traceability involves the collection, recording, and dissemination of key information throughout the food supply chain. From the collection of raw materials to the sale of the final product, detailed information about each link, such as the production date, batch number, raw material source, processing process, quality inspection results, etc., will be recorded and labeled on the food or its packaging, usually in the form of barcodes, QR codes, or RFID tags. These labeled information spreads in the supply chain as the food circulates, enabling consumers to trace the history and source of the food by scanning the label. At the same time, regulatory agencies can also use these data for effective supervision and auditing. In addition, in the event of a food safety problem, the labeling method can help quickly locate and recall the problem products.
[0003] However, tracing the history and source of food by scanning the label depends on the integrity and authenticity of the information. If there are human errors or recording omissions in a certain link of the supply chain, it will lead to the distortion of the traceability information.
[0004] Commonly, tracing food is achieved by combining the labeling method and the Frequent Pattern Tree (FP-tree) to mine the association rules in the production chain of food. However, due to the fact that the specific information of a single batch may be relatively sparse, and the FP-tree depends on frequent itemsets. If the frequency of key data is low, it may be ignored by the algorithm, resulting in the problem of traceability omission, and further leading to the problem of poor accuracy in food traceability. Summary of the Invention
[0005] In order to solve the technical problem that when the frequency of key data is low, tracing using the frequent pattern tree may have poor accuracy, the purpose of the present invention is to provide a method for tracing food safety data, and the specific technical solution adopted is as follows:
[0006] In a first aspect, an embodiment of the present invention provides a method for tracing food safety data, and the method includes:
[0007] Scan the identifier of each food package to obtain the production chain of each food; wherein, the production chain is regarded as an event.
[0008] Based on each event, construct a hierarchical clustering tree, and each leaf node of the hierarchical clustering tree is an event; divide the leaf node of each event and the upper-level leaf nodes in the hierarchical clustering tree into the same category to construct a category quantity sequence corresponding to each event; wherein, the category quantity sequence is arranged in the order of the size of the quantity.
[0009] Compare adjacent elements in the category quantity sequence to obtain the category expansion degree; determine the centrality of an event based on the similarity of the event to other events in the corresponding category sequence; combine the category expansion degree and the centrality to determine the production chain similarity of the event.
[0010] Combine the production chain similarity of the event and the frequency of occurrence of the event to determine the adaptive support degree corresponding to each event.
[0011] Construct an FP tree corresponding to the production chain of food according to the adaptive support degree corresponding to each event.
[0012] Further, construct a hierarchical clustering tree based on each event, where each leaf node of the hierarchical clustering tree is an event, including:
[0013] Use hierarchical clustering of bottom-up agglomerative clustering to construct an equal-level clustering tree; where each event includes multiple production chain data.
[0014] Further, divide the leaf node of each event and the upper-level leaf node in the hierarchical clustering tree into the same category to construct a category quantity sequence corresponding to each event, including:
[0015] Obtain the upper-level leaf nodes of the leaf node corresponding to each event in the hierarchical clustering tree to construct a category sequence corresponding to each event; construct a category quantity sequence from the number of elements in the category sequences of all events; where the elements in the category quantity sequence are the numerical values of the elements in the category sequence corresponding to each event, and the elements in the category quantity sequence are arranged in ascending order of quantity.
[0016] Further, the obtaining the upper-level leaf nodes of the leaf node corresponding to each event in the hierarchical clustering tree to construct a category sequence corresponding to each event includes:
[0017] For the leaf node corresponding to each event, use each upper-level leaf node of the leaf node in the hierarchical clustering tree as a sequence element to construct a category sequence corresponding to each event.
[0018] Further, the comparing adjacent elements in the category quantity sequence to obtain the category expansion degree includes:
[0019] Take any element in the category quantity sequence as the target element, calculate the difference between the target element and the previous element as the category difference; take the ratio of the category difference to the value of the previous element as the category expansion degree.
[0020] Further, the determining the centrality of an event based on the similarity of the event to other events in the corresponding category sequence includes:
[0021] Calculate the similarity between the calculation item and other items in the corresponding category sequence, which is used as the centrality of the item.
[0022] Further, combining the category expansion degree and the centrality to determine the production chain similarity of the item includes:
[0023] Taking the ratio of the centrality to the category expansion degree as the production chain similarity of the item.
[0024] Further, combining the category expansion degree and the centrality to determine the production chain similarity of the item further includes:
[0025] Calculate the similarity between the leaf node of the item and the same-level leaf nodes that have the same upper-level leaf node in the hierarchical clustering tree to obtain the candidate similarity. When the candidate similarity is greater than the production chain similarity, update the candidate similarity to the new production chain similarity.
[0026] Further, combining the production chain similarity of the item and the frequency of occurrence of the item to determine the adaptive support degree corresponding to each item includes:
[0027] Obtain the production chain similarity sequence and the item occurrence frequency sequence constructed by all items; among them, both the production chain similarity sequence and the item occurrence frequency sequence are numerically arranged according to the same rule;
[0028] For each item, determine the similarity weight and frequency weight of the item according to the order values of the item in the production chain similarity sequence and the item occurrence frequency sequence respectively;
[0029] Based on the similarity weight and frequency weight, weight the production chain similarity and the item occurrence frequency corresponding to the item respectively to obtain the adaptive support degree corresponding to the item.
[0030] Further, based on the similarity weight and frequency weight, weighting the production chain similarity and the item occurrence frequency corresponding to the item respectively to obtain the adaptive support degree corresponding to the item includes:
[0031] Weight the production chain similarity by the similarity weight to obtain the first support degree;
[0032] Weight the item occurrence frequency by the frequency weight to obtain the second support degree;
[0033] Taking the sum value of the first support degree and the second support degree as the adaptive support degree corresponding to the item.
[0034] In the second aspect, a food safety data traceability system is provided. The system includes the following modules:
[0035] An identification module for scanning the identifiers of each food package to obtain the production chain of each food; wherein, the production chain is regarded as an item.
[0036] A leaf node division module for constructing a hierarchical clustering tree based on each item, where each leaf node of the hierarchical clustering tree is an item; dividing the leaf nodes of each item and the upper-level leaf nodes in the hierarchical clustering tree into the same category to construct a category quantity sequence corresponding to each item; wherein, the category quantity sequence is arranged in the order of the magnitude of the quantity.
[0037] A production chain comparison module for comparing adjacent elements in the category quantity sequence to obtain the category expansion degree; determining the centrality of an item according to the same situation of the item and other items in the corresponding category sequence; combining the category expansion degree and the centrality to determine the production chain similarity of the item.
[0038] A support degree adjustment module for combining the production chain similarity of an item and the frequency of occurrence of the item to determine the adaptive support degree corresponding to each item.
[0039] An FP tree generation module for constructing an FP tree corresponding to the production chain of food according to the adaptive support degree corresponding to each item.
[0040] In a third aspect, an embodiment of the present invention provides an electronic device, including a memory and a processor, where an executable code is stored in the memory, and when the processor executes the executable code, the embodiments of all possible implementations in the first aspect are implemented.
[0041] In a fourth aspect, an embodiment of the present invention provides a computer program product, which includes: computer program code, and when the computer program code runs on a computer, the computer is enabled to execute the method in the first aspect or any possible implementation manner of the first aspect.
[0042] In a fifth aspect, an embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed in a computer, the computer is enabled to execute the embodiments of all possible implementations in the first aspect.
[0043] The embodiments of the present invention have at least the following beneficial effects:
[0044] By constructing a tree structure, the present application makes the positions of similar product tracking chains adjacent on the tree. Thus, even if there are input errors, it is easy to correct them through adjacent data during traceability, ensuring the accuracy and security of traceability. Each matter is used as a leaf node, which corresponds to a complete production chain in the food production process. When the category to which the leaf node belongs expands and the centrality of the leaf node is relatively strong, the similarity of the production chain between the leaf node and other leaf nodes should be adaptively adjusted so that the matter corresponding to the leaf node is in a position close to most matters. Then, when tracing the production chain of food, more node information in matters with a greater production chain similarity can be referred to, thereby realizing the adaptive adjustment of the support degree corresponding to each matter, obtaining the adaptive support degree of each matter, and further improving the accuracy of food traceability. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] To more clearly illustrate the technical solutions and advantages in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, the drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can be obtained based on these drawings.
[0046] Figure 1 It is a flowchart of a method for food safety data traceability provided by an embodiment of the present invention;
[0047] Figure 2 It is a schematic diagram of a hierarchical clustering tree provided by an embodiment of the present invention;
[0048] Figure 3 It is a system block diagram of a food safety data traceability system provided by an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0049] To further elaborate on the technical means and effects adopted by the present invention to achieve the intended invention purpose, the following, in combination with the drawings and preferred embodiments, details the specific implementation manners, structures, features, and effects of a method for food safety data traceability proposed according to the present invention.
[0050] In the following description, different "one embodiment" or "another embodiment" do not necessarily refer to the same embodiment. In addition, the specific features, structures, or characteristics in one or more embodiments can be combined in any suitable form.
[0051] Among them, in the description of the embodiments of the present invention, unless otherwise specified, " / " means "or". For example, A / B may mean A or B. The "and / or" in the text is only a relationship description of related objects, indicating that there can be three relationships. For example, A and / or B can mean: A exists alone, A and B exist simultaneously, and B exists alone. In addition, in the description of the embodiments of the present invention, "a plurality of" means two or more than two.
[0052] Hereinafter, the terms "first" and "second" are only used for descriptive purposes and cannot be construed as implying or suggesting relative importance or implicitly indicating the quantity of the indicated technical features. Thus, the features defined with "first" and "second" may explicitly or implicitly include one or more of such features.
[0053] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those of ordinary skill in the technical field to which the present invention belongs.
[0054] The embodiments of the present invention will be described below with reference to the accompanying drawings. As those of ordinary skill in the art know, with the development of technology and the emergence of new scenarios, the technical solutions provided by the embodiments of the present invention are also applicable to similar technical problems.
[0055] The following specifically describes the specific solution of a food safety data traceability method provided by the present invention with reference to the accompanying drawings.
[0056] Please refer to Figure 1 , which shows a step flow chart of a food safety data traceability method provided by an embodiment of the present invention. The method includes the following steps:
[0057] Step S100, scan the identifier of each food package to obtain the production chain of each food; wherein, the production chain is regarded as an event.
[0058] The annotation of food data mainly includes determining the key information to be recorded, such as the production date and raw material source, and then designing a suitable annotation format, such as a two-dimensional code or an RFID tag. Next, collect this information at each stage of food production, and convert it into a physical or digital form of annotation, attach it to the food package or record it in the database.
[0059] Since the food data generated by the same manufacturer are more similar in the processes of raw material collection, production, processing, and sales, the closer to the early stage of work, such as the raw material source area, etc.; the greater the differences in the later stage, such as the processing method, sales path, etc. Therefore, the entire production process of food is similar to a tree structure. Thus, it can be regarded as starting from a node and gradually splitting to form different nodes, and then forming different paths. Therefore, in the embodiments of the present invention, the FP-TREE construction method is used to improve the process of tree construction.
[0060] FP-TREE is a method for finding frequent item sets. By constructing a tree structure, as many paths as possible are shared, thereby accelerating the method of finding frequent items. The food process in the embodiments of the present invention is similar to this algorithm. Therefore, improvements in food traceability are made based on this algorithm.
[0061] Since FP-TREE reflects a similarity at the hierarchical level, in the embodiments of the present invention, this similarity is first obtained through hierarchical analysis, and then the adjusted FP-TREE is obtained by adjusting according to the actual element arrangement in FP-TREE. This helps to divide the items with similar previous paths into the same block more in the hierarchical structure, thus helping to detect anomalies during subsequent traceability and repairing a certain node of the abnormal data through the traceability results of adjacent data.
[0062] Since the analysis of the present invention is based on food data to achieve food traceability, first, the identification of each food package is scanned to scan out the production chain corresponding to each food; among them, each production chain is regarded as an item, and the item includes various production chain data, such as {production date, batch number, raw material source, processing process, transportation process, sales area}, for example, the production date is one kind of production chain data.
[0063] Step S200, construct a hierarchical clustering tree based on each of the said items. Each leaf node of the hierarchical clustering tree is an item; the leaf nodes of each item and the upper-level leaf nodes in the hierarchical clustering tree are divided into the same category, and a category quantity sequence corresponding to each item is constructed; wherein, the category quantity sequence is arranged in the order of the size of the quantity.
[0064] Regarding each item as the basic element of the hierarchical analysis method, a hierarchical clustering tree is obtained for each item through the hierarchical analysis method of bottom-up agglomerative clustering.
[0065] For each leaf node of the hierarchical clustering tree, here the leaf node corresponds to each item, and the upper-level node of this leaf node can be obtained in sequence. Please refer to Figure 2 , Figure 2 which is a schematic diagram of the hierarchical clustering tree, Figure 2A, B, C, D, E, F, BC, BCD, BCDEF, ABCDEF, and EF in it are all leaf nodes; as Figure 2 In Figure 2 , the upper-level leaf node of node B is leaf node BC, and the upper-upper-level leaf node is leaf node BCD. It should be noted that Figure 2 in Figure 2 , leaf nodes BC, BCD, BCDEF, and ABCDEF are all upper-level leaf nodes of leaf node B.
[0066] Obtain the upper-level leaf nodes of the leaf nodes corresponding to each matter in the hierarchical clustering tree, and construct a category sequence corresponding to each matter. More specifically: for the leaf node corresponding to each matter, use each upper-level leaf node of the leaf node in the hierarchical clustering tree as a sequence element to construct a category sequence corresponding to each matter.
[0067] For example, for matter A1, the leaf node corresponding to matter A1 is BC. Then, the upper-level nodes corresponding to leaf node BC are leaf nodes BCD, BCDEF, and ABCDEF. So, the category sequence corresponding to leaf node BC is {leaf node BCD, leaf node BCDEF, leaf node ABCDEF}.
[0068] At the same time, the number of elements in each category can be obtained, and the sequence formed by the number of elements in the category sequences of all matters is used as the category quantity sequence. Among them, the elements in the category quantity sequence are the quantity values of the elements in the category sequences corresponding to each matter, and the elements in the category quantity sequence are arranged in ascending order of quantity. In the embodiments of the present invention, it is defined that the elements in the category quantity sequence are arranged in ascending order.
[0069] Step S300, compare adjacent elements in the category quantity sequence to obtain the category expansion degree; determine the centrality of the matter according to the same situation of the matter and other matters in the corresponding category sequence; combine the category expansion degree and the centrality to determine the production chain similarity of the matter.
[0070] In the hierarchical analysis method of bottom-up agglomerative clustering, for a single node, when the category to which the node belongs expands, if the centrality of the node, that is, the category representativeness, is relatively strong, the similarity between the node and other nodes should be set larger. As a result, the matter corresponding to the node in the FP-TREE is in a position close to most matters. Therefore, when tracing the source, more node information in this matter can be referred to; here, the single node refers to a matter, that is, a matter in the FP-TREE, which corresponds to a complete production chain in the food production process.
[0071] Therefore, first analyze the similarity between different nodes in the hierarchical clustering tree to determine the production chain similarity of each matter.
[0072] First, take any element in the category quantity sequence as the target element, calculate the difference between the target element and the previous element as the category difference; take the ratio of the category difference to the value of the previous element as the category expansion degree.
[0073] Calculate the similarity between an item and other items in the corresponding category sequence as the centrality of the item. More specifically: take any item as the target item, and in each category sequence to which the target item belongs, calculate the cosine similarity between the target item and each item in the category sequence, and take the sum of the similarities as the centrality of the target item.
[0074] Take the ratio of the centrality to the expansion degree as the production chain similarity of the item.
[0075] Denote the bottom layer of the hierarchical clustering tree as the first layer, and successively upwards as: the second layer, the third layer, and so on.
[0076] As an embodiment of the present invention, it is also possible to calculate the similarity between the leaf node of an item and the leaf nodes of the same layer that have the same upper leaf node in the hierarchical clustering tree to obtain the candidate similarity. When the candidate similarity is greater than the production chain similarity, update the candidate similarity to the new production chain similarity.
[0077] Step S400, combine the production chain similarity of the item and the frequency at which the item appears to determine the adaptive support degree corresponding to each item.
[0078] Obtain the adaptive support degree of the item corresponding to the leaf node through the method of weighted summation of the production chain similarity and the frequency. Therefore, the respective weights need to be obtained first.
[0079] If comparing the ranking of the production chain similarity of an item with the ranking of the frequency, if the production chain similarity is larger, assign a smaller weight to the similarity; otherwise, assign a larger weight to the similarity.
[0080] Calculate the production chain similarities of all items, and construct a production chain similarity sequence from the production chain similarities of all items; count the frequencies at which all items appear, and construct an item appearance frequency sequence from the frequencies at which all items appear.
[0081] Among them, both the production chain similarity sequence and the item appearance frequency sequence are numerically arranged according to the same rule. In the embodiment of the present invention, the production chain similarity sequence and the item appearance frequency sequence are respectively arranged in descending order.
[0082] For each item, determine the similarity weight and frequency weight of the item according to the order values of the item in the production chain similarity sequence and the item appearance frequency sequence respectively.
[0083] In some embodiments, calculate the absolute value of the difference between the order values of the calculation matters in the production chain similarity sequence and the matter occurrence frequency sequence. Perform a negative correlation normalization mapping on the absolute value of the difference to obtain the similarity weight.
[0084] In some embodiments, the calculation formula for the similarity weight q is: ; where e is the natural constant; h is the absolute value of the difference between the order values of the matter in the production chain similarity sequence and the matter occurrence frequency sequence. It should be noted that the absolute value of the difference is the absolute value of the difference.
[0085] Take the difference between the constant 1 and the similarity weight as the frequency weight of the matter.
[0086] Based on the similarity weight and the frequency weight, respectively weight the production chain similarity corresponding to the matter and the matter occurrence frequency to obtain the adaptive support degree corresponding to the matter.
[0087] In some embodiments, the method for obtaining the adaptive support degree is: weight the production chain similarity by the similarity weight to obtain the first support degree; weight the matter occurrence frequency by the frequency weight to obtain the second support degree; take the sum value of the first support degree and the second support degree as the adaptive support degree corresponding to the matter.
[0088] Step S500, construct an FP tree corresponding to the production chain of the food according to the adaptive support degree corresponding to each matter.
[0089] Arrange the adaptive support degrees in descending order, use the adaptive support degree as the support degree when constructing the FP tree, and construct the FP tree in order to obtain an adaptive FP tree.
[0090] Through the corrected FP tree for data traceability, the flow path of data in the system can be effectively traced, thereby ensuring the integrity and security of the data. The FP tree (Frequent Pattern Tree) is a tree-shaped data structure used for mining frequent item sets. It represents all frequent item sets by constructing a compact tree, thereby improving the efficiency of data mining. In the context of data traceability, the FP tree obtained after adaptation can be applied in the following aspects:
[0091] Data source identification: By analyzing the FP tree, it is possible to identify from which sources the data was initially generated, which is crucial for understanding the original background and context of the data.
[0092] Data flow monitoring: When the data flows through different systems and components, the FP tree can help trace the flow path of the data to ensure the integrity and consistency of the data during transmission.
[0093] Data access control: Utilizing the structure of the FP tree, fine-grained data access control can be implemented to ensure that only authorized users and systems can access specific data.
[0094] Please refer to Figure 3 , which shows a system block diagram of a food safety data traceability system provided by an embodiment of the present invention. The system includes the following modules:
[0095] An identification module, configured to scan the identification of each food package to obtain the production chain of each food; wherein, the production chain is used as an item.
[0096] A leaf node division module, configured to construct a hierarchical clustering tree based on each item. Each leaf node of the hierarchical clustering tree is an item; the leaf nodes of each item and the upper-level leaf nodes in the hierarchical clustering tree are divided into the same category to construct a category quantity sequence corresponding to each item; wherein, the category quantity sequence is arranged in the order of the magnitude of the quantity.
[0097] A production chain comparison module, configured to compare adjacent elements in the category quantity sequence to obtain the category expansion degree; determine the centrality of an item according to the same situation of the item and other items in the corresponding category sequence; combine the category expansion degree and the centrality to determine the production chain similarity of the item.
[0098] A support degree adjustment module, configured to combine the production chain similarity of an item and the frequency of occurrence of the item to determine the adaptive support degree corresponding to each item.
[0099] An FP tree generation module, configured to construct an FP tree corresponding to the production chain of food according to the adaptive support degree corresponding to each item.
[0100] Optionally, the transmission medium can be a wired link, such as but not limited to, coaxial cable, optical fiber, and digital subscriber line, etc., or a wireless link, such as but not limited to, Wireless Fidelity (WIFI), Bluetooth, and mobile device network, etc.
[0101] It should be noted that: for the device provided in the above embodiment, only the above division of each functional module is used for illustration. In actual application, the above functions can be allocated to different functional modules according to needs, that is, the internal structure of the computer device is divided into different functional modules to complete all or part of the functions described above.
[0102] A computer device provided by an embodiment of the present invention. The computer device includes: a memory, a processor, and a computer program stored in the memory and running on the processor. When the processor executes the computer program, the computer device can execute any one of the food safety data traceability methods described above.
[0103] In addition, an embodiment of the present invention also protects a device, which may include a memory and a processor. Among them, executable program code is stored in the memory, and the processor is used to call and execute the executable program code to execute a food safety data traceability method provided by an embodiment of the present invention.
[0104] An embodiment of the present invention can divide the functions of the device according to the above method examples. For example, it can correspond to each functional module, or two or more functions can be integrated into one processing module. The above integrated module can be implemented in the form of hardware. It should be noted that the division of modules in this embodiment is illustrative, only a logical function division, and there may be other division methods in actual implementation.
[0105] In the case of dividing each module according to each function, the device may further include a signal uploading module, a determination module, an adjustment module, etc. It should be noted that all relevant contents of each step involved in the above method embodiment can be cited in the function description of the corresponding functional module, and will not be repeated here.
[0106] It should be understood that the device provided by an embodiment of the present invention is used to execute the above food safety data traceability method, so it can achieve the same effect as the above implementation method.
[0107] In the case of adopting an integrated unit, the device may include a processing module and a storage module. Among them, when the device is applied to a device, the processing module can be used to control and manage the actions of the device. The storage module can be used to support the device to execute mutual program codes, etc. Among them, the processing module can be a processor or a controller, which can implement or execute various exemplary logic blocks, modules, and circuits described in combination with the disclosure of the present invention. The processor can also be a combination that realizes computing functions, such as a combination of one or more microprocessors, a combination of digital signal processing (DSP) and a microprocessor, etc. The storage module can be a memory.
[0108] In addition, the device provided by an embodiment of the present invention may specifically be a chip, a component, or a module. The chip may include a connected processor and a memory; among them, the memory is used to store instructions, and when the processor calls and executes the instructions, the chip can execute a food safety data traceability method provided by the above embodiment.
[0109] An embodiment of the present invention also provides a computer-readable storage medium, in which computer program code is stored. When the computer program code runs on a computer, the computer is enabled to execute the above relevant method steps to implement a food safety data traceability method provided by the above embodiment.
[0110] An embodiment of the present invention also provides a computer program product. When the computer program product runs on a computer, it causes the computer to execute the above-related steps to implement a food safety data traceability method provided in the above embodiment.
[0111] Among them, the device, computer-readable storage medium, computer program product or chip provided in the embodiment of the present invention are all used to execute the corresponding method provided above. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding method provided above, and will not be elaborated here. Through the description of the above embodiments, those skilled in the art can understand that for the convenience and simplicity of description, only the above division of each functional module is used as an example. In actual applications, the above functions can be allocated to different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In the embodiments provided by the present invention, it should be understood that the disclosed device and method can be implemented in other ways.
[0112] The device embodiments described above are merely illustrative. For example, the division of modules or units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the displayed or discussed mutual coupling or direct coupling or communication connection may be through some interfaces. The indirect coupling or communication connection of the device or unit may be in an electrical, mechanical or other form.
[0113] It should also be noted that in this article, the terms "include", "comprise" or any other variant thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal device including a series of elements not only includes those elements, but also includes other elements not expressly listed, or also includes elements inherent to such process, method, article or terminal device. Without further limitation, an element defined by the statement "including one..." does not exclude the existence of additional identical elements in the process, method, article or terminal device including the said element.
[0114] It should be noted that the above sequence of embodiments of the present invention is only for description and does not represent the superiority or inferiority of the embodiments. The processes depicted in the drawings do not necessarily require the specific order or sequential order shown to achieve the desired result. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0115] Each embodiment in this specification is described in a progressive manner. For the same or similar parts among the embodiments, reference can be made to each other, and the differences between each embodiment and other embodiments are emphasized.
[0116] The above is only a specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art within the technical scope disclosed by the present invention can easily think of changes or substitutions, which should all be covered by the protection scope of the present invention.
Claims
1. A food safety data traceability method, characterized in that, The method includes the following steps: Scan the identification of each food package to obtain the production chain of each food; wherein, the production chain is regarded as an item; Construct a hierarchical clustering tree based on each item, where each leaf node of the hierarchical clustering tree is an item; divide the leaf node of each item and the upper leaf nodes in the hierarchical clustering tree into the same category, and construct a category quantity sequence corresponding to each item; wherein, the category quantity sequence is arranged in the order of the magnitude of the quantity; Compare adjacent elements in the category quantity sequence to obtain the category expansion degree; determine the centrality of the item according to the same situation of the item and other items in the corresponding category sequence; combine the category expansion degree and the centrality to determine the production chain similarity of the item; Combine the production chain similarity of the item and the frequency of occurrence of the item to determine the adaptive support degree corresponding to each item; Wherein, the method for determining the adaptive support degree is: obtain a production chain similarity sequence and an item occurrence frequency sequence constructed by all items; wherein, both the production chain similarity sequence and the item occurrence frequency sequence are numerically arranged according to the same rule; for each item, determine the similarity weight and frequency weight of the item according to the order values of the item in the production chain similarity sequence and the item occurrence frequency sequence respectively; based on the similarity weight and frequency weight, weight the production chain similarity and the item occurrence frequency corresponding to the item respectively to obtain the adaptive support corresponding to the item; Construct an FP tree corresponding to the production chain of the food according to the adaptive support degree corresponding to each item.
2. The food safety data traceability method according to claim 1, characterized in that The constructing a hierarchical clustering tree based on each item, where each leaf node of the hierarchical clustering tree is an item, includes: Use hierarchical clustering of bottom-up agglomerative clustering to construct a hierarchical clustering tree; wherein, each item includes multiple production chain data; wherein, the multiple production chain data includes: production date, batch number, raw material source, processing process, transportation process, sales area.
3. A food safety data traceability method according to claim 1, characterized in that The dividing the leaf node of each item and the upper leaf nodes in the hierarchical clustering tree into the same category to construct a category quantity sequence corresponding to each item includes: Obtain the upper leaf nodes in the hierarchical clustering tree of the leaf node corresponding to each item, and construct a category sequence corresponding to each item; construct a category quantity sequence from the number of elements in the category sequences of all items; wherein, the elements in the category quantity sequence are the quantity values of the elements in the category sequence corresponding to each item, and the elements in the category quantity sequence are arranged in the order of the magnitude of the quantity.
4. A food safety data traceability method according to claim 3, characterized in that, The obtaining the upper leaf nodes in the hierarchical clustering tree of the leaf node corresponding to each item to construct a category sequence corresponding to each item includes: For the leaf node corresponding to each item, use each upper leaf node of the leaf node in the hierarchical clustering tree as a sequence element to construct a category sequence corresponding to each item.
5. A food safety data traceability method according to claim 1, characterized in that, The comparing adjacent elements in the category quantity sequence to obtain the category expansion degree includes: Take any element in the category quantity sequence as the target element, calculate the difference between the target element and the previous element as the category difference; take the ratio of the category difference to the value of the previous element as the category expansion degree.
6. The food safety data traceability method according to claim 1, wherein Determining the centrality of an item based on the same situation of the item and other items in the corresponding category sequence, including: Calculating the similarity between the item and other items in the corresponding category sequence as the centrality of the item.
7. A food safety data traceability method according to claim 1, characterized in that, Combining the category expansion degree and the centrality to determine the production chain similarity of the item, including: Taking the ratio of the centrality to the category expansion degree as the production chain similarity of the item.
8. A food safety data traceability method according to claim 1, characterized in that, Combining the category expansion degree and the centrality to determine the production chain similarity of the item further includes: Calculating the similarity between the leaf node of the item and the same-level leaf nodes that have the same upper-level leaf node in the hierarchical clustering tree to obtain the candidate similarity. When the candidate similarity is greater than the production chain similarity, updating the candidate similarity as the new production chain similarity.
9. A food safety data traceability method according to claim 1, characterized in that, Based on the similarity weight and the frequency weight, respectively weighting the production chain similarity corresponding to the item and the item occurrence frequency to obtain the adaptive support degree corresponding to the item, including: Weighting the production chain similarity by the similarity weight to obtain the first support degree; Weighting the item occurrence frequency by the frequency weight to obtain the second support degree; Taking the sum value of the first support degree and the second support degree as the adaptive support degree corresponding to the item.
Citation Information
Patent Citations
Abnormal network security event identification method based on FP-Growth algorithm
CN116389036A
Power grid fault power protection maintenance plan making method, device, equipment and medium
CN118504939A