A black-box prediction model anomaly diagnosis method based on automatic causal discovery and Shapley value

CN122885732APending Publication Date: 2026-10-09ZHEJIANG UNIV +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610886749.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-06-18
Publication Date
2026-10-09

AI Technical Summary

Technical Problem

黑盒模型针对此类非自然样本给出的预测反馈往往是不可靠的,从而导致最终计算出的归因结果不准确

Benefits of technology

1)摆脱了对先验专家因果图的依赖,实现了全自动化的因果建模。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122885732A_ABST
    Figure CN122885732A_ABST
Patent Text Reader

Abstract

The application discloses a kind of black box prediction model anomaly diagnosis method based on automatic causal discovery and Shapley value, belong to industrial artificial intelligence and predictive maintenance field.Firstly, the real value of target variable and multidimensional independent variable are collected per hour, the predicted value of target variable is obtained through black box prediction model, and the prediction error is further obtained;Combined with sliding window, the collected data is constructed into enhanced training dataset, each time each dimension independent variable, target variable predicted value and prediction error are used as nodes to construct causal diagram, and counterfactual generator is established;When abnormality occurs, randomly select independent variable to form subset, get the value function of subset through counterfactual generator;After traversing all subsets, the relative contribution of each independent variable is calculated by causal Shapley value, and the independent variable located in the first K is the cause of abnormality.This method can accurately lock the source variable that drives error, so that the diagnosis result has clear physical action guiding significance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of industrial artificial intelligence and predictive maintenance, specifically involving an anomaly diagnosis method based on a black-box prediction model using automatic causal discovery and Shapley values. Background Technology

[0002] Today, prediction systems based on deep learning and complex ensemble models are widely used in critical fields such as industrial monitoring, financial risk control, and environmental monitoring. While these models significantly improve prediction accuracy, their internal operating mechanisms are often "black box" characteristics, meaning that the model's decision-making logic is opaque to human users. When a prediction system exhibits serious biases or anomalies (i.e., outliers in the prediction error), quickly and accurately locating the root cause of the anomaly (Root Cause Analysis, RCA) is crucial for ensuring the system's reliability, security, and trustworthiness.

[0003] In the existing technological system, the explanation and attribution of the predictive behavior of machine learning models are mainly achieved through two types of technical solutions: The first category is heuristic attribution methods, with representative schemes including LIME and SHAP. These methods typically quantify the contribution of input variables to the model output by perturbing input features or analyzing model gradients. For example, LIME approximates the behavior of a black-box model by locally fitting a linear model; SHAP assigns feature importance based on Shapley values ​​from game theory.

[0004] The second category is root cause analysis methods based on predefined causal graphs. To overcome the limitation of heuristic methods in ignoring the interactions between variables, some existing techniques attempt to introduce causal inference, such as Causal Shapley Values. By incorporating causal structure information, they distinguish between direct and indirect effects, thereby more accurately tracing the propagation path of anomalous events. These methods typically assume that the causal relationship between variables is known and utilize this known structure for counterfactual reasoning to calculate the causal contribution of variables to anomalous outcomes.

[0005] However, the existing methods still have the following drawbacks: 1) Heuristic attribution methods ignore the physical coupling mechanisms between variables, resulting in samples that violate the data distribution and causing attribution failure. Existing mainstream methods (such as LIME and SHAP) typically use feature masking or random permutation to simulate "feature missing" situations when evaluating feature importance. However, in complex industrial time series data, there are close spatiotemporal dependencies between variables. This crude independent perturbation disrupts the joint distribution between variables, generating "out-of-distribution samples" that violate physical common sense. The predictive feedback given by black-box models for such unnatural samples is often unreliable, leading to inaccurate attribution results.

[0006] 2) Relying solely on statistical correlation cannot distinguish between "causation" and "spurious correlation," and it is easy to misjudge intermediate variables as the root cause. Traditional sensitivity analysis methods mainly rely on statistical correlation. Existing techniques lack the ability to identify causality and are easily influenced by confounding variables, mistakenly identifying "intermediate transmission variables" exhibiting abnormal symptoms as the source of the problem, thus failing to trace back to the true root cause.

[0007] 3) Existing causal analysis techniques heavily rely on prior expert knowledge, making them difficult to implement in complex black-box scenarios. While some existing techniques attempt to introduce causal inference, they typically require a complete and accurate causal relationship graph as input. In real-world industrial monitoring or complex prediction scenarios, the internal structure of the system is extremely complex and dynamically changing, making it nearly impossible to obtain perfect domain expert knowledge or a predefined system topology. Once a prior graph is lacking or the graph structure is biased, such methods fail to function, lacking the ability to automatically discover causal structures.

[0008] Therefore, there is an urgent need to propose a new method for automatically discovering causal structures. Summary of the Invention

