A method for constructing causal relationship networks based on time series data
By constructing cluster clusters and using decision tree models to generate causal relationship network diagrams, the problem of insufficient recognition accuracy of causal relationship modeling in multivariable, large-scale, and complex structural time series data in the existing technology is solved, and efficient identification and visualization of causal relationships is achieved.
Patent Information
- Application Number
- CN202510442697.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-10
- Publication Date
- 2025-09-02
- Estimated Expiration
- 2045-04-10
AI Technical Summary
The existing causal modeling methods are insufficient in causal direction recognition accuracy and variable screening strategies in multivariable, large-scale, and complex structure time series data, and lack the combination of time-series trend structure recognition and machine learning models, resulting in insufficient causal characterization.
By constructing cluster clusters and using decision tree models to generate causal network graphs, including obtaining timing samples, performing hierarchical clustering, extracting causal sample pairs and calculating causal loss and driving intensity, generating graph structure to construct data sets, and finally building causal network graphs.
It improves the interpretability of variable screening and the analysis depth of causal inference, realizes structural visualization and numerical expression of the causal relationship network, and supports causal path tracking and key variable recognition.
Smart Images

Figure CN119990298B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of causal relationship networks, and in particular to a method for constructing a causal relationship network based on time series data. Background Art
[0002] Existing causal relationship modeling methods mostly rely on structural equation modeling, Granger causality test or reasoning mechanism based on graphical model, which has certain applicability in static data or low-dimensional time series scenarios. However, for multivariate, large-scale, and complex structured time series data, these methods still have obvious deficiencies in causal direction identification accuracy and variable screening strategies. Patent publication number CN114266322A discloses a method for constructing a time series causal relationship graph, which fits each two time series with a first time lag value to obtain a residual sequence, and uses the residual sequence to calculate the second time lag value, which can improve the accuracy of causal relationship judgment.
[0003] However, existing methods usually lack a structural recognition mechanism for the evolutionary trends between time series samples, making it difficult to effectively cluster variables based on time series trends. At the same time, for modeling causal relationships between variables, there is a lack of a modeling mechanism combined with machine learning models (such as decision trees), resulting in an inaccurate characterization of the directionality and intensity of causal driving relationships. Summary of the Invention
[0004] In response to the shortcomings of the existing technology, the present invention provides a method for constructing a causal network based on time series data, which solves the technical problems raised in the background technology by constructing clusters in the time series data and modeling the clusters through a decision tree model to output a causal network diagram.
[0005] To achieve the above objectives, the present invention is implemented through the following technical solutions:
[0006] A method for constructing a causal relationship network based on time series data, the method comprising:
[0007] S1. Obtain an ordered sequence of N time series samples;
[0008] S2. performing hierarchical clustering on the ordered sequence to obtain a target variable cluster;
[0009] S3. Extract several causal sample pairs from the target variable cluster, and select the causal sample pairs with the correct direction from the several causal sample pairs to generate a graph structure to construct a dataset;
[0010] Among them, the steps for generating the graph structure dataset are:
[0011] S3-1. From the target variable cluster, define a causal sample pair with a causal driving direction; wherein the causal sample pair is a binary pair of an input variable and a target variable;
[0012] S3-2, input the causal sample pair to the decision tree model, and after forward propagation of the input variables, output the predicted variables;
[0013] S3-3. Calculate the causal loss between the predictor variable and the target variable;
[0014] S3-4. If the causal loss is lower than the loss threshold, the causal driving direction of the causal sample pair is determined to be correct, otherwise the direction is determined to be incorrect;
[0015] S3-5. Calculate the causal driving strength of the input variable on the predictor variable in the causal sample pair with the correct direction; the causal driving strength is represented by the information gain score of the predictor variable;
[0016] S3-6. Collect all causal sample pairs with correct directions, record their causal driving directions and causal driving strengths, and generate a graph structure to construct a dataset.
[0017] S4. Construct a data set according to the graph structure and construct a causal relationship network graph.
[0018] In some embodiments, obtaining an ordered sequence of N time series samples includes:
[0019] S1-1. Mark the timestamps of N fixed time steps on the historical time axis;
[0020] S1-2. Obtaining original data samples corresponding to the timestamp to obtain N original data samples; wherein the data samples represent multi-dimensional feature vectors of the system state at the timestamp;
[0021] S1-3, performing data preprocessing on the N original data samples to obtain N standard data samples;
[0022] S1-4. Encode the timestamp into an independent time sequence number, and map and assign it to the corresponding standard data sample to generate the time series sample; wherein the time series sample is represented as a tuple of the time sequence number and the standard data sample;
[0023] S1-5. Sort the N time series samples according to the time sequence numbers to obtain an ordered sequence of N time series samples.
[0024] In some embodiments, performing hierarchical clustering on the ordered sequence to obtain a target variable cluster comprises:
[0025] S2-1. Construct a similarity matrix based on the ordered sequence of N time series samples;
[0026] Each matrix element of the similarity matrix is used to represent the similarity of a time series sample pair consisting of any two time series samples, and the similarity of the time series sample pair is mapped to the time series sample through the sample pair index;
[0027] S2-2. Perform iterative clustering of the time series samples based on the mapping relationship between the similarity matrix and the time series samples to construct a hierarchical clustering tree;
[0028] S2-3. Marking a number of pruned nodes in the hierarchical clustering tree;
[0029] S2-4. Starting from the pruning node, extract a target variable cluster in the hierarchical clustering tree; wherein the target variable cluster includes a plurality of time series samples.
[0030] In some embodiments, constructing a similarity matrix based on an ordered sequence of N time series samples includes:
[0031] S2-1-1. Select a time series sample corresponding to the current time sequence number from the ordered sequence of N time series samples;
[0032] S2-1-2. Mark the time series sample corresponding to the current time sequence number as the anchor sample, and mark the time series samples corresponding to the remaining time sequence numbers as non-anchor samples; where the number of non-anchor samples is N-1;
[0033] S2-1-3. Calculate the cosine similarity between the anchor sample and all non-anchor samples to obtain N-1 similarity values corresponding to the anchor time series sample;
[0034] S2-1-4. Sort the N-1 similarity values corresponding to the anchor time series sample according to the time sequence number to obtain an ordered sequence of similarities corresponding to the anchor time series sample;
[0035] S2-1-5. Execute S2-1-1 to S2-1-4 on the N time series samples in the ordered sequence to obtain N similarity ordered sequences;
[0036] S2-1-6. Align the N similarity ordered sequences up and down in chronological order to construct an N*(N-1)-dimensional similarity matrix.
[0037] In some embodiments, iterative clustering of the time series samples is performed based on the mapping relationship between the similarity matrix and the time series samples to construct a hierarchical clustering tree, including:
[0038] S2-2-1. Initialize N time series samples into N independent initial clusters to obtain an initial cluster set; each initial cluster contains only one time series sample;
[0039] S2-2-2. Obtain a merged cluster from the initial cluster set;
[0040] S2-2-3. Iteratively obtain merged clusters until the initial cluster set is updated to the hierarchical clustering tree.
[0041] In some embodiments, obtaining a merged cluster from an initial set of clusters includes:
[0042] S2-2-2-1. Perform distance transformation on the similarity matrix to construct a symmetrical distance matrix; each matrix element of the distance matrix represents the distance between two time series samples; the distance calculation expression is:
[0043] L = 1-CS;
[0044] Among them, L is the distance, which represents the difference between any two time series samples, and CS is the cosine similarity, which represents the similarity between any two time series samples;
[0045] S2-2-2-2. Find the matrix element corresponding to the minimum distance in the distance matrix;
[0046] S2-2-2-3. Selecting, from the set of initial clusters, the initial clusters corresponding to the two most similar time series samples according to the matrix element corresponding to the minimum distance;
[0047] S2-2-2-4. Perform cluster merging on the initial clusters corresponding to the two most similar time series samples to obtain the merged cluster.
[0048] In some embodiments, iteratively obtaining merged clusters until the initial cluster set is updated to the hierarchical clustering tree includes:
[0049] S2-2-3-1. Remove the initial clusters corresponding to the two most similar time series samples from the initial cluster set, and add the merged cluster to obtain an iterated cluster set;
[0050] S2-2-3-2. According to the preset aggregation strategy, calculate the updated distance between the merged cluster and each of the remaining clusters in the iterative cluster set, and construct an updated distance matrix constructed from the updated distances;
[0051] S2-2-3-3. Find the matrix element corresponding to the minimum distance in the updated distance matrix;
[0052] S2-2-3-4, repeat S2-2-3-1 to S2-2-3-3 until a cluster is found in the iterated cluster set, and the clustering is completed;
[0053] S2-2-3-5. Define the cluster cluster after clustering as the hierarchical clustering tree; wherein each node of the clustering tree corresponds to a cluster merging, and the node height corresponds to the sample distance at the time of cluster merging.
[0054] In some embodiments, starting from the pruning node, extracting a target variable cluster in the hierarchical clustering tree includes:
[0055] S2-4-1. Perform subtree traversal on one or more pruned nodes in the hierarchical clustering tree to extract all leaf nodes contained in each pruned node; wherein each leaf node corresponds to a time series sample;
[0056] S2-4-2. Aggregate all leaf nodes extracted from each pruned node to form a variable subcluster. Each variable subcluster contains several time series samples.
[0057] S2-4-3. Perform any pairwise combination of the time series samples in all aggregated variable subclusters to construct a causal sample pair set for causal modeling; the causal sample pair set contains M causal sample pairs, where M = N / 2;
[0058] S2-4-4. Define the set of causal sample pairs as the target variable cluster.
[0059] In some embodiments, defining causal sample pairs with causal driving directions from the target variable cluster includes:
[0060] S3-1-1. Mark any causal sample pair in the target variable cluster;
[0061] S3-1-2, extract the feature vectors of the two standard data samples in the marked causal sample pair;
[0062] S3-1-3. Define one of the feature vectors as the input variable and the other feature vector as the target variable to construct a causal sample pair with a causal driving direction.
[0063] In some embodiments, constructing a data set based on the graph structure and constructing a causal network graph includes:
[0064] S4-1. Traverse the graph structure to build a data set, and sequentially read all causal sample pairs with correct directions and their corresponding causal driving directions and causal driving strengths;
[0065] S4-2, setting the two time series samples in each causal sample pair as nodes in the graph structure;
[0066] S4-3. Establish a directed edge between two nodes according to the causal driving direction;
[0067] S4-4. Assigning the causal driving strength as the weight of the directed edge: Assigning the causal driving strength represented by the information gain score of the predictor variable as the weight of the directed edge; the weight of the directed edge is used to quantify the strength of the causal relationship;
[0068] S4-5. Repeat S4-1 to S4-4 until all causal sample pairs in the dataset are traversed and constructed through the graph structure.
[0069] S4-6. After all nodes and directed edges are established, a causal network diagram containing all time series nodes, directed edges, and edge weights is output.
[0070] The present invention provides a method for constructing a causal relationship network based on time series data, which has the following beneficial effects:
[0071] The present invention constructs a similarity matrix for time series samples and iteratively clusters them to generate a hierarchical clustering tree with a time evolution trend structure, which can efficiently identify potential target variable clusters and improve the interpretability of variable screening.
[0072] Furthermore, based on the pruning structure, time series sample pairs are extracted and combined with a decision tree model to perform a dual assessment of causal direction and driving strength. This not only determines the validity of causal paths, but also quantifies the causal driving strength between variables, enhancing the analytical depth of causal inference. Furthermore, causal sample pairs are constructed as nodes and edges in a graph structure, and information gain is used as edge weight. This enables the structural visualization and numerical representation of the causal network, facilitating subsequent causal path tracking, key variable identification, and strategic regulation of the target system. BRIEF DESCRIPTION OF THE DRAWINGS
[0073] Figure 1 This is a flow chart of a method for constructing a causal relationship network based on time series data according to the present invention;
[0074] Figure 2 This is a flow chart of merging clusters according to the present invention;
[0075] Figure 3 This is a flowchart for constructing a dataset based on the graph structure described in the present invention. DETAILED DESCRIPTION
[0076] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.
[0077] First, the prior art and related concepts involved in the embodiments of the present invention are described:
[0078] Decision tree model: A commonly used supervised learning method suitable for classification and regression tasks. Its basic idea is to divide the sample space into multiple subregions by layer-by-layer partitioning of input features, so that the labels of samples in each subregion tend to be consistent, thereby achieving the purpose of predicting the target variable.
[0079] Example 1: Please refer to Figures 1 to 3 The present invention provides a method for constructing a causal relationship network based on time series data, the steps of the construction method comprising:
[0080] S1. Obtain an ordered sequence of N time series samples;
[0081] Exemplarily, step S1 specifically includes:
[0082] S1-1. Mark the timestamps of N fixed time steps on the historical time axis;
[0083] S1-2. Obtaining original data samples corresponding to the timestamp to obtain N original data samples; wherein the data samples represent multi-dimensional feature vectors of the system state at the timestamp;
[0084] The system state refers to the overall operating status of the target system at a specific timestamp. It includes the values of multiple observed variables in the system at that timestamp, describing the system's state at that moment. The target system is defined based on the task requirements.
[0085] S1-3, performing data preprocessing on the N original data samples to obtain N standard data samples;
[0086] S1-4. Encode the timestamp into an independent time sequence number, and map and assign it to the corresponding standard data sample to generate the time series sample; wherein the time series sample is represented as a tuple of the time sequence number and the standard data sample;
[0087] S1-5. Sort the N time series samples according to the time sequence numbers to obtain an ordered sequence of N time series samples.
[0088] In this embodiment, by marking timestamps at fixed time steps on the historical timeline and obtaining the system state feature vector corresponding to each timestamp, a multidimensional time series dataset can be constructed that reflects the operating status of the target system at each time node. Data quality is further improved by combining preprocessing methods such as outlier processing, missing value filling, and standardization. By encoding timestamps as independent time series numbers and establishing a mapping relationship with standard data samples, time series samples with time attribute binding can be generated, which helps maintain time evolution logic. The resulting ordered sequence of time series samples provides data support for similarity calculation, cluster analysis, and causal modeling.
[0089] Furthermore, the steps of the construction method further include:
[0090] S2. performing hierarchical clustering on the ordered sequence to obtain a target variable cluster;
[0091] The S2 specifically includes:
[0092] S2-1. Construct a similarity matrix based on the ordered sequence of N time series samples;
[0093] Each matrix element of the similarity matrix is used to represent the similarity of a time series sample pair consisting of any two time series samples, and the similarity of the time series sample pair is mapped to the time series sample through the sample pair index;
[0094] The sample pair index represents the position index pair of the time series sample pair corresponding to any matrix element in the similarity matrix in the original sample sequence, and is used to uniquely identify the two time series samples associated with the similarity value.
[0095] For example, if the matrix element in row i and column j is , the sample pair index is (i, j), which represents the similarity between the i-th time series sample and the j-th time series sample. This index pair is used to track the mapping relationship between sample pairs in the process of building cluster trees and establishing causal sample pairs.
[0096] Exemplarily, step S2-1 specifically includes:
[0097] S2-1-1. Select a time series sample corresponding to the current time sequence number from the ordered sequence of N time series samples;
[0098] S2-1-2. Mark the time series sample corresponding to the current time sequence number as the anchor sample, and mark the time series samples corresponding to the remaining time sequence numbers as non-anchor samples; where the number of non-anchor samples is N-1;
[0099] S2-1-3. Calculate the cosine similarity between the anchor sample and all non-anchor samples to obtain N-1 similarity values corresponding to the anchor time series sample;
[0100] S2-1-4. Sort the N-1 similarity values corresponding to the anchor time series sample according to the time sequence number to obtain an ordered sequence of similarities corresponding to the anchor time series sample;
[0101] S2-1-5. Execute S2-1-1 to S2-1-4 on the N time series samples in the ordered sequence to obtain N similarity ordered sequences;
[0102] S2-1-6. Align the N similarity ordered sequences up and down in chronological order to construct an N*(N-1)-dimensional similarity matrix.
[0103] In this embodiment, by using each ordered time series sample as an anchor sample and calculating the cosine similarity between it and all other non-anchor samples, the similarity of each time series sample in the entire sample space is characterized. Furthermore, by sorting the similarity results by time sequence and performing structured concatenation, a similarity matrix of size N*(N-1) is constructed, which comprehensively reflects the full picture of the pairwise similarity relationships between samples.
[0104] Furthermore, the S2 specifically includes:
[0105] S2-2. Based on the mapping relationship between the similarity matrix and the time series samples, iterative clustering of the time series samples is performed to construct a hierarchical clustering tree; the hierarchical clustering tree is used to identify the similarity of the time evolution trends between the time series samples.
[0106] Exemplarily, step S2-2 specifically includes:
[0107] S2-2-1. Initialize N time series samples into N independent initial clusters to obtain an initial cluster set; each initial cluster contains only one time series sample;
[0108] S2-2-2. Obtain a merged cluster from the initial cluster set;
[0109] S2-2-3. Iteratively obtain merged clusters until the initial cluster set is updated to the hierarchical clustering tree.
[0110] Furthermore, the step S2-2-2 specifically includes:
[0111] S2-2-2-1. Perform distance transformation on the similarity matrix to construct a symmetrical distance matrix; each matrix element of the distance matrix represents the distance between two time series samples; the distance calculation expression is:
[0112] L = 1-CS;
[0113] Among them, L is the distance, which represents the difference between any two time series samples, and CS is the cosine similarity, which represents the similarity between any two time series samples;
[0114] S2-2-2-2. Find the matrix element corresponding to the minimum distance in the distance matrix;
[0115] S2-2-2-3. Selecting, from the set of initial clusters, the initial clusters corresponding to the two most similar time series samples according to the matrix element corresponding to the minimum distance;
[0116] S2-2-2-4. Perform cluster merging on the initial clusters corresponding to the two most similar time series samples to obtain the merged cluster.
[0117] By performing a distance transformation on the similarity matrix, a symmetric distance matrix was constructed to measure the differences between time series samples, providing a unified distance metric. By finding the minimum distance in the distance matrix and using this distance to identify the two most similar initial clusters, individual samples can be merged based on the minimum dissimilarity criterion.
[0118] Furthermore, the step S2-2-3 specifically includes:
[0119] S2-2-3-1. Remove the initial clusters corresponding to the two most similar time series samples from the initial cluster set, and add the merged cluster to obtain an iterated cluster set;
[0120] S2-2-3-2. According to the preset aggregation strategy, calculate the updated distance between the merged cluster and each of the remaining clusters in the iterative cluster set, and construct an updated distance matrix constructed from the updated distances;
[0121] The preset aggregation strategies include but are not limited to:
[0122] Single linkage method: take the minimum value of the distance between all time series sample pairs between two clusters;
[0123] Full link method: take the maximum value;
[0124] Average link method: take the average value.
[0125] S2-2-3-3. Find the matrix element corresponding to the minimum distance in the updated distance matrix;
[0126] S2-2-3-4, repeat S2-2-3-1 to S2-2-3-3 until a cluster is found in the iterated cluster set, and the clustering is completed;
[0127] S2-2-3-5. Define the cluster cluster after clustering as the hierarchical clustering tree; wherein each node of the clustering tree corresponds to a cluster merging, and the node height corresponds to the sample distance at the time of cluster merging.
[0128] In this embodiment, adaptive convergence of the clustering structure is achieved by removing the most similar clusters in each iteration and merging them into new clusters. Selectable aggregation strategies (including single linkage, full linkage, or average linkage) are used to calculate the updated distance between the new cluster and the remaining clusters. Ultimately, as all initial clusters gradually merge into a cluster tree structure, the system fully preserves the paths and merged distances of each aggregation, thereby constructing a hierarchical clustering tree that reflects the evolution of the similarity of time series samples.
[0129] Furthermore, the specific steps of S2 also include:
[0130] S2-3. Marking a number of pruned nodes in the hierarchical clustering tree;
[0131] Specifically, in a hierarchical clustering tree, one or more pruned nodes in the clustering tree are marked according to a preset pruning threshold or the hierarchical depth of the tree.
[0132] S2-4. Starting from the pruning node, extract a target variable cluster in the hierarchical clustering tree; wherein the target variable cluster includes a plurality of time series samples.
[0133] The specific implementation steps of step S2-4 are as follows:
[0134] S2-4-1. Perform subtree traversal on one or more pruned nodes in the hierarchical clustering tree to extract all leaf nodes contained in each pruned node; wherein each leaf node corresponds to a time series sample;
[0135] S2-4-2. Aggregate all leaf nodes extracted from each pruned node to form a variable subcluster. Each variable subcluster contains several time series samples.
[0136] S2-4-3. Perform any pairwise combination of the time series samples in all aggregated variable subclusters to construct a causal sample pair set for causal modeling; the causal sample pair set contains M causal sample pairs, where M = N / 2;
[0137] S2-4-4. Define the set of causal sample pairs as the target variable cluster.
[0138] In this embodiment, by performing subtree traversal on the marked pruned nodes in the hierarchical clustering tree, a set of time series samples with high similarity in the local aggregation structure can be effectively extracted. The leaf nodes under each pruned node are aggregated into independent variable subclusters, retaining the local time evolution characteristics reflected by the clustering tree pruning results. Furthermore, by performing pairwise combinations on the time series samples extracted in the subclusters, a set of causal sample pairs with directional potential is constructed. The target variable cluster generated in this process essentially completes the transition from structural screening to sample reorganization, and can effectively construct a causal sample pair structure with causal modeling significance on the basis of maintaining time similarity.
[0139] Furthermore, the steps of the construction method further include:
[0140] S3. Extract several causal sample pairs from the target variable cluster, and select the causal sample pairs with the correct direction from the several causal sample pairs to generate a graph structure to construct a dataset;
[0141] S4. Construct a data set according to the graph structure and construct a causal relationship network graph.
[0142] In this embodiment, by constructing a similarity matrix for time series samples and mapping and managing the sample pair index, it is possible to accurately track the similarity relationship between any two time series samples; then, based on the similarity, iterative clustering is performed to construct a hierarchical clustering tree structure to reveal the aggregation rules of the time series samples in the evolution trend. Furthermore, clusters of target variables with significant similarity are extracted through pruning operations, and on this basis, causal sample pairs are reorganized, and the graph structure data is constructed in combination with the causal drive direction screening mechanism to finally generate a causal network diagram. This embodiment realizes the full-process modeling of aggregating, screening and constructing a structured causal network layer by layer starting from the original time series samples, thereby improving the efficiency of the structural expression of potential causal relationships in complex time series data.
[0143] Example 2: See Figure 3 The technical solution of this embodiment 2 is different from that of embodiment 1 in that it discloses the specific implementation steps of constructing the causal network diagram in embodiment 1, namely, the specific implementation steps of steps S3 and S4.
[0144] The specific implementation steps of step S3 are:
[0145] S3-1. From the target variable cluster, define a causal sample pair with a causal driving direction; wherein the causal sample pair is a binary pair of an input variable and a target variable;
[0146] S3-2, input the causal sample pair to the decision tree model, and after forward propagation of the input variables, output the predicted variables;
[0147] S3-3. Calculate the causal loss between the predictor variable and the target variable;
[0148] Among them, causal loss is a supervised learning loss function set according to the type of target variable, including but not limited to: using mean square error when the target variable is a continuous variable, and using cross entropy loss when the target variable is a categorical variable.
[0149] The causal loss is used to measure the degree of prediction error of the input variable on the target variable under a specified causal driving direction. The lower the error, the better the prediction effect in this direction, which indicates that the input variable has a potential causal driving effect on the target variable.
[0150] S3-4. If the causal loss is lower than the loss threshold, the causal driving direction of the causal sample pair is determined to be correct, otherwise the direction is determined to be incorrect;
[0151] In this invention, in order to achieve causal relationship modeling between target variables, it is necessary to establish a driving direction determination and strength assessment mechanism for the variables in the time series sample pairs. To this end, the following terms and calculation logic are defined as follows:
[0152] "Input variable" refers to the variable used as model input to predict another variable in the causal relationship modeling process, usually coming from a standard data sample at a certain timestamp.
[0153] "Target variable" refers to the variable used as the prediction target in supervised modeling, that is, the label during model training, which usually comes from a standard data sample at another time stamp.
[0154] It should be noted that the target variable in this scenario is not equivalent to the "predictor variable." The predictor variable usually refers to the predicted result output by the model, while the target variable is the ground truth variable provided as a supervisory signal in the dataset.
[0155] To quantify the causal driving force of the input variables on the target variable, information gain is used as a scoring metric. Information gain is used to measure the degree to which the uncertainty of the target variable prediction result is reduced after the introduction of a certain input variable.
[0156] S3-5. Calculate the causal driving strength of the input variable on the predictor variable in the causal sample pair with the correct direction; the causal driving strength is represented by the information gain score of the predictor variable;
[0157] The calculation expression of the information gain score is:
[0158] ;
[0159] in, Represents the information gain of input variable X on target variable Y; that is, the score of causal driving strength;
[0160] Represents the information entropy of the target variable Y, which is used to measure the uncertainty of the target variable Y itself;
[0161] It represents the conditional entropy of the target variable Y when the input variable X is known; that is, the uncertainty remaining in the target variable Y after considering the input variable X. The conditional entropy characterizes the uncertainty remaining in the target variable Y after considering the input variable X.
[0162] When splitting features, the model selects the optimal split based on information gain. Therefore, the information gain value can be directly used as a quantitative indicator of the strength of causal driving force. If an input variable X has a large information gain on the target variable Y, it means that the decision tree model's prediction of the target variable Y is significantly enhanced after using input variable X as a split condition, indicating that input variable X is an important dependent variable driving the target variable Y. This driving force reflects the strength of the causal relationship from X to Y.
[0163] Ultimately, all causal sample pairs that meet the causal loss constraints and their information gain scores will serve as the data basis for constructing the causal network graph, and information gain is used to assign weights to the edges in the graph.
[0164] S3-6. Collect all causal sample pairs with correct directions, record their causal driving directions and causal driving strengths, and generate a graph structure to construct a dataset.
[0165] In this embodiment, by inputting the constructed causal sample pairs into a decision tree model and evaluating the prediction results using a supervised learning loss function, it is possible to determine the causal driving direction. Specifically, the causal loss is used to determine the rationality of the driving direction, and the information gain is used to quantify the degree to which the input variable reduces the uncertainty of the target variable. This allows the selection of causal sample pairs with clear causal directions and significant driving strength from multiple causal sample pairs. Ultimately, the data is aggregated to form a structured graph construction dataset.
[0166] Furthermore, the step S3-1 specifically includes:
[0167] S3-1-1. Mark any causal sample pair in the target variable cluster;
[0168] S3-1-2, extract the feature vectors of the two standard data samples in the marked causal sample pair;
[0169] S3-1-3. Define one of the feature vectors as the input variable and the other feature vector as the target variable to construct a causal sample pair with a causal driving direction.
[0170] During the causal modeling step, a decision tree model is used to predict the target variable. For each causal pair, an input variable X and a target variable Y are specified, and a decision tree model is trained to evaluate the predictive power of the input variable X on the target variable Y.
[0171] In this example, by clearly assigning roles to causal pairs within the target variable cluster and calibrating the feature vectors of two standard data samples as input and target variables, respectively, a clear variable dependency relationship is established for the causal modeling process. This sample pair structure incorporates potential driving directionality, ensuring stable and consistent semantics during causal judgments and providing a clear variable foundation for information gain calculations, thereby ensuring accurate causal direction screening and strength analysis.
[0172] The specific implementation steps of step S4 are:
[0173] S4-1. Traverse the graph structure to build a data set, and sequentially read all causal sample pairs with correct directions and their corresponding causal driving directions and causal driving strengths;
[0174] S4-2, setting the two time series samples in each causal sample pair as nodes in the graph structure;
[0175] S4-3. Establish a directed edge between the two nodes according to the causal driving direction; the directed edge is used to represent the directionality of the causal relationship;
[0176] S4-4. Assigning the causal driving strength as the weight of the directed edge. Assigning the causal driving strength represented by the information gain score of the predictor variable as the weight of the directed edge; the weight of the directed edge is used to quantify the strength of the causal relationship; that is, the information gain score of the predictor variable can be used to represent the edge weight of the directed edge between two nodes in the graph structure;.
[0177] S4-5. Repeat S4-1 to S4-4 until all causal sample pairs in the dataset are traversed and constructed through the graph structure.
[0178] S4-6. After all nodes and directed edges are established, a causal network diagram containing all time series nodes, directed edges, and edge weights is output.
[0179] In this embodiment, by converting causal sample pairs with correct directions and clear driving strengths into graph structure elements with nodes, directions, and weights, a causal network diagram is finally constructed. This causal network diagram not only retains the causal driving path and driving direction between time series sample variables, but also quantifies the strength of the causal driving relationship through edge weights, thereby providing a clear and visual expression carrier for causal structure modeling. With the help of this causal network diagram, users can more intuitively identify the driving variables and response paths of key time series sample variables in the target system, which helps to understand the causal mechanism between multiple time series data variables in complex target systems, thereby providing data support for downstream analysis tasks such as causal tracing, decision intervention, or mechanism regulation.
[0180] Illustratively, the target system of this embodiment may be the target system exemplified below.
[0181] Example 1: Biological gene regulation system
[0182] In the field of bioinformatics, gene expression data is typically collected in the form of time series to observe changes in the expression levels of different genes under specific conditions. This method can be used to identify regulatory causal networks between genes, for example, to determine the direction and intensity of the driving effect of certain transcription factors on downstream genes.
[0183] Example 2: Industrial process control system
[0184] In automated manufacturing or chemical production systems, multiple sensors monitor equipment operating conditions (such as temperature, pressure, and flow) and record these data as time series at a fixed frequency. This method can identify the causal relationships between process parameters, helping to determine which variable fluctuations are systemic responses and which are driving factors, thereby optimizing control strategies.
[0185] The above embodiments can be implemented in whole or in part by software, hardware, firmware, or any other combination thereof. When implemented using software, the above embodiments can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions or computer programs. When the computer instructions or computer program are loaded or executed on a computer, the process or function described in the embodiments of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via a wired method (e.g., infrared, wireless, microwave, etc.).
[0186] The computer-readable storage medium may be any available medium that can be accessed by a computer or a data storage device such as a server or data center that includes one or more available media. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., DVD ), or semiconductor media. The semiconductor media may be a solid-state drive.
[0187] In the several embodiments provided in this application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of the units is merely a logical function division of a waterway underwater terrain change analysis system and method. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0188] The above is only a specific implementation method of the present application, but the scope of protection of the present application is not limited thereto. Any technician familiar with this technical field can easily think of changes or replacements within the technical scope disclosed in this application, which should be covered by the scope of protection of the present application.
Claims
1. A method for constructing a causal relationship network based on time series data, characterized in that: The construction method comprises: S1. Obtain an ordered sequence of N time series samples; S2. performing hierarchical clustering on the ordered sequence to obtain a target variable cluster; The performing hierarchical clustering on the ordered sequence to obtain a target variable cluster includes: S2-1. Construct a similarity matrix based on the ordered sequence of N time series samples; Each matrix element of the similarity matrix is used to represent the similarity of a time series sample pair consisting of any two time series samples, and the similarity of the time series sample pair is mapped to the time series sample through the sample pair index; S2-2. Perform iterative clustering of the time series samples based on the mapping relationship between the similarity matrix and the time series samples to construct a hierarchical clustering tree; S2-3. Marking a number of pruned nodes in the hierarchical clustering tree; S2-4. Starting from the pruned node, extract a target variable cluster in the hierarchical clustering tree; wherein the target variable cluster includes a plurality of time series samples; S3. Extract several causal sample pairs from the target variable cluster, and select the causal sample pairs with the correct direction from the several causal sample pairs to generate a graph structure to construct a dataset; S4. Constructing a data set according to the graph structure and constructing a causal network graph; The steps of constructing the causal relationship network diagram include: S4-1. Traverse the graph structure to build a data set, and sequentially read all causal sample pairs with correct directions and their corresponding causal driving directions and causal driving strengths; S4-2, setting the two time series samples in each causal sample pair as nodes in the graph structure; S4-3. Establish a directed edge between the two nodes according to the causal driving direction; the directed edge is used to represent the directionality of the causal relationship; S4-4. Assigning the causal driving strength represented by the information gain score of the predictor variable as the weight of the directed edge; the weight of the directed edge is used to quantify the strength of the causal relationship; S4-5. Repeat S4-1 to S4-4 until all causal sample pairs in the dataset are traversed and constructed through the graph structure. S4-6. After all nodes and directed edges are established, a causal network diagram including all time series nodes, directed edges, and edge weights is output; The causal network diagram is applied to industrial automated manufacturing or chemical production systems to identify the causal relationship between various process parameters; the time series samples are the operating status of sensor monitoring equipment recorded at a fixed frequency.
2. The method for constructing a causal relationship network based on time series data according to claim 1, characterized in that: Get an ordered sequence of N time series samples, including: S1-1. Mark the timestamps of N fixed time steps on the historical time axis; S1-2. Obtaining original data samples corresponding to the timestamp to obtain N original data samples; wherein the data samples represent multi-dimensional feature vectors of the system state at the timestamp; S1-3, performing data preprocessing on the N original data samples to obtain N standard data samples; S1-4. Encode the timestamp into an independent time sequence number, and map and assign it to the corresponding standard data sample to generate the time series sample; wherein the time series sample is represented as a tuple of the time sequence number and the standard data sample; S1-5. Sort the N time series samples according to the time sequence numbers to obtain an ordered sequence of N time series samples.
3. The method for constructing a causal relationship network based on time series data according to claim 2, characterized in that: According to the ordered sequence of N time series samples, a similarity matrix is constructed, including: S2-1-1. Select a time series sample corresponding to the current time sequence number from the ordered sequence of N time series samples; S2-1-2. Mark the time series sample corresponding to the current time sequence number as the anchor sample, and mark the time series samples corresponding to the remaining time sequence numbers as non-anchor samples; where the number of non-anchor samples is N-1; S2-1-3. Calculate the cosine similarity between the anchor sample and all non-anchor samples to obtain N-1 similarity values corresponding to the anchor time series sample; S2-1-4. Sort the N-1 similarity values corresponding to the anchor time series sample according to the time sequence number to obtain an ordered sequence of similarities corresponding to the anchor time series sample; S2-1-5. Execute S2-1-1 to S2-1-4 on the N time series samples in the ordered sequence to obtain N similarity ordered sequences; S2-1-6, align N similarity ordered sequences up and down in time sequence, and construct dimensional similarity matrix.
4. The method for constructing a causal relationship network based on time series data according to claim 3, characterized in that: According to the mapping relationship between the similarity matrix and the time series samples, iterative clustering of the time series samples is performed to construct a hierarchical clustering tree, including: S2-2-1. Initialize N time series samples into N independent initial clusters to obtain an initial cluster set; each initial cluster contains only one time series sample; S2-2-2. Obtain a merged cluster from the initial cluster set; S2-2-3. Iteratively obtain merged clusters until the initial cluster set is updated to the hierarchical clustering tree.
5. The method for constructing a causal relationship network based on time series data according to claim 4, characterized in that: From the initial cluster set, obtain the merged cluster, including: S2-2-2-1. Perform distance transformation on the similarity matrix to construct a symmetrical distance matrix; each matrix element of the distance matrix represents the distance between two time series samples; the calculation expression of the distance between the two time series samples is: L = 1-CS; Among them, L is the distance between two time series samples, which represents the difference between any two time series samples. CS is the cosine similarity, which represents the similarity between any two time series samples. S2-2-2-2. Find the matrix element corresponding to the minimum distance in the distance matrix; S2-2-2-3. Selecting, from the set of initial clusters, the initial clusters corresponding to the two most similar time series samples according to the matrix element corresponding to the minimum distance; S2-2-2-4. Perform cluster merging on the initial clusters corresponding to the two most similar time series samples to obtain the merged cluster.
6. The method for constructing a causal relationship network based on time series data according to claim 5, characterized in that: Iteratively obtaining merged clusters until the initial cluster set is updated to the hierarchical clustering tree, including: S2-2-3-1. Remove the initial clusters corresponding to the two most similar time series samples from the initial cluster set, and add the merged cluster to obtain an iterated cluster set; S2-2-3-2. According to the preset aggregation strategy, calculate the updated distance between the merged cluster and each of the remaining clusters in the iterative cluster set, and construct an updated distance matrix constructed from the updated distances; S2-2-3-3. Find the matrix element corresponding to the minimum distance in the updated distance matrix; S2-2-3-4, repeat S2-2-3-1 to S2-2-3-3 until a cluster is found in the iterated cluster set, and the clustering is completed; S2-2-3-5. Define the cluster cluster after clustering as the hierarchical clustering tree; wherein each node of the clustering tree corresponds to a cluster merging, and the node height corresponds to the sample distance at the time of cluster merging.
7. The method for constructing a causal relationship network based on time series data according to claim 1, characterized in that: Starting from the pruning node, extracting a target variable cluster in the hierarchical clustering tree includes: S2-4-1. Perform subtree traversal on one or more pruned nodes in the hierarchical clustering tree to extract all leaf nodes contained in each pruned node; wherein each leaf node corresponds to a time series sample; S2-4-2. Aggregate all leaf nodes extracted from each pruned node to form a variable subcluster. Each variable subcluster contains several time series samples. S2-4-3. Perform any pairwise combination of the time series samples in all aggregated variable subclusters to construct a causal sample pair set for causal modeling; the causal sample pair set contains M causal sample pairs, where M = N / 2; S2-4-4. Define the set of causal sample pairs as the target variable cluster.
8. The method for constructing a causal relationship network based on time series data according to claim 1, characterized in that: From the target variable cluster, causal sample pairs with causal driving directions are defined, including: S3-1-1. Mark any causal sample pair in the target variable cluster; S3-1-2, extract the feature vectors of the two standard data samples in the marked causal sample pair; S3-1-3. Define one of the feature vectors as the input variable and the other feature vector as the target variable to construct a causal sample pair with a causal driving direction.
Citation Information
Patent Citations
Construction method of time sequence causal relationship graph
CN114266322A
State causal-associated power grid vulnerability network graph construction method
CN117787391A
Causal relationship network analysis method for high-dimensional few-shot time series
WO2024130569A1