Food safety data tracing method
By constructing hierarchical clustering trees and adaptive support, the problem of low frequency in food traceability is solved, and the high accuracy and safety of food traceability is achieved.
Patent Information
- Application Number
- CN202510622951.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-15
- Publication Date
- 2025-06-13
- Estimated Expiration
- 2045-05-15
AI Technical Summary
When using frequent pattern trees for food traceability, if the frequency of key data appears low, it may lead to poor traceability accuracy.
By scanning the logo of food packaging to obtain the production chain, building a hierarchical clustering tree, calculating the degree of category expansion and centrality, determining the similarity of the production chain, and adjusting the adaptive support degree in combination with frequency, and finally building an adaptive FP tree.
It improves the accuracy and safety of food traceability. Even if there is an entry error, it can be corrected through nearby data during traceability to ensure the integrity and authenticity of the information.
Smart Images

Figure CN120146875A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data processing, and particularly to a food safety data traceability method. 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 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 origin of the food by scanning the label. At the same time, regulatory agencies can also use this 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 origin 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, food traceability 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 sparse specific information of a single batch, and the FP tree depends on frequent item sets. If the key data appears with a low frequency, it may be ignored by the algorithm, resulting in the problem of traceability omission, and further leading to poor accuracy in food traceability. Summary of the Invention
[0005] In order to solve the technical problem that when the key data appears with a low frequency, the traceability using the frequent pattern tree may have poor accuracy, the purpose of the present invention is to provide a food safety data traceability method, and the specific technical solution adopted is as follows: In a first aspect, an embodiment of the present invention provides a food safety data traceability method, and the method includes: Scanning the identifier of each food package to obtain the production chain of each food; wherein, the production chain is regarded as an event; Based on each event, constructing a hierarchical clustering tree, and each leaf node of the hierarchical clustering tree is an event; dividing the leaf node of each event and the upper-level leaf nodes in the hierarchical clustering tree into the same category, and constructing a category quantity sequence corresponding to each event; wherein, the category quantity sequence is arranged in the order of the quantity size; Compare adjacent elements in the category quantity sequence to obtain the category expansion degree; determine the centrality of an event based on the similarity between the event and other events in the corresponding category sequence; combine the category expansion degree and the centrality to determine the production chain similarity of the event. 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. Construct an FP tree corresponding to the production chain of food according to the adaptive support degree corresponding to each event.
[0006] Further, construct a hierarchical clustering tree based on each event, where each leaf node of the hierarchical clustering tree is an event, including: Use hierarchical clustering of bottom-up agglomerative clustering to construct a hierarchical clustering tree; where each event includes multiple production chain data.
[0007] Further, divide the leaf node of each event and the upper leaf node in the hierarchical clustering tree into the same category to construct a category quantity sequence corresponding to each event, including: Obtain the upper 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.
[0008] Further, the obtaining the upper 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: For the leaf node corresponding to each event, 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 event.
[0009] Further, 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.
[0010] Further, the determining the centrality of an event based on the similarity between the event and other events in the corresponding category sequence includes: Calculate the similarity between the event and other events in the corresponding category sequence as the centrality of the event.
[0011] Further, the combining the category expansion degree and the centrality to determine the production chain similarity of the event includes: Take the ratio of the centrality and the degree of category expansion as the production chain similarity of the matter.
[0012] Furthermore, determining the production chain similarity of the matter by combining the degree of category expansion and the centrality further includes: Calculate the similarity between the leaf node of the matter and the leaf nodes at the same level 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.
[0013] Furthermore, determining the adaptive support degree corresponding to each matter by combining the production chain similarity of the matter and the frequency of occurrence of the matter includes: Obtain the production chain similarity sequence and the matter occurrence frequency sequence constructed by all matters; among them, both the production chain similarity sequence and the matter occurrence frequency sequence are numerically arranged according to the same rule; For each matter, determine the similarity weight and frequency weight of the matter according to the order values of the matter in the production chain similarity sequence and the matter occurrence frequency sequence respectively; Based on the similarity weight and frequency weight, weight the production chain similarity and the matter occurrence frequency corresponding to the matter respectively to obtain the adaptive support degree corresponding to the matter.
[0014] Furthermore, weighting the production chain similarity and the matter occurrence frequency corresponding to the matter respectively based on the similarity weight and frequency weight to obtain the adaptive support degree corresponding to the matter includes: 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.
[0015] In a second aspect, a food safety data traceability system is provided. The system includes the following modules: An identification module, configured to scan the identifier of each food package to obtain the production chain of each food; wherein, the production chain is used as a matter; A leaf node division module, configured to construct a hierarchical clustering tree based on each matter. Each leaf node of the hierarchical clustering tree is a matter; divide the leaf node of each matter and the upper-level leaf node in the hierarchical clustering tree into the same category to construct a category quantity sequence corresponding to each matter; wherein, the category quantity sequence is arranged in the order of the quantity size; 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 event according to the similarity between the event and other events in the corresponding category sequence; combine the category expansion degree and the centrality to determine the production chain similarity of the event. A support degree adjustment module, configured to combine the production chain similarity of an event and the frequency of occurrence of the event to determine the adaptive support degree corresponding to each event. 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 event.
[0016] In a third aspect, an embodiment of the present invention provides an electronic device, including a memory and a processor. An executable code is stored in the memory. When the processor executes the executable code, the embodiments of the first aspect are implemented.
[0017] In a fourth aspect, an embodiment of the present invention provides a computer program product, which includes: computer program code. When the computer program code runs on a computer, the computer is caused to execute the method in the first aspect or any possible implementation manner of the first aspect.
[0018] In a fifth aspect, an embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed in a computer, the computer is caused to execute the embodiments of the first aspect.
[0019] The embodiments of the present invention at least have the following beneficial effects: In this application, by constructing a tree structure, the positions of similar product tracking chains on the tree are close. Therefore, even if there is an input error, it is easy to correct it through adjacent data during traceability, ensuring the accuracy and security of traceability. Each event is used as a leaf node. Corresponding to the food production process, it is a complete production chain. When the category to which the leaf node belongs is expanding and the centrality of the leaf node is strong, the production chain similarity between the leaf node and other leaf nodes should be adaptively adjusted so that the event corresponding to the leaf node is in a position close to most events. Therefore, when tracing the production chain of food, more node information in the event with a greater production chain similarity can be referred to, thereby realizing the adaptive adjustment of the support degree corresponding to each event to obtain the adaptive support degree of each event, and further improving the accuracy of food traceability. Description of the Drawings
[0020] 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.
[0021] Figure 1 The method flowchart of a food safety data traceability method provided by an embodiment of the present invention; Figure 2 The schematic diagram of the hierarchical clustering tree provided by an embodiment of the present invention; Figure 3 The system block diagram of a food safety data traceability system provided by an embodiment of the present invention. Detailed implementation manners
[0022] To further elaborate on the technical means and effects adopted by the present invention to achieve the predetermined invention purpose, the following, in combination with the drawings and preferred embodiments, details the specific implementation manners, structures, features and effects of a food safety data traceability method according to the present invention are described in detail as follows.
[0023] 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.
[0024] Among them, in the description of the embodiments of the present invention, unless otherwise specified, " / " means "or". For example, A / B can mean A or B. The "and / or" in the text is only a description of the association relationship of the associated objects, indicating that three relationships can exist. 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" means two or more than two.
[0025] Hereinafter, the terms "first" and "second" are only used for descriptive purposes and cannot be construed as implying or indicating relative importance or implicitly specifying 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.
[0026] 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.
[0027] The embodiments of the present invention will be described below in conjunction with the accompanying drawings. As can be known to those of ordinary skill in the art, with the development of technology and the emergence of new scenarios, the technical solutions provided by the embodiments of the present invention are equally applicable to similar technical problems.
[0028] The following specifically describes the specific solution of a food safety data traceability method provided by the present invention in conjunction with the accompanying drawings.
[0029] Please refer to Figure 1 , which shows a flowchart of the steps of a food safety data traceability method provided by an embodiment of the present invention. The method includes the following steps: Step S100, scan the identification of each food package to obtain the production chain of each food; wherein, the production chain is regarded as an event.
[0030] 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.
[0031] Since the food data generated by the same manufacturer is more similar in the processes of raw material collection, production, processing, and sales in the early stage, such as the raw material source area, etc.; and the differences are greater 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. Therefore, 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 method of constructing an FP-TREE is used to improve the process of tree construction.
[0032] 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, the food traceability is improved based on this algorithm.
[0033] Since FP-TREE reflects a similarity at the hierarchical level, the embodiments of the present invention first obtain this similarity through hierarchical analysis, and then adjust it in the FP-TREE according to the actual element arrangement to obtain the adjusted FP-TREE, which helps to divide more matters with similar paths in the front into one block at the hierarchical structure, thereby helping to detect anomalies during subsequent traceability and repair a certain node of the abnormal data through the traceability results of adjacent data.
[0034] Since the analysis of the present invention realizes food traceability based on food data, each food package label is first scanned to identify the production chain corresponding to each food. Each production chain is 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 type of production chain data.
[0035] Step S200: Based on each item, construct a hierarchical clustering tree. 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 classified into the same category to construct a category quantity sequence corresponding to each item. The category quantity sequence is arranged in ascending order of quantity.
[0036] Take each item as the basic element of the analytic hierarchy process, and obtain the hierarchical clustering tree for each item through the bottom-up agglomerative clustering analytic hierarchy process.
[0037] For each leaf node of the hierarchical clustering tree, where the leaf node corresponds to each item, the upper-level node of the 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 2 In it, A, B, C, D, E, F, BC, BCD, BCDEF, ABCDEF, EF are all leaf nodes. For example, Figure 2 in it, the upper-level leaf node of node B is leaf node BC, and the upper-level leaf node of that is leaf node BCD. It should be noted that Figure 2 in it, leaf node BC, leaf node BCD, leaf node BCDEF, and leaf node ABCDEF are all upper-level leaf nodes of leaf node B.
[0038] Obtain the upper-level leaf nodes of the leaf nodes corresponding to each item in the hierarchical clustering tree, and construct a category sequence corresponding to each item. More specifically: for the leaf nodes corresponding to each item, take 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 item.
[0039] For example, for item A1, the leaf node corresponding to item A1 is BC. The upper-level nodes corresponding to leaf node BC are leaf node BCD, leaf node BCDEF, and leaf node ABCDEF. Then the category sequence corresponding to leaf node BC is {leaf node BCD, leaf node BCDEF, leaf node ABCDEF}.
[0040] Meanwhile, the number of elements in each category can be obtained, and the sequence formed by the number of elements in the category sequence 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 sequence corresponding to each matter, and the elements in the category quantity sequence are arranged in ascending order of quantity. In the embodiment of the present invention, it is defined that the elements in the category quantity sequence are arranged in ascending order.
[0041] 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.
[0042] In the bottom-up agglomerative clustering hierarchical analysis method, for a single node, when the category to which the node belongs expands, if the centrality or category representativeness of the node is relatively strong, the similarity between the node and other nodes should be set larger, so that 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, a 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.
[0043] Therefore, first, analyze the similarity between different nodes in the hierarchical clustering tree to determine the production chain similarity of each matter.
[0044] 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.
[0045] Calculate the similarity between the matter and other matters in the corresponding category sequence as the centrality of the matter. More specifically: take any matter as the target matter, and in each category sequence to which the target matter belongs, calculate the cosine similarity between the target matter and each matter in the category sequence, and take the sum of the similarities as the centrality of the target matter.
[0046] Take the ratio of the centrality and the expansion degree as the production chain similarity of the matter.
[0047] Record the bottom layer of the hierarchical clustering tree as the first layer, and successively upwards are: the second layer, the third layer...
[0048] As an embodiment of the present invention, it is also possible to calculate the similarity between the leaf node of an event and the sibling leaf nodes having the same upper-level leaf node in the hierarchical clustering tree to obtain a candidate similarity. When the candidate similarity is greater than the production chain similarity, the candidate similarity is updated as the new production chain similarity.
[0049] Step S400: 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.
[0050] The adaptive support degree of the event corresponding to the leaf node is obtained by the method of weighted summation of the production chain similarity and the frequency. Therefore, the respective weights need to be obtained first.
[0051] If comparing the ranking of the production chain similarity of an event with the ranking of the frequency, and the production chain similarity is larger, then a smaller weight is assigned to the similarity; otherwise, a larger weight is assigned to the similarity.
[0052] The production chain similarities of all events are calculated, and a production chain similarity sequence is constructed from the production chain similarities of all events; the frequencies of occurrence of all events are statistically obtained, and an event occurrence frequency sequence is constructed from the frequencies of occurrence of all events.
[0053] Among them, both the production chain similarity sequence and the event occurrence frequency sequence are numerically arranged according to the same rule. In the embodiment of the present invention, the production chain similarity sequence and the event occurrence frequency sequence are respectively arranged in descending order.
[0054] For each event, determine the similarity weight and frequency weight of the event according to the order values of the event in the production chain similarity sequence and the event occurrence frequency sequence respectively.
[0055] In some embodiments, calculate the absolute value of the difference between the order values of the event in the production chain similarity sequence and the event occurrence frequency sequence. Perform a negatively correlated normalization mapping on the absolute value of the difference to obtain the similarity weight.
[0056] 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 event in the production chain similarity sequence and the event occurrence frequency sequence. It should be noted that the absolute value of the difference is the absolute value of the difference.
[0057] Take the difference between the constant 1 and the similarity weight as the frequency weight of the event.
[0058] Based on the similarity weight and the frequency weight, respectively weight the production chain similarity corresponding to the event and the event occurrence frequency to obtain the adaptive support degree corresponding to the event.
[0059] In some embodiments, the method for obtaining the adaptive support degree is as follows: weighting the production chain similarity by the similarity weight to obtain the first support degree; weighting the occurrence frequency of the matter by the frequency weight to obtain the second support degree; taking the sum of the first support degree and the second support degree as the adaptive support degree corresponding to the matter.
[0060] Step S500, construct an FP tree corresponding to the production chain of the food according to the adaptive support degree corresponding to each matter.
[0061] 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 adaptive FP tree in sequence.
[0062] Data traceability can be effectively carried out through the corrected FP tree, which can effectively track the flow path of data in the system, 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: Data source identification: By analyzing the FP tree, it is possible to identify the sources from which the data was initially generated, which is crucial for understanding the original background and context of the data.
[0063] Data flow monitoring: When data flows through different systems and components, the FP tree can help track the flow path of the data, ensuring the integrity and consistency of the data during transmission.
[0064] Data access control: Using 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.
[0065] 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: An identification module, configured to scan the identifier of each food package to obtain the production chain of each food; wherein, the production chain is used as a matter. A leaf node division module, configured to construct a hierarchical clustering tree based on each matter, and each leaf node of the hierarchical clustering tree is a matter; divide the leaf node of each matter and the upper-level leaf nodes in the hierarchical clustering tree into the same category, and construct a category quantity sequence corresponding to each matter; wherein, the category quantity sequence is arranged in the order of the quantity size. A production chain comparison module, which is used to compare adjacent elements in the category quantity sequence to obtain the category expansion degree; determine the centrality of an event according to the similarity between the event and other events in the corresponding category sequence; combine the category expansion degree and the centrality to determine the production chain similarity of the event. A support degree adjustment module, which is used to combine the production chain similarity of an event and the frequency of occurrence of the event to determine the adaptive support degree corresponding to each event. An FP tree generation module, which is used to construct an FP tree corresponding to the production chain of food according to the adaptive support degree corresponding to each event.
[0066] Optionally, the transmission medium can be a wired link, such as but not limited to, coaxial cable, optical fiber, digital subscriber line, etc., or a wireless link, such as but not limited to, Wireless Fidelity (WIFI), Bluetooth, mobile device network, etc.
[0067] 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.
[0068] 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 introduced above.
[0069] In addition, an embodiment of the present invention also protects a device, which may include a memory and a processor. Among them, an 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.
[0070] 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 integrate two or more functions 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.
[0071] 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 embodiments can be cited in the function descriptions of the corresponding functional modules, and will not be elaborated here.
[0072] It should be understood that the device provided in the embodiments of the present invention is used to execute the above-mentioned food safety data traceability method, so the same effects as the above implementation method can be achieved.
[0073] 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 connection 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.
[0074] In addition, the device provided in the embodiments 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 the above-mentioned food safety data traceability method provided in the above embodiments.
[0075] The embodiments of the present invention also provide 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-mentioned relevant method steps to implement the food safety data traceability method provided in the above embodiments.
[0076] The embodiments of the present invention also provide a computer program product. When the computer program product runs on a computer, the computer is enabled to execute the above-mentioned relevant steps to implement the food safety data traceability method provided in the above embodiments.
[0077] Among them, the device, computer-readable storage medium, computer program product, or chip provided by the embodiments of the present invention are all used to execute the corresponding methods provided above. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding methods 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 conciseness 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.
[0078] 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 coupling or direct coupling or communication connection between each other can be through some interfaces. The indirect coupling or communication connection of the device or unit can be in an electrical, mechanical or other form.
[0079] 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 explicitly listed, or also includes elements inherent to such a process, method, article or terminal device. Without further limitation, the 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.
[0080] It should be noted that the above sequence of the 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 continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0081] Each embodiment in this specification is described in a progressive manner. The same or similar parts between each embodiment can be referred to each other, and the key points of each embodiment are the differences from other embodiments.
[0082] The above content 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 comprises the following steps: Scan the logo of each food package to obtain the production chain of each food; wherein the production chain is taken as a matter; A hierarchical clustering tree is constructed based on each item, wherein each leaf node of the hierarchical clustering tree is an item; the leaf node of each item and the upper leaf node in the hierarchical clustering tree are classified into the same category, and a category quantity sequence corresponding to each item is constructed; wherein the category quantity sequence is arranged in order of quantity; Compare adjacent elements in the category quantity sequence to obtain the category expansion degree; determine the centrality of the matter based on the similarity between the matter and other matters in the corresponding category sequence; and determine the production chain similarity of the matter by combining the category expansion degree and the centrality; Determine the adaptive support corresponding to each item by combining the production chain similarity of the item and the frequency of occurrence of the item; The method for determining the adaptive support is as follows: obtaining the production chain similarity sequence and the event frequency sequence constructed by all events; wherein the production chain similarity sequence and the event frequency sequence are numerically arranged according to the same rule; for each event, according to the order value of the event in the production chain similarity sequence and the event frequency sequence, the similarity weight and frequency weight of the event are determined; based on the similarity weight and frequency weight, the production chain similarity and event frequency corresponding to the event are weighted respectively to obtain the adaptive support corresponding to the event; According to the adaptive support corresponding to each item, the FP tree corresponding to the food production chain is constructed.
2. A food safety data traceability method according to claim 1, characterized in that: The hierarchical clustering tree is constructed based on each of the items, wherein each leaf node of the hierarchical clustering tree is an item, including: Hierarchical clustering with bottom-up agglomerative clustering is used to construct an equal-order clustering tree, in which each event includes multiple production chain data.
3. A food safety data traceability method according to claim 1, characterized in that: The step of classifying the leaf nodes of each item and the upper leaf nodes in the hierarchical clustering tree into the same category and constructing a sequence of the number of categories corresponding to each item includes: Obtain the upper leaf node of the leaf node corresponding to each item in the hierarchical clustering tree, and construct a category sequence corresponding to each item; construct a category quantity sequence from the number of elements in the category sequence 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 order of quantity.
4. A food safety data traceability method according to claim 3, characterized in that: The step of obtaining the leaf nodes corresponding to each event from the upper leaf nodes in the hierarchical clustering tree and constructing the category sequence corresponding to each event includes: For each leaf node corresponding to an event, each upper leaf node of the leaf node in the hierarchical clustering tree is used as a sequence element to construct a category sequence corresponding to each event.
5. A food safety data traceability method according to claim 1, characterized in that: The step of 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 degree of category expansion.
6. A food safety data traceability method according to claim 1, characterized in that: Determining the centrality of an item based on the similarity between the item and other items in the corresponding category sequence includes: The similarity between an item and other items in the corresponding category sequence is calculated as the centrality of the item.
7. A food safety data traceability method according to claim 1, characterized in that: The combining of the category expansion degree and the centrality to determine the production chain similarity of the matter includes: The ratio of the centrality to the category expansion degree is taken as the production chain similarity of the matter.
8. A food safety data traceability method according to claim 1, characterized in that: The combining of the category expansion degree and the centrality to determine the production chain similarity of the matter further includes: The similarity between the leaf node of the item and the leaf node of the same layer with the same upper leaf node in the hierarchical clustering tree is calculated to obtain the candidate similarity. When the candidate similarity is greater than the production chain similarity, the candidate similarity is updated to 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, the production chain similarity and the occurrence frequency of the items corresponding to the items are weighted respectively to obtain the adaptive support corresponding to the items, including: Weighting the similarity of the production chain by the similarity weight to obtain a first support degree; The occurrence frequency of the items is weighted by the frequency weight to obtain the second support degree; The sum of the first support and the second support is used as the adaptive support corresponding to the item.
Citation Information
Patent Citations
Domain knowledge-based multilayer association rules mining method and system
CN104281617A
Abnormal network security event identification method based on FP-Growth algorithm
CN116389036A
Tracing method for informatization management of hazardous wastes
CN118410213A
Bank order data processing method and device
CN118484733A
Power grid fault power protection maintenance plan making method, device, equipment and medium
CN118504939A