[0009] To address the existing technical problems, this invention proposes an anomaly diagnosis method based on a black-box prediction model using automatic causal discovery and Shapley values. The specific technical solution is as follows: S1. Input the values ​​of independent variables with multiple dimensions at historical moments into the black-box prediction model. After obtaining the predicted value of the target variable at each moment, subtract it from the true value of the target variable at the same moment to obtain the prediction error at each historical moment. S2, based on the predicted values ​​and prediction errors of the independent variables and target variables at all historical moments, a sliding window is used to construct the training dataset; further, all dimensions of the independent variables, predicted values ​​and prediction errors of the target variables at all historical moments in the training dataset are used as variable nodes, and directed edges are established between pairs of variable nodes to obtain the causal graph; S3, establish the mechanism equation between each variable node and all its parent nodes; S4, enter the time-by-time detection stage, obtain the real value of the target variable and the values ​​of all dimensions of the independent variables in real time, and determine whether the prediction error at the current time is greater than the threshold. If it is less than or equal to the threshold, it is considered that there is no abnormality and proceeds to the next time step. If it is greater than the threshold, it is considered that an abnormality has occurred and proceeds to S5. S5. Select independent variables of multiple dimensions to form a subset. Use a counterfactual generator to perform reverse calculation on each variable node in the causal graph based on the subset and mechanism equation to obtain the counterfactual covariate vector. Then, input the counterfactual covariate vector into the black box prediction model. Based on the output of the black box prediction model, the predicted value of the target variable at the current time and the prediction error at the current time, calculate the value function of the current subset. S6. Iterate through all subsets and repeat S5. Calculate the causal Shapley value of each independent variable based on the value function of all subsets. Further calculate the relative contribution of each independent variable. The independent variables with the highest relative contributions are the causes of the anomalies.

[0010] Furthermore, in S2, the training dataset consists of a full observation vector; specifically, the full observation vector is: ; in, Let f be the f-th dimension of the independent variable at time tk. To adjust the sliding window size, The total dimension of the independent variable. For the full observation vector, The predicted value of the target vector at time tk. Let be the prediction error at time t.

[0011] Furthermore, in S2, establishing directed edges between pairs of variable nodes includes: first, determining all directions of directed edges that are impossible to be valid based on the time priority axiom and the error convergence constraint, thereby establishing a set of illegal directed edges; second, establishing undirected edges between variable nodes by passing a conditional independence test on pairs of variable nodes that do not belong to the set of illegal directed edges; and finally, converting each undirected edge into a directed edge by combining the additive noise model and the set of illegal directed edges.

[0012] Furthermore, the set of illegal directed edges includes all directed edges that do not satisfy the temporal constraints of the time priority axiom or the error convergence constraint. The time priority axiom timing constraint states that a variable node with a later timestamp cannot be the parent node of a variable node with a earlier timestamp. The temporal constraint of the error convergence constraint is that the variable node corresponding to the prediction error at time t cannot be the parent node of any variable node corresponding to any independent variable at time t.

[0013] Furthermore, the specific steps of the conditional independence test are as follows: For any two variable nodes, use them as test node pairs to traverse all adjustment sets and perform a conditional independence test on each adjustment set. If there is no adjustment set that passes the test, it is determined that there is no undirected edge between the two variable nodes. If there is at least one adjustment set that passes the test, an undirected edge is established between the two variable nodes. The adjustment set is any set of variable nodes that does not contain the test node pairs.

[0014] Furthermore, the process of converting each undirected edge into a directed edge by combining the additive noise model and the set of illegal directed edges is as follows: S201, for variable nodes a and b with undirected edges, if one of the two candidate directions of the corresponding undirected edge belongs to the illegal directed edge set, then the other candidate direction is directly selected as the causal direction, thus establishing a directed edge; if neither of the two candidate directions of the corresponding undirected edge belongs to the illegal directed edge set, then variable node a is assumed to be the cause and variable node b to be the effect, and variable node b is assumed to be the cause and variable node a to be the effect, respectively, and the first regression model and the second regression model between cause and effect are established, and the corresponding first residual and the second residual are obtained. S202. Using the Hilbert-Schmidt independence criterion, test the independence between each residual and the corresponding hypothesis. If the first residual is independent of node a and the second residual is not independent of node b, then the direction of the corresponding edge is node a to node b; if the first residual is not independent of node a and the second residual is independent of node b, then the direction of the corresponding edge is node b to node a. S203, traverse all undirected edges and repeat S201-S202 to obtain a causal graph.

[0015] Furthermore, in S3, the specific content of the mechanism equation is as follows: ; in, It is a non-linear function used to obtain the k-th variable node. The predicted value; For noise variables, For nodes The set of parent variable nodes.

[0016] Furthermore, in step S5, a counterfactual generator is used to obtain the counterfactual covariate vector, specifically as follows: S501 uses the mechanism equation to calculate the noise variable of each node, which is then used as the fitting noise. S502, take the corrected noise of all time-time variable nodes corresponding to the independent variables in the subset, and combine it with the fitting noise of the independent variables in the remaining dimensions to obtain a mixed noise vector. S503 combines the mixed noise vector and the mechanism equation, and calculates the counterfactual value of each node from bottom to top according to the node order in the causal graph. It further combines the counterfactual values ​​of all independent variables from the previous time step to form a counterfactual covariate vector.

