Disclosure of Invention
The invention aims to provide the method for detecting the abnormal vehicle track, which improves the accuracy of track prediction, is convenient for effectively identifying numerical value abnormality and service abnormality, combines the track prediction module and the abnormal track detection module to carry out unsupervised abnormality detection, solves the problem that supervised learning is required to be used for identifying the service abnormality, is beneficial to detecting novel abnormality, and improves the accuracy and expandability of abnormality detection and the vehicle track abnormality detection method based on the circulating gate control unit.
The technical scheme disclosed by the invention is as follows:
for trajectory data, we first describe the following:
1. description of data
The track data set contains a plurality of tracks of a plurality of vehicles, and it is assumed that all the vehicle track data sets ctd= { CT 1 ,CT 2 …CT j …CT n J=0, 1,..n. CT is a set of trajectory data for a vehicle, and can be expressed as: CT= { T 1 ,T 2 …T i …T m I=0, 1,..m. Track T j Including relevant characteristics of vehicle travel, expressed as: t (T) i =(c i1 ,c i2 ,v i ,ts i ,w i ,t i ,a i …). The trajectory set CT is time-series data, and is arranged in chronological order.
Track T i May include geographic location, speed, time interval, load, current time, acceleration, and the like.
(1) Geographic location (c) i1 ,c i2 ):c i1 ,c i2 Representing the longitude and latitude, respectively, in which the vehicle is located. The geographic location marks the movement of the vehicle's position within the movement space.
(2) Velocity v i : the speed refers to the running speed of the vehicle at a certain time, and is generally acquired by using a GPS or other device.
(3) Time interval ts i : indicating that the vehicle has moved from the last track point T i-1 To the current track point T i Long travel time.
(4) Load w i : indicating the weight carried by the vehicle. For example, the load capacity of a truck on the road is one of indexes for judging abnormality; whether the taxi carries people or not is also helpful for judging whether the track of the taxi is abnormal or not.
(5) Current time t i : indicating the current time of travel of the vehicle.
(6) Acceleration a i : the vehicle is arranged at two partsAcceleration between trajectory points can be calculated by the formula a= (v i -v i-1 ) And/t.
2. Description of the problem
The invention adopts an algorithm to identify abnormal track points in the track, wherein the abnormal track points comprise numerical value abnormality and business abnormality. The correlation is defined as follows:
(1) Numerical anomaly
Numerical anomalies (Data Anomaly: DA) may also be referred to as linear anomalies, referring to points of the Anomaly trajectory that are more than a certain threshold distance from the normal trajectory. Can be defined as follows:
||T n -T a ||≥Av (1)
in the above, let T n For a normal trajectory, av is a set threshold, and the table of i·i is a distance measure, which may be a euclidean distance or Hausdorff equidistant measure. If the two tracks satisfy equation (1), T a Is a numerical anomaly track.
(2) Business anomalies
Business Anomalies (BAs) may also be referred to as nonlinear anomalies, meaning that normal and abnormal trajectories are mapped to specified values, e.g., 1 or 0, via some nonlinear function. Here, 1 is set to an abnormal value, and 0 is a normal value. Thus, a traffic anomaly may be defined as follows:
F(T a )=1,F(T n )=0 (2)
in the above formula, F is a nonlinear function, T n Is a normal trajectory, if equation (2) is satisfied, T a Is a business anomaly track.
Assuming that the vehicle trajectory t= (time, speed, load), fig. 1 assumes that the load is unchanged, and at 30 minutes, the speed changes from 100 to 110, and the trajectory changes normally, but if the speed changes to 140, the speed may exceed the abnormality threshold value to become numerical abnormality. In fig. 2, assuming that the vehicle speed is unchanged, the load is converted from 30 tons to 20 tons in 5 minutes, and the locus point T in the curve 5 And T 6 T in Euclidean distance versus Normal data curve 5 And T 6 The Euclidean distance has the same value, but FIG. 2 belongs to the business anomaly, because the load of the vehicle is not increased within 5 minutesMay vary too much.
3. Data processing
In order to accelerate the algorithm running speed and improve the model precision, normalization and smoothing processing are carried out on the data.
(1) Carrying out normalization processing on numerical data such as speed, time interval, load, acceleration and the like, wherein the normalization processing formula is as follows:
(2) The longitude and latitude take four bits after the decimal point, and the latitude and longitude range of the whole country is [70,140], the latitude range is [18,60], and the maximum minimum value is selected according to the latitude and longitude range of the whole country when the algorithm expansibility is considered and the latitude and longitude are normalized.
(3) The current time mainly considers the influence of vehicle tracks in different time periods in a day, divides 24 hours of the day into 6 time periods, and starts from 0 time, one time period every 4 hours, and uses a hot coding form. For example, period 1 is encoded as [1,0,0,0,0,0].
(4) The anomaly detection model is an unsupervised model, all data are unlabeled data, and it cannot be confirmed which track point is an anomaly track. However, when training LSTM, it is hoped that all track points are normal track, in order to reduce the influence of abnormal track points, the data can be smoothed, the characteristic "current time" is not smoothed, and the track points Ts are assumed i Is T i The smoothed trajectory points are smoothed as follows:
(5) In training the model, the similarity of adjacent track points is needed, euclidean distance is used as distance measurement mode in the model, and L is assumed t For the similarity between the trajectory points at time t and time t-1, q is the feature number of the trajectory point x, and the calculation formula is as follows.
For ease of computation, the similarity is mapped between [0,1], and the mapping function of equation (6) may be used:
from the above, L t The larger s t The smaller, i.e. the similarity L t The larger the impact on the outcome output is smaller.
Based on the principle, the vehicle track abnormality detection method based on the circulation gating unit comprises the following steps:
(1) S_GRU unit setting step: inputting the similarity s between the track point at the current moment and the track point at the previous moment at the front ends of the reset gate and the update gate of the GRU t Through s t Optimizing the similarity of the track points to obtain a gating circulating unit model S_GRU;
(2)s t setting a strategy: setting L t In order to achieve similarity between the track points at time t and time t-1, q is the feature number of track point x, L t The calculation formula is as follows:
mapping similarity to [0,1]]Between using L t Is obtained by the mapping function of:
(3) Reset gate calculation policy: reset gate r
t Controlling how much information of a previous state is written to a current candidate set
The smaller the reset gate, the former shapeThe less information in the state is written, the reset gate calculation formula is:
r t =σ(W r ·[h t-1 ,x t ]+η r *s t )
wherein eta is r Is a self-defined parameter, which represents the influence degree on the reset gate, and is initialized before model training, and the value range is set as 0,1];;s t The similarity of the track points at the time t and the time t-1 is shown; h is a t-1 When t=1, h represents the state value of the previous time t-1 Initially 0.X is x t Representing the input value, W, at the current time r Is the weight required to be trained by resetting the gate, r t Representing the output value of the reset gate, σ being the stimulus function;
(3) Updating a door calculation strategy: updating door z t The greater the value of the update gate, which is used to control the extent to which the state information at the previous time is brought into the current state, the more the state information at the previous time is brought into, the update gate calculation formula is:
z t =σ(W z ·[h t-1 ,x t ]+η z *s t )
wherein eta is z Is a self-defined parameter, which represents the influence degree of the updating door, is initialized before model training, and the value range is set as 0,1],W z Indicating the weight z of the update gate to be trained t Is the output value of the update gate, s t The similarity of the track points at the time t and the time t-1 is represented, and the meaning of other parameters is the same as that of the reset gate calculation strategy in the step (3);
(5) The track prediction module setting step: after a plurality of S_GRU units are connected in series, the S_GRU units are connected into a full-connection layer FC to form a track prediction module, and a track sequence T= (T) 1 ,T 2 ,...T p-1 ) As an input value of the track prediction module, the full connection layer FC is the output end of the track prediction module and outputs track points; the fully connected layer FC uses a plurality of sigma excitation functions, the calculation formula is:
(6) An abnormality detection module setting step: adopting a double-layer gating circulation unit, using S_GRU in a first layer, using GRU in a second layer, taking a hidden value h of the first layer as an input value of the GRU in the second layer, wherein the first layer processes the characteristics of numerical value abnormality and extracting track data in a second layer in a deeper layer, so as to process business abnormality and improve the accuracy of abnormality judgment; the last GRU unit is connected with a logistic regression function LR; track sequence
As the input end of the first GRU unit, the logistic regression function LR is output as the output end of the abnormality detection module, and whether the output is an abnormal value or not;
(7) The track prediction module is connected with the abnormality detection module: connecting the output end of the track prediction module with an abnormal track detection module, and obtaining a predicted value of the sequence T by the running track prediction module
(8) The output end of the abnormality detection module outputs a judgment strategy: obtaining a predicted value of the sequence T through a running track prediction module
Track sequence +.>
As an input value to the anomaly detection module; if it is
Then->
The distance between the detection module and the true value is a certain distance, the detection module belongs to an abnormal track point, and the final output value of the abnormality detection module is 1; if->
The predicted value is similar to the actual value and the predicted goal is achieved>
Is a normal track point, so the final output value of the abnormality detection module is 0; wherein: epsilon is a super parameter and can be set to 0.001; ts (Ts)
p Is the true value of the predicted track point, and p is the selected sequence length.
The beneficial effects of the invention are as follows: adopting two main modules of track prediction and anomaly detection; firstly, forming an S_GRU model of track prediction by using GRU and an attention mechanism, wherein the S_GRU model can reduce the influence of redundant data and improve the accuracy of track prediction; then taking the predicted track as input data, constructing a double-layer GRU abnormal track prediction model so as to effectively identify numerical value abnormality and business abnormality; the GRU_ATD model is combined with the track prediction module and the abnormal track detection module to perform unsupervised abnormal detection, so that the problem that supervised learning is required to be used for identifying business abnormality is solved, novel abnormality is detected, and the accuracy and expandability of abnormality detection are improved.
Detailed Description
The invention is further illustrated and described below in conjunction with the specific embodiments and the accompanying drawings:
referring to fig. 3 and 4, the gating cycle unit model adopted in the present invention is as follows:
the anomaly detection model mainly uses a training gating circulation unit (GRU: gated Recurrent Unit) to predict track points, the GRU is a variant of a long and short memory model (LSMT), the GRU model unifies forgetting gate and input gate in the LSMT model into an updated gate, the state h and the cell state C are combined, the final model is simpler than a standard LSMT, fewer parameters need to be trained, and the speed is faster.
The track data of the vehicle running mostly uses GPS to collect data, the GPS collects data according to seconds or minutes, the similarity of adjacent track points in the data set is large, and the excessive similar data disperses the attention of the model and reduces the prediction accuracy. Therefore, in order to improve the effectiveness of the algorithm, the invention optimizes the gating loop unit model s_gru by combining the similarity of the track points, namely: inputting the similarity s between the track point at the current moment and the track point at the previous moment at the front ends of the reset gate and the update gate of the GRU t Through s t The similarity of the track points is optimized to obtain a gating cycle unit model S_GRU, and a model structure diagram of the S_GRU is shown in fig. 3.
The S_GRU model of the invention can be expressed as y t+p =S_GRU(x t ,s t ,x t+1 ,s t+1 ...x t+p-1 ,s t+p-1 ) P is the number of track points input in a prediction period, y t+p Is the locus point that needs to be predicted. The forward propagation formula of the S_GRU model is shown below, where [ among others ]]Representing the product of the two vectors connected, representing the matrix.
(1) The gate is reset. Reset gate r
t Controlling how much information of a previous state is written to a current candidate set
The smaller the reset gate is, the less information of the previous state is written, the reset gate calculation formula is:
r t =σ(W r ·[h t-1 ,x t ]+η r *s t ) (7)
wherein eta is r Is a self-defined parameter, which represents the influence degree on the reset gate, and is initialized before model training, and the value range is set as 0,1];;s t The similarity of the track points at the time t and the time t-1 is shown; h is a t-1 When t=1, h represents the state value of the previous time t-1 Initially 0.X is x t Representing the input value, W, at the current time r Is the weight required to be trained by resetting the gate, r t Representing the output value of the reset gate, σ is the stimulus function, expressed as follows:
(1) The door is updated. Updating door z t The greater the value of the update gate, which is used to control the extent to which the state information at the previous time is brought into the current state, the more the state information at the previous time is brought into, the update gate calculation formula is:
z t =σ(W z ·[h t-1 ,x t ]+η z *s t ) (9)
wherein eta is z Is a self-defined parameter, which represents the influence degree of the updating door, is initialized before model training, and the value range is set as 0,1],W z Indicating the weight z of the update gate to be trained t Is the output value of the update gate, s t And (3) expressing the similarity of the track points at the time t and the time t-1, wherein the meaning of other parameters is the same as that of the reset gate calculation strategy in the step (3), and sigma is an excitation function and is as shown in the formula (8). s is(s) t Representing the similarity between the track point at the current moment and the track point at the last moment, s t The smaller the value, the less state information is brought in at the previous time.
(3) And outputting a state. The state output value at the current time is indicated and is taken as the input value at time t+1.
In the above, r t ,z t The output values of the formula (7) and the formula (9) are respectively, W is a parameter for demand training, the tanh function is a hyperbolic tangent function, and the expression is shown as the formula (12).
(4) And outputting a door. The output gate represents the result of the final prediction after a prediction period of the model. In the anomaly detection model, the trajectory prediction module follows the S_GRU with a full connection layer FC, which uses a plurality of sigma-excitation functions, see equation (8), with the final output being the trajectory point. The abnormal track detection module is a double-layer GRU, and is connected with a logistic regression function LR, wherein the LR function is calculated in the same way as the formula (8), and whether the final output of the module is an abnormal value or not. Both modules mainly use the excitation function sigma, but the output dimensions are different.
y t =σ(W o ·h t )
In the above, h t Representing the state value, W, at the current time o Is the weight that the output gate needs to train.
The principle of the abnormality detection model of the invention is as follows:
the abnormal track points are divided into numerical value abnormal points and business abnormal points, numerical value abnormal points are detected in most of non-supervision abnormal detection algorithms, and the business abnormal points are detected by using supervision abnormal detection methods, such as neural networks, support vector machines and the like. The supervised anomaly detection method has the defects of poor expansibility, only the anomaly data of the labels can be identified, in addition, the track data of the vehicles are more, the forms are changeable, and the track data with the labels are less. To solve the above problem, we propose an unsupervised abnormal trajectory detection algorithm gru_atd based on GRU. The anomaly detection module in the algorithm uses a double-layer gating circulation unit, uses S_GRU in a first layer, uses GRU in a second layer, uses a hidden value h of the first layer as an input value of GRU in the second layer, processes numerical anomaly in the first layer, and can extract characteristics of track data in a deeper layer in the second layer so as to process business anomaly, thereby being beneficial to improving the accuracy of anomaly judgment.
The basic idea of the GRU-based anomaly detection model is as follows: firstly, preprocessing and smoothing data, and then constructing a track prediction module based on S_GRU, wherein the track prediction module consists of S_GRU and a fully connected layer FC, and a track sequence T= (T)
1 ,T
2 ,...T
p-1 ) As a model of trajectory predictionInput value of block, ts
p Is the true value of the predicted track point, p is the selected sequence length, W is the weight of the model, the predicted value of the sequence T can be obtained by the running track prediction module when the model is randomly selected during initialization
Then constructing an abnormality detection module based on double-layer GRU, wherein the abnormality detection module consists of S_GRU, GRU and logistic regression LR, and the track sequence is +.>
As an input value of the abnormality detection module, if +.>
Then->
The distance from the true value is a trace point of abnormality, the final output value of the abnormality detection module is 1, epsilon is a super parameter, and can be set to 0.001. If->
The predicted value is similar to the actual value and the predicted goal is achieved>
Is the normal trace point and thus the final output value of the anomaly detection module is 0.
The output end of the track prediction module is connected to the track prediction module, and the running track prediction module obtains the predicted value of the sequence T
Track sequence +.>
As an input value to the anomaly detection module; the GRU-based anomaly detection model training architecture is shown in FIG. 4.
Output end of abnormality detection moduleAnd outputting a judgment strategy: obtaining a predicted value of the sequence T through a running track prediction module
Track sequence +.>
As an input value to the anomaly detection module; if it is
Then->
The distance between the detection module and the true value is a certain distance, the detection module belongs to an abnormal track point, and the final output value of the abnormality detection module is 1; if->
The predicted value is similar to the actual value and the predicted goal is achieved>
Is a normal track point, so the final output value of the abnormality detection module is 0; wherein: epsilon is a super parameter and can be set to 0.001; ts (Ts)
p Is the true value of the predicted track point, and p is the selected sequence length.
An embodiment employed by the present invention is as follows:
the pseudo code of the GRU_ATD algorithm training process is as follows, just describing the overall thought process of the algorithm.
After the GRU_ATD algorithm is trained, when an abnormal track is detected in real time, only an abnormal detection module is needed to detect the track, and the detection process is as follows:
finally, it should be noted that the above embodiments are only for illustrating the technical solution of the present invention, and not for limiting the scope of the present invention, and although the present invention has been described in detail with reference to the preferred embodiments, it should be understood by those skilled in the art that modifications or equivalent substitutions can be made to the technical solution of the present invention without departing from the spirit and scope of the technical solution of the present invention.