Drug inspection index dynamic traceability method based on comparative learning
By using the improved MoCo model for dynamic traceability of drug testing indicators, the problem of feature extraction and anomaly identification in existing drug quality testing methods under batch differences and changes in testing conditions has been solved, and high-precision, interpretable traceability analysis of drug testing indicators has been achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-25
- Publication Date
- 2026-03-27
Smart Images

Figure CN121745765A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of drug quality detection and intelligent analysis, and particularly relates to a drug inspection index dynamic tracing method based on contrast learning. BACKGROUND
[0002] The existing drug quality detection and abnormal analysis method usually relies on artificial rules, threshold judgment or single machine learning model, and it is difficult to fully model the batch difference, test condition change and time sequence dependence of complex test data. When dealing with test data of multiple batches, multiple conditions and multiple time periods, the traditional method often only analyzes a single feature or a fixed time window, lacks the ability to identify the semantic consistency of samples under different conditions, resulting in limited feature extraction dimension, poor model generalization, and difficulty in accurately reflecting the dynamic rules of drug index changes over time.
[0003] The existing contrast learning model such as MoCo is mainly designed for image or general sequence data, and its positive and negative sample construction method mainly relies on random enhancement, which fails to combine batch identification and test condition information in the drug inspection scene, and the key encoder momentum update strategy is fixed, which cannot adapt to the imbalance of sample time distribution. In addition, the existing method generally lacks a complete link from feature contrast to abnormal positioning and traceability report generation, making it difficult to realize time sequence tracking and risk identification of drug inspection index abnormalities, resulting in insufficient traceability result explainability and risk warning lag.
[0004] Therefore, how to provide a drug inspection index dynamic tracing method based on contrast learning is a problem that those skilled in the art need to solve. SUMMARY
[0005] One object of the present application is to provide a drug inspection index dynamic tracing method based on contrast learning. The present application combines contrast learning and time sequence modeling technology to realize dynamic tracing analysis of drug inspection index, and has the advantages of high accuracy, strong explainability and efficient tracing.
[0006] According to the drug inspection index dynamic tracing method based on contrast learning, the following steps are included:
[0007] Collecting drug inspection data, preprocessing and generating a standardized test data set;
[0008] Inputting the standardized test data set into an improved MoCo model, performing batch and condition embedding, constructing positive and negative sample pairs, and performing multi-scale convolution feature extraction and feature mapping processing to generate an initial feature vector set;
[0009] The weighted contrast loss value is calculated based on the initial feature vector, and the improved MoCo model parameters are updated and the initial feature vector is optimized based on the weighted contrast loss value and a time adaptive momentum update mechanism to generate a set of deep feature vectors;
[0010] The deep feature vectors are modeled in time sequence to establish a dependency relationship, and the feature changes at different time nodes are dynamically analyzed to generate a sequence of time sequence feature vectors;
[0011] The feature change rate is calculated based on the sequence of time sequence feature vectors, and a time-dependent matrix is constructed, key nodes are extracted and connected in time sequence to generate a dynamic change path;
[0012] The dynamic change path is extracted by index matching, threshold differentiation and normalized connection aggregation processing to generate a drug testing indicator dynamic traceability report.
[0013] Optionally, the drug testing data includes testing data of multiple batches, multiple time periods and multiple categories of drugs in the production, storage, transportation and testing links of the drugs, and the preprocessing includes outlier rejection, missing value completion, normalization and time alignment processing.
[0014] Optionally, the generation of the initial feature vector set specifically includes:
[0015] The standardized testing data set is divided by batch number, and the batch number sequence and testing condition parameter set are extracted from the drug testing data of each batch;
[0016] The batch number sequence is input into the batch embedding mapping layer of the improved MoCo model, the index mapping relationship is established through the embedding matrix unit, the discrete batch number is converted into a continuous embedding vector through the embedding matrix lookup, the continuous embedding vector is input into the linear transformation unit, the matrix multiplication and bias addition operation processing are performed, the mapping result is input into the nonlinear activation unit, the element-by-element activation is performed, and the activated feature vector is input into the normalization unit. The feature standardization processing is performed to obtain a batch identification embedding vector set;
[0017] The drug testing condition parameter set is input into the condition embedding mapping layer of the improved MoCo model, the parameter types of the drug testing condition parameter set are identified and divided through the standardization unit to obtain continuous parameters and discrete parameters, the continuous parameters are normalized in the continuous feature normalization unit to obtain continuous feature normalized vectors, and the discrete parameters are executed one-hot encoding processing in the discrete feature encoding unit. The sparse encoding vector is input into the embedding transformation unit, the embedding mapping and linear transformation are performed through the trained embedding matrix to obtain a continuous embedding vector, and the continuous feature normalized vector and the continuous embedding vector are input into the feature fusion unit to perform splicing and linear weighted fusion in the feature dimension to obtain a testing condition embedding vector set;
[0018] The batch identification embedding vector set and the test condition embedding vector set are spliced and feature-weighted fused in the vector dimension to obtain a comprehensive embedding vector set, and the comprehensive embedding vector set and the corresponding drug test data in the standardized test data set are feature-spliced to obtain an input sample set;
[0019] The input sample set is subjected to a sample matching operation, samples with the same batch identification field and the same test condition field are paired to obtain a positive sample pair set, and samples with different batch identification fields or different test condition fields are paired to obtain a negative sample pair set, and the positive and negative sample pair sets are input into the query encoder and the key encoder of the improved MoCo model;
[0020] In the query encoder and the key encoder, the input sample set is sequentially input into a plurality of feature extraction layers of different convolution scales, local feature capture and global feature aggregation are performed on the samples in each convolution layer through convolution receptive fields of different sizes, channel normalization and nonlinear activation processing are performed on the convolution output results of each layer, and the feature mapping results of the convolution outputs of each layer are feature-spliced and fused to generate a multi-scale convolution feature map set including local detail features and global semantic features;
[0021] The multi-scale convolution feature map set is subjected to a feature mapping operation, and the outputs of each convolution layer are spliced and fused after linear transformation and nonlinear activation function processing to generate an initial feature vector set.
[0022] Optionally, the improved MoCo model adds a batch embedding mapping layer and a condition embedding mapping layer relative to the original MoCo model, performs feature embedding mapping and vectorization coding processing on the batch identification and test condition information of the input sample to generate a batch identification embedding vector set and a test condition embedding vector set, in the feature extraction process, multi-scale convolution kernels are introduced into the query encoder and the key encoder to perform multi-scale convolution feature extraction and mapping operations on the input sample set to generate a drug initial feature vector set, in the sample construction mechanism, the batch identification information and the test condition parameters in the input sample are extracted, the samples are matched into positive sample pairs according to the rule that the batch identification is the same and the test condition is the same, and the samples are matched into negative sample pairs according to the rule that the batch identification is different or the test condition is different, in the contrast optimization process, a time-adaptive momentum update mechanism is used to update the key encoder parameters, and a sample confidence weighting term is introduced into the contrast loss function to perform feature optimization processing based on the weighted contrast loss value to generate a deep feature vector set;
[0023] The batch embedding mapping layer comprises an embedding matrix unit, a linear transformation unit, a nonlinear activation unit and a normalization unit;
[0024] The conditional embedding mapping layer comprises a standardization unit, a discrete feature encoding unit, a continuous feature normalization unit, an embedding transformation unit and a feature fusion unit.
[0025] The multi-scale convolution kernel comprises one-dimensional convolution kernels with receptive field sizes of three, five and seven respectively.
[0026] The time-adaptive momentum updating mechanism dynamically adjusts the momentum coefficient according to sample time distribution information, weights and fuses the key encoder parameters of the last iteration period and the query encoder parameters of the current period according to the momentum coefficient in each training iteration, performs parameter replacement operation, and updates the parameters of the key encoder.
[0027] The sample confidence weighting term integrates sample feature similarity and time distribution factors, performs Sigmoid normalization operation on the feature similarity of the sample pair, combines time index normalization processing, weights and sums the two types of normalized results according to a preset balance coefficient to obtain the confidence weight of the corresponding sample pair, and participates in feature distance weighting processing in the contrast loss calculation.
[0028] Optionally, the generation of the set of deep feature vectors specifically comprises:
[0029] The initial feature vector set is extracted from the initial feature vector set, and the difference value of each sample pair of initial feature vectors in the feature dimension is calculated, and the square sum of the dimension difference value is calculated, and the square root operation is performed to obtain the feature distance value of the corresponding sample pair, and the feature distance values of all sample pairs are arranged in the order of sample pairs to obtain the feature distance set.
[0030] Each feature distance value in the feature distance set and the corresponding sample confidence weighting term are multiplied according to the sample pair, and rearranged according to the index order of the sample pair to obtain the weighted feature distance set.
[0031] Based on the weighted feature distance set, the weighted feature distance of the positive sample pair is minimized, and the weighted feature distance of the negative sample pair is maximized, and the weighted operation results of all sample pairs are normalized and aggregated in the sample dimension to obtain the weighted contrast loss value.
[0032] In the contrast optimization process, the model parameters except the key encoder parameters in the improved MoCo model are updated by the gradient based on the weighted contrast loss value by the back propagation method, and the parameter smoothing update and replacement operation of the key encoder parameters are performed by the time-adaptive momentum updating mechanism according to the sample time distribution information, and the updated improved MoCo model is applied to the initial feature vector set for feature optimization and update to generate the set of deep feature vectors.
[0033] The update of the key encoder parameters specifically includes: determining the weight ratio of the momentum coefficient based on the sample distribution density of each time period in the sample time distribution information, obtaining a set of weighted coefficients, and weighting and fusing the key encoder parameters of the previous iteration period and the query encoder parameters of the current iteration period according to the weighted coefficients in the parameter dimension. In each training iteration, the weight ratio of the momentum coefficient is dynamically adjusted according to the sample time distribution density, and the key encoder parameters are updated smoothly and iteratively replaced.
[0034] Optionally, the generation of the time-series feature vector sequence specifically includes:
[0035] The deep feature vector set is sorted in ascending order according to the timestamp field of the drug test samples to obtain the feature vector sequence, and the time weight is calculated based on the time interval between adjacent time nodes to form a time index matrix.
[0036] The feature vector sequence is ordered by time index, and the difference between the deep feature vectors between adjacent time nodes is calculated in the feature dimension. The difference results are normalized and linearly transformed dimension by dimension to obtain the time step feature representation.
[0037] The time step feature representation and time index matrix are matched accordingly, continuous feature representation is extracted in time order, and weighted summation and normalization are performed to obtain the weighted average feature vector of each window. The sliding window is gradually shifted and the calculation is repeated. Local time-dependent features are obtained by sequentially splicing them in the time dimension.
[0038] The local time-dependent features are arranged in chronological order. Weighted fusion operations are performed on the feature vectors of different time periods in the feature dimension. The feature similarity values between any time periods are calculated. The similarity results are normalized and aggregated. Global dependencies between time periods are established in the time dimension to obtain the global time-series correlation matrix.
[0039] Based on the global time series correlation matrix, extract the time dependency coefficients of the corresponding rows using time steps as indices. Perform a weighted summation operation on the time dependency coefficients and the time step feature representations of the entire time step, and then normalize them. Perform a linear transformation on the processing results and repeat the above processing on all time nodes in chronological order, and then concatenate them sequentially to generate a time series feature vector sequence.
[0040] Optionally, the generation of the dynamically changing path specifically includes:
[0041] The time-series feature vectors of each time node and the time intervals between adjacent time nodes are extracted from the time-series feature vector sequence in chronological order to obtain the time interval sequence;
[0042] For the time series feature vectors of adjacent time nodes, perform difference calculation on each feature dimension, divide the difference of each dimension by the corresponding time interval to obtain the feature change rate vector of each time node, and arrange them in time order to obtain the feature change rate sequence.
[0043] The characteristic rate of change sequence is subjected to weighted smoothing in chronological order, and weighted summation and normalization are performed within each time window to obtain the smoothed characteristic rate of change sequence.
[0044] Calculate the similarity coefficient for the temporal feature vectors of any two time points, arrange the similarity in row and column positions according to time order, and normalize it in the row direction to obtain the time dependency matrix;
[0045] The smoothed feature change rate sequence and the time dependency matrix are weighted and fused. For each time node, the absolute value of the change rate is calculated on the feature dimension and then weighted and normalized according to the weight coefficients of the corresponding row in the time dependency matrix to obtain the time node importance score sequence.
[0046] The set of key nodes is determined based on the time node importance score sequence. The determination method is to calculate the mean and standard deviation of the corresponding score sequence, multiply the mean and the preset coefficient by the standard deviation as the threshold, and select the time nodes with scores not less than the threshold as key nodes.
[0047] The key nodes are connected in a chronological order, the direction of feature change between adjacent key nodes is marked, and the key nodes and their corresponding connections are sequentially spliced together in the time dimension to generate a dynamic change path.
[0048] Optionally, the generation of the dynamic traceability report for drug testing indicators specifically includes:
[0049] Match the time nodes in the dynamic change path with the corresponding indices of the samples in the weighted feature distance set, extract the feature distance values of the corresponding samples for each time node, and obtain the node feature distance sequence.
[0050] The mean and standard deviation of the node feature distance sequence are calculated. The node feature distance value is compared with the threshold obtained by multiplying the mean by a preset coefficient and the standard deviation. When the node feature distance value is greater than the threshold, the corresponding node is marked as an abnormal node.
[0051] Extract the corresponding temporal feature vectors of the adjacent nodes before and after the abnormal node in the dynamic change path, perform difference calculation and normalization on the feature dimension, and perform directed connection on the change direction between adjacent nodes to obtain the temporal feature association chain of the abnormal node.
[0052] By splicing and aggregating the temporal feature association chains of all abnormal nodes, the path diagram for tracing the abnormality of drug testing indicators is reconstructed. Based on the path diagram, the set of abnormal sources, the abnormal path analysis report, and the risk warning results are output. The above results are summarized to generate a dynamic traceability report of drug testing indicators.
[0053] The beneficial effects of this invention are:
[0054] This invention introduces an improved MoCo model based on contrastive learning into the dynamic traceability of drug testing indicators, achieving unified feature modeling and dynamic tracking of testing data from multiple batches, under multiple conditions, and across multiple time periods. Traditional drug testing traceability typically relies on static analysis or simple threshold judgments, which struggles to accurately reflect the evolution patterns of indicators under different batches and testing conditions, and also makes it difficult to promptly locate the source of anomalies. This invention introduces batch embedding mapping layers and condition embedding mapping layers into the model structure, performing embedding mapping and vectorized encoding on discretized batch numbers and testing condition parameters. This enables data from different sources to be aligned and correlated within a unified feature space, providing a structured foundation for subsequent feature extraction and dynamic analysis.
[0055] During feature extraction, this invention achieves multi-level extraction and fusion of local details and global features by setting multi-scale convolutional kernels within the query encoder and key encoder, thereby improving the model's ability to represent complex drug testing data. Simultaneously, a sample construction mechanism based on batch identifiers and testing conditions is introduced to replace traditional random data augmentation methods, making the pairing relationships between samples more consistent with actual semantic features and enhancing the model's adaptability to feature distributions in real-world scenarios. In the optimization phase, a time-adaptive momentum update mechanism and a sample confidence weighting term are employed, enabling dynamic adjustment of model parameters over time, resulting in more stable feature optimization and more accurate anomaly detection.
[0056] Through the aforementioned improvements, this invention has achieved significant results in dynamic modeling, anomaly identification, and traceability path reconstruction of drug testing indicators. The model can capture the changing trends of testing indicators over time, automatically generate key nodes and anomaly paths, and achieve full-process visual tracking of the drug testing process. Compared with traditional methods, this invention outperforms existing methods in terms of feature extraction accuracy, anomaly node identification rate, and temporal modeling stability. It effectively solves problems such as broken traceability paths, ambiguous anomaly localization, and unstable feature matching in existing technologies, providing high-precision, high-reliability, and highly interpretable technical support for drug quality testing and safety supervision. 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 a dynamic traceability method for drug testing indicators based on contrastive learning proposed in this invention;
[0059] Figure 2 This is a schematic diagram of the improved MoCo model structure of a dynamic traceability method for drug testing indicators based on contrastive learning proposed in this invention. Detailed Implementation
[0060] 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.
[0061] refer to Figures 1-2 A dynamic traceability method for drug testing indicators based on contrastive learning includes the following steps:
[0062] Collect drug testing data, preprocess it, and generate a standardized testing dataset;
[0063] The standardized test dataset is input into the improved MoCo model for batch and conditional embedding to construct positive and negative sample pairs. After multi-scale convolutional feature extraction and feature mapping, an initial set of feature vectors is generated.
[0064] The weighted contrastive loss value is calculated based on the initial feature vector. The parameters of the improved MoCo model are updated and the initial feature vector is optimized based on the weighted contrastive loss value and the time-adaptive momentum update mechanism, generating a set of deep feature vectors.
[0065] The deep feature vectors are modeled according to the time order, and the feature changes at different time points are dynamically analyzed to generate a time-series feature vector sequence.
[0066] Calculate the feature change rate based on the time-series feature vector sequence and construct the time dependency matrix. Extract key nodes and connect them according to the time sequence to generate a dynamic change path.
[0067] The dynamic change path is extracted by index matching, threshold discrimination, and normalized connection aggregation to generate a dynamic traceability report of drug testing indicators.
[0068] In this embodiment, the drug testing data includes testing data of multiple batches, multiple time periods, and multiple categories of drugs in the production, storage, transportation, and testing stages. The preprocessing includes outlier removal, missing value completion, normalization, and time alignment.
[0069] In this embodiment, the generation of the initial feature vector set specifically includes:
[0070] The standardized test dataset is divided by batch number, and the batch number sequence and test condition parameter set are extracted from the drug test data of each batch. The drug test conditions are the external environmental parameters and experimental setting parameters recorded during the drug test process, including the parameters of the testing equipment, experimental environment, test method, drug status and operator, which are obtained from the test records of the drug test system and the metadata of the experimental management system.
[0071] The specific parameters of the detection equipment include the equipment model, sampling frequency, number of detection channels, detection sensitivity, and detection light source wavelength;
[0072] The experimental environment parameters include laboratory temperature, humidity, atmospheric pressure, light intensity, air velocity, and environmental electromagnetic interference intensity.
[0073] The test method parameters include test method type, test standard number, sample amount, test temperature setting, reaction time, detection wavelength and calibration mode;
[0074] The drug status parameters include drug name, batch number, drug dosage form, drug purity, drug storage temperature, and sampling time.
[0075] The operator parameters include the inspector number, job category, operator proficiency level, qualification certificate information, and operation duration.
[0076] The batch number sequence is input into the batch embedding mapping layer of the improved MoCo model. An index mapping relationship is established through the embedding matrix unit. Discrete batch numbers are converted into continuous embedding vectors through embedding matrix lookup. The continuous embedding vectors are input into the linear transformation unit for matrix multiplication and bias addition. The mapping result is input into the nonlinear activation unit for element-wise activation. The activated feature vectors are input into the normalization unit for feature standardization to obtain the set of batch identifier embedding vectors.
[0077] The drug testing condition parameter set is input into the conditional embedding mapping layer of the improved MoCo model. The parameter types of the drug testing condition parameter set are identified and classified by the standardization unit to obtain continuous parameters and discrete parameters. In the continuous feature normalization unit, the continuous parameters are numerically normalized to obtain continuous feature normalized vectors. In the discrete feature encoding unit, the discrete parameters are one-hot encoded and the sparse encoded vectors are input into the embedding transformation unit. Embedding mapping and linear transformation are performed through the training embedding matrix to obtain continuous embedding vectors. The continuous feature normalized vectors and continuous embedding vectors are input into the feature fusion unit, and concatenation and linear weighted fusion are performed on the feature dimensions to obtain the set of testing condition embedding vectors. The training embedding matrix is a trainable weight structure in the conditional embedding mapping layer, which is used to establish the mapping relationship between discrete drug testing condition parameters and continuous embedding vector space. It is generated by random distribution in the initialization stage of the improved MoCo model and dynamically updated by the backpropagation algorithm of the contrastive loss function. Each matrix row corresponds to an initial vector representation of a discrete testing condition category.
[0078] The batch identifier embedding vector set and the test condition embedding vector set are concatenated and feature-weighted fused along the vector dimension to obtain a comprehensive embedding vector set. The comprehensive embedding vector set is then concatenated with the corresponding drug test data in the standardized test dataset to obtain the input sample set.
[0079] The input sample set is subjected to sample matching operation. Samples with the same batch identifier field and the same test condition field are paired to obtain a positive sample pair set. Samples with different batch identifier fields or different test condition fields are paired to obtain a negative sample pair set. The positive and negative sample pair sets are then input into the query encoder and key encoder of the improved MoCo model, respectively.
[0080] In the query encoder and key encoder, the input sample set is sequentially fed into multiple feature extraction layers with different convolutional scales. In each convolutional layer, local features are captured and global features are aggregated through convolutional receptive fields of different sizes. Channel normalization and non-linear activation processing are performed on the output results of each convolutional layer. Feature concatenation and fusion are performed on the feature mapping results of each convolutional layer to generate a multi-scale convolutional feature map set including local detail features and global semantic features.
[0081] A feature mapping operation is performed on the multi-scale convolutional feature map set. The outputs of each convolutional layer are processed by linear transformation and nonlinear activation function, and then concatenated and fused to generate an initial feature vector set.
[0082] In this embodiment, the improved MoCo model, compared to the original MoCo model, adds a batch embedding mapping layer and a conditional embedding mapping layer. It performs feature embedding mapping and vectorization encoding on the batch identifier and inspection condition information of the input samples, generating a set of batch identifier embedding vectors and a set of inspection condition embedding vectors. During feature extraction, multi-scale convolutional kernels are introduced into the query encoder and key encoder to perform multi-scale convolutional feature extraction and mapping operations on the input sample set, generating an initial set of drug feature vectors. Regarding the sample construction mechanism, a sample construction mechanism based on batch identifiers and inspection conditions is introduced to replace the original model's random data augmentation method. By extracting batch identifier information and inspection condition parameters from the input samples, samples are matched to form positive sample pairs according to the rule of identical batch identifiers and identical inspection conditions, and samples are matched to form negative sample pairs according to the rule of different batch identifiers or different inspection conditions. During the comparison optimization process, a time-adaptive momentum update mechanism is used to update the key encoder parameters, and a sample confidence weighting term is introduced into the comparison loss function. Feature optimization processing based on the weighted comparison loss value is performed to generate a set of deep feature vectors.
[0083] The batch embedding mapping layer includes embedding matrix units, linear transformation units, nonlinear activation units, and normalization units;
[0084] The conditional embedding mapping layer includes a normalization unit, a discrete feature encoding unit, a continuous feature normalization unit, an embedding transformation unit, and a feature fusion unit;
[0085] The multi-scale convolutional kernels include one-dimensional convolutional kernels with receptive field sizes of three, five, and seven, respectively.
[0086] The time-adaptive momentum update mechanism dynamically adjusts the momentum coefficient based on the sample time distribution information. In each training iteration, the key encoder parameters of the previous iteration period and the query encoder parameters of the current period are weighted and fused according to the momentum coefficient, and parameter replacement operation is performed to update the key encoder parameters.
[0087] The sample confidence weighting term integrates sample feature similarity and time distribution factors. It performs Sigmoid normalization on the feature similarity of sample pairs and combines it with time index normalization. The two normalization results are weighted and summed according to a preset balance coefficient to obtain the confidence weight of the corresponding sample pair. This weight is then used in the feature distance weighting process in the comparison loss calculation.
[0088] In this embodiment, the generation of the deep feature vector set specifically includes:
[0089] Extract positive and negative sample pairs from the initial feature vector set. Perform difference calculation on the feature dimension of the initial feature vector of each sample pair. After squaring and summing the difference results of each dimension, perform square root operation to obtain the feature distance value of the corresponding sample pair. Arrange the feature distance values of all sample pairs in the order of the sample pairs to obtain the feature distance set.
[0090] Each feature distance value in the feature distance set is multiplied by its corresponding sample confidence weighting term for each sample pair, and then rearranged according to the index order of the sample pairs to obtain the weighted feature distance set.
[0091] Based on the weighted feature distance set, the weighted feature distance of positive sample pairs is minimized, and the weighted feature distance of negative sample pairs is maximized. The weighted operation results of all sample pairs are normalized and aggregated in the sample dimension to obtain the weighted contrast loss value.
[0092] During the comparative optimization process, the model parameters in the improved MoCo model, except for the key encoder parameters, are updated by gradient through backpropagation based on the weighted comparative loss value. The key encoder parameters are then updated and replaced by a time-adaptive momentum update mechanism based on the sample time distribution information. The updated improved MoCo model is then applied to the initial feature vector set for feature optimization and update, generating a deep feature vector set.
[0093] The update of the key encoder parameters specifically includes: determining the weight ratio of the momentum coefficient based on the sample distribution density of each time period in the sample time distribution information, obtaining a set of weighted coefficients, and weighting and fusing the key encoder parameters of the previous iteration period and the query encoder parameters of the current iteration period according to the weighted coefficients in the parameter dimension. In each training iteration, the weight ratio of the momentum coefficient is dynamically adjusted according to the sample time distribution density, and the key encoder parameters are updated smoothly and iteratively replaced.
[0094] The sample time distribution information is obtained by extracting the timestamp field of drug test samples from the standardized test dataset, sorting the samples in chronological order, calculating the time interval between adjacent samples, and counting the number of samples in each time interval.
[0095] The specific steps to obtain the weighted coefficient set include: dividing the time axis into segments based on the sample distribution density of each time period in the sample time distribution information; calculating the proportion of drug test samples to the total number of samples in each time interval to obtain the sample distribution weight of each time period; performing weighted calculation of the momentum coefficient of each time period through a time adaptive momentum update mechanism; and performing linear normalization processing on the parameter dimension to obtain the weighted coefficient set, which is used to control the update ratio of the key encoder parameters in different time periods.
[0096] In this embodiment, the generation of the time-series feature vector sequence specifically includes:
[0097] The deep feature vector set is sorted in ascending order according to the timestamp field of the drug test samples to obtain the feature vector sequence, and the time weight is calculated based on the time interval between adjacent time nodes to form a time index matrix.
[0098] The feature vector sequence is ordered by time index, and the difference between the deep feature vectors between adjacent time nodes is calculated in the feature dimension. The difference results are normalized and linearly transformed dimension by dimension to obtain the time step feature representation.
[0099] The time step feature representation and time index matrix are matched accordingly, continuous feature representation is extracted in time order, and weighted summation and normalization are performed to obtain the weighted average feature vector of each window. The sliding window is gradually shifted and the calculation is repeated. Local time-dependent features are obtained by sequentially splicing them in the time dimension.
[0100] The local time-dependent features are arranged in chronological order. Weighted fusion operations are performed on the feature vectors of different time periods in the feature dimension. The feature similarity values between any time periods are calculated. The similarity results are normalized and aggregated. Global dependencies between time periods are established in the time dimension to obtain the global time-series correlation matrix.
[0101] Based on the global time series correlation matrix, extract the time dependency coefficients of the corresponding rows using time steps as indices. Perform a weighted summation operation on the time dependency coefficients and the time step feature representations of the entire time step, and then normalize them. Perform a linear transformation on the processing results and repeat the above processing on all time nodes in chronological order, and then concatenate them sequentially to generate a time series feature vector sequence.
[0102] In this embodiment, the generation of the dynamically changing path specifically includes:
[0103] The time-series feature vectors of each time node and the time intervals between adjacent time nodes are extracted from the time-series feature vector sequence in chronological order to obtain the time interval sequence;
[0104] For the time series feature vectors of adjacent time nodes, perform difference calculation on each feature dimension, divide the difference of each dimension by the corresponding time interval to obtain the feature change rate vector of each time node, and arrange them in time order to obtain the feature change rate sequence.
[0105] The characteristic rate of change sequence is subjected to weighted smoothing in chronological order, and weighted summation and normalization are performed within each time window to obtain the smoothed characteristic rate of change sequence.
[0106] Calculate the similarity coefficient for the temporal feature vectors of any two time points, arrange the similarity in row and column positions according to time order, and normalize it in the row direction to obtain the time dependency matrix. The similarity coefficient is obtained by multiplying the temporal feature vectors of the two time points element by element in each dimension and summing the summation results, and then dividing the summation results by the product of the square root of the sum of the squares of the temporal feature vectors of the two time points.
[0107] The smoothed feature change rate sequence and the time dependency matrix are weighted and fused. For each time node, the absolute value of the change rate is calculated on the feature dimension and then weighted and normalized according to the weight coefficients of the corresponding row in the time dependency matrix to obtain the time node importance score sequence.
[0108] The set of key nodes is determined based on the time node importance score sequence. The determination method is to calculate the mean and standard deviation of the corresponding score sequence, multiply the mean and the preset coefficient by the standard deviation as the threshold, and select the time nodes with scores not less than the threshold as key nodes.
[0109] The key nodes are connected in a chronological order, the direction of feature change between adjacent key nodes is marked, and the key nodes and their corresponding connections are sequentially spliced together in the time dimension to generate a dynamic change path.
[0110] In this embodiment, the generation of the dynamic traceability report for drug testing indicators specifically includes:
[0111] Match the time nodes in the dynamic change path with the corresponding indices of the samples in the weighted feature distance set, extract the feature distance values of the corresponding samples for each time node, and obtain the node feature distance sequence.
[0112] The mean and standard deviation of the node feature distance sequence are calculated. The node feature distance value is compared with the threshold obtained by multiplying the mean by a preset coefficient and the standard deviation. When the node feature distance value is greater than the threshold, the corresponding node is marked as an abnormal node.
[0113] Extract the corresponding temporal feature vectors of the adjacent nodes before and after the abnormal node in the dynamic change path, perform difference calculation and normalization on the feature dimension, and perform directed connection on the change direction between adjacent nodes to obtain the temporal feature association chain of the abnormal node.
[0114] The temporal feature association chains of all abnormal nodes are spliced and aggregated to reconstruct the path graph for tracing the abnormality of drug testing indicators. Based on the path graph, the abnormality source set, abnormal path analysis report and risk warning results are output and the above results are summarized to generate a dynamic traceability report for drug testing indicators. The reconstruction of the path graph for tracing the abnormality of drug testing indicators specifically includes: matching and splicing the temporal feature association chains of abnormal nodes in chronological order; performing feature alignment, weighted fusion and normalization processing on the first and last nodes of adjacent chains to obtain a continuous abnormal feature sequence; aggregating all continuous abnormal feature sequences and establishing a time-dimensional connection relationship to obtain the path graph for tracing the abnormality of drug testing indicators.
[0115] The specific steps for obtaining the anomaly source set, anomaly path analysis report, and risk warning results include: in the path graph, performing difference calculations on the feature dimensions of the time-series feature vectors of each anomaly node and the feature vectors of normal nodes to obtain a feature deviation value sequence; normalizing and aggregating the feature deviation value sequence according to the node time index; calculating the comprehensive deviation degree of each anomaly node; determining the anomaly source node set based on the deviation degree threshold; statistically summarizing the batch numbers and time intervals associated with each node in the anomaly source set to obtain the anomaly source set; extracting the feature change trends, deviation magnitudes, and time correlations of nodes in the anomaly path to obtain the anomaly path analysis report; and obtaining risk warning results based on the deviation degree level distribution.
[0116] The deviation levels include mild deviation, moderate deviation, and severe deviation. The mild deviation level corresponds to a node where the characteristic deviation value is in the lower range of the set threshold, indicating that the drug testing indicator has only slight fluctuations. The moderate deviation level corresponds to a node where the characteristic deviation value is in the middle range of the threshold, indicating that the drug testing indicator has significant abnormal changes but has not exceeded the warning line. The severe deviation level corresponds to a node where the characteristic deviation value exceeds the high threshold, indicating that the drug testing indicator has become obviously abnormal or unstable, requiring key early warning and intervention.
[0117] Example 1:
[0118] To verify the feasibility of this invention in practice, it was applied to a data traceability scenario covering the entire drug testing process at a large-scale drug quality testing and supervision center. This center is responsible for quality monitoring of various drugs during production, storage, transportation, and warehousing inspection, involving a wide variety of drugs, large batch spans, and complex testing environments. Traditional data traceability methods mainly rely on manual comparison of inspection records or static database searches, which cannot achieve dynamic correlation analysis of drug testing indicators across different batches, time periods, and testing conditions. When faced with abnormal fluctuations in drug indicators, significant batch-to-batch differences, or slight deviations in testing conditions, traditional systems often cannot quickly pinpoint the cause, especially failing to detect potential cross-batch quality anomalies or systemic deviations caused by environmental factors, resulting in significant delays in quality control and problem tracing.
[0119] In this embodiment, the testing data generated during the production, storage, transportation, and laboratory testing of pharmaceuticals are uniformly integrated into the dynamic traceability system for pharmaceutical testing indicators described in this invention. The system first performs preprocessing operations on the collected testing data, including outlier removal, missing value completion, normalization, and time alignment, to ensure data consistency in both the time dimension and numerical space. The standardized data is input into the improved MoCo model. The model vectorizes the batch numbers of pharmaceuticals through a batch embedding mapping layer, converting discrete numbers into continuous embedding representations. Simultaneously, in the conditional embedding mapping layer, embedding transformations and feature fusion are performed on the detection condition parameters, enabling the feature expressions of each batch of pharmaceuticals under different testing environments to be mapped to the same continuous feature space. During the training phase, the model automatically constructs positive and negative sample pairs according to the matching rules of batch identifiers and detection conditions, replacing the previous sample construction method that relied on random augmentation, ensuring semantic consistency between samples and the true comparability of detection conditions.
[0120] During feature extraction, the model introduces multi-scale convolutional kernel structures within the query encoder and key encoder to extract local features and global patterns from the input samples at multiple levels, thus taking into account both subtle differences and overall trend changes in drug testing data. In the contrastive learning phase, the model calculates a weighted contrastive loss value based on the similarity of sample features and combines this with a time-adaptive momentum update mechanism to smoothly update the key encoder parameters. This allows the model to progressively optimize parameters over time and maintain a stable representation of sample features across different time periods. Through this process, the system generates deep feature vectors that comprehensively reflect the changing patterns of drug testing indicators and further establishes temporal dependencies between samples, enabling dynamic modeling and time-series analysis of drug testing indicators.
[0121] In the application phase, the system of this invention models the dependencies of deep feature vectors in chronological order, dynamically analyzes the feature changes at each time point, and calculates the feature change rate sequence and time dependency matrix to identify key change nodes in the drug testing process. The system can automatically connect key nodes to form dynamic change paths, thereby generating a dynamic traceability report of drug testing indicators. This report not only shows the evolution trend of each testing indicator over time, but also identifies potential sources of anomalies and time-related paths, providing quality control personnel with clear traceability clues.
[0122] During a drug quality inspection cycle, the system, through unified modeling and dynamic analysis of test data from multiple batches, can quickly identify the relevant testing conditions and batch origins when drug indicators show abnormal fluctuations. It automatically generates anomaly paths and links them to specific testing stages. This dynamic traceability approach allows managers to quickly identify potential factors causing fluctuations, such as changes in ambient temperature, equipment deviations, or differences in operating conditions, and to conduct targeted corrections and re-inspections accordingly.
[0123] The application results of this invention at the center show that the system exhibits good robustness and adaptability in data integration, feature modeling, and anomaly tracing throughout the entire drug testing process. By introducing a batch and testing condition embedding mechanism, the model establishes a unified feature expression space among testing data from different sources and under different conditions; through time-dependent modeling and dynamic path generation, the system can automatically characterize the evolution of drug testing indicators; and through a weighted comparison optimization mechanism, the model maintains stable feature distribution and convergence under complex time spans and diverse conditions.
[0124] Table 1. Performance Comparison of the Invention and Traditional Dynamic Traceability Methods for Drug Testing Indicators
[0125] Indicator category Conventional method Inventive method Feature extraction accuracy (%) 88.3 95.7 Feature clustering purity (%) 81.6 92.4 Abnormal node identification rate (%) 79.2 91.8 Dynamic path reconstruction completeness (%) 84.1 94.6 Time-dependent modeling stability (standard deviation) 0.037 0.021 False positive rate (%) 8.9 3.2
[0126] As can be clearly seen from Table 1, the method of the present invention is superior to the traditional method in many indicators.
[0127] In terms of feature extraction accuracy, the method of this invention achieves 95.7%, a significant improvement compared to the 88.3% of traditional methods. This is because the improved MoCo model introduces a multi-scale convolutional kernel structure in the feature extraction stage, which can simultaneously capture local details and global trend features, thus providing a stronger expressive ability for nonlinear changes in drug detection data. Furthermore, through a dual embedding mapping mechanism of batch and detection conditions, the model can effectively distinguish the features of drug samples under different batches and conditions, improving the overall feature recognition accuracy.
[0128] In terms of feature clustering purity, the method of this invention achieves 92.4%, which is nearly 11 percentage points higher than the 81.6% of the traditional method. This improvement is attributed to the joint encoding strategy of batch identifier embedding and test condition embedding, which makes the clustering of samples from the same batch and under the same testing environment more compact in the feature space, reducing the overlap of dissimilar features, thereby improving clustering purity and sample discriminability.
[0129] In terms of anomaly node identification rate, the method of this invention achieves 91.8%, significantly higher than the 79.2% of traditional methods. This is because the model introduces a sample confidence weighting term during the contrastive learning phase. By comprehensively considering sample feature similarity and time distribution factors, it can more accurately distinguish between normal nodes and potential anomaly nodes, reducing the occurrence of false identifications. This mechanism enables the model to maintain high sensitivity and low error rate even in complex detection environments.
[0130] In terms of the completeness of dynamic path reconstruction, the method of this invention achieves 94.6%, a significant improvement compared to the 84.1% of traditional methods. Traditional methods typically construct paths based on static statistics or fixed time windows, making it difficult to reflect feature correlations across time periods. This invention introduces a time dependency matrix and a sliding window weighting mechanism, enabling the system to continuously track feature changes and form more coherent dynamic tracing paths, thereby achieving high completeness in path reconstruction.
[0131] Regarding the stability of time-dependent modeling, the standard deviation of the method in this invention is 0.021, while that of the traditional method is 0.037, demonstrating a significant improvement in stability. The improved MoCo model employs a time-adaptive momentum update mechanism, enabling the key encoder parameters to dynamically adjust with the time distribution, thereby maintaining the stability of parameter convergence and the consistency of feature representation during multi-batch, cross-time-segment training.
[0132] Regarding the false positive rate, the method of this invention has a false positive rate of only 3.2%, which is far lower than the 8.9% of the traditional method. This improvement comes from the weighted contrastive loss function and confidence calibration mechanism introduced into the model, which enables the model to automatically adjust the sample weights when making anomaly judgments, reducing false positives caused by low-confidence samples, thereby effectively improving the accuracy of anomaly detection.
[0133] 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.
Claims
1. A dynamic traceability method for drug testing indicators based on contrastive learning, characterized in that, Includes the following steps: Collect drug testing data, preprocess it, and generate a standardized testing dataset; The standardized test dataset is input into the improved MoCo model for batch and conditional embedding to construct positive and negative sample pairs. After multi-scale convolutional feature extraction and feature mapping, an initial set of feature vectors is generated. The weighted contrastive loss value is calculated based on the initial feature vector. The parameters of the improved MoCo model are updated and the initial feature vector is optimized based on the weighted contrastive loss value and the time-adaptive momentum update mechanism, generating a set of deep feature vectors. The deep feature vectors are modeled according to the time order, and the feature changes at different time points are dynamically analyzed to generate a time-series feature vector sequence. Calculate the feature change rate based on the time-series feature vector sequence and construct the time dependency matrix. Extract key nodes and connect them according to the time sequence to generate a dynamic change path. The dynamic change path is extracted by index matching, threshold discrimination, and normalized connection aggregation to generate a dynamic traceability report of drug testing indicators.
2. The method for dynamic traceability of drug testing indicators based on comparative learning according to claim 1, characterized in that, The drug testing data includes testing data from multiple batches, time periods, and categories of drugs during the production, storage, transportation, and testing processes. The preprocessing includes outlier removal, missing value completion, normalization, and time alignment.
3. The method for dynamic traceability of drug testing indicators based on contrastive learning according to claim 1, characterized in that, The generation of the initial feature vector set specifically includes: The standardized test dataset is divided by batch number, and the batch number sequence and test condition parameter set are extracted from the drug test data of each batch. The batch number sequence is input into the batch embedding mapping layer of the improved MoCo model. An index mapping relationship is established through the embedding matrix unit. Discrete batch numbers are converted into continuous embedding vectors through embedding matrix lookup. The continuous embedding vectors are input into the linear transformation unit for matrix multiplication and bias addition. The mapping result is input into the nonlinear activation unit for element-wise activation. The activated feature vectors are input into the normalization unit for feature standardization to obtain the set of batch identifier embedding vectors. The drug testing condition parameter set is input into the conditional embedding mapping layer of the improved MoCo model. The parameter types of the drug testing condition parameter set are identified and classified by the standardization unit to obtain continuous parameters and discrete parameters. In the continuous feature normalization unit, the continuous parameters are numerically normalized to obtain continuous feature normalization vectors. In the discrete feature encoding unit, the discrete parameters are one-hot encoded and the sparse encoded vectors are input into the embedding transformation unit. The embedding matrix is trained and the embedding mapping and linear transformation are performed to obtain continuous embedding vectors. The continuous feature normalization vectors and continuous embedding vectors are input into the feature fusion unit, and they are concatenated and linearly weighted along the feature dimension to obtain the set of testing condition embedding vectors. The batch identifier embedding vector set and the test condition embedding vector set are concatenated and feature-weighted fused along the vector dimension to obtain a comprehensive embedding vector set. The comprehensive embedding vector set is then concatenated with the corresponding drug test data in the standardized test dataset to obtain the input sample set. The input sample set is subjected to sample matching operation. Samples with the same batch identifier field and the same test condition field are paired to obtain a positive sample pair set. Samples with different batch identifier fields or different test condition fields are paired to obtain a negative sample pair set. The positive and negative sample pair sets are then input into the query encoder and key encoder of the improved MoCo model, respectively. In the query encoder and key encoder, the input sample set is sequentially fed into multiple feature extraction layers with different convolutional scales. In each convolutional layer, local features are captured and global features are aggregated through convolutional receptive fields of different sizes. Channel normalization and non-linear activation processing are performed on the output results of each convolutional layer. Feature concatenation and fusion are performed on the feature mapping results of each convolutional layer to generate a multi-scale convolutional feature map set including local detail features and global semantic features. A feature mapping operation is performed on the multi-scale convolutional feature map set. The outputs of each convolutional layer are processed by linear transformation and nonlinear activation function, and then concatenated and fused to generate an initial feature vector set.
4. The dynamic traceability method for drug testing indicators based on contrastive learning according to claim 3, characterized in that, Compared to the original MoCo model, the improved MoCo model adds a batch embedding mapping layer and a conditional embedding mapping layer. It performs feature embedding mapping and vectorization encoding on the batch identifier and inspection condition information of the input samples, generating a set of batch identifier embedding vectors and a set of inspection condition embedding vectors. During feature extraction, multi-scale convolutional kernels are introduced into the query encoder and key encoder to perform multi-scale convolutional feature extraction and mapping operations on the input sample set, generating an initial set of drug feature vectors. Regarding the sample construction mechanism, a sample construction mechanism based on batch identifiers and inspection conditions is introduced to extract batch identifier information and inspection condition parameters from the input samples. Samples are matched to form positive sample pairs according to the rule of identical batch identifiers and identical inspection conditions, and samples are matched to form negative sample pairs according to the rule of different batch identifiers or different inspection conditions. During the comparison optimization process, a time-adaptive momentum update mechanism is used to update the key encoder parameters, and a sample confidence weighting term is introduced into the comparison loss function. Feature optimization processing based on the weighted comparison loss value is performed to generate a set of deep feature vectors. The batch embedding mapping layer includes embedding matrix units, linear transformation units, nonlinear activation units, and normalization units; The conditional embedding mapping layer includes a normalization unit, a discrete feature encoding unit, a continuous feature normalization unit, an embedding transformation unit, and a feature fusion unit; The multi-scale convolutional kernels include one-dimensional convolutional kernels with receptive field sizes of three, five, and seven, respectively. The time-adaptive momentum update mechanism dynamically adjusts the momentum coefficient based on the sample time distribution information. In each training iteration, the key encoder parameters of the previous iteration period and the query encoder parameters of the current period are weighted and fused according to the momentum coefficient, and parameter replacement operation is performed to update the key encoder parameters. The sample confidence weighting term integrates sample feature similarity and time distribution factors. It performs Sigmoid normalization on the feature similarity of sample pairs and combines it with time index normalization. The two normalization results are weighted and summed according to a preset balance coefficient to obtain the confidence weight of the corresponding sample pair. This weight is then used in the feature distance weighting process in the comparison loss calculation.
5. The method for dynamic traceability of drug testing indicators based on contrastive learning according to claim 1, characterized in that, The generation of the deep feature vector set specifically includes: Extract positive and negative sample pairs from the initial feature vector set. Perform difference calculation on the feature dimension of the initial feature vector of each sample pair. After squaring and summing the difference results of each dimension, perform square root operation to obtain the feature distance value of the corresponding sample pair. Arrange the feature distance values of all sample pairs in the order of the sample pairs to obtain the feature distance set. Each feature distance value in the feature distance set is multiplied by its corresponding sample confidence weighting term for each sample pair, and then rearranged according to the index order of the sample pairs to obtain the weighted feature distance set. Based on the weighted feature distance set, the weighted feature distance of positive sample pairs is minimized, and the weighted feature distance of negative sample pairs is maximized. The weighted operation results of all sample pairs are normalized and aggregated in the sample dimension to obtain the weighted contrast loss value. During the comparative optimization process, the model parameters in the improved MoCo model, except for the key encoder parameters, are updated by gradient through backpropagation based on the weighted comparative loss value. The key encoder parameters are then updated and replaced by a time-adaptive momentum update mechanism based on the sample time distribution information. The updated improved MoCo model is then applied to the initial feature vector set for feature optimization and update, generating a deep feature vector set. The update of the key encoder parameters specifically includes: determining the weight ratio of the momentum coefficient based on the sample distribution density of each time period in the sample time distribution information, obtaining a set of weighted coefficients, and weighting and fusing the key encoder parameters of the previous iteration period and the query encoder parameters of the current iteration period according to the weighted coefficients in the parameter dimension. In each training iteration, the weight ratio of the momentum coefficient is dynamically adjusted according to the sample time distribution density, and the key encoder parameters are updated smoothly and iteratively replaced.
6. The method for dynamic traceability of drug testing indicators based on contrastive learning according to claim 1, characterized in that, The generation of the time-series feature vector sequence specifically includes: The deep feature vector set is sorted in ascending order according to the timestamp field of the drug test samples to obtain the feature vector sequence, and the time weight is calculated based on the time interval between adjacent time nodes to form a time index matrix. The feature vector sequence is ordered by time index, and the difference between the deep feature vectors between adjacent time nodes is calculated in the feature dimension. The difference results are normalized and linearly transformed dimension by dimension to obtain the time step feature representation. The time step feature representation and time index matrix are matched accordingly, continuous feature representation is extracted in time order, and weighted summation and normalization are performed to obtain the weighted average feature vector of each window. The sliding window is gradually shifted and the calculation is repeated. Local time-dependent features are obtained by sequentially splicing them in the time dimension. The local time-dependent features are arranged in chronological order. Weighted fusion operations are performed on the feature vectors of different time periods in the feature dimension. The feature similarity values between any time periods are calculated. The similarity results are normalized and aggregated. Global dependencies between time periods are established in the time dimension to obtain the global time-series correlation matrix. Based on the global time series correlation matrix, extract the time dependency coefficients of the corresponding rows using time steps as indices. Perform a weighted summation operation on the time dependency coefficients and the time step feature representations of the entire time step, and then normalize them. Perform a linear transformation on the processing results and repeat the above processing on all time nodes in chronological order, and then concatenate them sequentially to generate a time series feature vector sequence.
7. The method for dynamic traceability of drug testing indicators based on contrastive learning according to claim 1, characterized in that, The generation of the dynamic change path specifically includes: The time-series feature vectors of each time node and the time intervals between adjacent time nodes are extracted from the time-series feature vector sequence in chronological order to obtain the time interval sequence; For the time series feature vectors of adjacent time nodes, perform difference calculation on each feature dimension, divide the difference of each dimension by the corresponding time interval to obtain the feature change rate vector of each time node, and arrange them in time order to obtain the feature change rate sequence. The characteristic rate of change sequence is subjected to weighted smoothing in chronological order, and weighted summation and normalization are performed within each time window to obtain the smoothed characteristic rate of change sequence. Calculate the similarity coefficient for the temporal feature vectors of any two time points, arrange the similarity in row and column positions according to time order, and normalize it in the row direction to obtain the time dependency matrix; The smoothed feature change rate sequence and the time dependency matrix are weighted and fused. For each time node, the absolute value of the change rate is calculated on the feature dimension and then weighted and normalized according to the weight coefficients of the corresponding row in the time dependency matrix to obtain the time node importance score sequence. The set of key nodes is determined based on the time node importance score sequence. The determination method is to calculate the mean and standard deviation of the corresponding score sequence, multiply the mean and the preset coefficient by the standard deviation as the threshold, and select the time nodes with scores not less than the threshold as key nodes. The key nodes are connected in a chronological order, the direction of feature change between adjacent key nodes is marked, and the key nodes and their corresponding connections are sequentially spliced together in the time dimension to generate a dynamic change path.
8. The method for dynamic traceability of drug testing indicators based on contrastive learning according to claim 1, characterized in that, The generation of the dynamic traceability report for drug testing indicators specifically includes: Match the time nodes in the dynamic change path with the corresponding indices of the samples in the weighted feature distance set, extract the feature distance values of the corresponding samples for each time node, and obtain the node feature distance sequence. The mean and standard deviation of the node feature distance sequence are calculated. The node feature distance value is compared with the threshold obtained by multiplying the mean by a preset coefficient and the standard deviation. When the node feature distance value is greater than the threshold, the corresponding node is marked as an abnormal node. Extract the corresponding temporal feature vectors of the adjacent nodes before and after the abnormal node in the dynamic change path, perform difference calculation and normalization on the feature dimension, and perform directed connection on the change direction between adjacent nodes to obtain the temporal feature association chain of the abnormal node. By splicing and aggregating the temporal feature association chains of all abnormal nodes, the path diagram for tracing the abnormality of drug testing indicators is reconstructed. Based on the path diagram, the set of abnormal sources, the abnormal path analysis report, and the risk warning results are output. The above results are summarized to generate a dynamic traceability report of drug testing indicators.