[0017] Furthermore, in S1, the black-box prediction model is a prediction model that only provides input and output interfaces to predict the target variable based on the values ​​of the input independent variables, but the internal mechanism of the model cannot be directly observed or analyzed.

[0018] Furthermore, in S5, the specific formula for calculating the value function is as follows: ; in, The counterfactual prediction error is obtained by subtracting the true value of the target variable at the current moment from the output of the black-box prediction model. The value function of subset S For absolute values, This represents the prediction error at the current moment.

[0019] The beneficial effects of this invention are: 1) It eliminates the reliance on prior expert causal graphs and achieves fully automated causal modeling.

[0020] Compared to existing methods such as Causal Shapley Values ​​that rely on predefined causal graphs, this invention does not require extensive domain expert knowledge or system topology beforehand. By explicitly introducing prediction errors into the causal discovery process and imposing logical constraints, this invention can automatically learn causal relationships containing time lags and instantaneous effects from observational data. This advantage solves the problem of attribution failure caused by the difficulty in obtaining or the presence of biased causal graphs in complex industrial scenarios, significantly lowering the implementation threshold and achieving end-to-end automated diagnosis.

[0021] 2) It overcomes the interference of feature correlation and the OOD (Out-of-Distribution) sample problem, ensuring the physical consistency of inference.

[0022] Compared to heuristic methods such as LIME or SHAP that employ perturbation or occlusion, this invention utilizes a mechanism equation model for counterfactual reasoning, strictly adhering to the data manifold distribution among variables. By intervening at the "noise level" rather than through brute-force numerical substitution, this invention preserves the physical context of the uninterrupted portions of anomalous samples, effectively avoiding misleading the black-box model by generating out-of-distribution samples that violate physical common sense. This allows for high-fidelity diagnostic results even in tightly coupled, complex systems.

[0023] 3) It has achieved a leap from correlational explanation to causal error correction, thus enabling accurate attribution.

[0024] Existing technologies often rely on statistical correlation, which can easily misclassify intermediate variables that are highly correlated with abnormal results but are actually victims as root causes. This invention, by calculating the Shapley value, can clearly distinguish between direct and indirect causes and quantify the actual net contribution of each variable to eliminating prediction errors. This evaluation system based on counterfactual error correction capabilities gives the diagnostic results clear practical guidance, accurately pinpointing the source variables driving the errors. Attached Figure Description

[0025] Figure 1 This is an overall framework diagram of the present invention.

[0026] Figure 2 This is a schematic diagram of the process for constructing the residual-enhanced causal graph and structural equation surrogate model in the method of this invention.

[0027] Figure 3 This is a flowchart illustrating the counterfactual generator in the method of the present invention.

[0028] Figure 4 This is a schematic diagram of the path-specific causal attribution process based on Shapley values ​​in the method of this invention. Detailed Implementation

[0029] To make the above-mentioned objects, features, and advantages of the present invention more apparent and understandable, the specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings. Many specific details are set forth in the following description to provide a thorough understanding of the present invention. However, the present invention can be practiced in many other ways different from those described herein, and those skilled in the art can make similar modifications without departing from the spirit of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed below. Technical features in the various embodiments of the present invention can be combined accordingly without mutual conflict.

[0030] For ease of explanation, some of the terms used in this invention will first be explained.

[0031] Black-box models refer to complex machine learning models (such as deep learning networks or complex ensemble models) whose internal operating mechanisms are opaque and whose decision-making logic is difficult for humans to understand directly. In this technique, it is the object of diagnosis, that is, a model that can provide prediction results but cannot directly explain why prediction errors occur.

[0032] Structural equation modeling: In this invention, it is used as a "transparent proxy" to replace the black-box model. It is a model that explicitly characterizes the causal generation mechanism and topological structure between variables through a system of mathematical equations (including nonlinear functions and exogenous noise terms), and is used to describe the causal relationship between covariates, target variables, and prediction errors.

[0033] The null hypothesis is a conservative statement that states "no effect, no difference". It is the baseline hypothesis that needs to be overturned in statistical tests.

[0034] Counterfactual reasoning refers to a logical deduction method based on causal models. In this invention, it specifically refers to the process of "attribution-intervention-prediction," which mathematically constructs a hypothetical scenario (counterfactual world) where "a certain variable would not have an anomaly," in order to observe the impact of this hypothesis on the final prediction error.

[0035] The causal Shapley score is an attribution metric based on game theory. Unlike the traditional Shapley score, which is based solely on statistical correlation of data, it incorporates a causal graph structure to quantify the marginal contribution of each input variable, through direct or indirect paths, to eliminating model prediction errors (i.e., bringing the system back to normal).

[0036] Based on the above background, the problem defined in this invention is: assuming a pre-trained black-box prediction model is given... The model is based on a set of dimensional time series covariates To predict the target variable At a specific moment or sample point, the model produces a predicted value. This leads to prediction errors. .

