Method and device for detecting abnormal connected subgraph
By iteratively solving the gradient of the anomaly detection function in the dynamic attribute network and identifying connected subgraphs composed of nodes corresponding to non-zero function variables, the problem of difficulty in detecting anomalies and connectivity at the same time in the existing technology is solved, and high accuracy is achieved. Anomaly detection.
Patent Information
- Application Number
- CN202010424210.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-05-19
- Publication Date
- 2024-09-13
- Estimated Expiration
- 2040-05-19
AI Technical Summary
The existing technology is difficult to detect anomalies and connectivity in dynamic attribute networks at the same time, and cannot take into account the detection accuracy of both aspects.
By constructing a dynamic attribute network, using the preset anomaly detection function and iteratively solving the gradient until the iteration stop condition is met, the connected subgraph composed of nodes corresponding to non-zero function variables is identified as an abnormally connected subgraph.
It realizes that the detected subgraphs are both abnormal and connected, which improves the accuracy and efficiency of anomaly detection in dynamic attribute networks.
Smart Images

Figure CN111737647B
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to artificial intelligence (AI) technology, and more particularly to a method and device for detecting abnormal connected subgraphs. Background Art
[0002] Graphs or networks, as a general data structure, exist in all aspects of the real world, such as road traffic networks, online social networks, etc. A network consists of two parts: nodes and edges. Usually, the nodes or edges of these networks have attributes. For example, each node on the road traffic network is an intersection, and each edge is a road. The attributes of each node (intersection) can be the number of vehicles passing through the intersection, the average speed of vehicles, etc. The above attribute values are generally not fixed, but change over time. For example, during the off-work hours, the traffic volume at the intersection increases, the number of vehicles passing through the intersection increases, and the average speed of vehicles decreases; while at other times, the number of vehicles passing through the intersection decreases, and the average speed of vehicles increases. Such networks with attribute values that change over time are called dynamic attribute networks. Detecting abnormal connected subgraphs of dynamic attribute networks has important practical significance. For example, when it is necessary to detect whether there is a congested area in the road traffic network within a period of time, it can be determined whether there is a congested area in the road traffic network within the period of time by detecting whether there is an abnormal connected subgraph in the corresponding road traffic network within the period of time, because the interconnected roads during the congestion period constitute a connected subgraph, and the attribute values of the area represented by the connected subgraph are abnormal (such as increased traffic volume, etc.).
[0003] However, the prior art lacks a solution that can detect abnormal connected subgraphs, and cannot ensure that the detected subgraphs take both abnormality and connectivity into account. Summary of the invention
[0004] In view of this, an embodiment of the present invention provides a method for detecting abnormally connected subgraphs, including:
[0005] Build a dynamic attribute network based on raw data;
[0006] Assign initial values to all variables and parameters of the preset anomaly detection function;
[0007] By iteratively solving the gradient of each variable of the anomaly detection function and updating the gradient of each variable so that the function value continues to increase until the iteration stop condition is met;
[0008] When the iteration stop condition is met, the connected subgraph composed of the nodes corresponding to the non-zero function variables is regarded as an abnormal connected subgraph;
[0009] Among them, the function value of the anomaly detection function represents the degree of anomaly of the dynamic attribute network; an attribute of each node at a time in the dynamic attribute network corresponds to a variable of the anomaly detection function, and each variable takes a value between zero and 1. A variable of zero indicates that the attribute of the corresponding node at the corresponding time is normal, and a variable of non-zero indicates that the attribute of the corresponding node at the corresponding time is abnormal; the iteration stopping condition is that the 2-norm of the variable after the gradient update and the variable before the last gradient solution is less than a threshold.
[0010] The embodiment of the present invention also provides a method for detecting anomalies of dynamic attribute networks, including:
[0011] When the dynamic attribute network detects a corresponding abnormal connected subgraph, determining that the dynamic attribute network is abnormal at the time and node area corresponding to the abnormal connected subgraph;
[0012] Wherein, the abnormal connected subgraph is detected by applying the above method.
[0013] An embodiment of the present invention also provides an electronic device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the computer program is executed by the processor, the method for detecting abnormal connected subgraphs or the method for detecting anomalies in a dynamic attribute network is implemented.
[0014] An embodiment of the present invention also provides a computer-readable storage medium, on which an information processing program is stored. When the information processing program is executed by a processor, the method for detecting abnormal connected subgraphs or the method for detecting dynamic attribute network anomalies is implemented.
[0015] The technical solution provided by the embodiment of the present invention detects abnormal connected subgraphs through a preset abnormal detection function, which can ensure that the detected subgraphs are abnormal and connected.
[0016] Other features and advantages of the present application will be described in the following description, and partly become apparent from the description, or be understood by implementing the present application. Other advantages of the present application can be realized and obtained by the schemes described in the description and the drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The accompanying drawings are used to provide an understanding of the technical solution of the present application and constitute a part of the specification. Together with the embodiments of the present application, they are used to explain the technical solution of the present application and do not constitute a limitation on the technical solution of the present application.
[0018] Figure 1 A schematic flow chart of a method for detecting abnormally connected subgraphs provided by an embodiment of the present invention;
[0019] Figure 2 A schematic flow chart of a method for detecting abnormally connected subgraphs provided in another embodiment of the present invention;
[0020] Figure 3 A schematic diagram of the structure of a dynamic attribute network in an embodiment of the present invention;
[0021] Figure 4 A schematic flow chart of a method for detecting abnormally connected subgraphs provided in another embodiment of the present invention;
[0022] Figure 5 A schematic flow chart of a method for detecting abnormally connected subgraphs provided in another embodiment of the present invention;
[0023] Figure 6 A schematic diagram of dynamic detection of abnormal connected subgraphs in one embodiment of the present invention;
[0024] Figure 7 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention;
[0025] Figure 8 A schematic diagram of the structure of another electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0026] The present application describes multiple embodiments, but the description is exemplary rather than restrictive, and it is obvious to those skilled in the art that there may be more embodiments and implementations within the scope of the embodiments described in the present application. Although many possible feature combinations are shown in the drawings and discussed in the specific embodiments, many other combinations of the disclosed features are also possible. Unless specifically limited, any feature or element of any embodiment may be used in combination with any other feature or element in any other embodiment, or may replace any other feature or element in any other embodiment.
[0027] The present application includes and contemplates combinations of features and elements known to those of ordinary skill in the art. The embodiments, features and elements disclosed in the present application may also be combined with any conventional features or elements to form a unique invention scheme defined by the claims. Any features or elements of any embodiment may also be combined with features or elements from other invention schemes to form another unique invention scheme defined by the claims. Therefore, it should be understood that any feature shown and / or discussed in the present application may be implemented individually or in any appropriate combination. Therefore, except for the limitations made according to the attached claims and their equivalents, the embodiments are not subject to other restrictions. In addition, various modifications and changes may be made within the scope of protection of the attached claims.
[0028] In addition, when describing representative embodiments, the specification may have presented the method and / or process as a specific sequence of steps. However, to the extent that the method or process does not rely on the specific order of the steps described herein, the method or process should not be limited to the steps of the specific order described. As will be understood by those of ordinary skill in the art, other sequences of steps are also possible. Therefore, the specific sequence of the steps set forth in the specification should not be interpreted as a limitation to the claims. In addition, the claims for the method and / or process should not be limited to the steps of performing them in the order written, and those skilled in the art can easily understand that these sequences can be changed and still remain within the spirit and scope of the embodiments of the present application.
[0029] Figure 1 A flow chart of a method for detecting abnormally connected subgraphs provided by an embodiment of the present invention is shown as follows: Figure 1 As shown, the method includes:
[0030] Step 101, constructing a dynamic attribute network based on original data;
[0031] Step 102, assigning initial values to all variables and parameters of the preset anomaly detection function;
[0032] Step 103, solving the gradient of each variable of the anomaly detection function by iteration and updating the gradient of each variable so that the function value increases continuously until the iteration stop condition is met;
[0033] Step 104, taking the connected subgraph formed by the nodes corresponding to the non-zero function variables when the iteration stop condition is met as an abnormal connected subgraph;
[0034] Among them, the function value of the anomaly detection function represents the degree of anomaly of the dynamic attribute network; an attribute of each node at a time in the dynamic attribute network corresponds to a variable of the anomaly detection function, and each variable takes a value between zero and 1. A variable of zero indicates that the attribute of the corresponding node at the corresponding time is normal, and a variable of non-zero indicates that the attribute of the corresponding node at the corresponding time is abnormal; the iteration stopping condition is that the 2-norm of the variable after the gradient update and the variable before the last gradient solution is less than a threshold.
[0035] In one example, the anomaly detection function includes one of the following:
[0036] Relaxed lifted mean scan EMS function, expected Poisson statistics based EBP function, Kulldorff scan statistics based function.
[0037] In one example, the step of assigning initial values to all variables and parameters of a preset anomaly detection function includes:
[0038] Define anomaly detection function f, and set all variables of function f Assign the default value, assign the parameter t to 0, and assign the parameter s to the default value;
[0039] Where t represents the number of iterations, and i corresponds to the node number; It represents the function variable corresponding to the node numbered i when the number of iterations is t. i takes the value of an integer from 1 to n×w. All variables The value range is between [0,1], n represents the total number of nodes, w represents the number of moments in the preset time period, and s represents the subgraph scale.
[0040] In one example, the iteratively solving the gradient of the variable of the anomaly detection function and updating the gradient of the variable so that the function value continuously increases includes:
[0041] Each time the gradient is solved, the following operations are performed:
[0042] For all variables of the anomaly detection function f Find the gradient, expressed as
[0043] Find the first s variables with the largest gradient among all variables, solve the corresponding maximum connected subgraph at the nodes corresponding to the first s variables, and construct the set S of nodes corresponding to the maximum connected subgraph H ;
[0044] Each gradient update performs the following operations:
[0045] Using the gradient of the solution Update the corresponding variables so that In S H The variable value corresponding to the node outside is set to 0. Less than 0, let like make
[0046] Find the first s variables with the largest values among all variables, and solve the corresponding maximum connected subgraph at the nodes corresponding to the first s variables. The nodes corresponding to the maximum connected subgraph constitute the set S T ;
[0047] Keep the set S T The current value of the variable corresponding to the middle node, and the values of the other variables are set to 0;
[0048] After each gradient update, the following operations are performed:
[0049] Determine whether the 2-norm of the variable after the gradient update and the variable before the last gradient solution is less than the threshold;
[0050] If it is not less than the threshold, it means that the iteration stop condition is not met and the iteration continues.
[0051] When it is less than or equal to the threshold, it means that the iteration stop condition is met and the iteration stops.
[0052] In one example, when the anomaly detection function is an EMS function, the anomaly detection function is expressed as:
[0053] The formula for finding the gradient for each variable is:
[0054] in, Represents the attribute value corresponding to node i when the number of iterations is t.
[0055] In one example, the iteration stop condition is expressed as: δ is the threshold.
[0056] The technical solution provided by the embodiment of the present invention utilizes an anomaly detection function to find the most abnormal connected subgraph by continuously increasing the function of the function, thereby ensuring that the detected subgraph is abnormal and connected.
[0057] Figure 2 A schematic flow chart of a method for detecting abnormally connected subgraphs provided by another embodiment of the present invention is shown as follows: Figure 2 As shown, the method includes:
[0058] Step 201, constructing a dynamic attribute network based on original data;
[0059] A network consists of two parts: nodes and edges. An edge refers to the connection between two adjacent nodes. Usually, the nodes or edges of these networks have attributes. In this embodiment, a network whose node or edge attributes change over time is called a dynamic attribute network.
[0060] In one example, constructing a dynamic attribute network based on original data includes:
[0061] Build a dynamic attribute network based on the original data through data modeling.
[0062] Among them, data modeling includes: constructing node and edge data. For example, when building a monitoring road traffic network, each intersection is regarded as a node, and each section of road between any two adjacent intersections is regarded as an edge. The attribute on each node can be set to the number of vehicles passing through the corresponding intersection. At this time, data modeling needs to number each intersection from 1 to n, and each section of road from 1 to m. If w time points are monitored, w images will be obtained.
[0063] In another example, the dynamic attribute network can be mathematically represented as a sequence of graphs with the same set of nodes and edges. For example, the dynamic attribute network includes n nodes, m edges, and w moments, so there are a total of w graphs, represented as: (G1,...,G w ), G i =(V,E,W i (V)),V={1,...,n},i=1,...,w,G i represents the graph corresponding to the i-th moment, each graph has |V| = n nodes, |E| = m edges, W i (V) represents the attribute set of each node at the i-th moment.
[0064] Step 202, assigning initial values to all variables and parameters of the preset anomaly detection function;
[0065] Among them, the function value of the anomaly detection function represents the degree of anomaly of the dynamic attribute network; an attribute of each node in the dynamic attribute network at a time corresponds to a variable of the anomaly detection function, and each variable takes a value between zero and 1. A variable of zero indicates that the attribute of the corresponding node at the corresponding time is normal, and a variable of non-zero indicates that the attribute of the corresponding node at the corresponding time is abnormal.
[0066] Among them, a variable of the function corresponds to an attribute of a node at a time. The attribute can be a single attribute of the node, such as the attribute of each node in the monitoring road traffic network at the corresponding time is the number of vehicles passing the node at the corresponding time, or it can be a fusion attribute after weight calculation of multiple attributes of the node. For example, the attributes of each node in the monitoring road traffic network at the corresponding time include two: the number of vehicles passing the node at the corresponding time and the average speed of the passing vehicles. At this time, it is necessary to comprehensively calculate a value of these two attributes according to a certain weight as the attribute of the node at the corresponding time. For example, if a node 1 has two attributes a and b, then the attribute a and attribute b of the node 1 at time t1 are calculated according to the preset weight to form a fusion attribute corresponding to a variable v1. Another node 2 also has two attributes a and b, then the attribute a and attribute b of the node 2 at time t1 are calculated according to the preset weight to form a fusion attribute corresponding to a variable v2; the same applies to other times and other nodes.
[0067] In one example, the anomaly detection function includes one of the following:
[0068] Relaxed lifted mean scan EMS function, expected Poisson statistics based EBP function, Kulldorff scan statistics based function.
[0069] For example, when the anomaly detection function is an EMS function, the function is expressed as:
[0070]
[0071] In one example, the step of assigning initial values to all variables and related parameters of the preset anomaly detection function includes:
[0072] Define anomaly detection function f, and set all variables of function f Assign the default value, assign the parameter t to 0, and assign the parameter s to the default value;
[0073] Where t represents the number of iterations, and i corresponds to the node number; It represents the function variable corresponding to the node numbered i when the number of iterations is t. i takes the value of an integer from 1 to n×w. All variables The value range is between [0,1], n represents the total number of nodes, w represents the number of moments in the preset time period, and s represents the subgraph scale, that is, the number of nodes in the abnormally connected subgraph.
[0074] The initial value of a variable is usually a small value close to 0. For example, all variables can be The value is assigned to be 0.000001. s can be preset based on experience, such as being assigned a value of 3.
[0075] In another example, a function f is defined for detecting abnormal nodes and building attribute associations at different times. The function must be differentiable, and one attribute of each node corresponds to one variable at one time, which are x i ,i=1,...,n×w, the value range of the variable is x i Between [0,1]. When assigning initial values, the function variable Generally, a small value close to 0 is used, such as 0.000001, so that t = 0, i = 1, ..., n × w. The subgraph scale s is used to determine the size of the abnormal connected subgraph required to be detected (here refers to the number of nodes).
[0076] Step 203, iteratively solving the gradient of the variables of the anomaly detection function and updating the gradient of the variables so that the function value increases continuously, including:
[0077] Each time the gradient is solved, the following operations are performed:
[0078] For all variables of the anomaly detection function f Find the gradient, expressed as
[0079] Find the first s variables with the largest gradient among all variables, solve the corresponding maximum connected subgraph at the nodes corresponding to the first s variables, and construct the set S of nodes corresponding to the maximum connected subgraph H ;
[0080] Each gradient update performs the following operations:
[0081] Using the gradient of the solution Update the corresponding variables so that In S H The variable value corresponding to the node outside is set to 0. Less than 0, let like make
[0082] Find the first s variables with the largest values among all variables, and solve the corresponding maximum connected subgraph at the nodes corresponding to the first s variables. The nodes corresponding to the maximum connected subgraph constitute the set S T ;
[0083] Keep the set S T The current value of the variable corresponding to the middle node, and the values of the other variables are set to 0;
[0084] After each gradient update, the following operations are performed:
[0085] Determine whether the 2-norm of the variable after the gradient update and the variable before the last gradient solution is less than the threshold;
[0086] If it is not less than the threshold, it means that the iteration stop condition is not met and the iteration continues.
[0087] When it is less than or greater than the threshold, it means that the iteration stop condition is met and the iteration stops.
[0088] Among them, the gradient represents the degree of change of the function on each variable. For all variables of the anomaly detection function f Find the gradient, expressed as
[0089] The implementation method for solving the maximum connected subgraph may be any existing method for solving the maximum connected subgraph, which will not be described in detail here.
[0090] Among them, the gradient obtained in the previous step is used to update the corresponding variables so that In S H The variable value corresponding to the node outside is set to 0. Less than 0, let like make This operation can ensure that the variable value range is [0,1], and the updated variable value increases the function value f.
[0091] Among them, the iteration stop condition can be expressed as: The threshold δ may be preset, for example, to 0.001.
[0092] Step 204 , taking the connected subgraph formed by the nodes corresponding to the non-zero function variables when the iteration stop condition is met as an abnormal connected subgraph.
[0093] Among them, in graph theory, connected graphs are based on the concept of connectivity. In an undirected graph G, if there is a path connecting vertex i to vertex j (of course there must be a path from j to i), then i and j are said to be connected. If G is a directed graph, then all edges in the path connecting i and j must be in the same direction. If any two points in the graph are connected, then the graph is called a connected graph. The maximum connected subgraph refers to a set of nodes. Find a subset of the subset whose nodes are connected to each other and have the largest number of nodes.
[0094] Among them, an abnormally connected subgraph refers to a series of subgraphs that are connected at every moment in a time period. The attribute values of these subgraphs on the network at the corresponding moment are abnormal, and the subgraphs remain connected (any two nodes in the subgraph are connected by a path). At the same time, the attributes of the subgraphs at different moments have a certain association. This association refers to the subgraphs at two adjacent moments. The subgraph at the latter moment has a certain overlap with the subgraph at the previous moment (referring to the overlap of the node sets of the two subgraphs). The overlap means that the abnormal state at the previous moment has a certain probability of continuing to the next moment. For example Figure 3 As shown in the figure: dark colors represent nodes with abnormal attributes, light colors represent nodes with normal attributes, w represents time, and there are three time moments (1, 2, 3) in the figure. A function must be defined in advance to maximize the function value and find the dark nodes with abnormal corresponding attribute values. At the same time, these nodes are connected at each time moment. For example, when w=2, the three dark nodes are connected to each other by edges, and the corresponding subgraph remains connected. Moreover, the nodes of the discovered subgraph at consecutive moments have a certain overlap. For example, when w=1 and w=2, the subgraph represented by the two dark nodes before and after, the two nodes at the bottom are both abnormal. The corresponding real-life situation may be that the two dark nodes at time w=1 affect their neighboring nodes, causing them to also become abnormal, resulting in a state where the three nodes are dark at time w=2. The connected subgraph composed of three dark nodes is an abnormal connected subgraph.
[0095] Among them, a non-zero variable means that the variable value is not zero, indicating that the attribute of the node corresponding to the variable is abnormal, and the connected subgraph composed of the nodes corresponding to the non-zero variable is the connected subgraph composed of nodes with abnormal attributes.
[0096] The technical solution provided by the embodiment of the present invention can ensure that the detected subgraph is abnormal and that the detected subgraph is connected. However, it is difficult for the detection method in the prior art to simultaneously meet the two conditions of ensuring that the detected subgraph is abnormal and that the detected subgraph is connected.
[0097] Figure 4 A schematic flow chart of a method for detecting abnormally connected subgraphs provided by another embodiment of the present invention is shown as follows: Figure 4 As shown, the method includes:
[0098] Step 401, constructing a dynamic attribute network through data modeling based on the original data, the dynamic attribute network includes n nodes, m edges, and w moments;
[0099] The dynamic attribute network can also be mathematically represented as a sequence of graphs with the same node and edge sets. Then there are w graphs in total (G1,...,G w ),G i =(V,E,W i (V)),V={1,...,n},i=1,...,w,G i represents the graph corresponding to the i-th moment, each graph has |V| = n nodes, |E| = m edges, W i (V) represents the attribute set of each node at the i-th moment.
[0100] Step 402, define a function f for detecting abnormal nodes and building attribute associations at different times. The function must be differentiable. Each attribute of each node corresponds to a variable at one time. All variables x i The value range of is between [0,1];
[0101] In this embodiment, the function adopts a relaxed elevated mean scan function (EMS), through which nodes with abnormal attribute values in a dynamic attribute network can be detected.
[0102] Step 403, make the function variable Assign the default value, parameter t is 0, and parameter s is the default value;
[0103] The initial value of a variable is usually a small value close to 0. For example, all variables can be The value is assigned to be 0.000001. s can be preset based on experience, such as being assigned a value of 3.
[0104] Among them, t represents the iteration variable, that is, the number of iterations; it means that after the algorithm executes a round of operations, the subsequent operations must be repeatedly executed, and the execution to the tth time is called iteration t.
[0105] The subgraph scale s is used to determine the size of the detected connected subgraph (here, the number of nodes). S can be determined empirically, depending on the number of nodes contained in the abnormal connected subgraph to be discovered, so different subgraph scales can be set for different applications.
[0106] Step 404, find the gradients of all variables of the function, which are expressed as
[0107] Step 405, find the first s variables with the largest gradient among all variables, solve the largest connected subgraph at the nodes corresponding to these s variables, and the corresponding nodes constitute a set S H ;
[0108] Among them, the set S H There are s nodes, each of which is connected by an edge. The value of s is a pre-set positive integer.
[0109] Step 406, using the gradient obtained in the previous step, update the corresponding variable;
[0110] even though In S H The variable value corresponding to the node outside is set to 0. Less than 0, let like make
[0111] Among them, through Less than 0, let like make It can be ensured that the value range of the variable is [0,1], and the updated variable value increases the function value f;
[0112] In this step, the function value increases through gradient update. One node is associated with one function variable, so the function variable at each moment is from x1 to x n , each node is associated with an attribute value. Finding an abnormal connected subgraph means finding a node set with the largest abnormal attribute value. A function variable of 0 indicates that the attribute value of this node at that moment is not abnormal, and a non-zero value indicates that the attribute value of the corresponding node at that moment is abnormal. Then x iThe maximum function value is obtained by a function with its attribute value, that is, the highest abnormality, so the node corresponding to the function variable non-0 may be a higher probability of an abnormal node. After the gradient update in step 406, the value of the function variable changes. The original value of 0 may become greater than 0, and the original non-0 value may become 0, which leads to the original S H The set no longer satisfies the connectivity constraint, so step 407 again finds the first s values with the largest non-zero values and finds a maximum subset of nodes corresponding to the s variables to satisfy the connectivity constraint.
[0113] Step 407, find the first s variables with the largest values among all variables, solve the largest connected subgraph at the nodes corresponding to these s variables, and the corresponding nodes constitute a set S T ;
[0114] In each iteration, step 406 ensures that the abnormality of the subgraph represented by the function value becomes larger, and step 407 indicates that the nodes of the obtained subgraph are connected. This is repeated and the subgraph will get closer and closer to the most abnormal subgraph.
[0115] Step 408, retain the set S T The current value of the variable corresponding to the middle node, and the values of the other variables are set to 0. The steps are: let t = t + 1, i∈S T When x (t+1) remain unchanged, When x (t+1) =0;
[0116] Step 409, using the function variable value updated in step 408 as the input function value of step 404, and repeating steps 404 to 408 until the 2-norm of the function variable input in step 404 and the function value updated in step 408 is less than a threshold δ;
[0117] Among them, the iteration stop condition can be expressed as:
[0118] The threshold δ can be set based on experience and specific applications, for example, 0.001. A value less than the threshold means that the function value does not change, and the abnormal subgraph found is closest to the most abnormal subgraph in reality.
[0119] Among them, step 404 to step 405 is repeated, which is the iteration mentioned above. The function value changes once in each round. When it is close to the most abnormal value in reality, the change of the function value will become smaller and smaller each time. Theoretically, it can approach 0, but in reality, the algorithm will not be executed infinitely, so a threshold is set. When the change of the function value is less than this threshold, the algorithm iteration stops.
[0120] Step 410: When the 2-norm of the function variable input in step 404 and the function value updated in step 408 is less than the threshold δ, the nodes corresponding to all non-zero function variables constitute the final set S F , the set S F The connected subgraph composed of corresponding nodes is the abnormal connected subgraph.
[0121] The technical solution provided by the embodiment of the present invention solves the dynamic subgraph optimization problem with topological constraints (subgraph connectivity) by using a gradient-based approach. It not only ensures that for the defined abnormal function, the function value corresponding to the attribute of the node in the subgraph at each moment is maximized, but also satisfies the connectivity between the nodes of the subgraph at each moment. That is, this solution solves the optimization problem of functions with discrete constraints on dynamic attribute graphs.
[0122] Figure 5 A schematic flow chart of a method for detecting abnormally connected subgraphs provided by another embodiment of the present invention is shown as follows: Figure 5 As shown, the method includes:
[0123] Step 501, constructing a dynamic attribute network through data modeling based on the original data, the dynamic attribute network includes n nodes, m edges, and w moments;
[0124] Among them, modeling refers to the correspondence between actual data and nodes, edges, and attributes in the algorithm.
[0125] In this embodiment, n=5, m=5, w=3. The constructed dynamic attribute network is Figure 3 As shown, dark colors represent nodes with abnormal attribute values, light colors represent nodes with normal attribute values, solid lines represent edges within the network at each moment, and dotted lines represent connections between the same nodes at different moments.
[0126] Step 502, defining anomaly detection function f;
[0127] In this embodiment, the anomaly detection function f is an EMS function, which is expressed as:
[0128]
[0129] Among them, a represents the attribute of the node, x represents the function variable corresponding to the node, n is the number of nodes, w is the number of moments, i is the node number, and t is the iteration variable.
[0130] Step 503: All variables of function f Assign an initial value of 0.000001, an initial value of t of 0, and an initial value of s of 3;
[0131] like Figure 5As shown, each graph has 5 nodes, a total of 15 nodes. Assuming that each node corresponds to an attribute, the attribute value at each moment can be expressed as The variable corresponding to each node at each time is expressed as Will Assign an initial value of 0.000001, an initial value of 0 to t, and an initial value of 3 to s.
[0132] Step 504, find the gradient of each variable, denoted as
[0133] The formula for finding the gradient is:
[0134]
[0135] Step 505: Find the first s variables with the largest gradient among all variables, and solve the largest connected subgraph at the nodes corresponding to these s variables. The corresponding nodes constitute a set S H ;
[0136] Among them, through this step, a direction that satisfies the connectivity requirement and increases the function value can be found. Assuming that the current function variable obtains a function value of 1, continuing to change the function variable may increase the function value. Finding the gradient represents the direction that increases the function value the most. For example, the function variable x1 corresponding to node 1 increases by 0.1, the function variable x2 corresponding to node 2 increases by 0.2, and so on, so that the function value increases the most. Then (0.1, 0.2, ...) is the gradient mentioned here. Just like climbing a mountain, with a certain stride, in which direction can you go up the most, the gradient can show how each variable changes to make the function value change the most.
[0137] Step 506, using the gradient obtained in step 4, update the corresponding variable;
[0138] even though In S H The variable value corresponding to the node outside is set to 0. Less than 0, let like make
[0139] Among them, this step can ensure that the value range of the variable is [0,1].
[0140] Among them, by updating all variables in this step, the function value can be increased. The function value represents the degree of abnormality. To find the most abnormal subgraph, the function value must be as large as possible. Therefore, in the algorithm, the problem of finding abnormal subgraphs becomes a problem of maximizing the function value.
[0141] Step 507, find the first s variables with the largest values among all variables, solve the largest connected subgraph at the nodes corresponding to these s variables, and the corresponding nodes constitute a set S T ;
[0142] Step 508, retain the set S T The current value of the variable corresponding to the middle node, and the values of the other variables are set to 0;
[0143] In this step, t=t+1, when i∈S T , x (t+1) remain unchanged, x (t+1) =0.
[0144] The updated non-zero function variables may not necessarily continue to meet the connectivity requirement. Steps 507 and 208 may allow the non-zero function variables to meet the connectivity requirement again.
[0145] Step 509, using the function variable value obtained in step 508 as the input function variable value of step 504, and continuing iteration, that is, repeating steps 504 to 508 until the 2-norm of the function variable input in step 504 and the function value updated in step 508 is less than the threshold δ;
[0146] Step 510: All nodes corresponding to non-zero function variables constitute the final set S F , the set S F The maximum connected graph composed of corresponding nodes is taken as the abnormal connected subgraph.
[0147] The schematic diagram of the principle of continuous iteration of this embodiment is as follows Figure 6 As shown in the figure, different shades of gray represent the candidate value range of the function variable in the current step. Figure 6 It can be seen that by continuously increasing the function value, the most abnormal subgraph can be found.
[0148] Another embodiment of the present invention further provides a method for detecting a dynamic attribute network anomaly, the method comprising:
[0149] When the dynamic attribute network detects a corresponding abnormal connected subgraph, determining that the dynamic attribute network is abnormal at the time and node area corresponding to the abnormal connected subgraph;
[0150] The abnormally connected subgraph is a subgraph detected by applying the method described in any of the above embodiments.
[0151] In one example, the dynamic attribute network is constructed by data modeling, represented as G i =(V,E,W i (V)), V={1,...,n}, i=1,...,w;
[0152] Among them, G i represents the dynamic attribute network graph corresponding to the i-th moment. Each graph has |V| = n nodes, |E| = m edges, and W i (V) represents the attribute set of each node at the i-th moment.
[0153] The technical solution provided by the embodiment of the present invention determines whether a dynamic attribute network is abnormal within a certain time period by detecting whether there is an abnormal connected subgraph, thereby realizing automatic detection of whether a dynamic attribute network is abnormal and greatly improving detection efficiency.
[0154] The embodiment of the present invention further provides an electronic device, such as Figure 7 As shown, including:
[0155] A construction unit, configured to construct a dynamic attribute network based on raw data;
[0156] An assignment unit, configured to assign initial values to all variables and parameters of a preset anomaly detection function;
[0157] An iteration unit is configured to solve the gradient of each variable of the anomaly detection function through iteration and update the gradient of each variable so that the function value increases continuously until an iteration stop condition is met;
[0158] A determination unit is set to regard a connected subgraph consisting of nodes corresponding to non-zero function variables as an abnormal connected subgraph when an iteration stop condition is met;
[0159] Among them, the function value of the anomaly detection function represents the degree of anomaly of the dynamic attribute network; an attribute of each node at a time in the dynamic attribute network corresponds to a variable of the anomaly detection function, and each variable takes a value between zero and 1. A variable of zero indicates that the attribute of the corresponding node at the corresponding time is normal, and a variable of non-zero indicates that the attribute of the corresponding node at the corresponding time is abnormal; the iteration stopping condition is that the 2-norm of the variable after the gradient update and the variable before the last gradient solution is less than a threshold.
[0160] In one example, the anomaly detection function includes one of the following:
[0161] Relaxed lifted mean scan EMS function, expected Poisson statistics based EBP function, Kulldorff scan statistics based function.
[0162] In one example, the step of assigning initial values to all variables and parameters of a preset anomaly detection function includes:
[0163] Define anomaly detection function f, and set all variables of function f Assign the default value, assign the parameter t to 0, and assign the parameter s to the default value;
[0164] Where t represents the number of iterations, and i corresponds to the node number; It represents the function variable corresponding to the node numbered i when the number of iterations is t. i takes the value of an integer from 1 to n×w. All variables The value range is between [0,1], n represents the total number of nodes, w represents the number of moments in the preset time period, and s represents the subgraph scale.
[0165] In one example, the iteratively solving the gradient of the variable of the anomaly detection function and updating the gradient of the variable so that the function value continuously increases includes:
[0166] Each time the gradient is solved, the following operations are performed:
[0167] For all variables of the anomaly detection function f Find the gradient, expressed as
[0168] Find the first s variables with the largest gradient among all variables, solve the corresponding maximum connected subgraph at the nodes corresponding to the first s variables, and construct the set S of nodes corresponding to the maximum connected subgraph H ;
[0169] Each gradient update performs the following operations:
[0170] Using the gradient of the solution Update the corresponding variables so that In S H The variable value corresponding to the node outside is set to 0. Less than 0, let like make
[0171] Find the first s variables with the largest values among all variables, and solve the corresponding maximum connected subgraph at the nodes corresponding to the first s variables. The nodes corresponding to the maximum connected subgraph constitute the set S T ;
[0172] Keep the set S T The current value of the variable corresponding to the middle node, and the values of the other variables are set to 0;
[0173] After each gradient update, the following operations are performed:
[0174] Determine whether the 2-norm of the variable after the gradient update and the variable before the last gradient solution is less than the threshold;
[0175] If it is not less than the threshold, it means that the iteration stop condition is not met and the iteration continues.
[0176] When it is less than or equal to the threshold, it means that the iteration stop condition is met and the iteration stops.
[0177] In one example, when the anomaly detection function is an EMS function, the anomaly detection function is expressed as:
[0178] The formula for finding the gradient for each variable is:
[0179]
[0180] in, Represents the attribute value corresponding to node i when the number of iterations is t.
[0181] In one example, the iteration stop condition is expressed as: δ is the threshold.
[0182] The technical solution provided by the embodiment of the present invention utilizes an anomaly detection function to find the most abnormal connected subgraph by continuously increasing the function of the function, thereby ensuring that the detected subgraph is abnormal and connected.
[0183] The embodiment of the present invention further provides an electronic device, such as Figure 8 As shown, the device comprises:
[0184] A determination unit, configured to determine that the dynamic attribute network is abnormal at a time and a node area corresponding to the abnormal connected subgraph when the dynamic attribute network detects a corresponding abnormal connected subgraph;
[0185] The abnormally connected subgraph is a subgraph detected by applying the method described in any of the above embodiments.
[0186] An embodiment of the present invention also provides an electronic device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the computer program is executed by the processor, the computer program implements any of the above-mentioned methods for detecting abnormal connected subgraphs, or any of the above-mentioned methods for detecting dynamic attribute network anomalies.
[0187] An embodiment of the present invention also provides a computer-readable storage medium, on which an information processing program is stored. When the information processing program is executed by a processor, it implements any of the above methods for detecting abnormal connected subgraphs, or any of the above methods for detecting dynamic attribute network anomalies.
[0188] It will be appreciated by those skilled in the art that all or some of the steps, systems, and functional modules / units in the methods disclosed above may be implemented as software, firmware, hardware, and appropriate combinations thereof. In hardware implementations, the division between the functional modules / units mentioned in the above description does not necessarily correspond to the division of physical components; for example, a physical component may have multiple functions, or a function or step may be performed by several physical components in cooperation. Some or all components may be implemented as software executed by a processor, such as a digital signal processor or a microprocessor, or implemented as hardware, or implemented as an integrated circuit, such as an application-specific integrated circuit. Such software may be distributed on a computer-readable medium, which may include a computer storage medium (or non-transitory medium) and a communication medium (or temporary medium). As known to those skilled in the art, the term computer storage medium includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules, or other data). Computer storage media include, but are not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital versatile disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tapes, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to store the desired information and can be accessed by a computer. In addition, it is well known to those of ordinary skill in the art that communication media typically contain computer-readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transport mechanism, and may include any information delivery media.
Claims
1. A method for detecting abnormally connected subgraphs, comprising: Build a dynamic attribute network based on raw data; Assign initial values to all variables and parameters of the preset anomaly detection function; By iteratively solving the gradient of each variable of the anomaly detection function and updating the gradient of each variable so that the function value continues to increase until the iteration stop condition is met; When the iteration stop condition is met, the connected subgraph composed of the nodes corresponding to the non-zero function variables is regarded as an abnormal connected subgraph; Determining whether there is a congested area in the road traffic network within the preset time period by detecting whether there is an abnormally connected subgraph in the corresponding road traffic network within the preset time period; The function value of the anomaly detection function represents the degree of anomaly of the dynamic attribute network; an attribute of each node at a time in the dynamic attribute network corresponds to a variable of the anomaly detection function, and each variable takes a value between zero and 1. A variable of zero indicates that the attribute of the corresponding node at the corresponding time is normal, and a variable of non-zero indicates that the attribute of the corresponding node at the corresponding time is abnormal; the iteration stop condition is that the 2-norm of the variable after the gradient update and the variable before the last gradient solution is less than a threshold; The construction of a dynamic attribute network based on the original data includes: constructing a monitoring road traffic network, with each intersection as a node, each section of road between any two adjacent intersections as an edge, and the attribute on each node being the number of vehicles passing through the corresponding intersection; The step of assigning initial values to all variables and parameters of the preset anomaly detection function includes: Define anomaly detection function f, and set all variables of function f Assign the default value, assign the parameter t to 0, and assign the parameter s to the default value; Where t represents the number of iterations, and i corresponds to the node number; It represents the function variable corresponding to the node numbered i when the number of iterations is t. i takes the value of an integer from 1 to n×w. All variables The value range of is between [0,1], n represents the total number of nodes, w represents the number of moments in the preset time period, and s represents the subgraph scale; The gradient of the variable of the anomaly detection function is solved iteratively and the gradient of the variable is updated so that the function value is continuously increased, including: Each time the gradient is solved, the following operations are performed: For all variables of the anomaly detection function f Find the gradient, expressed as Find the first s variables with the largest gradient among all variables, solve the corresponding maximum connected subgraph at the nodes corresponding to the first s variables, and construct the set S of nodes corresponding to the maximum connected subgraph H ; Each gradient update performs the following operations: Using the gradient of the solution Update the corresponding variables so that In S H The variable value corresponding to the node outside is set to 0. Less than 0, let like make Find the first s variables with the largest values among all variables, and solve the corresponding maximum connected subgraph at the nodes corresponding to the first s variables. The nodes corresponding to the maximum connected subgraph constitute the set S T ; Keep the set S T The current value of the variable corresponding to the middle node, and the values of the other variables are set to 0; After each gradient update, the following operations are performed: Determine whether the 2-norm of the variable after the gradient update and the variable before the last gradient solution is less than the threshold; If it is not less than the threshold, it means that the iteration stop condition is not met and the iteration continues; When it is less than or equal to the threshold, it means that the iteration stop condition is met and the iteration stops.
2. The method according to claim 1, characterized in that The anomaly detection function includes one of the following: Relaxed lifted average scan EMS function, expected Poisson statistics based EBP function, Kulldorff scan statistics based function.
3. The method according to claim 1 or 2, characterized in that: When the anomaly detection function is an EMS function, the anomaly detection function is expressed as: The formula for finding the gradient for each variable is: in, Indicates the attribute value corresponding to the node numbered i when the number of iterations is t.
4. The method according to claim 1, characterized in that: The iteration stop condition is expressed as: δ is the threshold.
5. A method for detecting anomalies in a dynamic attribute network, comprising: When the dynamic attribute network detects a corresponding abnormal connected subgraph, determining that the dynamic attribute network is abnormal at the time and node area corresponding to the abnormal connected subgraph; Wherein, the abnormal connected subgraph is detected by applying the method described in any one of claims 1-4.
6. The detection method according to claim 5, characterized in that: The dynamic attribute network is constructed by data modeling and is represented by G k =(V,E,W k (V)), V={1,...,n},k=1,...,w; Among them, G k represents the dynamic attribute network graph corresponding to the kth moment. Each graph has |V| = n nodes, |E| = m edges, and W k (V) represents the attribute set of each node at the kth moment.
7. An electronic device, characterized in that: include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements a method for detecting abnormal connected subgraphs as described in any one of claims 1 to 4, or a method for detecting dynamic attribute network anomalies as described in any one of claims 5-6.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores an information processing program, and when the information processing program is executed by the processor, it implements the method for detecting abnormal connected subgraphs as described in any one of claims 1-4, or the method for detecting dynamic attribute network anomalies as described in any one of claims 5-6.
