A data-driven adaptive shared bicycle prediction method
By constructing a dynamic adjacency matrix and a spatiotemporal graph neural network, and combining multi-source data, the problem of dynamic station connectivity and the influence of external factors in shared bicycle prediction is solved, and more accurate prediction of shared bicycle station entry and exit vehicles is achieved.
Patent Information
- Application Number
- CN202310103314.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-13
- Publication Date
- 2025-11-11
- Estimated Expiration
- 2043-02-13
AI Technical Summary
Existing shared bike prediction methods cannot dynamically capture the connectivity between stations and do not consider the impact of station POIs and weather factors, resulting in inaccurate predictions.
A data-driven adaptive shared bicycle prediction method is adopted. By constructing a dynamic adjacency matrix and combining multi-source data such as historical site data, weather data and POIs data, a spatiotemporal graph neural network is used for prediction, including an external feature fusion layer, a local feature fusion layer and an adaptive feature layer. The group attention mechanism and group convolutional layer are used to extract site features.
It improves the accuracy of shared bicycle prediction, dynamically reflects the station connectivity, reduces model parameters and training time, and enhances prediction performance.
Smart Images

Figure CN116128138B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of intelligent transportation - traffic flow prediction, specifically a data-driven adaptive shared bicycle prediction method. Background Technology
[0002] Bike sharing, as a convenient and green mode of transportation, has become widely popular worldwide. The complementarity between bike sharing and other public transportation can save social costs. Simultaneously, due to the convenience and personalization of bike sharing, people are increasingly relying on this mode of transportation. As of August 2022, 1,880 bike sharing systems had been deployed in more than 50 countries and regions globally, with over eight million bikes available for consumer use. Based on the marginal effect of networks, more bike sharing stations further enhance user experience and increase company revenue. Therefore, bike sharing companies often set up a large number of stations. For example, as of May 2022, New York's Citi bike system had 1,627 stations, and Chicago's Divvy bike system had 1,111 stations. While providing convenience to users, the sheer number of stations and the complex and dynamic relationships between them present challenges for companies in terms of operation and management.
[0003] Current shared bike prediction methods can be broadly categorized into three types: cluster-based prediction, grid-based prediction, and site-based prediction. Cluster-based prediction addresses the inability to predict for every single site. It typically clusters sites based on attributes to simplify the number of sites and predicts the number of entries and exits for each cluster. Grid-based prediction, given that geographical location is a crucial factor in shared bike prediction, often divides a city into a grid to capture temporal location information. Models such as convolutional neural networks are then used to extract relevant spatial location factors. Single-site-based prediction, which previously couldn't directly predict the number of entries and exits at a single site, has seen improvements with the emergence and development of graph neural networks. In graphs, nodes represent bike stations, and edges represent connections between stations. This method has been applied to capture spatial relationships between sites and has made progress in site prediction.
[0004] Existing methods have the following shortcomings: 1. Due to the varying connectivity between shared bicycle sites at different times, existing studies use fixed adjacency matrices to determine the connections between sites, failing to consider dynamic relationships. Therefore, they cannot dynamically capture the connections between sites. For example, in the early morning, most shared bicycles are idle, with no riding records between sites; during peak riding periods, the connections between sites are close. 2. Previous inventions did not consider the impact of external spatial characteristics (POIs) on shared bicycle sites. For example, in the morning, the number of bicycles leaving sites near residential areas is higher, while the number entering sites in commercial areas is higher, and vice versa in the evening. Therefore, the lack of consideration for shared bicycle site characteristics led to inaccurate predictions. 3. Previous inventions rarely considered external factors such as weather. As an outdoor mode of transportation, shared bicycles are highly susceptible to weather conditions. Failure to consider weather and other external factors leads to inaccurate predictions of shared bicycle usage. Summary of the Invention
[0005] This invention addresses the shortcomings of existing technologies by proposing a data-driven adaptive shared bicycle prediction method. This method aims to more accurately predict the number of shared bicycles leaving and entering stations by comprehensively considering multi-source data such as historical data, weather data, and POIs (Points of Interest) data from shared bicycle stations. This will help shared bicycle operators adjust their vehicle delivery strategies in a timely manner to ensure a reasonable distribution of shared bicycles.
[0006] To achieve the above-mentioned objectives, the present invention adopts the following technical solution:
[0007] The present invention provides a data-driven adaptive shared bicycle prediction method, characterized by the following steps:
[0008] Step 1: Obtain and preprocess data on vehicles entering and leaving all shared bicycle stations:
[0009] Step 1.1: Obtain the riding records of shared bicycles, and each riding record includes: initial station, ending station, start time, and end time; obtain historical weather feature records; obtain the POIs spatial features of each shared bicycle station.
[0010] Step 1.2: Construct a graph structure dataset G based on the predicted time intervals, where the graph structure data for the t-th time interval is denoted as G. t =(V t A t H t ,F t V t Let A represent the set of shared bicycle stations for the t-th time interval. tLet A represent the adjacency matrix between shared bicycle stations during the t-th time interval; if there is a bicycle riding record from shared bicycle station i to shared bicycle station j during the t-th time interval, then let A... t The element a in the i-th row and j-th column ij The value is 1; otherwise, a ij The value is 0; H t Represents the characteristics of all shared bicycle stations within the t-th time interval, where, Let represent the characteristics of shared bicycle station j within the t-th time interval, including: the number of shared bicycles entering station j and the number of shared bicycles leaving station j; Let Let represent the historical weather characteristics within the t-th time interval; Represent the POIs features of all shared bicycle stations; where N w The number of weather features is represented by N, and the number of shared bicycle stations is represented by N. p Indicates the number of features in POIs;
[0011] Step 1.3: Set the width of the sliding window to T, and partition the graph structure dataset G using the sliding window to obtain the sample set D = {(X1,Y1),(X2,Y2),...,(X...}. n ,Y n ),...,(X N ,Y N )}, where (X n ,Y n X represents the nth sample. n Let X represent the historical data of the nth sliding window, and let X be... n ={G n,1 G n,2 ,...,G n,t ,...,G n,T}, G n,t Y represents the graph structure data of the t-th time interval in the historical data of the n-th sliding window. n X represents the historical data of the nth sliding window. n The predicted number of vehicles entering and exiting all shared bicycle stations within the (n+1)th time interval; Let This represents the historical weather characteristics of all time intervals within the nth sliding window, and F n,t This represents the historical weather characteristics of the t-th time interval within the n-th sliding window;
[0012] Step 2: Construct a spatiotemporal graph neural network, including: an external feature fusion layer, a local feature fusion layer, an adaptive feature layer, and an output layer; wherein, the external feature fusion layer includes a feature embedding layer and a feature fusion layer; the local feature fusion layer includes a local attention layer and a grouped convolutional layer;
[0013] Step 2.1: Define the current iteration number as z and initialize z = 1; define the iteration threshold as Z; initialize the parameters in the neural network;
[0014] Step 2.2, processing of the external feature fusion layer;
[0015] Step 2.2.1, the external feature embedding layer uses equations (1) and (2) to embed POIs features P and historical weather features. Spatial embedding is performed to obtain the spatial features of the embedded POIs. Weather spatial features embedded in the nth sliding window
[0016] E p =PW p (1)
[0017]
[0018] In equations (1) and (2), Let N represent two parameters to be learned. e Indicates the dimension of the embedding;
[0019] Step 2.2.2, the external feature fusion layer uses equations (3) and (4) to respectively process E p , Perform a linear transformation to obtain the spatial features E' of POIs. p and the weather features in the nth sliding window
[0020] E′ p =E p W′ p +b p (3)
[0021]
[0022] In equations (3) and (4), W' p W' w b p b w There are four parameters to be learned;
[0023] Step 2.2.3, the external feature fusion layer calculates E' p , The feature similarity between the stations is calculated, and the feature similarity is mapped to the 0-1 interval using equation (5) to obtain the similarity value S between the stations in the nth sliding window. n :
[0024]
[0025] Step 2.2.4, the external feature fusion layer uses equations (6) and (7) to process E p and Perform a linear transformation to obtain the updated POIs features F. p and updated weather features
[0026] F p =S n (E p W″ p +b′ p (6)
[0027]
[0028] In equations (6) and (7), b' p ,b' w These are two bias parameters to be learned; W″ p , W″ w These are two weight parameters to be learned;
[0029] Step 2.2.5, the external feature fusion layer uses equation (8) to obtain the stitched feature F within the nth sliding window. n And use equation (8) to analyze the spliced feature F n Perform the transformation to obtain the transformed concatenated feature F' n :
[0030]
[0031] F' n =σ(F n )⊙tanh(F n (9)
[0032] In equations (8) and (9), tanh represents the activation function, σ represents the Sigmoid activation function, Concat() represents the concatenation operation, and ⊙ represents the dot product operation.
[0033] Step 2.3, the local feature fusion layer includes: a group attention module and a group convolutional layer; wherein, the group attention layer is divided into a random group attention layer and a fixed group attention layer:
[0034] Step 2.3.1, the random grouping attention layer uses equation (10) to analyze the features H of shared bicycle stations within the t-th time interval under the nth sliding window. n,t The features are shuffled and then grouped again to obtain the grouped features of shared bicycle stations.
[0035]
[0036] In equation (10), Shuffle represents the shuffling operation, and Split represents the grouping operation. This represents the feature of the k-th group station within the t-th time interval under the n-th sliding window, where u represents the total number of groups;
[0037] Step 2.3.2: The random grouping attention layer uses equation (11) to identify the relationship between the features of the i-th grouping site within the t-th time interval under the n-th sliding window, and obtains the updated features of the i-th grouping site within the t-th time interval under the n-th sliding window. Where z = N / u represents the number of shared bicycle stations in each group; This represents the updated features of shared bicycle station j in the k-th group during the t-th time interval under the n-th sliding window;
[0038] Step 2.3.3, the random grouping attention layer uses equation (13) to... After rearranging to restore the original positions, residual connection and normalization are performed to obtain the updated feature H' within the t-th time interval under the n-th sliding window. n,t :
[0039]
[0040] In equation (13), Reshuffle represents the operation of restoring the order before shuffling, and Reshuffle and Shuffle are opposite operations. BatchNorm represents batch normalization.
[0041] Step 2.3.4, the random grouping attention layer uses equation (14) to obtain the station features H″ within the t-th time interval under the n-th sliding window. t,n :
[0042] H″ n,t =BatchNorm(FFN(H' n,t )+H n,t (14)
[0043] In equation (14), FFN represents a feedforward neural network; + represents a residual connection;
[0044] Step 2.3.5, the fixed group attention layer uses equations (15)-(17) to apply H″ n,t The local fusion features within the t-th time interval are obtained through processing.
[0045] Step 2.4, processing of the grouped convolutional layers;
[0046] Step 2.4.1, the grouped convolutional layer uses equation (18) to obtain the convolutional features within the t-th time interval.
[0047]
[0048] In equation (18), * 2d Θ represents a 2D convolution operation, and Θ represents the convolution parameters;
[0049] Step 2.4.2, the grouped convolutional layer uses equation (19) to obtain the spliced site features F within the t-th time interval. all,t :
[0050]
[0051] Step 2.4.3, the grouped convolutional layer uses equation (20) to calculate the dynamic adjacency matrix A in the t-th time interval. d,t :
[0052]
[0053] In equation (20), F represents all,t The transpose of ; * indicates the convolution operation;
[0054] Step 2.4.4, the grouped convolutional layer uses equation (21) to obtain the final adjacency matrix in the t-th time interval.
[0055]
[0056] Step 2.5, processing of the adaptive feature layer;
[0057] Step 2.5.1, the adaptive feature layer uses equation (22) to obtain the updated shared bicycle station features F within the t-th time interval. c,t :
[0058] F c,t =Θ* 2d Maxpooling(Θ* 2d F all,t ) (twenty two)
[0059] In equation (22), Maxpooling represents the max pooling operation. 2d Θ represents 2D convolution, and Θ represents the convolution parameters;
[0060] Step 2.5.2, the adaptive feature layer uses equation (23) to obtain the updated shared bicycle station features F' within the t-th time interval. c,t :
[0061]
[0062] In equation (23), ⊙ represents dot product, and W1 and W2 represent the parameters to be learned; express Transpose of;
[0063] Step 2.6, the output layer uses equation (24) to obtain the dimensionality-reduced shared bicycle station features O in the t-th time interval. t And this will be used as the output of the model:
[0064] O t =FFN(F all,t +F' c,t ) (twenty four)
[0065] In equation (24), FFN represents a feedforward neural network;
[0066] Step 2.7: Using the mean squared error (MSE) as the loss function, and with the goal of minimizing the loss function, the parameters in the spatiotemporal graph attention network are optimized and updated through the time backpropagation algorithm until z > Z, thus stopping the training. This yields a trained spatiotemporal graph attention network model, which is used to predict the number of shared bicycles entering and leaving the station in future time periods.
[0067] The data-driven adaptive shared bicycle prediction method described in this invention is also characterized in that step 2.3.2 includes the following steps:
[0068] Step 2.3.2.1: Calculate the attention score between the k-th group of shared bicycle stations i and j in the t-th time interval under the n-th sliding window using equation (11). This yields the attention score matrix between sites.
[0069]
[0070] In equation (12), H represents the feature of the k-th group site. n,t,k The characteristics of shared bicycle station j in China, where a is the parameter to be learned. TThis indicates a rank transformation operation on 'a', LeakyReLU is a non-linear activation function, W represents the parameters to be learned, and || denotes the concatenation operation. z represents the set of sites in the k-th group within the t-th time interval under the n-th sliding window; z represents the total number of shared single sites;
[0071] Step 2.3.2.2: Use equation (12) to obtain the node features updated at the t-th time interval under the nth sliding window.
[0072]
[0073] In equation (12), This represents the updated features of the k-th group within the t-th time interval under the n-th sliding window.
[0074] Step 2.3.5 includes the following steps:
[0075] Step 2.3.5.1: The fixed group attention layer uses equation (15) to analyze the features H″ of shared bicycle stations within the t-th time interval under the nth sliding window. n,t Grouping the shared bicycle stations yields the characteristics of each group.
[0076]
[0077] In equation (15), split means grouping. This represents the feature of the k-th group station within the t-th time interval under the n-th sliding window, where u represents the total number of groups;
[0078] Step 2.3.5.2: The fixed group attention layer uses equation (16) to identify the connections between sites within the group, and obtains the node features updated using the attention mechanism.
[0079]
[0080] In equation (16), This represents the updated features of the shared bicycle stations in the k-th group within the t-th time interval under the n-th sliding window; + indicates residual connection; BatchNorm indicates batch normalization; Attention indicates the attention mechanism.
[0081] Step 2.3.5.3: The fixed local feature fusion layer uses equation (16) to obtain the updated local fusion features in the t-th time interval. And output to the grouped convolutional layer:
[0082]
[0083] In equation (17), FFN represents a feedforward neural network and BatchNorm represents batch normalization.
[0084] The present invention provides an electronic device, including a memory and a processor, wherein the memory is used to store a program that supports the processor in executing any of the adaptive shared bicycle prediction methods, and the processor is configured to execute the program stored in the memory.
[0085] The present invention discloses a computer-readable storage medium on which a computer program is stored, wherein the computer program, when executed by a processor, performs any of the steps of the adaptive shared bicycle prediction method.
[0086] Compared with the prior art, the beneficial effects of the present invention are as follows:
[0087] 1. This invention considers the entry and exit data of all shared bicycle stations in the city, historical weather data, and POIs data of each station, and proposes a dynamic adjacency matrix. This dynamic adjacency matrix can better reflect the connection relationship between stations in different time periods. Combined with the static adjacency matrix, it can more realistically depict the connection relationship between stations and improve the prediction accuracy of the model.
[0088] 2. This invention uses a grouped attention mechanism to capture the spatial relationships between local stations. By using random and fixed block partitioning, the location of the stations can be ignored, thus extracting the spatial relationships between stations more fully. Grouped convolution identifies historical time data of local stations through dilated convolution, and then an adaptive graph neural network is used to dynamically extract global temporal and spatial features. The use of grouped attention mechanism and grouped convolution can extract local spatial and temporal information more fully, thereby improving the prediction accuracy of the model.
[0089] 3. The local feature fusion layer of this invention uses a grouped attention mechanism, which significantly reduces the model parameters of the attention layer without compromising prediction accuracy. Simultaneously, by using grouped convolution to identify historical time data of local stations, this method reduces model training time compared to other time series information extraction methods, thus enabling its application to large-scale shared bicycle station prediction without causing parameter explosion.
[0090] 4. The adaptive feature layer of this invention integrates weather, external features of POIs, and historical features of shared single-station points. By using a multi-source data fusion method, it can make full use of multi-source information, thereby helping to improve the prediction effect. Attached Figure Description
[0091] Figure 1 This is a network structure diagram of the present invention;
[0092] Figure 2 This is an unfolded diagram of the local feature fusion layer of the present invention;
[0093] Figure 3 This is an unfolded view of the external feature fusion layer of the present invention;
[0094] Figure 4 This is a flowchart illustrating the overall process of the present invention. Detailed Implementation
[0095] In this embodiment, a data-driven adaptive shared bicycle prediction method comprehensively considers multi-source data, including vehicle interaction data between shared bicycle stations, historical data of individual stations, weather data, and POIs data. Historical weather data and POIs data can capture the impact of external features on the bicycle system; a local attention mechanism captures the spatial relationships between local stations in the shared bicycle system; a grouped convolutional layer captures the historical changes of individual shared stations; an adaptive feature layer extracts station features from both temporal and spatial dimensions; and finally, a convolutional layer compresses the output to output the number of vehicles entering and exiting each station, thereby predicting the number of shared bicycles at each station within a certain future time interval. Specifically, as... Figure 4 As shown, the prediction steps are as follows:
[0096] Step 1: Obtain and preprocess data on vehicles entering and leaving all shared bicycle stations:
[0097] Step 1.1: Obtain the riding records of shared bicycles, and each riding record includes: initial station, ending station, start time, and end time; obtain historical weather feature records; obtain the POIs spatial features of each shared bicycle station.
[0098] Step 1.2: Construct a graph structure dataset G based on the predicted time intervals, where the graph structure data for the t-th time interval is denoted as G. t =(V t A t H t ,F t V t Let A represent the set of shared bicycle stations for the t-th time interval. t Let A represent the adjacency matrix between shared bicycle stations during the t-th time interval. If, during the t-th time interval, there is a bicycle riding record from shared bicycle station i to shared bicycle station j, then let A... t The element a in the i-th row and j-th column ij The value is 1; otherwise, a ij The value is 0; H tRepresents the characteristics of all shared bicycle stations within the t-th time interval, where, Let represent the characteristics of shared bicycle station j within the t-th time interval, including: the number of shared bicycles entering station j and the number of shared bicycles leaving station j; Let Let represent the historical weather characteristics within the t-th time interval; Represents the POIs (Points of Interest) characteristics of all shared bicycle stations; N w The number of weather features is represented by N, and the number of shared bicycle stations is represented by N. p This indicates the number of POIs. The shared bike system data used in this example comes from the Chicago Divvy shared bike system. From January 1, 2022 to May 1, 2023, the Divvy system had a total of 5,545,597 ride records. The system has N = 440 shared bike stations, where t = 1 hour is used as a time interval. w =11 includes 11 weather characteristics such as rainfall, humidity, temperature, and UV index, N p =30 includes the 30 nearest functional buildings near shared bicycle stations.
[0099] Step 1.3: Set the width of the sliding window to T, and use the sliding window to partition the graph structure dataset G into sample sets D = {(X1,Y1),(X2,Y2),...,(X...}. n ,Y n ),...,(X N ,Y N )}, where (X n ,Y n X represents the nth sample. n Let X represent the historical data of the nth sliding window, and let X be... n ={G n,1 G n,2 ,...,G n,t ,...,G n,T}, G n,t Y represents the graph structure data of the t-th time interval in the historical data of the n-th sliding window. n X represents the historical data of the nth sliding window. n The predicted number of vehicles entering and exiting all shared bicycle stations within the (n+1)th time interval; Let This represents the historical weather characteristics of all time intervals within the nth sliding window, and F n,tThis represents the historical weather characteristics of the t-th time interval within the n-th sliding window; in this embodiment, T=8 indicates that the number of shared bicycles entering and leaving the station on the ninth day is predicted using relevant data from shared bicycle stations at the same time interval eight days prior to the prediction period. 70% of the dataset is used for training, 20% for validating the model, and 10% for testing the model.
[0100] Step 2, as follows Figure 1 As shown, a spatiotemporal graph neural network is constructed, including: an external feature fusion layer, a local feature fusion layer, an adaptive feature layer, and an output layer; wherein, the external feature fusion layer includes a feature embedding layer and a feature fusion layer; the local feature fusion layer includes a local attention layer and a grouped convolutional layer; the specific steps of the model are as follows:
[0101] Step 2.1: Define the current iteration number as z and initialize z = 1; define the iteration threshold as Z; initialize the parameters in the neural network; in this example, define the maximum threshold as Z = 200.
[0102] Step 2.2, as follows Figure 3 As shown, the processing of the external feature fusion layer;
[0103] Step 2.2.1, the feature embedding layer uses equations (1) and (2) to embed POIs features P and historical weather features. Spatial embedding is performed to obtain the spatial features of the embedded POIs. Weather spatial features embedded in the nth sliding window
[0104] E p =PW p (1)
[0105]
[0106] In equations (1) and (2), Let N represent two parameters to be learned. e This represents the dimension of the embedding; in this example, the dimension N of the feature embedding is... e =20;
[0107] Step 2.2.2, the feature fusion layer uses equations (3) and (4) to respectively process E p , Perform a linear transformation to obtain the spatial features E' of POIs. p and the weather features in the nth sliding window
[0108] E' p =E p W' p+b p (3)
[0109]
[0110] In equations (3) and (4), W' p W' w b p b w There are four parameters to be learned;
[0111] Step 2.2.3, the feature fusion layer calculates E' p , To prevent excessive parameter fluctuations from causing the model to fail to converge, feature similarity is mapped to the 0-1 interval using equation (5), thus obtaining the similarity value S between stations within the nth sliding window. n :
[0112]
[0113] Step 2.2.4, the feature fusion layer uses equations (6) and (7) to process E p and Perform feature updates to obtain the updated POIs features F p and updated weather features
[0114] F p =S n (E p W″ p +b′ p (6)
[0115]
[0116] In equations (6) and (7), W″ p , W″ w ,b' p ,b' w These are the parameters to be learned;
[0117] Step 2.2.5: The feature fusion layer uses equation (8) to obtain the concatenated feature F within the nth sliding window. n And use equation (8) to analyze the spliced feature F n Perform the transformation to obtain the transformed concatenated feature F' n :
[0118]
[0119] F' n =σ(F n )⊙tanh(F n(9)
[0120] In equations (8) and (9), tanh represents the activation function, σ represents the Sigmoid activation function, Concat() represents the concatenation operation, and ⊙ represents the dot product operation.
[0121] Step 2.3, the local feature fusion layer's processing borrows from patch-attention in Swim-Transformer. This invention further extends patch-attention by dividing it into random grouping attention and fixed grouping attention modules. The random grouping attention layer first randomly groups all sites, uses an attention mechanism to capture the relationships within each block, and then rearranges them. This operation can ignore the positions between sites and capture the connections between different sites. The fixed grouping attention layer does not randomly group sites; it directly groups them and then uses an attention mechanism to capture the relationships within each group. The above operations can ignore the positions between sites and capture the connections between different sites. The process is as follows: Figure 2 As shown below, the group attention module processes the data:
[0122] Step 2.3.1, the random grouping attention layer uses equation (10) to analyze the features H of shared bicycle stations within the t-th time interval under the nth sliding window. n,t The features are shuffled and then grouped again to obtain the grouped features of shared bicycle stations.
[0123]
[0124] In equation (10), shuffle represents the shuffling operation, and split represents the grouping operation. This represents the feature of the k-th group station within the t-th time interval under the n-th sliding window, and u represents the total number of groups; in this example, the number of groups is set to u = 10.
[0125] Step 2.3.2: The random grouping attention layer uses equation (11) to identify the relationship between the features of the k-th grouped site within the t-th time interval under the n-th sliding window, and obtains the updated features of the k-th grouped site within the t-th time interval under the n-th sliding window. Where z = N / u represents the number of shared bike stations in each group; in this example, each group has z = 44 shared bike stations.
[0126] Step 2.3.2.1: Calculate the attention score between the k-th group of shared bicycle stations i and j in the t-th time interval under the n-th sliding window using equation (11). This yields the attention score matrix between sites.
[0127]
[0128] In equation (12), H represents the feature of the k-th group site. t,n,k The features of the j-th station are given, and a is a parameter to be learned. T This indicates a rank transformation operation on 'a', LeakyReLU is a non-linear activation function, W represents the parameters to be learned, and || denotes the concatenation operation. This represents the set of stations in the k-th group within the t-th time interval under the n-th sliding window;
[0129] Step 2.3.2.2: Use equation (12) to obtain the node features updated at the t-th time interval under the nth sliding window.
[0130]
[0131] In equation (12), This represents the updated features of the k-th group within the t-th time interval under the n-th sliding window;
[0132] Step 2.3.3: To ensure the location invariance of shared bicycle stations, the station features updated using the attention mechanism are... Rearrangement is performed to restore the original positions; at the same time, residual connections are performed to accelerate model convergence. The randomized grouped attention layer uses equation (13) to... After rearranging to restore the original positions, residual connection and normalization are performed to obtain the updated feature H' within the t-th time interval under the n-th sliding window. n,t :
[0133]
[0134] In equation (13), Reshuffle represents the operation of restoring the order before shuffling, and Reshuffle and Shuffle are opposite operations. BatchNorm represents batch normalization.
[0135] Step 2.3.4: Feature fusion is performed using a feedforward neural network, and residual connections are established to prevent the network from becoming too deep and causing gradient vanishing. The random grouping attention layer uses equation (14) to obtain the station features H″ within the t-th time interval under the n-th sliding window. n,t :
[0136] H″ n,t =BatchNorm(FFN(H' n,t)+H n,t (14)
[0137] In equation (14), FFN represents a feedforward neural network; + represents a residual connection;
[0138] Step 2.3.5, the local feature fusion layer uses equations (15)-(17) to process H″. n,t Processing is performed to obtain local fusion features.
[0139] Step 2.3.5.1: The local feature fusion layer uses equation (15) to perform a local feature fusion on the shared bicycle stations within the t-th time interval under the n-th sliding window. n,t Grouping, resulting in
[0140]
[0141] In equation (15), split represents grouping, where, Let v represent the feature of the kth group station within the t-th time interval under the nth sliding window, and v represent the total number of groups;
[0142] Step 2.3.5.2: The fixed group attention layer uses equation (16) to identify the connections between sites within the group, and obtains the node features updated using the attention mechanism.
[0143]
[0144] In equation (16), This represents the updated features of the shared bicycle stations in the k-th group within the t-th time interval under the n-th sliding window; + indicates residual connection; BatchNorm indicates batch normalization; Attention indicates the attention mechanism.
[0145] Step 2.3.5.3: The fixed local feature fusion layer uses equation (16) to obtain the updated local fusion features in the t-th time interval. And output it to the last layer:
[0146]
[0147] In equation (17), FFN represents a feedforward neural network, and BatchNorm represents batch normalization.
[0148] Step 2.4: The random grouping attention layer and the fixed grouping attention layer focus on capturing the spatial location relationships between shared bicycle stations. However, the historical traffic of a single station is also important for future predictions. Previous inventions mainly used TCN to identify the historical information of individual stations. However, due to the large number of shared bicycle stations in the shared bicycle system, this leads to a sharp increase in TCN model parameters and a slowdown in training speed. Therefore, this invention simplifies TCN by using grouped convolutions to replace the TCN model in capturing the historical information of stations, and the processing of the grouped convolutional layers;
[0149] Step 2.4.1: The grouped convolutional layers use equation (18) to obtain the convolutional features within the t-th time interval.
[0150]
[0151] In equation (18), * 2d Θ represents a 2D convolution operation, and Θ represents the convolution parameters;
[0152] Step 2.4.2: The grouped convolutional layer uses equation (19) to obtain the stitched site features F within the t-th time interval. all,t :
[0153]
[0154] Step 2.4.3: The grouped convolutional layer uses equation (20) to calculate the dynamic adjacency matrix A in the t-th time interval. d,t :
[0155]
[0156] In equation (20), Indicates F all,t Perform a transposition operation;
[0157] Step 2.4.4: Use equation (21) to obtain the final adjacency matrix in the t-th time interval by combining the dynamic adjacency matrix and the static adjacency matrix. This adjacency matrix contains both fixed connection information between stations and connection information captured through external features:
[0158]
[0159] Step 2.5, processing of the adaptive feature layer;
[0160] Step 2.5.1: The adaptive feature layer performs a convolution operation on the stitched site features using equation (22), and uses a max pooling layer to avoid over-averaging, to obtain the updated shared bicycle site features F in the t-th time interval. c,t :
[0161] F c,t =Θ* 2d Maxpooling(Θ* 2d F all,t ) (twenty two)
[0162] In equation (22), Maxpooling represents the max pooling operation. 2d Θ represents a 2D convolution operation, and Θ represents the convolution parameters;
[0163] Step 2.5.2, the adaptive feature layer uses equation (23) to obtain the updated shared bicycle station features F' within the t-th time interval. c,t ::
[0164]
[0165] In equation (23), ⊙ represents the dot product operation, and W1 and W2 represent the parameters to be learned. express The transpose operation;
[0166] Step 2.6: Since the final features of shared bicycle stations can only include the number of entries and the number of stations, a feedforward neural network is used to reduce the station features. The output layer uses equation (24) to obtain the dimensionality-reduced shared bicycle station features O in the t-th time interval. t And this will be used as the output of the model:
[0167] O t =FFN(F all,t +F' c,t ) (twenty four)
[0168] In equation (24), FFN represents a feedforward neural network;
[0169] Step 2.7: Using the mean squared error (MSE) as the loss function, and aiming to minimize the loss function, the parameters in the spatiotemporal graph attention network are optimized and updated using the time backpropagation algorithm until z > Z. Training ends, and a trained spatiotemporal graph attention network model is obtained. This model is then used to predict the number of shared bicycles entering and leaving the station in future time periods. The training and testing process is as follows: Figure 4 As shown.
[0170] In this embodiment, an electronic device includes a memory and a processor. The memory stores a program that supports the processor in executing the above-described method, and the processor is configured to execute the program stored in the memory.
[0171] In this embodiment, a computer-readable storage medium stores a computer program, which is executed by a processor to perform the steps of the above method.
[0172] This example uses the shared bicycle systems of two foreign cities for real-time prediction: the Capital Bike System in Washington, D.C., and the Divvy Bike System in Chicago. It compares the results with three machine learning methods—Hyper Flow (HA), Continuous Moving Average (HA_s), and Autoregressive Model of Differential Integrated Moving Average (ARIMA)—and six deep learning methods—TCN, BiLSTM, ConvLSTM, ASTGCN, LSGCN, and STAGNN. The experimental results are as follows:
[0173] Table 1: Comparison of Model Experiment Results
[0174]
[0175] As shown in Table 1, the Adaptive Shared Bike Prediction Method (ASTGCN) was tested on the Divvy and Capital datasets at three different time intervals: 20 min, 40 min, and 60 min. Overall, the experimental results of this invention show improvements in both MAE (Mean Absolute Error) and RMSE (Root Mean Square Error), demonstrating the effectiveness of the model in predicting the entry and exit of vehicles at actual shared bike stations.
Claims
1. A data-driven adaptive shared bicycle prediction method, characterized in that, Includes the following steps: Step 1: Obtain and preprocess data on vehicles entering and leaving all shared bicycle stations: Step 1.1: Obtain the riding records of shared bicycles, and each riding record includes: initial station, ending station, start time, and end time; obtain historical weather feature records; obtain the POIs spatial features of each shared bicycle station. Step 1.2: Construct a graph-structured dataset based on the predicted time intervals. G , among which, the t The graph structure data for each time interval is denoted as , Indicates the first t A set of shared bicycle stations for a time interval. Indicates the first t The adjacency matrix between shared bicycle stations within each time interval; t During these time intervals, if from the shared bicycle station i To the shared bicycle station j If there is a record of cycling, then... The Middle i Line number j Column elements The value is 1, otherwise, The value is 0; Indicates the first t Characteristics of all shared bicycle stations within a time interval; let This represents the historical weather characteristics within the t-th time interval; make Represents the POIs characteristics of all shared bicycle stations; where, The number of weather features. This indicates the number of shared bicycle stations. Indicates the number of features of POIs; Step 1.3: Set the width of the sliding window to T, and use the sliding window to view the graph structure dataset. G The samples are partitioned to obtain the sample set. ,in, This represents the nth sample. Let represent the historical data of the nth sliding window, and , This represents the historical data of the nth sliding window. t Graph structure data for each time interval, This represents the historical data of the nth sliding window. The predicted number of vehicles entering and exiting all shared bicycle stations within the (n+1)th time interval; Let This represents the historical weather characteristics of all time intervals within the nth sliding window, and ; In the nth sliding window, the first... t Historical weather characteristics over a time interval; Step 2: Construct a spatiotemporal graph neural network, including: an external feature fusion layer, a local feature fusion layer, an adaptive feature layer, and an output layer; wherein, the external feature fusion layer includes a feature embedding layer and a feature fusion layer; the local feature fusion layer includes a local attention layer and a grouped convolutional layer; Step 2.1: Define the current iteration number as z and initialize z = 1; define the iteration threshold as Z; initialize the parameters in the neural network; Step 2.2, processing of the external feature fusion layer; Step 2.2.1, the external feature embedding layer for POIs features and historical weather characteristics Spatial embedding is performed to obtain the spatial features of the embedded POIs. Weather spatial features embedded in the nth sliding window ; Step 2.2.2, the external feature fusion layer respectively... Perform a linear transformation to obtain the spatial features of POIs. and the n Weather features in a sliding window ; Step 2.2.3, the external feature fusion layer is calculated. , The feature similarity between them is calculated, and the feature similarity is mapped to the 0-1 interval to obtain the first... n Similarity values between sites within a sliding window ; Step 2.2.4, the external feature fusion layer is based on right and Perform a linear transformation to obtain the updated POIs features. and updated weather features ; Step 2.2.5, the external feature fusion layer is based on and Get the first n The spliced features within a sliding window and the spliced features Perform the transformation to obtain the transformed splicing features. ; Step 2.3, the local feature fusion layer includes: a group attention module and a group convolutional layer; wherein, the group attention layer is divided into a random group attention layer and a fixed group attention layer; Step 2.3.1, the random grouping attention layer on the nth sliding window... t Characteristics of shared bicycle stations within a time interval The features are shuffled and then grouped again to obtain the grouped features of shared bicycle stations. ;in, This indicates the nth sliding window. t Within the time interval, the first k Features of each group of sites; Step 2.3.2, the random grouping attention layer identifies the nth sliding window under the... t Within the time interval, the first i The relationship between the features of the grouped sites is obtained, and the nth sliding window is used to obtain the relationship between the features of the grouped sites. t The updated version within the time interval k Features of each group site ,in, z=N / u This indicates the number of shared bike stations within each group; Indicates the first n The first sliding window t The time interval is the first k Shared bike stations in each group j Updated features; Step 2.3.3, the random grouping attention layer pair After rearranging to restore the original positions, residual joins and normalization are performed to obtain the nth sliding window. t Features updated within a time interval ; Step 2.3.4, the random grouping attention layer obtains the nth sliding window under the nth... t Site characteristics within a time interval ; Step 2.3.5, the fixed group attention layer pair Processing is performed to obtain the first... t Local fusion features within a time interval ; Step 2.4, processing of the grouped convolutional layers; Step 2.4.1, the grouped convolutional layer obtains the first... t Features after convolution within each time interval ; Step 2.4.2, the grouped convolutional layer uses equation (19) to obtain the first... t Site features spliced within a time interval : (19) In equation (19), Indicates splicing; Step 2.4.3, the grouped convolutional layer calculates the first... t Dynamic adjacency matrix within a time interval and the t The final adjacency matrix within each time interval ; Step 2.5, processing of the adaptive feature layer; Step 2.5.1, the adaptive feature layer uses equation (22) to obtain the first... t Features of shared bicycle stations updated within a time interval : (22) In equation (22), This indicates a max pooling operation. Represents 2D convolution. Represents the convolution parameters; Step 2.5.2, the adaptive feature layer uses equation (23) to obtain the first... t Features of shared bicycle stations updated within a time interval : (23) In equation (23), This represents the dot product. Indicates the parameters to be learned; express Transpose of; Step 2.6, the output layer uses equation (24) to obtain the first... t Features of shared bicycle stations after dimensionality reduction within a time interval And this will be used as the output of the model: (24) In equation (24), This represents a feedforward neural network; Step 2.7: Using the mean squared error (MSE) as the loss function, and with the goal of minimizing the loss function, the parameters in the spatiotemporal graph attention network are optimized and updated through the time backpropagation algorithm until z > Z, thus stopping the training. This yields a trained spatiotemporal graph attention network model, which is used to predict the number of shared bicycles entering and leaving the station in future time periods.
2. The data-driven adaptive shared bicycle prediction method according to claim 1, characterized in that, Step 2.3.2 includes the following steps: Step 2.3.2.1: Calculate the nth sliding window using equation (11). t Within the time interval, the first k Grouped shared bicycle stations i and shared bicycle stations j Attention scores between This yields the attention score matrix between sites. : (11) In equation (12), Indicates the first k Features of each group site China shared bicycle stations j Features These are the parameters to be learned. Indicates to Perform a transpose operation. It is a non-linear activation function. Indicates the parameters to be learned. This indicates a splicing operation. This indicates the nth sliding window. t Within the time interval, the first k The set of sites in each group; z represents the total number of shared single sites; Step 2.3.2.2: Use equation (12) to obtain the nth sliding window. t Node features updated at time intervals : (12) In equation (12), This indicates the nth sliding window. t Within the time interval, the first k The updated features of each group.
3. The data-driven adaptive shared bicycle prediction method according to claim 1, characterized in that, Step 2.3.5 includes the following steps: Step 2.3.5.1: The fixed group attention layer uses equation (15) to apply the nth sliding window to the nth... t Characteristics of shared bicycle stations within a time interval Grouping the shared bicycle stations yields the characteristics of each group. : (15) In equation (15), Indicates grouping, This indicates the nth sliding window. t Within the time interval, the first k Features after grouping sites Indicates the total number of groups; Step 2.3.5.2: The fixed group attention layer uses equation (16) to identify the connections between sites within the group, and obtains the node features updated using the attention mechanism. : (16) In equation (16), This indicates the nth sliding window. t Within the time interval, the first k Features of the group's updated shared bicycle stations; Indicates residual connection; BatchNorm This indicates batch normalization processing; This represents the attention mechanism; Step 2.3.5.3: The fixed group attention layer uses equation (17) to obtain the first... t Updated local fusion features within a time interval And output to the grouped convolutional layer: (17) In equation (17), This represents a feedforward neural network. This indicates batch normalization processing.
4. An electronic device, comprising a memory and a processor, characterized in that, The memory is used to store a program that supports the processor in executing any of the adaptive shared bicycle prediction methods of claims 1-3, and the processor is configured to execute the program stored in the memory.
5. A computer-readable storage medium storing a computer program thereon, characterized in that, The computer program, when run by a processor, executes the steps of the adaptive shared bicycle prediction method according to any one of claims 1-3.
Citation Information
Patent Citations
Shared bicycle idle pile prediction method based on residual graph convolution
CN111461287A
Public transport passenger flow combination graph neural network prediction method based on multi-source data
CN114912669A