[0037] When the system detects a prediction error for a target sample When there is a significant deviation from the normal distribution (i.e., an anomaly or outlier occurs), and the variables are unknown... ,Target and error Given a specific causal topological structure, how to utilize historical observation datasets? It automatically constructs an alternative causal model and calculates each covariate using this model. The prediction error is abnormal causal contribution This contribution should be able to quantitatively reflect the contribution of multiple variables. The generation mechanism did not malfunction, and the prediction error was normal. The degree of return to normal, thereby through the The values ​​are sorted by size to uniquely identify the root cause variable that caused the prediction to fail.

[0038] Therefore, this invention proposes a black-box model anomaly diagnosis method based on automatic causal discovery and Shapley value, which includes three steps: constructing a residual-enhanced causal graph and a structural equation surrogate model, a counterfactual generator based on the structured equation model, and a path-specific causal attribution index based on Shapley value.

[0039] like Figure 1 As shown, the specific steps are as follows: Step 1: Constructing a residual-enhanced cause-effect graph and structural equation surrogate model The core of this step lies in establishing a causal model that can mathematically represent the intrinsic generation mechanism among input covariates, target variables, and black-box model prediction errors. By explicitly introducing "prediction error" into the causal network, a hybrid causal discovery algorithm combining constraint-based and function-based approaches is used to reconstruct a causal graph containing time-lag and instantaneous effects from the observed data. Furthermore, a structural causal equation is fitted, laying the structural foundation for subsequent counterfactual inference. The overall process is as follows: Figure 2 As shown.

[0040] The specific implementation process is as follows: 1. Construction and reconstruction of prediction error-enhanced time series datasets.

[0041] 1.1) Obtain historical observation dataset .

[0042] Suppose there exists a time t. The covariate sequences of each dimension are combined to obtain the time series of observed covariates. and a sequence of target variables containing all target variables at time t. Therefore, the construction yields all data from the initial time to time t. and Historical observation dataset .

[0043] Depending on the specific application scenario, the covariate sequence can be coal feed rate, air supply rate, turbine valve opening, main steam temperature, and main steam pressure, while the target variable is the power generation capacity.

[0044] In order to improve the trained black-box prediction model To attribute abnormal behavior, this embodiment does not directly analyze the model's internal parameters (such as neural network weights or tree split points), but instead employs a "black box probing" strategy to calculate the prediction error at each time step. :

[0045] 1.2) This prediction error Incorporate it into the system as a new observed variable to construct an enhanced variable set.

[0046] Considering the autocorrelation and lagged causality present in time series data, this embodiment adopts time lag embedding technology to transform the dynamic time series problem into a static graph structure learning problem.

[0047] Set the maximum time lag order as That is, the sliding window size is Define the moment Full observation vector Includes the current moment and the past. All copies of variables at each time point:

[0048] in, Let f be the observation covariate vector of dimension f at time tk. This represents the predicted value of the target variable at time tk.

[0049] In this definition, the present invention specifically includes only the prediction error at the current moment. Instead, they view historical errors as implicit states or determined by historical inputs at the time, thus focusing on explaining the generation mechanism of current errors through historical covariates.

[0050] Based on this, the present invention starts from time t and traverses the historical observation dataset. By analyzing all time points and calculating the corresponding full observation vectors, a sample size of [sample size] is obtained. Enhanced training dataset , , where T is the total length of the time series in the historical observation dataset. It consists of the full observation vector corresponding to each time step.

[0051] 2. Discovery of hybrid causal skeletons based on conditional independence tests.

[0052] Based on dataset This invention employs an improved PC algorithm (Peter-Clark algorithm) to initially determine the causal connection skeleton between variables in a causal graph. This process aims to identify which lagged or instantaneous variables have significant dependencies on the current variable.

[0053] It should be noted that the PC algorithm is a classic Bayesian network structure learning method. Its core objective is to infer causal relationships or conditional independence relationships between variables from observed data and construct a directed acyclic graph. In this invention, it is used to infer causal relationships between variables and thus establish a causal connection skeleton.

[0054] because It contains multiple variables, each with an index. This invention uses... To represent the a-th variable node (e.g., Possibly , , or ).

[0055] The system uses the dataset Any pair of variable nodes Perform conditional independence tests to initially establish undirected edges between all variable nodes.

