Drug resistance monitoring and medication decision-making method and system based on machine learning and knowledge graph
By using machine learning and knowledge graph technologies, the problems of scattered multi-source data and insufficient identification of drug resistance in broiler farming have been solved. This has enabled unified governance and comparability of drug resistance monitoring results, improved the accuracy and feasibility of medication decisions, and reduced the risk of drug resistance and food safety hazards.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- JIANGSU INST OF POULTRY SCI
- Filing Date
- 2026-04-16
- Publication Date
- 2026-06-16
AI Technical Summary
In broiler farming, existing technologies suffer from inconsistent and scattered multi-source data, making it difficult to form stable and comparable drug resistance monitoring sequences across batches and farms. The ability to identify drug resistance trends is insufficient, and monitoring results are difficult to translate into actionable medication decisions.
By acquiring multi-source aquaculture data, performing field standardization, unit conversion, encoding mapping, and missing data labeling, a temporal heterogeneous graph based on machine learning and knowledge graph is constructed. Self-supervised representation learning and attention message passing are used to generate drug resistance risk prediction results. Combined with drug use knowledge graph and rule set, a list of recommended, caution-to-use, and prohibited drugs is output.
It has achieved unified governance and improved comparability of multi-source data, enhanced the accuracy of drug resistance trend identification and early warning, transformed into actionable and interpretable medication decisions, and reduced the risk of drug resistance aggravation and food safety.
Smart Images

