A method for predicting the passenger flow of long-sequence urban rail transit inbound stations based on the Informer model
By applying the Informer model in the prediction of passenger flow in urban rail transit inbound stations, combining data preprocessing and feature engineering, the shortcomings of traditional models in long-sequence data processing are solved, and higher prediction accuracy and stability are achieved.
Patent Information
- Application Number
- CN202410397879.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-03
- Publication Date
- 2025-03-18
- Estimated Expiration
- 2044-04-03
AI Technical Summary
When processing long-sequence passenger flow data of urban rail transit incoming stations, the traditional machine learning-based time series prediction model has poor adaptability, weak feature extraction ability, and low computing efficiency, resulting in low prediction accuracy.
The long-sequence urban rail transit passenger flow situation prediction method based on the Informer model is adopted, and the model parameters are optimized to improve the prediction accuracy through data preprocessing, feature engineering, feature importance analysis and Informer model construction.
It effectively improves the accuracy and stability of passenger flow forecasts in urban rail transit inbound stations, can better adapt to long sequence data, and improve the generalization ability and computing efficiency of the model.
Smart Images

Figure CN118350658B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of traffic prediction, and in particular relates to a method for predicting the situation of long-sequence urban rail transit inbound passenger flow based on an Informer model. Background Art
[0002] With the acceleration of urbanization, urban rail transit plays an increasingly important role in people's travel. Accurately predicting the passenger flow trend of urban rail transit is of great significance to ensure passenger travel safety, optimize the allocation of transportation resources, and improve operational efficiency. However, traditional machine learning-based time series prediction models such as autoregressive model (AR), moving average model (MA) and deep learning-based neural network models such as long short-term memory network (LSTM), gated recurrent unit (GRU) and other passenger flow prediction methods have poor adaptability to data when processing long sequence data, weak feature extraction ability, low computational efficiency, etc., resulting in low prediction accuracy. Therefore, how to accurately predict the passenger flow trend of long-sequence urban rail transit has become an urgent problem to be solved.
[0003] Informer is a model based on the self-attention mechanism. It uses a multi-scale time encoder and decoder to consider information on different time scales at the same time. It uses an adaptive length attention mechanism to automatically adjust the attention range according to the sequence length, so as to better extract features in the sequence. It uses a gated convolution unit to reduce the number of parameters and the amount of calculation in the model, and improve the computational efficiency of the model. Compared with the Transformer model, the Informer model uses long-range dependency modeling and local self-attention mechanism to perform better on long sequence data. The improved probabilistic sparse multi-head attention mechanism can better control the sparsity of attention weights, improve the generalization ability of the model, and reduce the computational cost, and improve the training and reasoning efficiency of the model. Therefore, the Informer model can better adapt to the long sequence prediction problem of time series data. However, there are few studies that apply the Informer model to the field of urban rail transit station passenger flow situation prediction. Summary of the invention
[0004] Purpose of the invention: In order to overcome the shortcomings of the prior art, the Informer model is applied to the prediction of the passenger flow situation of urban rail transit entering the station, and a long-sequence urban rail transit entering the station passenger flow situation prediction method based on the Informer model is provided, which can effectively improve the prediction accuracy and stability.
[0005] Technical solution: To achieve the above purpose, the present invention provides a method for predicting the passenger flow situation of long-sequence urban rail transit inbound stations based on the Informer model, comprising the following steps:
[0006] S1: Collect historical passenger flow data and weather data, pre-process the raw data, and establish an initial data set;
[0007] S2: Perform data feature engineering:
[0008] Analyze historical inbound passenger flow data, weather, date characteristics and other data, extract date characteristics, weather characteristics, segmented passenger flow characteristics, and typical passenger flow characteristics for long-sequence inbound passenger flow prediction, add the extracted features to the initial data set, establish a feature-containing data set, and divide it into a feature analysis data set and a prediction data set;
[0009] S3: Feature Importance Analysis:
[0010] According to the feature analysis data set, the importance index of the features is analyzed based on the Random Forest model, and a feature screening formula is proposed and used to select the features with high importance to reconstruct the prediction data set, and the reconstructed data set is divided into a training set, a validation set, and a data set to be predicted;
[0011] S4: Construct a long-sequence passenger flow situation prediction model based on the Informer model and programming technology;
[0012] S5: Input the training data set into the constructed long-sequence inbound passenger flow prediction model for training, conduct parameter optimization experiments, and obtain the best prediction model with the best parameters;
[0013] S6: Input the inbound passenger flow data set to be predicted into the optimal prediction model to obtain the inbound passenger flow situation prediction result in the future period.
[0014] Furthermore, in step S1, data preprocessing is performed: the historical passenger flow data is cleaned, including missing values, duplicate values and outlier processing. Programming technology is used to automatically remove duplicates, outliers and missing values are identified by visualizing data distribution, and the mean, median and other technologies are used to fill or correct them to obtain the initial data set.
[0015] Furthermore, the data feature engineering in step S2:
[0016] Extract date features. Date features reflect the impact of dates on passenger flow, such as which day of the week it is, whether it is a holiday, whether it is a working day, or whether it is a winter or summer vacation.
[0017] Extract weather characteristics. Among the external characteristics that affect urban rail transit passenger flow, weather is an important influencing factor. No rainfall, rainfall, and special weather are divided into characteristic values.
[0018] Extract segmented passenger flow characteristics and predict inbound passenger flow. The segmented passenger flow characteristics are mainly manifested in the morning and evening peak passenger flow characteristics. The dates that conform to the morning and evening peak rules are divided into morning peak, evening peak, and off-peak time period characteristics. In order to further distinguish the morning and evening peak passenger flow rising periods, peak periods, falling periods, and off-peak periods, the passenger flow change rate can be used as another characteristic value of the segmented passenger flow characteristics. The calculation of the passenger flow change rate is usually based on the passenger flow data in adjacent time periods. For example, if you want to calculate the passenger flow change rate from time period t1 to time period t2, you need to first find the passenger flow difference ΔQ between the two time periods. The passenger flow change rate can be expressed by dividing the passenger flow difference by the passenger flow in time period t1 and multiplying it by 100% to convert it into a percentage:
[0019]
[0020] Where Q t1 and Q t2 are the passenger flows in time periods t1 and t2 respectively.
[0021] Extract typical passenger flow characteristics, plot the incoming passenger flow data into a line graph according to a certain time granularity, and analyze the periodic changes in the distribution of incoming passenger flow; make a comparison chart of the historical incoming passenger flow distribution, and select the historical characteristic daily passenger flow data with a higher degree of passenger flow distribution overlap as the matching historical characteristic day passenger flow data, so as to calculate the historical characteristic daily average incoming passenger flow as the typical passenger flow characteristic value.
[0022] The calculation formula for the average daily passenger flow entering the station based on historical characteristics is:
[0023]
[0024] Among them C i is the passenger flow entering the station at the current time of the matching feature day selected from the historical passenger flow, and m is the actual number obtained.
[0025] Add the features extracted in the above steps to the initial data set to create a data set containing features.
[0026] Furthermore, in the feature importance analysis in step S3, the features are analyzed by a random forest model, which is composed of multiple decision trees. During the training process, each decision tree will randomly sample the data set and the features. The importance score of each feature in the random forest is calculated based on the Gini Importance, which is calculated by measuring the average reduced impurity of each feature at the node used as the splitting criterion in the decision tree in the random forest. Gini impurity is an indicator of the sample purity in the node, and Gini importance measures the contribution of each feature to reducing the node impurity. The specific calculation formula is as follows:
[0027]
[0028]
[0029] where X is the feature whose importance is to be evaluated, T is the number of trees in the random forest, Samples(t) is the number of samples used in the t-th tree, Gini(t) is the Gini index of the t-th tree, C is the number of classes, and p(i|t) is the proportion of samples belonging to class i in node t.
[0030] Before the data set is input into the random forest model, the day of the week, whether it is a weekday or a holiday, whether it is a winter or summer vacation, weather characteristics, and morning and evening peak characteristics are uniquely encoded, and the average passenger flow on the historical characteristic day and the actual passenger flow are normalized.
[0031] The feature screening formula is used to select features with high importance. The calculation formula for the i-th feature screening result R(i) is as follows:
[0032] R(i)=F(G i ,G max ×k)
[0033] Among them, G i is the Gini importance of the ith feature, G max It is the feature with the largest Gini importance in the feature set. F(x) is the screening function, which outputs the screening result based on the comparison of the two input parameters. k is the feature screening parameter with a value between [0,1]. The k value is determined according to the model training results.
[0034] Furthermore, in step S4, a long-sequence passenger flow situation prediction model is constructed based on the Informer model and programming technology, including position encoding of time features, construction of model components such as attention mechanism, encoder, decoder, and setting of model initial parameters. The specific steps are as follows:
[0035] A1: Program to construct position coding, provide absolute position information about time features, and capture the periodicity of time. Perform absolute position coding on time features and calculate the sine and cosine codes of time features. The absolute position coding formula is as follows:
[0036]
[0037]
[0038] where timestamps is the hour, day, or month portion of a timestamp and period is the length of the period of the corresponding time unit, such as the number of hours in a day, the number of days in a month, or the number of months in a year.
[0039] A2: Programmatically construct the probabilistic sparse multi-head attention mechanism (Muti-headProbSparseSelf-attention) of the Informer model to capture the dependencies between different positions in the sequence. Specifically, the Informer model probabilistically selects key positions to calculate the attention weights through the probabilistic sparse self-attention mechanism, thereby reducing the computational complexity. Specifically, given the query matrix Q, key matrix K, and value matrix V, the classic self-attention mechanism formula is as follows:
[0040]
[0041] Based on the classic self-attention mechanism formula, assuming that q i , k i , v i The attention of the i-th query matrix Q can be defined as:
[0042]
[0043] The time complexity of calculating this probability is quadratic. If p(kj|qi) is close to uniform distribution, then its probability distribution should be:
[0044]
[0045] Use KL divergence to calculate the relative entropy of the attention probability distribution of Q and the probability distribution of uniform distribution. The sparsity measurement formula of the i-th Q is:
[0046]
[0047] If the M value of the i-th Q is large, it means that its attention probability p is more different from other parts, and the more likely it is the important part. Based on the above measurement method, the probability sparse self-attention calculation method can be expressed as:
[0048]
[0049] where Q' is the sparsified matrix of Q.
[0050] Then, set the parameters of the attention mechanism, including whether to use a mask, sampling factor, scaling factor, and dropout ratio in the attention mechanism. Whether to use a mask determines whether the time order in the sequence data needs to be considered. The sampling factor controls the sparsity of the sparse attention mechanism. The scaling factor controls the range of the output. Adjusting the scale can help the model better learn the appropriate attention weights. The dropout ratio is used to control the discard rate when calculating the attention weights to reduce overfitting.
[0051] A3: Program to build the Informer model. The Informer model mainly consists of two parts: the encoder and the decoder. The input sequence is input into the encoder, and the connected feature graph is generated as the hidden representation of the encoder through the probabilistic sparse multi-head attention module and the self-attention distillation module. Then, the long sequence with zero filled target elements is input into the decoder to generate the prediction result.
[0052] Specifically, when designing the encoder, the Informer model uses the self-attention distillation mechanism to halve the single-level features in the time dimension, making the encoder more efficient when processing long sequence inputs. The feature map output by the probabilistic sparse self-attention has redundant combinations of the value matrix V, which will cause some repeated information in the model when learning. Therefore, the distillation operation is used to give higher weights to the dominant features with dominant attention, and generate a focused self-attention feature map in the next layer. The process of the self-attention distillation operation from layer j to layer j+1 is as follows:
[0053]
[0054] Among them, [X] AB It represents the attention block. It contains multi-head ProbSparse self-attention and basic operations, where Conv1d() performs 1-D convolution on the time dimension and uses the ELU activation function. After stacking one layer, add the maximum pooling layer MaxPool() and convert X t Downsample to its half slice, thus reducing the overall memory usage. Then concatenate the outputs of all stacks to obtain the feature map of the encoder.
[0055] When designing the decoder, the Informer model uses batch generation prediction to directly output multi-step prediction results through a single forward calculation. The decoder input vector is:
[0056]
[0057] in, is the start tag, is a placeholder for the target sequence (set the scalar to 0). Sample a length L in the input sequence token The sequence X tokenAs the starting mark, this sequence is the slice before the output sequence, which is connected with the target sequence and input into the Decoder. There are two layers inside the Decoder. The first layer is to perform masked multi-head probable sparse self-attention calculation (Masked Multi-head ProbSparse Self-attention) on the input of the Decoder. Masked multi-head attention is to set the mask dot product to -∞ to prevent each position from paying attention to the subsequent position, thereby avoiding autoregression. The second layer performs a multi-head attention calculation (Multi-headAttention) on the result calculated by the first layer and the feature map output by the Encoder. Finally, a fully connected layer (Full Connected Layer) is used to obtain the final output.
[0058] A4: Set the initial parameters of the model.
[0059] Furthermore, the step S5 predictive model training: determining the length of the prediction sequence. The strategy for adjusting the model hyperparameters is as follows:
[0060] B1: Adjust the hyperparameters related to model capacity and complexity, including the hidden layer dimension of the model, the number of heads in the multi-head attention mechanism, the number of encoder layers, the number of decoder layers, and the dimension of the feed-forward neural network. Increasing the values of these parameters can increase the capacity and expressiveness of the model, but may also increase the risk of overfitting. Therefore, the appropriate value is selected by the prediction indicator mean square error (MSE) on the experimental test set.
[0061] B2: Adjust the input sequence length of the encoder and the start tag sequence length and feature selection parameters of the decoder. Longer input sequences can capture longer-term temporal dependencies, but may also increase computational and memory requirements. Longer start tag sequences can provide more contextual information, which helps the decoder better understand the input sequence and generate accurate prediction sequences. But it will also increase computational and memory requirements. Therefore, the appropriate value is selected by balancing the prediction indicator mean square error (MSE) on the experimental test set and the time spent on the prediction task. By adjusting the feature screening parameters, features are dynamically selected and appropriate values are selected based on the model training results.
[0062] B3: Adjust the probability of overfitting strategy Dropout. Increasing dropout can reduce the risk of overfitting, but may reduce the performance of the model. Choose an appropriate value by experimentally checking whether the loss function on the training set, validation set, and test set converges and comparing the error gap.
[0063] B4: Adjust the learning rate of the model, because the choice of learning rate is affected by other hyperparameters. This embodiment adopts an exponential learning rate decay adaptive learning rate method. The learning speed of the model is controlled by reducing the size of the learning rate after each training batch (epoch). The learning rate lr calculation formula is as follows:
[0064] lr=lr0×decay_factor t
[0065] Where lr0 is the initial learning rate, decay_factor is the decay factor, and t is the current epoch.
[0066] Select the appropriate attenuation factor by observing the performance of the model on the training set and the validation set. If the model is overfitted on the training set (good performance on the training set but poor performance on the validation set), the attenuation factor can be appropriately reduced; if the performance of the model on the training set and the validation set does not change much, the attenuation factor can be appropriately increased.
[0067] Furthermore, the prediction result output of step S6 is: applying the trained Informer model to the incoming passenger flow data to be predicted to obtain the prediction result of the incoming passenger flow situation in the future period of time.
[0068] The scheme of the present invention can be summarized as: historical data preprocessing, feature engineering analysis, feature importance evaluation, Informer model construction, parameter optimization and passenger flow prediction output. Through data processing and feature extraction, combined with the Informer model and parameter adjustment, the prediction of passenger flow entering the urban rail transit station is realized.
[0069] The present invention proposes a method for predicting the passenger flow situation of long-sequence urban rail transit inbound stations based on the Informer model. Through historical data preprocessing, feature engineering, feature importance analysis, Informer model construction and optimization training, accurate prediction of future inbound passenger flow is achieved. The probabilistic sparse multi-head attention mechanism and position encoding are used to improve the generalization ability and efficiency of the model. Through data cleaning, feature extraction, model construction and parameter optimization, the optimal model suitable for urban rail transit inbound passenger flow prediction is obtained, and accurate prediction of future inbound passenger flow situation is achieved.
[0070] Beneficial effects: Compared with the prior art, the present invention combines data processing, feature engineering and Informer model construction, effectively improving the accuracy and efficiency of urban rail transit inbound passenger flow prediction. Through feature importance analysis and model optimization, it can better capture the laws and trends in historical data and provide reliable predictions for future passenger flow trends. The probabilistic sparse multi-head attention mechanism and position encoding help the model better understand long sequence data and improve prediction accuracy. The method of the present invention can provide important decision-making support for urban transportation management departments, optimize transportation resource allocation, and enhance passenger travel experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0071] Figure 1 It is a model framework diagram of the present invention;
[0072] Figure 2 This is the distribution diagram of the passenger flow data entering the station in September 2023 at a time granularity of 60 minutes in this embodiment;
[0073] Figure 3 This is the distribution diagram of the passenger flow data entering the station in October 2023 at a time granularity of 60 minutes in this embodiment;
[0074] Figure 4 This is a comparison chart of the weekly passenger flow distribution in this embodiment excluding holidays;
[0075] Figure 5 A comparison chart is provided for the distribution of passenger flow entering the station on holidays every day in this embodiment;
[0076] Figure 6 This is the architecture diagram of the Informer model;
[0077] Figures 7 to 9 The passenger flow prediction results of the RF+Informer model on weekdays, weekends, and holidays are shown in the figure;
[0078] Figures 10-12 The passenger flow prediction results of the RF+Informer model without classic features on weekdays, weekends, and holidays;
[0079] Figures 13-15 The following are the passenger flow prediction results of the RF+Informer model without segmentation features on weekdays, weekends, and holidays. DETAILED DESCRIPTION
[0080] The present invention is further explained below in conjunction with the accompanying drawings and specific embodiments. It should be understood that these embodiments are only used to illustrate the present invention and are not used to limit the scope of the present invention. After reading the present invention, various equivalent forms of modifications to the present invention by those skilled in the art all fall within the scope defined by the claims attached to this application.
[0081] The present invention provides a method for predicting the passenger flow of long-sequence urban rail transit inbound stations based on an Informer model. In this embodiment, the method of the present invention is applied to predicting the passenger flow of long-sequence urban rail transit inbound stations. The model framework is as follows: Figure 1 As shown, it specifically includes the following steps:
[0082] S1: Collect historical passenger flow data and weather data, pre-process the raw data, and establish an initial data set;
[0083] In this embodiment, the passenger flow data of a subway station from May to October 2023 extracted by the AFC system of a certain city subway is cleaned, including the processing of missing values, duplicate values and outliers. Programming technology is used for automatic deduplication, outliers and missing values are identified by visualizing data distribution, and they are filled or corrected using techniques such as mean and median. The data structure of the initial data set after preprocessing (at a 60-minute granularity) is shown in Table 1, where date is the timestamp and actual_count is the cumulative passenger flow in the 60 minutes before the current moment.
[0084] Table 1 Data structure of initial dataset
[0085]
[0086] In addition, the historical weather conditions in Nanjing from May to October 2023 were obtained from the meteorological website, including data on weather, temperature, wind speed, whether there was precipitation, etc., in preparation for the subsequent extraction of weather characteristics.
[0087] S2: Perform data feature engineering, analyze historical inbound passenger flow data, weather, date characteristics and other data, extract date features, weather features, segmented passenger flow features, and typical passenger flow features for long-sequence inbound passenger flow forecasts, add the extracted features to the initial data set, and establish a data set containing features;
[0088] (1) Date characteristics
[0089] The date feature reflects the impact of the date on the passenger flow, such as the day of the week, whether it is a holiday, whether it is a working day, whether it is a winter or summer vacation. The date feature coding table extracted in this embodiment is shown in Table 2 below.
[0090] Table 2 Date feature coding table
[0091]
[0092] (2) Weather characteristics
[0093] Among the external characteristics that affect the passenger flow of urban rail transit, weather is an important influencing factor. In this embodiment, no rainfall, rainfall, and special weather (rainstorm, heavy fog, etc.) are divided into characteristic values. The weather characteristic coding table is shown in Table 3 below.
[0094] Table 3 Weather characteristics coding table
[0095]
[0096] (3) Passenger flow characteristics by segment
[0097] The segmented passenger flow characteristics of the incoming passenger flow forecast are mainly manifested in the morning and evening peak passenger flow characteristics. The segmented passenger flow characteristics feature coding table is shown in Table 4.
[0098] Table 4. Feature coding table of segmented passenger flow characteristics
[0099]
[0100] In order to further distinguish the rising period, peak period, falling period and flat period of passenger flow in the morning and evening peaks, the passenger flow change rate can be used as another characteristic value of the segmented passenger flow characteristics. The calculation of the passenger flow change rate is usually based on the passenger flow data in adjacent time periods. For example, if you want to calculate the passenger flow change rate from time period t1 to time period t2, you need to first find the passenger flow difference ΔQ between the two time periods. The passenger flow change rate can be converted into a percentage by dividing the passenger flow difference by the passenger flow in time period t1 and multiplying it by 100%:
[0101]
[0102] Where Q t1 and Q t2 are the passenger flows in time periods t1 and t2 respectively.
[0103] (4) Typical passenger flow characteristics
[0104] This paper extracts typical passenger flow features as the feature values of the prediction task, and takes the historical characteristic daily average passenger flow as the typical passenger flow feature. In this embodiment, the passenger flow data for September and October 2023 are plotted into a line graph at a time granularity of 60 minutes, as shown in Figure 2 , Figure 3 As shown in the figure, the distribution of passenger flow entering the station has a daily change pattern, and there are morning and evening peak patterns. Considering the difference between the passenger flow distribution on weekdays and weekends, this embodiment chooses a weekly change pattern, but it is affected by holidays. The weekly passenger flow distribution excluding holidays is compared, as shown in the figure. Figure 4 . The analysis of the figure shows that the weekly passenger flow distribution overlaps a lot. Then compare the daily passenger flow distribution during holidays, such as Figure 5. From the analysis of the figure, it can be seen that the distribution of daily passenger flow entering the station during holidays has similar changing patterns, which has a certain reference value. Therefore, this embodiment extracts the features of historical passenger flow data, and uses Monday to Sunday (non-holidays) and holidays to calculate the average passenger flow entering the station on historical characteristic days as the feature value of the prediction task. The historical characteristic days select the first three matching characteristic days. For example, if you predict this Monday (non-holidays), then select the last three Mondays (non-holidays). To predict October 6 (holiday), select October 2 to 4 (holidays), and do not select October 5. This is because the prediction task of this embodiment is to predict the distribution of passenger flow entering the station for the next day at a granularity of 60 minutes. Therefore, when calculating the average passenger flow entering the station on a historical typical day, only the passenger flow data 24 hours before the prediction start time can be used. The calculation formula for the average passenger flow entering the station on a historical characteristic day is as follows:
[0105]
[0106] Among them C i is the passenger flow entering the station at the current time of the matching feature day selected from the historical passenger flow, and m is the actual number obtained.
[0107] The extracted date features, weather features, segmented passenger flow features, and typical passenger flow features are added to the initial data set to generate a feature-containing data set. The data set structure is shown in Table 5.
[0108] Table 5 contains the structure of the feature dataset
[0109]
[0110] S3: Feature importance analysis: Based on the Random Forest model, the importance index of the features obtained in S2 is analyzed, and the prediction data set is reconstructed by fusing the features with high importance using the screening formula. The reconstructed prediction data set is divided into a training set, a validation set, and a data set to be predicted;
[0111] This embodiment analyzes the features by constructing a random forest model, which consists of multiple decision trees. During the training process, each decision tree will perform random feature sampling on the data set. The importance score of each feature in the random forest is calculated using the Gini Importance, which is calculated by measuring the average reduced impurity of each feature at the node used as the splitting criterion in the decision tree in the random forest. Gini impurity is an indicator of sample purity in a node, and Gini importance measures the contribution of each feature to reducing node impurity. The specific calculation formula is as follows:
[0112]
[0113]
[0114] where X is the feature whose importance is to be evaluated, T is the number of trees in the random forest, Samples(t) is the number of samples used in the t-th tree, Gini(t) is the Gini index of the t-th tree, C is the number of classes, and p(i|t) is the proportion of samples belonging to class i in node t.
[0115] Before the data set is input into the random forest model, the day of the week, whether it is a weekday or a holiday, whether it is a winter or summer vacation, weather characteristics, and morning and evening peak characteristics are uniquely encoded, and the average passenger flow on the historical characteristic day and the actual passenger flow are normalized.
[0116] In this embodiment, the feature vector obtained in step S2 is calculated by this method to obtain the importance matrix G of all features in the data set = {G1, ...G m}, then the screening result formula of the i-th feature is as follows:
[0117] R(i)=F(G i ,G max ×k)
[0118] Among them, G i is the Gini importance of the ith feature, G max It is the feature with the largest Gini importance in the feature set. F(x) is the screening function, which outputs the screening result based on the comparison of the two input parameters. k is the feature screening parameter with a value between [0,1]. The k value is determined according to the model training results.
[0119] S4: Build a long-sequence passenger flow prediction model based on the Informer model and programming technology, perform position encoding on time features, build model components such as attention mechanism, encoder, decoder, and set the initial parameters of the model;
[0120] The specific steps to build the model are as follows:
[0121] A1: Programming to construct position coding, provide absolute position information about time features, and capture the periodicity of time. This embodiment performs absolute position coding on time features, calculates the sine code and cosine code of the time features, and the absolute position coding formula is as follows:
[0122]
[0123]
[0124] where timestamps is the hour, day, or month portion of a timestamp and period is the length of the period of the corresponding time unit, such as the number of hours in a day, the number of days in a month, or the number of months in a year.
[0125] A2: Program the probabilistic sparse multi-head attention mechanism (Muti-headProbSparse Self-attention) of the Informer model to capture the dependencies between different positions in the sequence. Set the parameters of the attention mechanism, including whether to use a mask, sampling factor, scaling factor, and dropout ratio in the attention mechanism. Whether to use a mask determines whether the time order in the sequence data needs to be considered. The sampling factor controls the sparsity of the sparse attention mechanism, and the scaling factor controls the range of the output. Adjusting the scale can help the model better learn the appropriate attention weights. The dropout ratio is used to control the discard rate when calculating the attention weights to reduce overfitting. This embodiment sets the initial values of the attention mechanism parameters as shown in Table 6.
[0126] Table 6 Attention mechanism parameters
[0127]
[0128]
[0129] A3: Programming to build the Informer model. The Informer model architecture is shown in the figure below. Figure 6 The Informer model mainly consists of two parts: the encoder and the decoder. The input sequence is input into the encoder, and the connected feature graph is generated as the hidden representation of the encoder through the probabilistic sparse multi-head attention module and the self-attention distillation module. Then, the long sequence filled with zeros of the target elements is input into the decoder to generate the prediction result.
[0130] Specifically, in the design of the Encoder, the Informer model in this embodiment uses the self-attention distillation mechanism (Self-attention Distilling) to halve the single-level features in the time dimension, thereby making the Encoder more efficient when processing long sequence inputs. The feature map output by the probabilistic sparse self-attention has redundant combinations of the value matrix V, which will cause some repeated information in the model when learning. Therefore, the distillation operation is used to give higher weights to the dominant features with dominant attention, and generate a focused self-attention feature map in the next layer. The process of the self-attention distillation operation from layer j to layer j+1 is as follows:
[0131]
[0132] Among them, [X] ABIt represents the attention block. It contains multi-head ProbSparse self-attention and basic operations, where Conv1d() performs 1-D convolution on the time dimension and uses the ELU activation function. After stacking one layer, add the maximum pooling layer MaxPool() and convert X t Downsample to its half slice, thus reducing the overall memory usage. Then concatenate the outputs of all stacks to obtain the feature map of the encoder.
[0133] When designing the decoder, the Informer model uses batch generation prediction to directly output multi-step prediction results through a single forward calculation. The decoder input vector is:
[0134]
[0135] in, is the start tag, is a placeholder for the target sequence (set the scalar to 0). Sample a length L in the input sequence token The sequence X token As the starting mark, this sequence is the slice before the output sequence, which is connected with the target sequence and input into the Decoder. There are two layers inside the Decoder. The first layer performs masked multi-head probable sparse self-attention calculation (Masked Multi-headProbSparse Self-attention) on the input of the Decoder. Masked multi-head attention is to set the mask dot product to -∞ to prevent each position from paying attention to the subsequent position, thereby avoiding autoregression. The second layer performs a multi-head attention calculation (Multi-headAttention) on the result calculated by the first layer and the feature map output by the Encoder. Finally, a fully connected layer (Full Connected Layer) is used to obtain the final output.
[0136] A4: Set the initial parameters of the model. In this embodiment, the initial parameters are set as shown in Table 7.
[0137] Table 7 Initial parameter table
[0138]
[0139] S5: input the training data set obtained in step S3 into the long sequence inbound passenger flow prediction model constructed in step S4, select parameters for comparative experiments, optimize the prediction performance, and obtain a relatively optimal prediction model;
[0140] This example uses a training data set with a time granularity of 60 minutes to predict the passenger flow in the next day, so the length of the prediction sequence is 17 (daily operating hours 6:00 to 23:00). The strategy for adjusting the model hyperparameters is as follows:
[0141] First, adjust the hyperparameters related to model capacity and complexity, the hidden layer dimension of the model, the number of heads in the multi-head attention mechanism, the number of layers of the encoder, the number of layers of the decoder, and the dimension of the feed-forward neural network. Increasing the values of these parameters can increase the capacity and expressiveness of the model, but may also increase the risk of overfitting. Therefore, the appropriate value is selected by the prediction indicator mean square error (MSE) on the experimental test set. The parameters selected in this embodiment are shown in Table 8 below.
[0142] Table 8 Model capacity and complexity parameters
[0143]
[0144]
[0145] Then, adjust the input sequence length of the encoder and the start tag sequence length of the decoder. A longer input sequence can capture longer-term time dependencies, but it may also increase computing and memory requirements. A longer start tag sequence can provide more contextual information, which helps the decoder to better understand the input sequence and generate accurate prediction sequences. But it will also increase computing and memory requirements. Therefore, the appropriate value is selected by balancing the prediction indicator mean square error (MSE) on the experimental test set and the time spent on the prediction task. By adjusting the feature screening parameters, features are dynamically selected, and appropriate values are selected according to the model training results. The parameters selected in this embodiment are shown in Table 9 below.
[0146] Table 9 Codec parameter table
[0147]
[0148] Next, adjust the probability of overfitting strategy Dropout. Increasing dropout can reduce the risk of overfitting, but may reduce the performance of the model. Select the appropriate value by testing whether the loss function on the training set, validation set, and test set converges and comparing the error gap. The parameters selected in this embodiment are shown in Table 10 below.
[0149] Table 10 Overfitting parameters
[0150]
[0151] Finally, adjust the learning rate of the model, because the choice of learning rate is affected by other hyperparameters. This embodiment adopts an exponential learning rate decay adaptive learning rate method. It controls the learning speed of the model by reducing the size of the learning rate after each epoch of training. The learning rate lr calculation formula is as follows:
[0152] lr=lr0×decay_factor t
[0153] Where lr0 is the initial learning rate, decay_factor is the decay factor, and t is the current epoch.
[0154] The appropriate attenuation factor is selected by observing the performance of the model on the training set and the validation set. If the model is overfitted on the training set (the performance of the training set is good but the performance of the validation set is poor), the attenuation factor can be appropriately reduced; if the performance of the model on the training set and the validation set does not change much, the attenuation factor can be appropriately increased. The parameters selected in this embodiment are shown in Table 11.
[0155] Table 11 Learning rate parameter table
[0156]
[0157] S6: Input the inbound passenger flow data set to be predicted obtained in step S3 into the relatively optimal prediction model obtained in step S5 to obtain the inbound passenger flow situation prediction result in the future period of time.
[0158] This example first conducts a comparative experiment on the prediction of short-term inbound passenger flow between the model of the present invention (RF+Informer) and the baseline models Informer and Transformer, and analyzes the experimental results. The experimental results will show the prediction performance of different models on different date types, and evaluate the prediction accuracy of the model by comparing the mean absolute error (MAE), root mean square error (RMSE), and mean percentage error (MAPE) indicators. Then, ablation experiments are conducted on the two features of typical passenger flow and segmented passenger flow, and the experimental results are analyzed to verify the effectiveness of typical passenger flow features and segmented passenger flow features in the prediction of short-term inbound passenger flow based on the RF+Informer combined model.
[0159] (1) Performance comparison between RF+Informer model and baseline model
[0160] In this experiment, RF+Informer is compared with the baseline models Transformer and Informer. The experiment predicts the passenger flow of the next day on three different date types: weekdays, weekends, and holidays. The prediction results of passenger flow on weekdays, weekends, and holidays are as follows: Figure 7 , Figure 8 , Fig. 9 The prediction result evaluation index table is shown in Table 12.
[0161] Table 12 Evaluation index table of Informer model and baseline model
[0162]
[0163] First, the experimental results show that the prediction performance of the RF+Informer model is better than that of the baseline model in all three types of dates (weekdays, weekends, and holidays). Specifically, in the weekday scenario, the MAE (mean absolute error) of the RF+Informer model is 47.49, which is significantly lower than the 227.50 of the Transformer model and the 65.83 of the Informer model; the RMSE (root mean square error) and MAPE (mean percentage error) also show a similar downward trend, decreasing to 55.91 and 15.16% respectively, indicating that the RF+Informer model has higher accuracy in predicting passenger flow on weekdays.
[0164] In the weekend scenario, the RF+Informer model also showed superior performance. Its MAE was 56.71, which was significantly improved compared with 235.72 of the Transformer model and 92.07 of the Informer model. The RMSE and MAPE were also reduced to 73.59 and 18.73% respectively, indicating that the RF+Informer model has better stability in dealing with weekend passenger flow fluctuations.
[0165] In holiday scenarios, although the prediction errors of all models increased, the RF+Informer model still performed best. Its MAE was 126.86, lower than the 258.34 of the Transformer model and the 145.76 of the Informer model; the RMSE and MAPE were also relatively low, at 162.45 and 23.62% respectively, showing the superiority of the RF+Informer model in dealing with the significant changes in passenger flow during holidays.
[0166] (2) Validation of typical passenger flow characteristics
[0167] In order to verify the effectiveness of typical passenger flow features in predicting the passenger flow situation of long-sequence inbound stations, an ablation experiment was conducted to compare the prediction performance of the model with and without typical passenger flow features. The passenger flow prediction results on weekdays, weekends, and holidays without typical passenger flow features are shown in the figure below. Fig.10 , Fig.11 , Fig.12 The evaluation index table for verifying the prediction results of typical passenger flow characteristics is shown in Table 13.
[0168] Table 13 Evaluation index table of RF+Informer typical passenger flow characteristics experimental results
[0169]
[0170] From the data in the table, we can see that after adding the classic passenger flow features, the prediction performance of the model on the three date types has improved. Specifically, on weekdays, MAE decreased by about 14.4%, RMSE decreased by about 25.1%, and MAPE decreased by about 17.9%; on weekends, MAE decreased by about 26.7%, RMSE decreased by about 9.8%, and MAPE decreased by about 10.9%; on holidays, MAE decreased by about 12.2%, RMSE decreased by about 5.4%, and MAPE decreased by about 7.4%. These results show that classic passenger flow features play an important role in improving the prediction performance of the model.
[0171] (3) Validation of segmented passenger flow characteristics
[0172] In order to verify the effectiveness of segmented passenger flow features in predicting the passenger flow situation of long-sequence inbound stations, an ablation experiment was conducted to compare the prediction performance of the model with and without segmented passenger flow features. The passenger flow prediction results on weekdays, weekends, and holidays without segmented passenger flow features are shown in the figure below. Fig.13 , Fig.14 , Fig.15 The evaluation index table for verifying the segmented passenger flow feature prediction results is shown in Table 14.
[0173] Table 14 Evaluation index table of RF+Informer segmented passenger flow feature prediction results
[0174]
[0175]
[0176] After adding segmented passenger flow features to the model, the prediction performance of the model is improved. On weekdays, after adding segmented passenger flow features, the MAE, RMSE and MAPE values of the model decreased by 4.15, 2.63 and 1.77 percentage points respectively. On weekends, the MAE and RMSE values of the model decreased by 3.26 and 1.95 respectively, while the MAPE value decreased by 0.27 percentage points. On holidays, the performance of the model improved most significantly, with MAE, RMSE and MAPE values decreasing by 16.24, 10.61 and 2.83 percentage points respectively. The experimental results show that segmented passenger flow features can improve the prediction accuracy of the model. By dividing the passenger flow data within a day into different time periods and considering the passenger flow change rules in different time periods, the segmented passenger flow features enable the model to better understand and simulate the dynamic changes of passenger flow.
[0177] In summary, the long-sequence inbound passenger flow situation prediction method based on the RF+Informer combined model proposed in the present invention effectively integrates multiple features and combines the feature selection ability of random forest and the long-sequence processing ability of the Informer model to achieve accurate prediction of the station passenger flow situation. This method has important application value in subway station passenger flow management, operation scheduling and passenger flow planning.
[0178] This embodiment also provides a long-sequence urban rail transit inbound passenger flow situation prediction system based on the Informer model, the system includes a network interface, a memory and a processor; wherein the network interface is used to realize the reception and transmission of signals in the process of sending and receiving information between other external network elements; the memory is used to store computer program instructions that can be run on the processor; the processor is used to execute the steps of the above-mentioned consensus method when running the computer program instructions.
[0179] The present embodiment also provides a computer storage medium, which stores a computer program, and the method described above can be implemented when the processor executes the computer program. The computer readable medium can be considered to be tangible and non-temporary. Non-limiting examples of non-temporary tangible computer-readable media include non-volatile memory circuits (such as flash memory circuits, erasable programmable read-only memory circuits or mask read-only memory circuits), volatile memory circuits (such as static random access memory circuits or dynamic random access memory circuits), magnetic storage media (such as analog or digital tapes or hard drives) and optical storage media (such as CDs, DVDs or Blu-ray discs), etc. The computer program includes processor executable instructions stored on at least one non-temporary tangible computer-readable medium. The computer program may also include or rely on stored data. The computer program may include a basic input / output system (BIOS) that interacts with the hardware of a special-purpose computer, a device driver that interacts with a specific device of a special-purpose computer, one or more operating systems, user applications, background services, background applications, etc.
[0180] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0181] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0182] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0183] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
Claims
1. A method for predicting the passenger flow situation of long-sequence urban rail transit inbound stations based on the Informer model, characterized in that: The steps include: S1: Collect historical passenger flow data and weather data, pre-process the raw data, and establish an initial data set; S2: Perform data feature engineering: Analyze the historical inbound passenger flow data, weather, and date characteristic data, extract the date characteristics, weather characteristics, segmented passenger flow characteristics, and typical passenger flow characteristics for long-sequence inbound passenger flow prediction, add the extracted features to the initial data set, establish a feature-containing data set, and divide it into a feature analysis data set and a prediction data set; S3: Perform feature importance analysis: Based on the random forest model, the importance index of features is analyzed, and a feature screening formula is proposed and used to select features with high importance to reconstruct the prediction data set, and the reconstructed data set is divided into a training set, a validation set, and a data set to be predicted. S4: Construct a long-sequence passenger flow situation prediction model based on the Informer model and programming technology; S5: Input the training set and the validation set into the constructed long-sequence inbound passenger flow prediction model for training, conduct parameter optimization experiments, and obtain the best prediction model with the best parameters; S6: input the data set to be predicted into the optimal prediction model to obtain the prediction result of the passenger flow situation in the future; In step S3, the feature importance analysis is performed on the features using the random forest model. The importance score of each feature in the random forest is calculated by using the Gini importance-based calculation method. The Gini importance of the feature X to be evaluated is calculated as follows: Where T is the number of trees in the random forest, Samples(t) is the number of samples used in the t-th tree, Gini(t) is the Gini index of the t-th tree, C is the number of categories, and p(i|t) is the proportion of samples belonging to category i in node t. The feature screening formula is used to select features with high importance. The calculation formula for the i-th feature screening result R(i) is as follows: R(i)=F(G i ,G max ×k) Among them, G i is the Gini importance of the ith feature, G max It is the feature with the largest Gini importance in the feature set. F() is a screening function that outputs the screening result based on the size of the two input parameters. k is a feature screening parameter with a value between [0,1]. The k value is determined according to the model training results. In step S5, the training data set is input into the long sequence inbound passenger flow prediction model, and the strategy of adjusting the model parameters is adopted to optimize the prediction performance and obtain a relatively optimal prediction model; The strategy for adjusting model parameters is as follows: B1: For hyperparameters related to model capacity and complexity, including hidden layer dimension, number of heads in the multi-head attention mechanism, number of encoder layers, number of decoder layers, and dimension of the feedforward neural network, appropriate values are selected through the mean square error of the prediction indicator on the experimental test set; B2: For the input sequence length of the encoder and the starting tag sequence length of the decoder, select appropriate values by balancing the prediction indicator MSE and the prediction task time consumption to capture time dependency and provide sufficient context information; adjust the input sequence length of the encoder, the starting tag sequence length of the decoder and the feature selection parameter k; dynamically select features by adjusting the feature screening parameter k, and select appropriate values according to the model training results; B3: Adjust the probability of Dropout in the overfitting strategy to reduce the risk of overfitting while maintaining model performance. Select the appropriate value by comparing the loss function and error on the training set, validation set, and test set. B4: Adjust the learning rate of the model and use an adaptive learning rate method with exponential decay to reduce the learning rate after each training batch to control the learning speed of the model.
2. According to claim 1, a method for predicting the long-sequence urban rail transit passenger flow based on the Informer model is characterized in that: The data preprocessing in step S1 includes cleaning the historical inbound passenger flow data, using programming technology to automatically remove duplicates, identifying abnormal values and missing values through visualizing data distribution, and filling or correcting them.
3. According to claim 1, a method for predicting the long-sequence urban rail transit passenger flow based on the Informer model is characterized in that: In the step S2, the data feature engineering analyzes date characteristics and extracts date characteristics of days of the week, holidays, working days, and summer and winter vacations; analyzes weather influencing factors and divides no rainfall, rainfall, and special weather into weather characteristics; analyzes morning and evening peak characteristics and divides dates that conform to the morning and evening peak rules into morning peak, evening peak, and flat peak time period characteristics, and further extracts the trend characteristics of passenger flow change rate to reflect passenger flow changes as segmented passenger flow characteristics; The cyclical change law of the passenger flow distribution in the station is analyzed by drawing a line graph, and the passenger flow distribution comparison chart method is used to match the historical characteristic days to calculate the average passenger flow in the station on the historical characteristic days as the typical passenger flow characteristic value. The calculation formula is as follows: Among them, C i is the passenger flow entering the station at the current time of the matching feature day selected from the historical passenger flow, and m is the actual number obtained.
4. According to claim 1, a method for predicting the long-sequence urban rail transit passenger flow based on the Informer model is characterized in that: In step S4, a long-sequence passenger flow situation prediction model is constructed based on the Informer model and programming technology, including constructing position encoding, attention mechanism, integrating various components of the model, and setting initial parameters of the model; The specific steps of constructing the long-sequence passenger flow situation prediction model in step S4 are as follows: A1: Program to construct position coding, provide absolute position information about time features, and capture the periodicity of time; perform absolute position coding on time features and calculate the sine and cosine codes of time features. The formula is as follows: Among them, timestamps is the hour, day or month part of the timestamp, and period is the period length of the corresponding time unit; A2: Program the probabilistic sparse multi-head attention mechanism of the Informer model to capture the dependencies between different positions in the sequence and set the parameters of the attention mechanism; A3: Program the encoder and decoder of the Informer model. Input the input sequence into the encoder, generate a connected feature map as the hidden representation of the encoder through the probabilistic sparse multi-head attention module and the self-attention distillation module, and then input the long sequence with the target element padded to zero into the decoder to generate the prediction result. A4: Set the initial parameters of the model; In step A3, the decoder generates the prediction result as follows: Using batch generation prediction, multi-step prediction results are directly output through a forward calculation; the input vector of the decoder is: in, is the start tag, is a placeholder for the target sequence; a length of L is sampled in the input sequence token The sequence X token As the starting mark, this sequence is the slice before the output sequence, which is connected with the target sequence and input into the Decoder; there are two layers inside the Decoder. The first layer performs masked multi-head probabilistic sparse self-attention calculation on the input of the Decoder. Masked multi-head attention sets the masked dot product to -∞ to prevent each position from paying attention to the subsequent positions, thereby avoiding autoregression; the second layer performs a multi-head attention calculation on the result calculated by the first layer and the feature map output by the Encoder, and finally obtains the final output through a fully connected layer.
5. According to claim 4, a method for predicting the long-sequence urban rail transit passenger flow based on the Informer model is characterized in that: The operation of the self-attention distillation module of the encoder in step A3 and the encoder feature map generation process are as follows: The distillation operation is used to give higher weights to the dominant features with dominant attention, and generate a focused self-attention feature map in the next layer; the process of the self-attention distillation operation from layer j to layer j+1 is as follows: Among them, [X] AB represents the attention block, which contains multi-head ProbSparse self-attention and basic operations, where Conv1d() performs 1-D convolution on the time dimension and uses the ELU activation function; after stacking one layer, add the maximum pooling layer MaxPool() and convert X t Downsample to its half slice, thereby reducing the overall memory usage, and then concatenate the outputs of all stacks to obtain the feature map of the encoder.
Citation Information
Patent Citations
Urban rail transit short-time passenger flow prediction method based on recurrent neural network
CN113902011A
Networked data prediction method based on causal Transform
CN116777068A
Rail transit passenger flow prediction method based on improved LSTM network
CN117252311A
Random forest-based fruit string picking characteristic factor analysis method and device
CN117493856A
Vehicle lane changing trajectory prediction method based on random forest and improved Informer model
CN117807413A