[0056] If in a given adjustment set (That is, R is the total observation vector) A subset of R, and R does not contain and Under the condition of ), null hypothesis Established ( The null hypothesis is given, and the hypothesis is as follows: and In a given set of adjustments (If it becomes independent later), then it is judged and If there is no direct causal edge between the two sides, remove the edge from the causal graph. The test method for whether the hypothesis holds can be Fisher-Z transform (for linear relationships, a significance level of 0.05 can be set) or kernel-based conditional mutual information (CMI, for nonlinear relationships).

[0057] In this process, the present invention introduces two temporal constraint logics: the time-first axiom and the error convergence constraint, to prune the search space: The Time Priority Axiom states that a variable at a future time cannot be the parent node of a variable at a past time. That is, if a variable... timestamp Later timestamp Then the direction of cause and effect can only be Or there may be no connection, therefore, by using the time priority axiom, it can be pre-labeled. A directed edge is impossible.

[0058] Error convergence constraint: due to It is the difference between the predicted result and the actual value; in causal logic, it is a covariate. and target It is the effect, not the cause. Therefore, in the skeletal discovery phase, we can presuppose... Not used as any covariate The parent node.

[0059] By traversing all pairs of variable nodes using the above method, a causal graph skeleton composed of undirected edges is constructed.

[0060] 3. Instantaneous causal direction identification based on additive noise model.

[0061] The causal graph skeleton obtained through the above steps only establishes undirected edges between variable nodes, and undirected edges still exist, especially those at the same time step. Instantaneous relationships (e.g.) and (between). To address the uncertainty in causal direction caused by Markov equivalence classes, this embodiment introduces an additive noise model based on structural non-Gaussianity for direction identification.

[0062] For connection variables in the skeleton and The undirected edges are assumed to be either cause or effect (i.e., respectively). → and → Establish the following two regression models:

[0063]

[0064] in, For nonlinear regression functions (such as Gaussian process regression or neural networks). and It is noise.

[0065] Subsequently, the regression residuals were calculated separately. and :

[0066]

[0067] The Hilbert-Schmidt independence criterion (HSIC) is used to test the independence between the residuals and the corresponding hypotheses' causes. If... And not Then the direction of causality is determined as follows: And establish directed edges. Otherwise, determine the causal direction. → And establish directed edges.

[0068] This step is particularly useful for resolving causal entanglements between complex industrial coupled variables, ultimately generating a directed acyclic graph (DAG), denoted as . ,in, These are graph nodes, and each node consists of a variable node. The directed edges between nodes represent the causal relationships between variable nodes.

[0069] 4. Parameterized fitting of structural equation surrogate model (SCM).

[0070] After establishing the causal diagram After determining the topology, this invention needs to construct a computable and operable structural equation model as a "transparent proxy" for the black-box model.

[0071] For each node in the graph (Including covariate X, target variable Y, and the core error of concern) (Based on its set of parent nodes) Establish the generation mechanism equation:

[0072] in, It is a non-linear function used to fit the deterministic influence mechanism of the parent node on the child node. In this invention, a deep learning network is used as... Predicted nodes The predicted value; It is an exogenous noise variable, representing random fluctuations or external shocks in the variable that cannot be explained by the parent node.

[0073] In practical implementation, a deep learning model with high fitting ability is used as the function. The training process is as follows: using the augmented training dataset constructed in step one... Based on this, for causal graphs Each node in Extract its parent node set Nodes are extracted by using the observed values ​​in the dataset as input features (independent variables). The observed values ​​are used as the target label (dependent variable). A supervised learning task is constructed with mean squared error (MSE) as the loss function, which is:

[0074] in, For dataset The total number of samples in the sample, Indicates the first Nodes in each sample The actual observed value, Indicates the first Nodes in each sample The parent node observation vector, These are the learnable parameters of the neural network. The neural network parameters are iteratively optimized using the gradient descent algorithm to minimize the difference between predicted and observed values ​​until the model converges. The resulting trained neural network represents the nonlinear deterministic influence mechanism of the parent node on the child node. .

[0075] After training, the fitting residual for each sample at each node is calculated based on the training set data. :

[0076] The residual sequence is treated as exogenous noise. The empirical observations were then used to further fit the results using kernel density estimation. probability density function .

[0077] Through the above process, the model not only encodes the time dependencies and instantaneous coupling relationships between variables, but also explicitly establishes one or more relationships from the input covariates. Pointing prediction error causal pathways (e.g.) This allows the system to understand when a certain input variable... When abnormal fluctuations occur, what path do they travel through and ultimately lead to prediction errors? The deviations provide a mathematically rigorous "digital twin" environment for subsequent counterfactual inferences about root causes.

[0078] Step 2: Counterfactual Generator Based on Structured Equation Model In step one, a hybrid causal graph containing prediction error nodes is constructed. After fitting the mechanism equation, this step aims to utilize the model to perform high-fidelity counterfactual data generation during the inference phase. The core technical challenge lies in: when the system detects a specific moment... The sample showed abnormal prediction error How can we generate a condition where a certain covariate is incompatible with the physical / logical coupling mechanism between variables? A hypothetical scenario sample where "no anomalies occurred".

[0079] Unlike traditional feature masking or random permutation techniques, the counterfactual generator constructed in this embodiment employs an "Abduction-Action-Prediction" process based on Pearl's hierarchy of causality theory. This ensures that the generated counterfactual samples strictly follow the data manifold distribution, thereby guaranteeing the effectiveness of subsequent attributions. The overall process is as follows: Figure 3 As shown.

[0080] Specifically, the workflow of the counterfactual generator is as follows: 1. Noise attribution in abnormal samples.

[0081] During the inference phase, the real-time monitoring system acquires the current values ​​of covariates, target variables, predicted values ​​of target variables, and prediction errors, and updates the values ​​of each node in the causal graph.

[0082] When the real-time monitoring system detects the time Prediction error When the threshold is exceeded, the system first locks the observation vector at that moment. ,in, Cause-and-effect diagram The Middle Each variable node at time... The actual observed values ​​(i.e., the predicted values ​​output by the black box model).

[0083] To understand the specificity of this anomalous sample, a "causal" operation is performed, which involves inferring the potential exogenous noise value that led to the current observation state.

[0084] Based on the mechanism equation trained in step one The system processes each node in the causal graph. Perform the reverse calculation. Since the observed values ​​at this point... and parent node observations Since everything is known, we can calculate the sample at a specific time. The specific exogenous shock experienced is denoted as :

[0085] This set of calculated noise vectors It has significant physical implications: it strips away the deterministic transmission effects between variables, extracting the independent random perturbations experienced by the system at that specific moment. This allows subsequent counterfactual inference to preserve the "context" of the anomalous sample, meaning that apart from the manipulated variable, the rest of the system remains in its state at that specific anomalous moment, rather than degenerating into a general average state.

[0086] 2. Intervention design based on root cause hypothesis.

[0087] In obtaining a specific noise vector Afterward, the system enters the intervention phase. The goal of this phase is to test each covariate one by one. As a potential root cause, the system needs to construct a "counterfactual world" in which the tested variable is assumed to be a valid cause. The generation mechanism returned to normal, while other external conditions remained unchanged.

[0088] Specifically, for each root cause candidate variable to be tested (in ), define intervention operations by modifying Exogenous noise terms instead of directly modifying The value of can be expressed as:

[0089] That is, the system will use variables Corresponding abnormal noise value Replace it with the expected noise value of the variable under normal conditions (usually 0, i.e.) (or the probability density function under the normal distribution calculated in step one) Random values ​​from medium-resampled samples.

[0090] At the same time, for causal graphs except All other nodes Preserve the specific noise value obtained from its abduction. No change. This operation constructs a mixed noise vector. :

[0091] 3. Cascade prediction and sample reconstruction with unchanged mechanism.

[0092] Finally, the system is based on a hybrid noise vector. Using a causal graph structure, the values ​​of counterfactual samples are regenerated. This process must strictly follow the topological order of the causal graph to ensure the correct propagation of the elimination of anomalous effects.

[0093] The system processes each node sequentially according to its topological order in the cause-effect graph. Perform forward computation to generate counterfactual values. The calculation formula is as follows:

[0094] in, Representing variables The value of the parent node in the counterfactual world.

[0095] There are two scenarios here: if The variable being intervened If a node is a descendant of another node, then the value of its parent node is... It may have already changed due to upstream intervention, thus through nonlinear functions. Transfer the effect of "repair" to And calculate the corresponding .like no The descendants, and not It retains the original observation values. As its This is because neither its parent node nor the noise term has changed.

[0096] Through this cascading update mechanism, the counterfactual generator constructed in this invention will eventually output a complete counterfactual covariate vector containing all covariate nodes. .

[0097] This vector represents "if at time..." Only variables The abnormal perturbations are removed, and the system's physical transmission mechanism and the external environment of other variables remain unchanged, representing the state the system should be in. The samples generated by this method naturally fall on the manifold of the joint distribution of variables, thus overcoming the defect that samples generated by traditional methods may violate physical common sense and lead to the failure of black-box model predictions.

[0098] Step 3: Path-Specific Causal Attribution Indicators Based on Shapley Values Traditional attribution methods (such as standard SHAP or LIME) often ignore the dependency structure between variables, assume that features are independent, or sample only on marginal distributions, which can lead to serious attribution bias in time series data. This invention proposes a path-specific attribution index based on causal Shapley values. Based on the causal graphical model and counterfactual generation mechanism constructed in the preceding steps, and utilizing a cooperative game theory framework combined with the counterfactual generator in step two, it accurately identifies the "marginal cleansing effect" of each variable on the final error through direct or indirect paths, thereby quantitatively calculating the causal contribution of each covariate to the anomaly in prediction error. The overall process is as follows: Figure 4 As shown.

[0099] 1. Define the alliance value function based on causal intervention.

[0100] To transform root cause analysis into a cooperative game problem, we first define "alliance" and "value function".

[0101] Let covariate index set Let be the set of participants in the game. For any subset ,definition For a “repaired coalition”, i.e., a set of hypotheses The variable mechanism in the collection has been restored to normal, and the set... The variables in the data are still subject to abnormal noise.

[0102] Based on the counterfactual generator established in step two, this invention defines a causal value function. Used to measure when the set of variables The degree of improvement in the black-box model's prediction error after the fix.

[0103] The calculation process for the causal value function is as follows: First, build a system for alliances Mixed noise vector .

[0104] For the nth component in the vector, if Then, both the component and the historical time component are taken as their normal noise expectation (e.g., 0); if Then retain the anomalous noise observations obtained from abduction in step two counterfactual generator. :

[0105] in, For the characteristic function, when When it is established, the value is 0; when If the condition is not met, the value is 1.

[0106] Secondly, input the mixed noise vector into the structural equation model established in step one. According to the cause-and-effect diagram Topological order concatenation generates counterfactual covariate vectors .

[0107] This step is crucial because it automatically addresses the "path dependency" problem—that is, it repairs the set—using causal graphs. The variables in the set not only change their own values, but also improve the state of their descendant nodes through causal paths, even if the descendant nodes are not in the set. middle.

[0108] Finally, the generated counterfactual vector The covariate data at the current moment are input into the original black-box prediction model. Calculate the counterfactual prediction error :

[0109] in, The true value of the target variable; These are the predicted values ​​obtained by the black-box model based on the repaired covariates.

[0110] And define the value function The amount by which the error magnitude is reduced at the current moment:

[0111] in, The absolute value represents the magnitude of the error. This represents the prediction error at the current moment.

[0112] The physical meaning is: if only the set is repaired The variable mechanism in the system allows the prediction error to revert to the normal range.

[0113] 2. Calculate the path-specific causal Shapley value.

[0114] To allocate each variable fairly Total error elimination To contribute to this invention, the Shapley value axiomatic method is employed. Unlike traditional Shapley values ​​which directly permutate and combine eigenvalues, this invention calculates causal Shapley values.

[0115] For any variable Its causal contribution Defined as, among all possible repair permutations, Join the Repair Alliance The average marginal contribution it brings.

[0116] The mathematical expression is as follows:

[0117] in, Represents variables The causal marginal contribution The number of elements in the set. For factorial, To make variables Add to collection The new set obtained from it, D does not contain Any subset of.

[0118] This difference not only includes After being repaired, directly to The impact of the output also implicitly includes After being repaired, through the causal chain The indirect effect of improving the state of downstream variables due to propagation further reduces the error.

[0119] Traversing all subsets of the causal graph For each The corresponding marginal contribution is calculated. Then, a weighted sum was obtained. Because it iterates through all subsets. The computational complexity is In the variable dimension When the value is high, this embodiment uses Monte Carlo sampling for approximate calculation. That is, random sampling... The system arranges a sequence of variables and calculates the mean marginal gain of each variable at the time it is added to the sequence, in order to achieve a balance between computational efficiency and accuracy.

[0120] 3. Normalization and sorting output of root cause contribution.

[0121] Calculated It has a clear physical meaning: it quantifies the change in variables. How much can the prediction error of the black-box model be expected to decrease when the generation mechanism resets from an abnormal state to a normal state?

[0122] To generate the final root cause analysis report, the system performs the following processing: First, address negative contributions. In some complex coupled systems, fixing a single variable may temporarily increase the error by disrupting a certain "error compensation mechanism" (i.e., In the context of root cause diagnosis, this invention primarily focuses on the positive driving forces that lead to increased errors, and therefore can address... Truncation or absolute value taking is performed to ensure that the final retained values ​​are... All are greater than or equal to 0, but it is preferred to retain the sign. This is for users or experts to conduct further analysis.

[0123] Typically, the root dependent variable Significantly positive.

[0124] Secondly, calculate the relative contribution ratio (RCR):

[0125] Finally, based on The root cause list is generated by sorting all covariates in descending order of their numerical values. Before the system selects a list. The Top-K variables are output as the root causes of the prediction failure.

[0126] Through the above three steps, this invention fully realizes a closed-loop process from unsupervised causal structure discovery to anomaly counterfactual generation based on structural equations, and then to accurate attribution based on game theory.

[0127] The embodiments described above are merely preferred embodiments of the present invention and are not intended to limit the invention. Those skilled in the art can make various changes and modifications without departing from the spirit and scope of the invention. Therefore, all technical solutions obtained through equivalent substitution or transformation fall within the protection scope of the present invention.

Claims

1. An anomaly diagnosis method based on a black-box prediction model using automatic causal discovery and Shapley values, characterized in that, include: S1. Input the values ​​of independent variables with multiple dimensions at historical moments into the black-box prediction model. After obtaining the predicted value of the target variable at each moment, subtract it from the true value of the target variable at the same moment to obtain the prediction error at each historical moment. S2, based on the predicted values ​​and prediction errors of the independent variables and target variables at all historical moments, a sliding window is used to construct the training dataset; further, all dimensions of the independent variables, predicted values ​​and prediction errors of the target variables at all historical moments in the training dataset are used as variable nodes, and directed edges are established between pairs of variable nodes to obtain the causal graph; S3, establish the mechanism equation between each variable node and all its parent nodes; S4, enter the time-by-time detection stage, obtain the real value of the target variable and the values ​​of all dimensions of the independent variables in real time, and determine whether the prediction error at the current time is greater than the threshold. If it is less than or equal to the threshold, it is considered that there is no abnormality and proceeds to the next time step. If it is greater than the threshold, it is considered that an abnormality has occurred and proceeds to S5. S5. Select independent variables of multiple dimensions to form a subset. Use a counterfactual generator to perform reverse calculation on each variable node in the causal graph based on the subset and mechanism equation to obtain the counterfactual covariate vector. Then, input the counterfactual covariate vector into the black box prediction model. Based on the output of the black box prediction model, the predicted value of the target variable at the current time and the prediction error at the current time, calculate the value function of the current subset. S6. Iterate through all subsets and repeat S5. Calculate the causal Shapley value of each independent variable based on the value function of all subsets. Further calculate the relative contribution of each independent variable. The independent variables with the highest relative contributions are the causes of the anomalies.

2. The anomaly diagnosis method based on a black-box prediction model using automatic causal discovery and Shapley value as described in claim 1, characterized in that, In S2, the training dataset consists of a full observation vector; specifically, the full observation vector is: ; in, Let f be the f-th dimension of the independent variable at time tk. To adjust the sliding window size, The total dimension of the independent variable. For the full observation vector, The predicted value of the target vector at time tk. Let be the prediction error at time t.

3. The anomaly diagnosis method based on a black-box prediction model using automatic causal discovery and Shapley value as described in claim 1, characterized in that, In S2, establishing directed edges between variable node pairs includes: first, based on the time priority axiom and error convergence constraints, pre-determining all directions of directed edges that cannot be valid, thereby establishing a set of illegal directed edges; second, establishing undirected edges between variable node pairs outside the set of illegal directed edges through conditional independence tests; and finally, combining the additive noise model and the set of illegal directed edges, converting each undirected edge into a directed edge.

4. The anomaly diagnosis method based on a black-box prediction model using automatic causal discovery and Shapley value as described in claim 3, characterized in that, The set of illegal directed edges includes all directed edges that do not satisfy the temporal constraints of the time priority axiom or the error convergence constraint. The time priority axiom timing constraint states that a variable node with a later timestamp cannot be the parent node of a variable node with a earlier timestamp. The temporal constraint of the error convergence constraint is that the variable node corresponding to the prediction error at time t cannot be the parent node of any variable node corresponding to any independent variable at time t.

5. The anomaly diagnosis method based on a black-box prediction model using automatic causal discovery and Shapley value as described in claim 3, characterized in that, The specific steps of the conditional independence test are as follows: For any two variable nodes, use them as test node pairs to traverse all adjustment sets and perform a conditional independence test on each adjustment set. If there is no adjustment set that passes the test, it is determined that there is no undirected edge between the two variable nodes. If there is at least one adjustment set that passes the test, an undirected edge is established between the two variable nodes. The adjustment set is any set of variable nodes that does not contain the test node pairs.

6. The anomaly diagnosis method based on a black-box prediction model using automatic causal discovery and Shapley value as described in claim 3, characterized in that, The process of converting each undirected edge into a directed edge by combining the additive noise model and the set of illegal directed edges is as follows: S201, for variable nodes a and b with undirected edges, if one of the two candidate directions of the corresponding undirected edge belongs to the illegal directed edge set, then the other candidate direction is directly selected as the causal direction, thus establishing a directed edge; if neither of the two candidate directions of the corresponding undirected edge belongs to the illegal directed edge set, then variable node a is assumed to be the cause and variable node b to be the effect, and variable node b is assumed to be the cause and variable node a to be the effect, respectively, and the first regression model and the second regression model between cause and effect are established, and the corresponding first residual and the second residual are obtained. S202. Using the Hilbert-Schmidt independence criterion, test the independence between each residual and the corresponding hypothesis. If the first residual is independent of node a and the second residual is not independent of node b, then the direction of the corresponding edge is node a to node b; if the first residual is not independent of node a and the second residual is independent of node b, then the direction of the corresponding edge is node b to node a. S203, traverse all undirected edges and repeat S201-S202 to obtain a causal graph.

7. The anomaly diagnosis method based on a black-box prediction model using automatic causal discovery and Shapley value as described in claim 1, characterized in that, The specific content of the mechanism equation in S3 is as follows: ; in, It is a non-linear function used to obtain the k-th variable node. The predicted value; For noise variables, For nodes The set of parent variable nodes.

8. The anomaly diagnosis method based on a black-box prediction model using automatic causal discovery and Shapley value as described in claim 1, characterized in that, In step S5, the counterfactual generator is used to obtain the counterfactual covariate vector, specifically as follows: S501 uses the mechanism equation to calculate the noise variable of each node, which is then used as the fitting noise. S502, take the corrected noise of all time-time variable nodes corresponding to the independent variables in the subset, and combine it with the fitting noise of the independent variables in the remaining dimensions to obtain a mixed noise vector. S503 combines the mixed noise vector and the mechanism equation, and calculates the counterfactual value of each node from bottom to top according to the node order in the causal graph. It further combines the counterfactual values ​​of all independent variables from the previous time step to form a counterfactual covariate vector.

9. The anomaly diagnosis method based on a black-box prediction model using automatic causal discovery and Shapley value as described in claim 1, characterized in that, In S1, the black-box prediction model is a prediction model that only provides input and output interfaces to predict the target variable based on the values ​​of the input independent variables, but the internal mechanism of the model cannot be directly observed or analyzed.

10. The anomaly diagnosis method based on a black-box prediction model using automatic causal discovery and Shapley value as described in claim 1, characterized in that, In S5, the specific formula for calculating the value function is as follows: ; in, The counterfactual prediction error is obtained by subtracting the true value of the target variable at the current moment from the output of the black-box prediction model. The value function of subset S For absolute values, This represents the prediction error at the current moment.