Figure CN122224409A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of intelligent analysis of livestock and poultry breeding data, and in particular to a method and system for drug resistance monitoring and medication decision-making based on machine learning and knowledge graphs. Background Technology
[0002] Antimicrobial drugs are widely used in broiler farming for the prevention and treatment of bacterial diseases. Changes in drug resistance in common pathogens such as Escherichia coli directly affect treatment efficacy and medication costs, and may lead to drug residues and food safety risks. Current technologies for monitoring bacterial resistance typically employ drug sensitivity testing methods such as disk diffusion and broth dilution, outputting results for sensitivity, intermediate, and resistance, or minimum inhibitory concentration (MIC) values. Regarding data management, some testing institutions and large-scale farming enterprises have deployed laboratory information management systems, farming management systems, and environmental monitoring systems to record test results, sampling information, medication records, batch information, and environmental indicators. Simultaneously, statistical reports, trend charts, and predictive analysis tools based on historical data for drug resistance analysis are gradually emerging. In some scenarios, machine learning is being explored for drug resistance risk assessment, combined with medication guidelines or contraindications information to verify medication compliance.
[0003] However, the aforementioned existing technologies still have shortcomings in practical applications in broiler farming, mainly in the following aspects:
[0004] 1. Inconsistent and scattered data from multiple sources: Detection data, sampling information, medication records, batch and site environmental data often come from different sources. Field naming, coding systems, units and time formats are inconsistent, and entity names have aliases and spelling differences, making it difficult to automatically aggregate data and conduct long-term rolling comparisons. It is difficult to form a stable and comparable monitoring sequence across batches and sites for drug resistance results.
[0005] 2. Insufficient ability to identify drug resistance trends: Existing analyses mostly rely on summaries and statistics based on time or drug, making it difficult to identify trends in drug resistance profiles and the risk of multiple drug resistance in the context of multi-entity associations and temporal evolution, thus limiting the timeliness and accuracy of early warnings.
[0006] 3. Monitoring results are difficult to translate into actionable medication decisions: The test results are often disconnected from medication knowledge such as contraindications, withdrawal periods, drug interactions, indications and dosage constraints. This makes it difficult to form a clear list of recommendations, precautions and prohibitions, and there is a lack of traceable explanatory basis, so it is still easy to rely on experience-based medication or non-standard medication.
[0007] Therefore, there is a need for a method and system for drug resistance monitoring and medication decision-making that can address the shortcomings of the existing technologies. Summary of the Invention
[0008] One objective of this invention is to propose a method and system for drug resistance monitoring and medication decision-making based on machine learning and knowledge graphs. Addressing the problems in existing technologies where drug sensitivity testing and minimum inhibitory concentration (MIC) testing data, sampling information, medication records, batch information, and farm environmental data are scattered and inconsistent across multiple sources, making it difficult to conduct long-term rolling comparisons of drug resistance results, identify changes in drug resistance profiles and multidrug resistance risks in a timely manner, and translate drug resistance monitoring results into actionable medication recommendations, the following technical solution is proposed: Acquire multi-source farming data and form a raw dataset; perform field standardization, unit conversion, encoding mapping, and missing data labeling on the raw data... Standardized data is obtained; record representations are acquired based on self-supervised representation learning; candidate retrieval and entity alignment are performed on entity mentions to generate an alignment result dataset containing candidate entity sets and confidence scores; a temporal heterogeneous graph with timestamp attributes is constructed based on the alignment results, and candidate alignment edges are built between anchor nodes and candidate entity nodes with confidence scores as edge weights; the temporal heterogeneous graph is input into a temporal heterogeneous graph representation learning model, and attention message passing is modulated using confidence gating to output drug resistance risk prediction results; a drug use knowledge graph and rule set are constructed, and rule-constrained fusion reasoning is performed on candidate drug use schemes to output a recommendation list, a caution list, a prohibition list, and explanatory information. This invention has the technical effects of improving the comparability and usability of multi-source data, enhancing the ability to assess and warn of drug resistance evolution risks, and transforming prediction results into interpretable and executable drug use decisions.
[0009] This invention provides a method for drug resistance monitoring and medication decision-making based on machine learning and knowledge graphs, including:
[0010] S1. Acquire multi-source breeding data corresponding to the target broiler breeding scenario and aggregate them to form a raw dataset; S2. Standardize the raw dataset to obtain standardized data, input it into a representation learning model to obtain record representations, perform entity alignment on entity mentions in the standardized data, determine a candidate entity set for each entity mention, and generate a confidence score for each candidate entity to form an alignment result dataset; S3. Construct a time-series heterogeneous graph with timestamp attributes based on the alignment result dataset, determine the corresponding anchor node for each entity mention, determine candidate entity nodes for each candidate entity, construct candidate alignment edges between anchor nodes and candidate entity nodes, and write the corresponding confidence scores into the edge weights of the candidate alignment edges. Attributes; S4. Input the temporal heterogeneous graph into the temporal heterogeneous graph representation learning model, update the node representation through attention-based message passing, determine the gating coefficient for each edge in the temporal heterogeneous graph based on the edge weight attribute, perform gating modulation on the attention weight corresponding to the edge to obtain the gating message passing weight, and output the drug resistance risk prediction result based on the updated node representation; S5. Construct a drug knowledge graph and the corresponding rule set; S6. Input the drug resistance risk prediction result, drug knowledge graph and rule set into the fusion reasoning module, perform associated knowledge retrieval based on the drug knowledge graph, perform rule constraint reasoning on candidate drug regimens, and output drug decision information, including a recommendation list, a caution list and a prohibition list.
[0011] Optionally, S1 includes:
[0012] The drug susceptibility test data and minimum inhibitory concentration (MIC) test data of Escherichia coli are obtained from the detection data source, wherein the detection data includes sample identification information, strain identification information, drug identification information, test result information, and test time information;
[0013] The sampling information, medication records, and batch information are obtained from the aquaculture management data source. The sampling information includes sampling time, sampling site or sample type, batch identification information corresponding to the sampling, and farm identification information corresponding to the sampling. The medication records include medication time, drug identification information, administration route, dosage, and administration duration. The batch information includes batch identification information, age information, and pen identification information.
[0014] The site environmental data is obtained from an environmental data source, wherein the site environmental data includes environmental indicator values and collection time corresponding to the site identification information;
[0015] The acquired multi-source aquaculture data are appended with source identifiers and collection times according to the record level, and then aggregated to form the original dataset.
[0016] Optionally, S2 includes:
[0017] The original dataset is subjected to field standardization processing, which includes standardization of drug name, strain name, site identification information, batch identification information, and time format.
[0018] The original dataset is processed by unit conversion to convert the relevant values of the detection results and medication-related values into a preset unified unit;
[0019] The original dataset is subjected to encoding mapping processing to map drug codes, field codes, batch codes, and pen codes to a preset unified code;
[0020] The original dataset is processed by missing field labeling to obtain the standardized data. The standardized data is then input into the self-supervised learning model, which outputs the record representation. For each entity mention in the standardized data, a candidate entity set is retrieved from the candidate entity library based on the record representation. The candidate entity library consists of entities already existing in the standardized data and a pre-configured alias mapping table. For each candidate entity in the candidate entity set, a confidence score is calculated based on the record representation, and a corresponding confidence score evidence chain is generated. The confidence score evidence chain includes name similarity evidence, unit consistency evidence, time consistency evidence, and field consistency evidence. The candidate entity set, the confidence score, and the confidence score evidence chain are associated and stored with the entity mentions to form the alignment result dataset.
[0021] Furthermore, when calculating the confidence score for each candidate entity in the candidate entity set, the method further includes: calculating a data quality score corresponding to the record mentioned by the entity, wherein the data quality score is determined based on the number of missing markers, the number of modifications to field specification processing, and the data source reliability score; using the data quality score and the confidence evidence chain together to obtain the calibrated confidence score, and writing the calibrated confidence score as the edge weight attribute of the candidate alignment edge.
[0022] Optionally, S3 includes:
[0023] Based on the alignment result dataset, duplicates and type labels are applied to sample identification information, strain identification information, drug identification information, medication record, test record, batch identification information, and site identification information, respectively, to generate sample nodes, strain nodes, drug nodes, medication event nodes, test event nodes, batch nodes, and site nodes.
[0024] The detection event node is determined by sample identification information, strain identification information, drug identification information, detection result information, and detection time information in the same detection record. The node characteristics of the detection event node include at least one of drug sensitivity detection results and minimum inhibitory concentration (MIC) detection results. Based on the field environmental data, multiple environmental observation records are divided according to collection time. An environmental observation node is generated for each environmental observation record. The node characteristics of the environmental observation node include environmental index values. Field-to-environmental observation association edges are constructed between field nodes and environmental observation nodes, and a timestamp attribute corresponding to the collection time is set for each environmental observation node. Edges are generated based on the association relationships between records in the alignment result dataset, and the edges are labeled with their types. The edges include sample-to-strain association edges, detection event-to-sample association edges, detection event-to-strain association edges, detection event-to-drug association edges, medication event-to-drug association edges, medication event-to-batch association edges, and batch-to-field association edges.
[0025] The medication event node is determined by the medication time, drug identification information, route of administration, dosage, and duration of administration in the same medication record; a timestamp attribute for sampling time is set for the sample node, a timestamp attribute for detection time is set for the detection event node, and a timestamp attribute for medication time is set for the medication event node, so that all nodes and edges in the initial temporal heterogeneous graph contain timestamp attributes; for each entity mention in the alignment result dataset, an anchor node corresponding to the record containing the entity mention is determined, and the anchor node is at least one of the sample node, medication event node, detection event node, batch node, and field node;
[0026] The top M candidate entities with the highest confidence are retained to determine the top M candidate entity nodes, and the top M candidate alignment edges between the anchor node and the top M candidate entity nodes are constructed, where M is an integer greater than or equal to 2; the confidence corresponding to the candidate alignment edge is written into the edge weight attribute of the candidate alignment edge.
[0027] The confidence evidence chain is encoded into the edge feature vector of the candidate aligned edge, and the edge feature vector includes name similarity feature, unit consistency feature, time consistency feature and field area consistency feature; thus, the initial temporal heterogeneous graph is obtained.
[0028] Optionally, S4 includes:
[0029] The initial temporal heterogeneous graph is input into the temporal heterogeneous graph Transformer model, and the initial node representation of each node is initialized based on the node features of each node, the edge type of each edge, and the timestamp attribute in the initial temporal heterogeneous graph.
[0030] For each edge in the initial temporal heterogeneous graph, the attention weight of the edge is calculated based on the node representation of the source node connected by the edge, the node representation of the target node, and the edge type. For each edge in the initial temporal heterogeneous graph, the edge weight attribute of the edge is read, and the edge weight attribute is mapped to the edge through a preset gating function to obtain the gating coefficient of the edge. The preset gating function is a monotonic mapping function, which includes at least one of the Sigmoid function, a piecewise linear function, and a normalization function.
[0031] When the edge weight attribute is less than a preset threshold, the corresponding gating coefficient is set to 0 or less than a preset decay value to suppress message transmission of low confidence edges; for each edge in the initial temporal heterogeneous graph, the attention weight of the edge and the gating coefficient of the edge are multiplied and fused to obtain the unnormalized gating message transmission weight of the edge.
[0032] For all connected edges of the same target node, the unnormalized gated message passing weights of each edge are summed to obtain a weight sum value. The unnormalized gated message passing weights of each edge are then divided by the weight sum value to obtain the gated message passing weights corresponding to each edge. According to the time order determined by the timestamp attribute, the adjacent node representations of each node are weighted and aggregated based on the gated message passing weights to obtain the aggregated representation of each node. The node representation of each node is then updated based on the aggregated representation to obtain the updated node representation.
[0033] The updated node representation is input into the prediction layer to obtain the target prediction result, wherein the target prediction result includes drug resistance risk score by drug dimension, drug resistance spectrum change risk score and multidrug resistance risk score;
[0034] The drug resistance spectrum change risk score is the difference or divergence value between the drug resistance risk score vectors of multiple drugs corresponding to the target strain within the first time window and the second time window. The divergence value includes at least one of Kullback-Leibler divergence, Jensen-Shannon divergence, and cosine distance.
[0035] The multidrug resistance risk score is the probability or count of the target strain's resistance risk score to at least K drugs or at least K drug classes being greater than a preset threshold, where K is an integer greater than or equal to 2.
[0036] Optionally, S5 includes:
[0037] Acquire medication knowledge data, including drug information, drug category information, indication information, contraindication information, withdrawal period information, and drug interaction information; construct a medication knowledge graph based on the medication knowledge data, wherein drugs, drug categories, indications, contraindications, withdrawal periods, and drug interactions are respectively constructed as corresponding entities, and the subordinate relationships between drugs and drug categories, the correspondence between drugs and indications, the constraint relationships between drugs and contraindications, the constraint relationships between drugs and withdrawal periods, and the interaction relationships between drugs are constructed as corresponding relationships; generate a rule set based on the medication knowledge graph, wherein the contraindication information is mapped to prohibition rules, the withdrawal period information is mapped to withdrawal period constraint rules, the drug interaction information is mapped to combination drug use constraint rules, and dosage constraint rules and caution rules are generated based on the drug information and the indication information; output the medication knowledge graph and the rule set.
[0038] Optionally, S6 includes:
[0039] The target prediction results are parsed into a set of candidate drug regimens, where each candidate drug regimen includes drug identification information and a corresponding drug resistance risk score;
[0040] Based on the medication knowledge graph, for each candidate medication regimen in the candidate medication regimen set, the drug category entity, indication entity, contraindication entity, withdrawal period entity, and drug interaction entity corresponding to the drug identification information are retrieved, and the association path corresponding to the candidate medication regimen is generated.
[0041] The candidate drug regimen set, the associated path, and the rule set are input into the fusion reasoning module. Rule constraint reasoning is performed on the candidate drug regimen set according to the rule set, including: determining the infeasibility of the candidate drug regimen set based on the prohibition rule and the withdrawal period constraint rule to determine the prohibition list;
[0042] Based on the rules of caution and the rules of combination therapy, risk constraints are assessed on candidate drug regimens that have not been deemed infeasible in order to determine a list of drugs to be used with caution.
[0043] For candidate drug regimens not included in the prohibited list and the cautious use list, a recommended list is determined based on the efficacy of the indication and the drug resistance risk score; the drug decision information is output, wherein the drug decision information includes the recommended list, the cautious use list and the prohibited list, and the drug decision information also includes explanatory information, wherein the explanatory information includes knowledge graph association path information corresponding to the candidate drug regimen and the hit rule identification information; the rule constraint reasoning performed by the fusion reasoning module includes at least one of knowledge graph-based path retrieval reasoning, constraint satisfaction-based feasibility determination and score fusion based on differentiable rule constraints.
[0044] Furthermore, the rule-constrained reasoning performed by the fusion reasoning module also includes: using the prohibition rule and the withdrawal period constraint rule as hard constraints, determining the feasibility of each candidate drug regimen, and including candidate drug regimens that violate the hard constraints in the prohibition list; using the caution rule, the dosage constraint rule, and the combination drug constraint rule as soft constraints, calculating rule penalty values for candidate drug regimens that are not determined to violate the hard constraints; calculating a comprehensive recommendation score for candidate drug regimens based on the drug resistance risk score, indication matching score, and rule penalty values, and generating the recommendation list according to the comprehensive recommendation scores;
[0045] The comprehensive recommendation score is obtained by weighting and fusing the drug resistance risk score with the indication matching score after monotonic transformation, and then subtracting the rule penalty value; the rule identification information of the rule that violates the hard constraint and the rule identification information that generates the rule penalty value are written into the explanation information.
[0046] On the other hand, the present invention also provides a drug resistance monitoring and medication decision-making system based on machine learning and knowledge graphs, including:
[0047] The data acquisition module is used to acquire multi-source aquaculture data and aggregate it to form a raw dataset;
[0048] The standardization and alignment module is used to standardize the original dataset to obtain standardized data, obtain record representations, and perform entity alignment on entity references to generate an aligned result dataset.
[0049] The graph construction module is used to construct a time-series heterogeneous graph with timestamp attributes based on the alignment result dataset, and to construct candidate alignment edges between anchor nodes and candidate entity nodes, and to write the confidence score into the edge weight attribute of the candidate alignment edges.
[0050] The graph learning prediction module is used to input the temporal heterogeneous graph into the temporal heterogeneous graph representation learning model, determine the gating coefficients based on the edge weight attributes to gating the attention weights, and output the drug resistance risk prediction results.
[0051] The knowledge graph rules module is used to construct a medication knowledge graph and rule set;
[0052] The fusion reasoning output module is used to input drug resistance risk prediction results, drug knowledge graph and rule set into the fusion reasoning module, and output drug decision information, which includes a recommendation list, a caution list and a prohibition list.
[0053] The beneficial effects of this invention are:
[0054] 1. Achieve unified governance and improved comparability of multi-source data: By standardizing fields, converting units, mapping codes and marking missing data, and combining the entity alignment mechanism of self-supervised representation learning, candidate entity sets and confidence scores are generated. This ensures that the references of key entities such as drugs, strains, fields, and batches are unified across data sources and time records, thereby supporting long-term rolling comparison and traceability analysis of drug resistance results across different batches and fields, and reducing errors caused by manual cleaning and inconsistent standards.
[0055] 2. Improve the accuracy and robustness of drug resistance situation identification and prediction: The uncertainty of entity alignment is written into the temporal heterogeneous graph as candidate alignment edges and their confidence, and the attention message passing is modulated by confidence gating in the temporal heterogeneous graph representation learning to suppress the noise propagation of low confidence edges, thereby more stably depicting the drug resistance evolution process and improving the assessment and early warning effect of drug resistance risk, drug resistance spectrum change risk and multidrug resistance risk by drug dimension.
[0056] 3. Transform drug resistance monitoring results into actionable and interpretable medication decisions: By constructing a medication knowledge graph and rule set that includes contraindications, withdrawal periods, drug interactions, indications, and dosage constraints, rule-constrained fusion reasoning is performed on the predicted candidate medication regimens to automatically generate recommended lists, caution lists, and prohibited lists, and output explanations of the hit rules and associated paths, thereby reducing experience-based or non-standard medication use, reducing the risks of drug resistance aggravation, drug residues, and food safety, and helping to control medication costs. Attached Figure Description
[0057] The accompanying drawings are provided to further illustrate the invention and form part of the specification. They are used in conjunction with embodiments of the invention to explain the invention and do not constitute a limitation thereof. In the drawings:
[0058] Figure 1 This is a flowchart of the drug resistance monitoring and medication decision-making method based on machine learning and knowledge graphs proposed in this invention;
[0059] Figure 2 This is a detailed flowchart of step S4, drug resistance risk prediction, of the present invention.
[0060] Figure 3A detailed flowchart for constructing the timing heterogeneity graph in step S3 of this invention is provided. Detailed Implementation
[0061] The present invention will now be described in further detail with reference to the accompanying drawings. These drawings are simplified schematic diagrams, illustrating only the basic structure of the invention, and therefore only show the components relevant to the invention.
[0062] refer to Figure 1 A method for drug resistance monitoring and medication decision-making based on machine learning and knowledge graphs, characterized by including:
[0063] S1. Acquire multi-source breeding data corresponding to the target broiler breeding scenario and aggregate them to form a raw dataset; S2. Standardize the raw dataset to obtain standardized data, input it into a representation learning model to obtain record representations, perform entity alignment on entity mentions in the standardized data, determine a candidate entity set for each entity mention, and generate a confidence score for each candidate entity to form an alignment result dataset; S3. Construct a time-series heterogeneous graph with timestamp attributes based on the alignment result dataset, determine the corresponding anchor node for each entity mention, determine candidate entity nodes for each candidate entity, construct candidate alignment edges between anchor nodes and candidate entity nodes, and write the corresponding confidence scores into the edge weights of the candidate alignment edges. Attributes; S4. Input the temporal heterogeneous graph into the temporal heterogeneous graph representation learning model, update the node representation through attention-based message passing, determine the gating coefficient for each edge in the temporal heterogeneous graph based on the edge weight attribute, perform gating modulation on the attention weight corresponding to the edge to obtain the gating message passing weight, and output the drug resistance risk prediction result based on the updated node representation; S5. Construct a drug knowledge graph and the corresponding rule set; S6. Input the drug resistance risk prediction result, drug knowledge graph and rule set into the fusion reasoning module, perform associated knowledge retrieval based on the drug knowledge graph, perform rule constraint reasoning on candidate drug regimens, and output drug decision information, including a recommendation list, a caution list and a prohibition list.
[0064] In this specific embodiment, S1 includes:
[0065] The data acquisition module, deployed on the local server of the farm, establishes fixed connections with the detection data source, the aquaculture management data source, and the environmental data source, and performs incremental retrieval at a fixed collection cycle of 10 minutes. The incremental retrieval uses the auto-incrementing primary key or business time field of each data source as the water level marker and updates the water level marker after each successful data entry. If each retrieval fails, it will be retried 3 times with a fixed number of retries and the reason for failure will be recorded for traceability.
[0066] The detection data source is a laboratory information management system, whose output detection data simultaneously covers E. coli drug susceptibility testing data and minimum inhibitory concentration (MIC) testing data. Each detection record includes at least sample identification information, strain identification information, drug identification information, test result information, and test time information. The sample identification information uniquely identifies the sample obtained in a single sampling; the strain identification information uniquely identifies the strain isolated from the sample; the drug identification information uniquely identifies the antimicrobial drug used in the test; and the test result information is given in at least one form of drug susceptibility testing result or MIC test result, and each is presented as a discrete value set. In addition to numerical concentration representation, detection time information is used to indicate the time when the corresponding business occurred;
[0067] The data source for aquaculture management is the aquaculture management system. The sampling information, medication records, and batch information output by the system are stored and retrieved separately at the record level. The sampling information includes the sampling time, sampling site or sample type, batch identification information corresponding to the sampling, and farm identification information corresponding to the sampling. The medication record includes the medication time, drug identification information, route of administration, dosage, and duration of administration. The batch information includes the batch identification information, age information, and pen identification information. All of the above time fields retain their original accuracy as the time of business occurrence and are uniformly recorded in Beijing time UTC+8.
[0068] The environmental data source is an environmental monitoring system. The environmental data of the site area output by the system is organized according to the site identification information and the environmental index values and the collection time constitute an environmental observation record. The environmental index values are recorded in the form of key-value pairs, including temperature, humidity, ammonia concentration and carbon dioxide concentration, while maintaining the original units and original decimal precision. The collection time is used to represent the time when the service occurs on the environmental sensor side.
[0069] To meet the requirement of attaching source identifiers and collection times at different record levels, the data acquisition module generates and writes a source identifier and collection time before each record is entered into the database. The source identifier is used to uniquely identify the source system of the record and is taken from a fixed set of strings. Data sources for monitoring, aquaculture management, and environmental data. One of the features is the data collection time, which is used to record the system time when the current fetch action is completed and written to local storage, and is saved as a millisecond-level timestamp.
[0070] Ultimately, the multi-source aquaculture data are aggregated using a unified record encapsulation structure to form the original dataset, which is represented by a set as follows:
[0071] type payload ,sid ,ct ;
[0072] in Represents the original dataset. This represents the total number of records in the original dataset. Indicates a record index that satisfies Indicates the first 1 record Indicates the record type and is used to distinguish between test records, sampling records, medication records, batch records, and environmental observation records; payload Indicates and type The corresponding field payloads, and each field's content is fully represented by key-value pairs. This indicates the source identifier and is consistent with the source identifier field. The data collection time is indicated and is consistent with the data collection time field. The original dataset is stored in the local database in an append-only manner, and the original field values of each record are kept unmodified to ensure that subsequent steps can complete field standardization, unit conversion and encoding mapping based on the original standards.
[0073] In this specific embodiment, S2 includes:
[0074] The normalization and alignment module performs the normalization and alignment on the original dataset on the local server. To achieve this, each record is processed individually. Perform field specification processing to obtain specified field values and synchronously accumulate the number of field specification processing modifications. The drug name specification standardizes the drug name strings in the records into standard drug names according to the pre-set drug alias specification table and outputs standard drug identification information. The strain name specification standardizes the strain names into the format of "species name + isolation number" according to the pre-set strain naming rules and outputs standard strain identification information. The field identification information specification and batch identification information specification map the field names and batch names of different systems into unified field identification information and batch identification information according to the pre-set coding rules. The time format specification standardizes each time field into a millisecond-level Unix timestamp and keeps the time zone as Beijing time UTC+8 and sets the unparsed time fields as missing.
[0075] Then, unit conversion was performed on the recorded test results and medication-related values to obtain values with unified units. The minimum inhibitory concentration (MIC) test results were unified to [unit name missing]. The dosage is uniformly set as follows: The original unit and conversion factor are written into the audit field of the record to ensure traceability;
[0076] Then, code mapping processing is performed on drug code, field code, batch code, and pen code to map them to a preset unified code. The preset unified code is maintained by a central dictionary table and provides a definite mapping relationship of "source system code - unified code" in the form of key-value pairs.
[0077] Then, missing field marking is performed and the number of missing marks is accumulated. The missing data marker uses a fixed string <MIS> written into the corresponding field to explicitly distinguish between "empty value" and "field not found", thus obtaining standardized data and aggregating it into a standardized dataset. ;
[0078] Then the standardized dataset Input the self-supervised learning model to output a record representation for each record. The self-supervised learning model is a field sequence Transformer encoder, whose input consists of records. The field keys and values are concatenated in a fixed order and then segmented at the character level. The model structure includes two Transformer encoding layers, each with four attention heads, a hidden dimension of 128, a feedforward layer dimension of 256, and a Dropout rate of 0.1. Model training employs a contrastive learning objective, using two views of the same record as positive sample pairs. These two views are generated by performing a field masking operation on the field values at a predetermined ratio of 0.2, with the masking symbol being <MASK>. Training uses the Adam optimizer with a learning rate of [missing information]. The batch size is 256, the training rounds are 5, and the training is performed on a local server GPU. After training, the <CLS> position output vector of each record is taken as the record representation. ;
[0079] During the entity alignment phase, each entity mention in the standardized data is defined as... ,in Representing records The Middle A candidate entity library is constructed by identifying entity strings that need to be aligned, and the entity references cover four types of fields: drug identification information, strain identification information, site identification information, and batch identification information. For use in retrieving a set of candidate entities, the candidate entity library The dataset is obtained by merging two parts and using unified entity identification information for deduplication. The first part is a standardized dataset. The first part is a set of entities that have already appeared in the system, and stores the standard name, uniform code, first appearance time and last appearance time for each entity. The second part is a pre-configured alias mapping table, and stores the alias string, standard name and uniform code for each alias record to support cross-system alias merging.
[0080] For each entity mention The record containing the entity's mention will be represented. The query vector is formed by concatenating the character-level name vector mentioned by the entity and then entering it into the candidate entity database. Perform nearest neighbor retrieval in the vector index to return a set of candidate entities. The vector index is constructed from the entity vectors calculated by the same Transformer encoder as the records using the standard name and uniform code of the candidate entities, and is retrieved using cosine similarity, with a fixed number of 20 candidate entities returned.
[0081] For candidate entity set Each candidate entity in Generate a confidence-based evidence chain and calculate the calibrated confidence level, where the confidence-based evidence chain consists of name similarity features. Unit consistency characteristics Time consistency characteristics Consistency characteristics with the site area Composed of and all are intervals Determined numerical values within, name similarity features Mentioned by entity Canonical names and candidate entities The standard name is used to calculate the Jaccard similarity of character tuples, which is the unit consistency feature. When an entity mentions a field involving numerical units, the value is 1 if the "standardized record unit is consistent with the candidate entity's standard unit"; otherwise, it is 0. In fields not involving units, the value is consistently 1. This is a time consistency feature. To record Does the business timestamp fall within the candidate entity? First occurrence time and last occurrence time extended window The field area consistency characteristic is determined within one day and is 1 if it meets the condition, otherwise 0. To record Site identification information and candidate entities The value is 1 if the field area affiliation information is consistent, otherwise it is 0, and it is fixed at 0.5 when the candidate entity does not have field area affiliation information;
[0082] Simultaneously calculate the data quality score corresponding to the record mentioned by the entity. Data quality score Based on the number of missing markers Number of modifications in field specification processing and data source reliability score Determined and within the range Data source reliability score Source identifier written in step S1 Mapping obtained and When "detecting data source" and When serving as a "data source for aquaculture management" and When it is an "environmental data source" and will and Normalized to preset upper limits of 20 and 50 respectively and Linear fusion obtained This ensures that the data quality score decreases when the number of missing tags or modifications increases, and increases when the data source reliability score increases;
[0083] Based on this, for each pair Calculate the confidence level after calibration And it serves as the source of edge weights for subsequent S3 candidate alignment edges, and its calculation formula is as follows:
[0084] ;
[0085] in Indicates entity mention With candidate entities The calibrated confidence level and the range of values are This represents the Sigmoid function and is used to map linear scores to... Indicates the bias parameter and its value is This represents the weight of the name similarity feature and has a value of 2.0. Represents the unit consistency feature weight and takes the value of This represents the weight of the time consistency feature and its value is... This represents the weight of the field area consistency feature and its value is... This represents the weight of the data quality score and has a value of 1.0. Indicates name similarity features, Indicates the characteristic of unit consistency. Indicates time consistency characteristics. Indicates the consistency characteristics of the field area. Representing records Data quality score, Indicates a record index. This indicates that the entity within the record mentions the index. Indicates the candidate entity index;
[0086] Finally, each entity will be mentioned. The corresponding candidate entity set calibrated confidence level of each candidate entity and by and The confidence evidence chain, which together constitutes the entity mention, is stored in association with the entity mention information, and the alignment result dataset is formed with fields such as "entity mention identifier information, candidate entity identifier information, calibrated confidence level, confidence evidence chain, source identifier, and business timestamp". .
[0087] In this specific embodiment, S3 includes:
[0088] The graph building module is based on the aligned result dataset. With standardized datasets Constructing the initial temporal heterogeneous graph ,in This represents the initial temporal heterogeneous graph, with the subscript 0 indicating the initial state. Represents a set of nodes. Represents the set of edges;
[0089] The graph building module supports The sample identification information, strain identification information, drug identification information, batch identification information, and site identification information are deduplicated and type-labeled. The deduplication key is taken from the unified code corresponding to the sample identification information, strain identification information, drug identification information, batch identification information, and site identification information, respectively, and then classified accordingly. The system generates sample nodes, strain nodes, drug nodes, batch nodes, and field area nodes, and writes a node type label and a unique code for each node to ensure that the same node can be reused across records.
[0090] The graph building module supports Each detection record generates a detection event node. The unique key of the detection event node is the concatenated hash value of the sample identifier, strain identifier, drug identifier, and detection time information of that detection record. The node characteristics of the detection event node are fixed and include two parts: drug susceptibility test results and minimum inhibitory concentration (MIC) test results. The drug susceptibility test results are categorized as follows: Encoded as a three-dimensional One-Hot vector, the minimum inhibitory concentration detection results are categorized as follows: After transformation, truncation and normalization are performed, and missing marker bits are added to distinguish missing markers (MIS).
[0091] The graph building module supports Each medication record generates a medication event node. The unique key of the medication event node is a hash value concatenated from the medication time, the unified code corresponding to the drug identifier information, the route of administration, the dosage, the duration of administration, and the unified code corresponding to the batch identifier information. The node features of the medication event node are fixed and include three parts: the route of administration code vector, the normalized dosage, and the normalized duration of administration. The route of administration is determined by... Drinking water, injection, feed mixing Encoded as a three-dimensional One-Hot vector, with a uniform unit for drug dosage. And by interval Linear normalization to The duration of drug administration is uniformly measured in days and is divided into intervals. Linear normalization to ;
[0092] The graph building module supports The environmental data of the site is generated into environmental observation nodes one by one according to the collection time. The unique key of the environmental observation node is the hash value of the unified code corresponding to the site identification information and the collection time. The node characteristics of the environmental observation node are fixed and include four environmental indicators: temperature, humidity, ammonia concentration and carbon dioxide concentration, and a missing flag bit is added to each indicator value.
[0093] Regarding the writing of timestamp attributes, the graph construction module writes the timestamp attribute corresponding to the sampling time for sample nodes, the timestamp attribute corresponding to the detection time for detection event nodes, the timestamp attribute corresponding to the medication time for medication event nodes, the timestamp attribute corresponding to the collection time for environmental observation nodes, and the minimum sampling time of all associated sampling records of the batch as the timestamp attribute for batch nodes, and the minimum collection time of all associated environmental observation records of the field as the timestamp attribute for field area nodes.
[0094] Regarding edge construction, the graph construction module is based on Determining the relationship between records in The system generates and labels edges that associate samples with strains, detection events with samples, detection events with strains, detection events with drugs, medication events with drugs, medication events with batches, batches with fields, and fields with environmental observations. The timestamp attribute of each edge is written to the business timestamp corresponding to the source record that generated the edge, so that all nodes and edges in the initial time-series heterogeneous graph contain timestamp attributes.
[0095] Regarding candidate alignment edge construction, the graph construction module targets... Each entity mentioned Anchor nodes are determined according to the following rules: when an entity mentions a record to which it belongs, the anchor node is the sample node corresponding to that sample record; when an entity mentions a record to which it belongs, the anchor node is the detection event node corresponding to that detection record; when an entity mentions a record to which it belongs, the anchor node is the medication event node corresponding to that medication record; when an entity mentions a record to which it belongs, the anchor node is the batch node corresponding to that batch record; and when an entity mentions a record to which it belongs, the anchor node is the field node corresponding to that environmental observation record.
[0096] The graph building module mentions this entity. Candidate entity set Based on the calibrated confidence level Sort in descending order and keep the first few Candidate entities and take and the former The entity nodes corresponding to each candidate entity are reused or newly created as candidate entity nodes. In the next step, a candidate alignment edge is constructed between the anchor node and each candidate entity node, and the corresponding calibrated confidence level is then set. Write the edge weight attribute of the candidate aligned edge, and include the name similarity feature in the confidence evidence chain. Unit consistency characteristics Time consistency characteristics Consistency characteristics with the site area Edge feature vectors encoded in a fixed order as candidate aligned edges ,in This represents the four-dimensional edge feature vector of the candidate aligned edges, with the first to fourth dimensions corresponding to... and At the same time, data quality scores will be given. The additional edge attributes of the candidate alignment edge are written for subsequent modules to read, and the timestamp attribute of each candidate alignment edge is written as an entity mention. The business timestamps of the records are used to ensure the temporal consistency of candidate alignment edges in subsequent temporal modeling, resulting in an initial temporal heterogeneous graph containing business-related edges and candidate alignment edges, and possessing timestamp and edge weight attributes. .
[0097] In this specific embodiment, S4 includes:
[0098] The graph learning prediction module predicts the initial temporal heterogeneous graph. The temporal heterogeneity graph Transformer model is executed to output drug resistance risk prediction results, whereby... This represents a set of nodes, and the node types include sample nodes, strain nodes, drug nodes, medication event nodes, detection event nodes, batch nodes, site nodes, and environmental observation nodes. This represents a set of edges, where the edge type includes business-related edges and candidate-aligned edges, and each edge has a timestamp attribute;
[0099] The number of layers in the Transformer model for temporal heterogeneous graphs Attention count Model hidden dimensions Single-head dimension And configure a node type embedding vector with a dimension of 16 for each node type, and configure an edge type embedding vector with a dimension of 16 for each edge type;
[0100] For any node Initialize the initial node representation ,in The result is obtained by concatenating the node feature vector, the node type embedding vector, and the timestamp position encoding vector and then projecting them through a linear layer. The timestamp position encoding vector is generated by the node timestamp attribute according to a fixed sine and cosine position encoding and has an output dimension of 16 to represent temporal information.
[0101] For either side Calculate the unnormalized attention score for this edge. ,in Represented by the source node Target node representation Together with the edge-type embedding vector, a linear mapping is performed, followed by scaling dot product attention to obtain the result. Represents the Transformer layer index and satisfies ;
[0102] To achieve gated modulation based on edge weight attributes, the graph learning prediction module defines edge weight attributes for each edge. Among them, the candidate aligned edges Take the calibrated confidence level Business-related edges The value is fixed at 1 to indicate a defined association;
[0103] For each edge Depend on Calculate the gating coefficient It was then used to perform gating modulation of attention scores, and for the same target node The set of all incoming edges Normalization is performed to obtain the gated message passing weights. The calculation is as follows:
[0104] ;
[0105] in Indicates from the source node To the target node The gating of message passing weights and their value range is Represents an exponential function. Represents the gating coefficient and its value range is 1. This indicates the unnormalized attention score. Indicates the relationship with the target node The set of all connected source nodes. Representing an edge edge weight attribute, Indicates the gate threshold and takes Used to suppress message passing on low-confidence edges This represents the Sigmoid function. Represents the Sigmoid slope parameter and takes Indicates the Sigmoid bias parameter and takes Indicates the same target node Another source node;
[0106] During message aggregation, the graph learning prediction module performs predictions at each layer. Perform causal masking according to the time order determined by the timestamp attribute, the causal masking being such that when the edge... The timestamp is greater than the node When the timestamp is used, the edge does not participate in the aggregation calculation of the node, thus ensuring that the node representation is only updated by its historical or contemporary information;
[0107] For each target node Represent the source node corresponding to its incoming edge by Weighted summation yields the aggregated representation, which is then updated via linear transformation, residual connection, layer normalization, and feedforward network. The feedforward network is a two-layer fully connected network with a middle dimension of 256, an activation function of ReLU, and a dropout value of 0.1.
[0108] Finish After the layer is updated, the updated node representations of each node are obtained. The strain node representation and drug node representation are input into the prediction layer, which outputs the target prediction result. The prediction layer is a two-layer multilayer perceptron, and its input is a concatenated vector of the strain node representation, drug node representation, and their element-wise product, with a concatenation dimension of . The hidden layer has a dimension of 128 and the activation function is ReLU. The output layer is 1-dimensional and is processed by Sigmoid to obtain the drug resistance risk score according to the drug dimension.
[0109] The drug resistance spectrum change risk score was obtained by summarizing the drug resistance risk score vector of the same strain within a fixed first time window of 7 days and a second time window of 7 days, and then calculating the Jensen-Shannon divergence and linearly normalizing it.
[0110] Multidrug resistance risk score Furthermore, the drug resistance risk score based on the drug dimension is greater than the threshold. The percentage of drugs is used as a score to output the drug resistance risk prediction result.
[0111] In this specific embodiment, S5 includes:
[0112] The knowledge graph rules module executes on the local server to generate a medication knowledge graph and rule set. This module reads medication knowledge data from a local knowledge data warehouse. This data is pre-stored in structured tables and maintained according to six categories: drug information table, drug category information table, indication information table, contraindication information table, withdrawal period information table, and drug interaction information table. The drug information table includes the drug's unified code, standard drug name, approval number, recommended routes of administration, dosage unit, and dosage range. The drug category information table includes the drug category code and name. The indication information table includes the indication code, indication name, and applicable animal species field, with the applicable animal species always including "broiler chicken." The contraindication information table includes the drug's unified code, contraindication condition code, and contraindication condition description. The withdrawal period information table includes the drug's unified code, animal species field, and withdrawal period days. The drug interaction information table includes the drug's unified code... Unified Drug Coding Interaction type and interaction description, with the interaction type taking the form of a fixed enumeration set. Forbidden pairing, pairing with caution Furthermore, all the above tables use the unified drug code as the primary key, which is consistent with the drug identification information in the S2 standardized data, to ensure that the subsequent S6 can be directly retrieved through the drug identification information.
[0113] The knowledge graph rule module constructs a medication knowledge graph based on the medication knowledge data. ,in Representing a knowledge graph of medication use. This represents a set of entities with fixed entity types, including drug entities, drug category entities, indication entities, contraindication entities, withdrawal period entities, and drug interaction entities. It represents a set of relations with a fixed relation type, including subordinate relations between drugs and drug categories, correspondence between drugs and indications, constraints between drugs and contraindications, constraints between drugs and withdrawal periods, and interactions between drugs.
[0114] During entity construction, the knowledge graph rules module uniformly encodes each drug to generate a unique drug entity and writes the drug standard name, approval number, recommended route of administration, dosage unit and dosage range information as entity attributes. It encodes each drug category to generate a unique drug category entity and writes the drug category name attribute. It encodes each indication to generate a unique indication entity and writes the indication name and applicable animal species attribute. It generates a unique contraindication entity for each record in the contraindication information table and writes the contraindication condition code and contraindication condition description attribute. It generates a unique withdrawal period entity for each record in the withdrawal period information table and writes the animal species attribute and withdrawal period days attribute. It generates a unique drug interaction entity for each record in the drug interaction information table and writes the interaction type and interaction description attribute.
[0115] During relationship construction, the knowledge graph rule module establishes subordinate relationships between drug entities and drug category entities based on the mapping relationship between the drug information table and the drug category information table; establishes correspondence relationships between drug entities and indication entities based on the mapping relationship between the drug information table and the indication information table; establishes constraint relationships between drug entities and contraindicated entities based on the contraindication information table; establishes constraint relationships between drug entities and withdrawal period entities based on the withdrawal period information table; and establishes interaction relationships between drug entities and drug interaction entities based on the drug interaction information table, while simultaneously uniformly encoding the drugs. Unified coding with drugs Write attributes of interacting entities to support bidirectional retrieval;
[0116] In terms of storage implementation, medication knowledge graph Write the data into the graph database and establish unique indexes for drug uniform codes, drug category codes, and indication codes to ensure identifiable retrieval and path tracing based on drug identification information;
[0117] During rule set generation, the knowledge graph rule module is based on the medication knowledge graph. Generate rule sets The rule set The rules are stored in the form of a list of rule objects, and each rule object contains five fields: rule identifier information, rule type, trigger condition, constraint parameters, and disposal action. The prohibition information is mapped to the prohibition rule, and the trigger condition for the prohibition rule is that the unified drug code of the candidate drug scheme hits the constraint relationship between the drug entity and the prohibition entity, and the prohibition condition code is consistent with the broiler production stage identifier of the candidate scenario. The disposal action is to determine that the candidate drug scheme is infeasible and output it to the prohibition list.
[0118] The withdrawal period information is mapped to withdrawal period constraint rules. The triggering condition for the withdrawal period constraint rules is that the unified drug code of the candidate drug treatment plan matches the constraint relationship between the drug entity and the withdrawal period entity, and the animal species attribute is "broiler chicken". The constraint parameter is the number of days of withdrawal period and is written into the rule object. The action is to determine the candidate drug treatment plan that is less than the number of days of withdrawal period in the subsequent step S6 as infeasible and output it to the prohibited list.
[0119] Drug interaction information is mapped to combination drug constraint rules, and the triggering condition for the combination drug constraint rules is the existence of a drug uniform code in the candidate drug regimen set. Unified coding with drugs If the combination hits drug interaction entities with the interaction type of "incompatible" or "use with caution", the action is as follows: when the interaction type is "incompatible", the candidate drug regimen involved is determined to be infeasible and output to the prohibited list; when the interaction type is "use with caution", the candidate drug regimen involved is marked as risk-constrained and output to the caution list.
[0120] Simultaneously, dosage constraint rules and caution rules are generated based on the drug information table and indication information table. The triggering condition for the dosage constraint rule is that the unified drug code of the candidate drug regimen matches the correspondence between the drug entity and the indication entity, and the applicable animal species of the indication entity is "broiler chicken". The constraint parameters are the route of administration, dosage unit and dosage range information, which are written into the rule object. The action is to determine whether the route of administration and dosage of the candidate drug regimen fall within the constraint parameters in the subsequent step S6. If they are inconsistent, the result is output to the caution list and a rule penalty value is generated.
[0121] The triggering condition for the cautious use rule is that although the candidate drug regimen meets the indication correspondence, the category risk identifier corresponding to its drug category entity is "restricted use" and the category risk identifier is given in a defined field in the drug category information table. The action is to output the candidate drug regimen to the cautious use list and generate a rule penalty value.
[0122] Finally, the knowledge graph rules module will integrate the medication knowledge graph. and rule set The output is fixed in the form of a version number, and the update timestamp of the medication knowledge data is recorded in the version number.
[0123] In this specific embodiment, S6 includes:
[0124] The fusion inference output module executes on the local server to combine the drug resistance risk prediction results with the drug use knowledge graph. and rule set Integrate and generate medication decision-making information;
[0125] The fusion inference output module first parses the drug resistance risk prediction results into a set of candidate drug regimens. ,in Describes a set of candidate drug regimens where each element is a candidate drug regimen. Indicates a drug's unified code and is related to The standardized data contain consistent drug identification information, and the candidate drug regimens are consistent. Fixed inclusion of drug uniform coding and the corresponding drug resistance risk score Taken from S4 output by drug dimension and the value range is And the higher the value, the higher the risk of drug resistance;
[0126] The fusion inference output module will according to Sort the drug treatment plans in ascending order and extract the top 20 candidate treatment plans for subsequent reasoning to ensure stable output and fixed computational cost;
[0127] The fusion inference output module receives parameters of the current medication scenario. And use it as input for rule determination. Fixed inclusion of target indication code Planned medication timestamp Expected slaughter time stamp and current production stage identifier ,in The indications are determined by the farm's disease diagnosis process and represented by the indication codes in the indication information table. Given by the medication plan and using millisecond-level Unix timestamps, Given by the batch slaughter plan and using millisecond-level Unix timestamps. The batch age information is mapped and matched with the taboo condition codes in the taboo information table for consistency.
[0128] against Each candidate drug regimen The fusion reasoning output module is based on a medication knowledge graph. Perform related knowledge retrieval to generate related paths ,in Indicates a unified coding system for drugs. The corresponding set of associated paths, and each path consists of a sequence of triples (head entity, relation, tail entity), the associated knowledge retrieval returns the subordinate relationship path from drug entity to drug category entity, the correspondence relationship path from drug entity to indication entity, the constraint relationship path from drug entity to contraindication entity, the constraint relationship path from drug entity to withdrawal period entity, and the interaction relationship path from drug entity to drug interaction entity, and writes the returned results into the path field of the explanation information to ensure traceability;
[0129] Subsequently, the fusion reasoning output module analyzes each candidate medication regimen. The rule-based reasoning is performed and the rules are divided into hard constraints and soft constraints. The hard constraints consist of the parts of the prohibition rules, withdrawal period constraints, and combination drug constraints with the interaction type of "incompatible". The soft constraints consist of the parts of the caution rules, dosage constraints, and combination drug constraints with the interaction type of "cautious".
[0130] In the hard constraint determination, the fusion inference output module performs an infeasibility determination on the disabled rule, and the determination condition is... There exists a constraint relationship between the drug entity and the incompatible entity, and the incompatible condition code of the incompatible entity is related to the production stage identifier. Consistent, the fusion reasoning output module determines the infeasibility of executing the withdrawal period constraint rule, and the determination condition is... There exists a constraint relationship between a drug entity and a withdrawal period entity, and the animal species attribute of the withdrawal period entity is "broiler chicken". If the number of days is less than the withdrawal period, the fusion reasoning output module determines that the execution of the "incompatible" combination drug constraint rule is infeasible, and the determination condition is that... Another candidate drug regimen exists. Make or There exist entities that point to the same drug interaction entity, and the interaction type of this entity is "incompatible," and the drug unique identifier pair recorded in its attributes is... or Any candidate drug regimen that violates any hard constraint It is directly added to the disabled list, and the rule identifier and corresponding association path are written in the explanation information. And it will no longer be included in subsequent ratings;
[0131] For candidate drug regimens that do not violate hard constraints, the fusion inference output module calculates the indication matching score. And calculate the rule penalty value. Indication matching score The value is 0 or 1 if and only if There exists a correspondence between a drug entity and an indication entity, and the indication code of the indication entity is equal to the target indication code. hour otherwise Rule penalty value The summation of soft constraint penalties and truncated to Furthermore, the calculation method is as follows: when the "use with caution" rule is hit, an additional 0.30 is added; when the "inconsistency judgment" of the dosage constraint rule is hit, an additional 0.40 is added; and when the "use with caution" combination drug constraint rule is hit, an additional 0.20 is added. The rule identification information of the hit is written into the explanation information respectively.
[0132] During the scoring fusion phase, the fusion inference output module calculates a comprehensive recommendation score for each candidate medication regimen that does not violate hard constraints. Based on this, a recommendation list is generated, calculated using the following formula:
[0133] ;
[0134] in Indicates candidate drug regimens The comprehensive recommendation score is used to sort and generate a recommendation list. This represents the weight of the transformation term in the drug resistance risk score and takes... This indicates a drug resistance risk score that is consistent with the aforementioned definition. Indicates the indication matching score weight and takes This indicates an indication matching score that is consistent with the aforementioned definition. Indicates the weight of the rule penalty item and takes This indicates that the rule penalty value is consistent with the aforementioned definition;
[0135] The fusion inference output module categorizes all candidate drug regimens that do not violate hard constraints into... Sort in descending order and sort the first 5 items while simultaneously satisfying Candidate drug regimens that do not violate hard constraints but meet the requirements will be included in the recommended list. or Candidate drug regimens are included in the list of drugs to be used with caution, and explanatory information is written for each candidate drug regimen in the recommended list, the list of drugs to be used with caution, and the explanatory information always includes the drug's unique identifier. Drug resistance risk score Indication matching score Rule penalty value Overall Recommendation Rating Association path In addition to the rule identification information of the hit, output medication decision information and ensure that the list conclusions are traceable and interpretable.
[0136] The above description is only a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any equivalent substitutions or modifications made by those skilled in the art within the scope of the technology disclosed in the present invention, based on the technical solution and inventive concept of the present invention, should be covered within the scope of protection of the present invention.
[0137] By combining self-supervised data standardization and entity alignment, temporal heterogeneous graph representation learning, and rule-constrained reasoning based on knowledge graphs, this invention forms a closed-loop mechanism to address the problems caused by the dispersion and inconsistent definitions of multi-source data in broiler farming scenarios, such as "difficulty in rolling comparison, difficulty in identifying changes in drug resistance profiles and multidrug resistance risks, and difficulty in outputting actionable medication recommendations." Firstly, it unifies fields, units, and codes at the data layer, and drives entity alignment with record representation, ensuring consistent referencing of key entities such as drugs, strains, farm areas, and batches across systems and time periods, thus providing a basis for subsequent evolutionary modeling. It provides a comparable and traceable data foundation; secondly, at the modeling layer, information such as detection, medication, batch, and environment is organized in the form of a time-stamped heterogeneous graph, enabling the model to output drug resistance risk, drug resistance spectrum change risk, and multidrug resistance risk by drug dimension under the conditions of multi-entity association and time evolution; finally, at the decision-making layer, a drug knowledge graph and rules such as contraindications, withdrawal period, interaction, indications, and dosage are introduced to transform the prediction results into a recommendation list, a caution list, and a prohibition list, and provide explanations of the hit rules and associated paths, thereby achieving the technical effects of risk warning and precise medication decision support.
[0138] This invention addresses the critical technical issue of "uncertainty in entity alignment and the propagation of noise to downstream models," by making scenario-oriented improvements to the algorithm structure. Instead of outputting a single alignment result, it preserves a set of candidate entities for each entity mention and generates a confidence score and a chain of confidence evidence. These are written into a temporal heterogeneous graph as candidate alignment edges. A gating coefficient derived from edge weight mapping is introduced into the attention message passing of the temporal heterogeneous graph Transformer to modulate the edge-level attention weights. This mechanism suppresses the message passing of low-confidence alignment edges, reducing the risk of mispropagation caused by aliases, inconsistent encoding, and missing fields, thereby improving the robustness and predictive stability of drug resistance evolution modeling. Simultaneously, by combining hard and soft constraints with rule reasoning and scoring fusion, schemes that do not meet contraindications and withdrawal periods are directly eliminated. Furthermore, penalties are imposed on risks related to combined drug use and dosage, making the generated list more practically feasible and more conducive to reducing the risks and costs of non-standard drug use.
Claims
1. A method for drug resistance monitoring and medication decision-making based on machine learning and knowledge graphs, characterized in that, include: S1. Obtain multi-source breeding data corresponding to the target broiler breeding scenario and aggregate them to form the original dataset; S2. Perform data standardization on the original dataset to obtain standardized data, input it into the representation learning model to obtain record representations, perform entity alignment on entity mentions in the standardized data, determine a candidate entity set for each entity mention, and generate confidence scores for each candidate entity to form the alignment result dataset; S3. Construct a time-series heterogeneous graph with timestamp attributes based on the alignment result dataset. For each entity mention, determine the corresponding anchor node and for each candidate entity, determine the candidate entity node. Construct candidate alignment edges between anchor nodes and candidate entity nodes and write the corresponding confidence into the edge weight attribute of the candidate alignment edge. S4. Input the temporal heterogeneous graph into the temporal heterogeneous graph representation learning model, update the node representation through attention-based message passing, determine the gating coefficient for each edge in the temporal heterogeneous graph according to the edge weight attribute of the edge, perform gating modulation on the attention weight corresponding to the edge to obtain the gating message passing weight, and output the drug resistance risk prediction result based on the updated node representation. S5. Construct a drug knowledge graph and corresponding rule set; S6. Input the drug resistance risk prediction results, drug knowledge graph and rule set into the fusion reasoning module, perform related knowledge retrieval based on the drug knowledge graph, perform rule constraint reasoning on candidate drug regimens, and output drug decision information, including a recommendation list, a list of drugs to be used with caution and a list of drugs to be prohibited.
2. The drug resistance monitoring and medication decision-making method based on machine learning and knowledge graphs according to claim 1, characterized in that, S1 includes: The drug susceptibility test data and minimum inhibitory concentration (MIC) test data of Escherichia coli are obtained from the detection data source, wherein the detection data includes sample identification information, strain identification information, drug identification information, test result information, and test time information; The sampling information, medication records, and batch information are obtained from the aquaculture management data source. The sampling information includes sampling time, sampling site or sample type, batch identification information corresponding to the sampling, and farm identification information corresponding to the sampling. The medication records include medication time, drug identification information, administration route, dosage, and administration duration. The batch information includes batch identification information, age information, and pen identification information. The site environmental data is obtained from an environmental data source, wherein the site environmental data includes environmental indicator values and collection time corresponding to the site identification information; The acquired multi-source aquaculture data are appended with source identifiers and collection times according to the record level, and then aggregated to form the original dataset.
3. The drug resistance monitoring and medication decision-making method based on machine learning and knowledge graphs according to claim 1, characterized in that, S2 include: The original dataset is subjected to field standardization processing, which includes standardization of drug name, strain name, site identification information, batch identification information, and time format. The original dataset is processed by unit conversion to convert the relevant values of the detection results and medication-related values into a preset unified unit; The original dataset is subjected to encoding mapping processing to map drug codes, field codes, batch codes, and pen codes to a preset unified code; The original dataset is processed by missing field labeling to obtain the standardized data. The standardized data is then input into the self-supervised learning model, which outputs the record representation. For each entity mention in the standardized data, a candidate entity set is retrieved from the candidate entity library based on the record representation. The candidate entity library consists of entities already existing in the standardized data and a pre-configured alias mapping table. For each candidate entity in the candidate entity set, a confidence score is calculated based on the record representation, and a corresponding confidence score evidence chain is generated. The confidence score evidence chain includes name similarity evidence, unit consistency evidence, time consistency evidence, and field consistency evidence. The candidate entity set, the confidence score, and the confidence score evidence chain are associated and stored with the entity mention to form the alignment result dataset.
4. The drug resistance monitoring and medication decision-making method based on machine learning and knowledge graphs according to claim 1, characterized in that, S3 includes: Based on the alignment result dataset, duplicates and type labels are applied to sample identification information, strain identification information, drug identification information, medication record, test record, batch identification information, and site identification information, respectively, to generate sample nodes, strain nodes, drug nodes, medication event nodes, test event nodes, batch nodes, and site nodes. The detection event node is determined by sample identification information, strain identification information, drug identification information, detection result information, and detection time information in the same detection record. The node characteristics of the detection event node include at least one of drug sensitivity detection results and minimum inhibitory concentration (MIC) detection results. Based on the field environmental data, multiple environmental observation records are divided according to collection time. An environmental observation node is generated for each environmental observation record. The node characteristics of the environmental observation node include environmental index values. Field-to-environmental observation association edges are constructed between field nodes and environmental observation nodes, and a timestamp attribute corresponding to the collection time is set for each environmental observation node. Edges are generated based on the association relationships between records in the alignment result dataset, and the edges are labeled with their types. The edges include sample-to-strain association edges, detection event-to-sample association edges, detection event-to-strain association edges, detection event-to-drug association edges, medication event-to-drug association edges, medication event-to-batch association edges, and batch-to-field association edges. The medication event node is determined by the medication time, drug identification information, route of administration, dosage, and duration of administration in the same medication record; a timestamp attribute for sampling time is set for the sample node, a timestamp attribute for detection time is set for the detection event node, and a timestamp attribute for medication time is set for the medication event node, so that all nodes and edges in the initial temporal heterogeneous graph contain timestamp attributes; for each entity mention in the alignment result dataset, an anchor node corresponding to the record containing the entity mention is determined, and the anchor node is at least one of the sample node, medication event node, detection event node, batch node, and field node; The top M candidate entities with the highest confidence are retained to determine the top M candidate entity nodes, and the top M candidate alignment edges between the anchor node and the top M candidate entity nodes are constructed, where M is an integer greater than or equal to 2; the confidence corresponding to the candidate alignment edge is written into the edge weight attribute of the candidate alignment edge. The confidence evidence chain is encoded into the edge feature vector of the candidate aligned edge, and the edge feature vector includes name similarity feature, unit consistency feature, time consistency feature and field area consistency feature; thus, the initial temporal heterogeneous graph is obtained.
5. The drug resistance monitoring and medication decision-making method based on machine learning and knowledge graphs according to claim 1, characterized in that, S4 include: The initial temporal heterogeneous graph is input into the temporal heterogeneous graph Transformer model, and the initial node representation of each node is initialized based on the node features of each node, the edge type of each edge, and the timestamp attribute in the initial temporal heterogeneous graph. For each edge in the initial temporal heterogeneous graph, the attention weight of the edge is calculated based on the node representation of the source node connected by the edge, the node representation of the target node, and the edge type. For each edge in the initial temporal heterogeneous graph, the edge weight attribute of the edge is read, and the edge weight attribute is mapped to the edge through a preset gating function to obtain the gating coefficient of the edge. The preset gating function is a monotonic mapping function, which includes at least one of the Sigmoid function, a piecewise linear function, and a normalization function. When the edge weight attribute is less than a preset threshold, the corresponding gating coefficient is set to 0 or less than a preset decay value to suppress message transmission of low confidence edges; for each edge in the initial temporal heterogeneous graph, the attention weight of the edge and the gating coefficient of the edge are multiplied and fused to obtain the unnormalized gating message transmission weight of the edge. For all connected edges of the same target node, the unnormalized gated message passing weights of each edge are summed to obtain a weight sum value. The unnormalized gated message passing weights of each edge are then divided by the weight sum value to obtain the gated message passing weights corresponding to each edge. According to the time order determined by the timestamp attribute, the adjacent node representations of each node are weighted and aggregated based on the gated message passing weights to obtain the aggregated representation of each node. The node representation of each node is then updated based on the aggregated representation to obtain the updated node representation. The updated node representation is input into the prediction layer to obtain the target prediction result, wherein the target prediction result includes drug resistance risk score by drug dimension, drug resistance spectrum change risk score and multidrug resistance risk score; The drug resistance spectrum change risk score is the difference or divergence value between the drug resistance risk score vectors of multiple drugs corresponding to the target strain within the first time window and the second time window. The divergence value includes at least one of Kullback-Leibler divergence, Jensen-Shannon divergence, and cosine distance. The multidrug resistance risk score is the probability or count of the target strain's resistance risk score to at least K drugs or at least K drug classes being greater than a preset threshold, where K is an integer greater than or equal to 2.
6. The drug resistance monitoring and medication decision-making method based on machine learning and knowledge graphs according to claim 1, characterized in that, S5 include: Acquire medication knowledge data, including drug information, drug category information, indication information, contraindication information, withdrawal period information, and drug interaction information; construct a medication knowledge graph based on the medication knowledge data, wherein drugs, drug categories, indications, contraindications, withdrawal periods, and drug interactions are respectively constructed as corresponding entities, and the subordinate relationships between drugs and drug categories, the correspondence between drugs and indications, the constraint relationships between drugs and contraindications, the constraint relationships between drugs and withdrawal periods, and the interaction relationships between drugs are constructed as corresponding relationships; generate a rule set based on the medication knowledge graph, wherein the contraindication information is mapped to prohibition rules, the withdrawal period information is mapped to withdrawal period constraint rules, the drug interaction information is mapped to combination drug use constraint rules, and dosage constraint rules and caution rules are generated based on the drug information and the indication information; output the medication knowledge graph and the rule set.
7. The drug resistance monitoring and medication decision-making method based on machine learning and knowledge graphs according to claim 1, characterized in that, S6 include: The target prediction results are parsed into a set of candidate drug regimens, where each candidate drug regimen includes drug identification information and a corresponding drug resistance risk score; Based on the medication knowledge graph, for each candidate medication regimen in the candidate medication regimen set, the drug category entity, indication entity, contraindication entity, withdrawal period entity, and drug interaction entity corresponding to the drug identification information are retrieved, and the association path corresponding to the candidate medication regimen is generated. The candidate drug regimen set, the associated path, and the rule set are input into the fusion reasoning module. Rule constraint reasoning is performed on the candidate drug regimen set according to the rule set, including: determining the infeasibility of the candidate drug regimen set based on the prohibition rule and the withdrawal period constraint rule to determine the prohibition list; Based on the rules of caution and the rules of combination therapy, risk constraints are assessed on candidate drug regimens that have not been deemed infeasible in order to determine a list of drugs to be used with caution. For candidate drug regimens not included in the prohibited list and the cautious use list, a recommended list is determined based on the efficacy of the indication and the drug resistance risk score; the drug decision information is output, wherein the drug decision information includes the recommended list, the cautious use list and the prohibited list, and the drug decision information also includes explanatory information, wherein the explanatory information includes knowledge graph association path information corresponding to the candidate drug regimen and the hit rule identification information; the rule constraint reasoning performed by the fusion reasoning module includes at least one of knowledge graph-based path retrieval reasoning, constraint satisfaction-based feasibility determination and score fusion based on differentiable rule constraints.
8. The drug resistance monitoring and medication decision-making method based on machine learning and knowledge graphs according to claim 7, characterized in that, The rule-constrained reasoning performed by the fusion reasoning module further includes: using the prohibition rule and the withdrawal period constraint rule as hard constraints, determining the feasibility of each candidate drug regimen, and including candidate drug regimens that violate the hard constraints in the prohibition list; using the caution rule, the dosage constraint rule, and the combination drug constraint rule as soft constraints, calculating rule penalty values for candidate drug regimens that are not determined to violate the hard constraints; calculating a comprehensive recommendation score for candidate drug regimens based on the drug resistance risk score, indication matching score, and rule penalty values, and generating the recommendation list according to the comprehensive recommendation score; The comprehensive recommendation score is obtained by weighting and fusing the drug resistance risk score with the indication matching score after monotonic transformation, and then subtracting the rule penalty value; the rule identification information of the rule that violates the hard constraint and the rule identification information that generates the rule penalty value are written into the explanation information.
9. The drug resistance monitoring and medication decision-making method based on machine learning and knowledge graphs according to claim 3, characterized in that, When calculating the confidence score for each candidate entity in the candidate entity set, the method further includes: calculating a data quality score for the record corresponding to the entity mention, wherein the data quality score is determined based on the number of missing markers, the number of modifications to field specification processing, and the data source reliability score; using the data quality score and the confidence evidence chain together to obtain a calibrated confidence score, and writing the calibrated confidence score as the edge weight attribute of the candidate alignment edge.
10. A drug resistance monitoring and medication decision-making system based on machine learning and knowledge graphs, used to execute the drug resistance monitoring and medication decision-making method based on machine learning and knowledge graphs as described in any one of claims 1 to 9, comprising: The data acquisition module is used to acquire multi-source aquaculture data and aggregate it to form a raw dataset; The standardization and alignment module is used to standardize the original dataset to obtain standardized data, obtain record representations, and perform entity alignment on entity references to generate an aligned result dataset. The graph construction module is used to construct a time-series heterogeneous graph with timestamp attributes based on the alignment result dataset, and to construct candidate alignment edges between anchor nodes and candidate entity nodes, and to write the confidence score into the edge weight attribute of the candidate alignment edges. The graph learning prediction module is used to input the temporal heterogeneous graph into the temporal heterogeneous graph representation learning model, determine the gating coefficients based on the edge weight attributes to gating the attention weights, and output the drug resistance risk prediction results. The knowledge graph rules module is used to construct a medication knowledge graph and rule set; The fusion reasoning output module is used to input drug resistance risk prediction results, drug knowledge graph and rule set into the fusion reasoning module, and output drug decision information, which includes a recommendation list, a caution list and a prohibition list.