Passenger flow prediction method and device
By comprehensively analyzing historical and future passenger flow, weather and holiday data, extracting multiple characteristics and analyzing them, the traditional passenger flow prediction method has solved the shortcomings in accuracy and timeliness, and a more accurate future passenger flow prediction is achieved.
Patent Information
- Application Number
- CN202510266238.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-06
- Publication Date
- 2025-06-24
AI Technical Summary
Traditional passenger flow prediction methods are difficult to achieve the required prediction accuracy and timeliness when processing complex and changeable tourism data, especially when considering a variety of factors that affect passenger flow.
By obtaining passenger flow timing data, weather status data and holiday status data in historical and future time periods, the feature extraction module is used to determine trend, seasonal and periodic characteristics, and combined with weather and holiday characteristics, the decoder module is used to analyze to obtain future passenger flow forecast data.
Accurate prediction of future passenger flow is achieved, prediction accuracy and timeliness are improved, and the prediction results are inaccurate due to the single passenger flow data element being considered.
Smart Images

Figure CN120197752A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of big data processing, and in particular, to a passenger flow prediction method and device. Background Art
[0002] In the management field of some public areas, accurately predicting the passenger flow in the area is crucial for optimizing resource allocation, improving the tourist experience, and ensuring public safety. However, traditional passenger flow prediction methods face many challenges. Especially when dealing with complex and changeable tourism data, it is difficult to achieve the required prediction accuracy and timeliness. In the prediction scenario, the passenger flow is affected by multiple factors. However, since traditional statistical analysis methods are difficult to simultaneously consider and quantify the influence of these complex factors on the passenger flow, they often only consider the influence of a single factor, which results in limited generalization ability of the prediction model. In addition, traditional prediction models are difficult to capture the internal laws of these time series. Especially in the case of large amounts of data and complex non-linear relationships, the deviation of the prediction results will increase significantly.
[0003] For the above problems, no effective solution has been proposed yet. Summary of the Invention
[0004] Embodiments of this application provide a passenger flow prediction method and device to at least solve the technical problem that the prediction result is inaccurate due to considering a single passenger flow data element in the relevant passenger flow analysis and prediction scenario.
[0005] According to one aspect of the embodiments of this application, a passenger flow prediction method is provided, including: obtaining first passenger flow time series data, first weather state data, and first holiday state data in a first historical time period, and obtaining second weather state data and second holiday state data in a first future time period; using a feature extraction module in a passenger flow prediction model to determine a first trend feature sequence, a first seasonal feature sequence, and a first periodic feature matrix based on a preset period corresponding to the first passenger flow time series data, determining a first weather feature sequence corresponding to the first weather state data and the second weather state data, and determining a first holiday feature sequence corresponding to the first holiday state data and the second holiday state data; using a decoder module in the passenger flow prediction model to analyze the first trend feature sequence, the first seasonal feature sequence, the first periodic feature matrix, the first weather feature sequence, and the first holiday feature sequence to obtain passenger flow prediction data in the first future time period.
[0006] Optionally, the first passenger flow time series data includes the daily passenger flow data within the first historical time period; the first weather condition data includes the daily weather condition data within the first historical time period; the first holiday status data includes the status indication data of whether each day within the first historical time period is a holiday; the second weather condition data includes the daily weather condition data within the first future time period; the second holiday status data includes the status indication data of whether each day within the first future time period is a holiday.
[0007] Optionally, use the feature extraction module in the passenger flow prediction model to determine the first trend feature sequence, the first seasonal feature sequence, and the first periodic feature matrix based on a preset period corresponding to the first passenger flow time series data, including: use the moving average method to smooth the first passenger flow time series data to obtain the first trend passenger flow data; determine the difference between the first passenger flow time series data and the first trend passenger flow data as the first seasonal passenger flow data; use a linear network to encode the first trend passenger flow data and the first seasonal passenger flow data respectively to obtain the first trend feature sequence and the first seasonal feature sequence; encode and segmentally reorganize the first passenger flow time series data based on the preset period to obtain the first periodic feature matrix.
[0008] Optionally, use the moving average method to smooth the first passenger flow time series data to obtain the first trend passenger flow data, including: for each passenger flow data in the first passenger flow time series data, determine the average value of all passenger flow data within a preset length of time window including the passenger flow data as the passenger flow trend data corresponding to the passenger flow data; form the first trend passenger flow data by arranging the passenger flow trend data corresponding to all passenger flow data in time series.
[0009] Optionally, encode and segmentally reorganize the first passenger flow time series data based on the preset period to obtain the first periodic feature matrix, including: perform point convolution mapping encoding on each passenger flow data in the first passenger flow time series data to obtain the first encoding result; use one week as the preset period, split and reorganize the first encoding result to obtain the second periodic feature matrix, where each row in the second periodic feature matrix corresponds to the encoding result of the passenger flow data for one week; perform a transpose operation on the second periodic feature matrix to obtain the first periodic feature matrix.
[0010] Optionally, determining a first weather feature sequence corresponding to the first weather state data and the second weather state data, and determining a first holiday feature sequence corresponding to the first holiday state data and the second holiday state data includes: performing one-hot encoding on each weather state data in the first weather state data and the second weather state data respectively to obtain a second encoding result, and analyzing the second encoding result by using a long short-term memory network to obtain the first weather feature sequence; performing one-hot encoding on each status indication data in the first holiday state data and the second holiday state data respectively to obtain a third encoding result, and analyzing the third encoding result by using a long short-term memory network to obtain the first holiday feature sequence.
[0011] Optionally, the training process of the passenger flow prediction model includes: constructing an initial model, where the initial model at least includes a feature extraction module and a decoder module; obtaining second passenger flow time series data, third weather state data, and third holiday state data within a plurality of second historical time periods, and obtaining third passenger flow time series data, fourth weather state data, and fourth holiday state data within a third historical time period after each second historical time period; using the second passenger flow time series data, third weather state data, third holiday state data within each second historical time period, and the fourth weather state data and fourth holiday state data within the corresponding third historical time period as a training sample, and using the third passenger flow time series data within the corresponding third historical time period as the sample label of the training sample; dividing the obtained multiple training samples and sample labels into a training set and a validation set; iteratively training the initial model by using the training set, and validating the trained model by using the validation set when each training batch is completed, and when a preset termination condition is satisfied, using the trained model as the passenger flow prediction model.
[0012] According to another aspect of the embodiments of the present application, there is also provided a passenger flow prediction device, including: a data acquisition module, configured to acquire first passenger flow time series data, first weather state data, and first holiday state data within a first historical time period, and acquire second weather state data and second holiday state data within a first future time period; a feature analysis module, configured to use the feature extraction module in the passenger flow prediction model to determine a first trend feature sequence, a first seasonal feature sequence, and a first periodic feature matrix based on a preset period corresponding to the first passenger flow time series data, determine a first weather feature sequence corresponding to the first weather state data and the second weather state data, and determine a first holiday feature sequence corresponding to the first holiday state data and the second holiday state data; a passenger flow prediction module, configured to use the decoder module in the passenger flow prediction model to analyze the first trend feature sequence, the first seasonal feature sequence, the first periodic feature matrix, the first weather feature sequence, and the first holiday feature sequence to obtain passenger flow prediction data within the first future time period.
[0013] According to another aspect of the embodiments of the present application, there is also provided a computer program product, which includes: a computer program, wherein when the computer program is executed by a processor, the above-mentioned passenger flow prediction method is implemented.
[0014] According to another aspect of the embodiments of the present application, there is also provided an electronic device, which includes: a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to execute the above-mentioned passenger flow prediction method through the computer program.
[0015] In the embodiments of the present application, by comprehensively analyzing historical passenger flow, weather conditions, and holiday information, as well as future weather conditions and holiday information, and quantitatively considering various factors, various information is converted into a feature sequence with time series characteristics, accurately capturing the internal laws of various influencing factors in the time series, so as to accurately predict the future passenger flow, effectively solving the technical problem of inaccurate prediction results caused by single consideration of passenger flow data elements in relevant passenger flow analysis and prediction scenarios. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments and descriptions thereof of the present application are used to explain the present application and do not constitute an improper limitation of the present application. In the drawings:
[0017] Figure 1 is a schematic flowchart of an optional passenger flow prediction method according to the embodiments of the present application;
[0018] Figure 2 is a schematic diagram of an optional moving average processing according to the embodiments of the present application;
[0019] Figure 3 is a flowchart of an optional extraction of a periodic feature matrix according to the embodiments of the present application;
[0020] Figure 4 is a schematic structural diagram of an optional passenger flow prediction device according to the embodiments of the present application;
[0021] Figure 5 is a schematic diagram of an electronic device for processing the passenger flow prediction method according to the embodiments of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0022] To enable those skilled in the art to better understand the solution of this application, the following will clearly and completely describe the technical solution in the embodiments of this application with reference to the accompanying drawings in the embodiments of this application. Obviously, the described embodiments are only a part of the embodiments of this application, rather than all the embodiments. Based on the embodiments in this application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of this application.
[0023] It should be noted that the terms "first", "second", etc. in the description, claims and drawings of this application are used to distinguish similar objects, and do not necessarily need to describe a specific order or sequence. It should be understood that such used data can be interchanged under appropriate circumstances so that the embodiments of this application described here can be implemented in an order other than those illustrated or described here. In addition, the terms "comprising" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device comprising a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products or devices.
[0024] To better understand the embodiments of this application, the following first translates and explains some nouns or terms that appear in the description process of the embodiments of this application:
[0025] Point convolutional coding: Point convolutional mapping coding is a deep learning technology used to extract local features from time-series data. It is implemented through point convolutional layers, which can adjust the weights between channels without changing the data features, thereby generating new feature representations, helping to improve the computational efficiency and feature learning ability of the model.
[0026] Patch recombination: Patching refers to dividing the original data (such as images, video frames, or geospatial data, etc.) into a series of sub-regions of a fixed size, which are called patches. After completing the feature extraction or analysis of the patches, these independent patches are recombined into a complete data representation to restore or maintain the context information of the original data.
[0027] One-hot encoding: It is a data preprocessing technology mainly used to convert categorical variables into numerical variables so that machine learning algorithms can understand and process them.
[0028] Transformer model: Its core lies in the self-attention mechanism, which enables the model to focus on the relationships between different positions in the input sequence without relying on the cyclic dependencies in traditional recurrent neural networks. It is suitable for processing any type of time-series data.
[0029] Example 1
[0030] According to an embodiment of the present application, a passenger flow prediction method is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. And although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in a different order than here.
[0031] Figure 1 is a schematic flowchart of an optional passenger flow prediction method provided according to an embodiment of the present application. As Figure 1 shown, the method at least includes steps S102 - S106, where:
[0032] Step S102, obtain the first passenger flow time series data, the first weather state data, and the first holiday state data within the first historical time period, and obtain the second weather state data and the second holiday state data within the first future time period.
[0033] Among them, the data corresponding to the first historical time period is the basis for passenger flow prediction. In order to analyze the internal characteristics such as the trend and season of the data, the duration of the first historical time period can be set slightly longer, such as half a year or one year. And the first future time period is usually the time period for which passenger flow prediction is required, and the specific duration can be set according to requirements, such as one week, and no specific limitation is made here.
[0034] Optionally, the above passenger flow, weather and other data can all be collected on a daily basis. Specifically, the first passenger flow time series data includes: the daily passenger flow data within the first historical time period; the first weather state data includes: the daily weather state data within the first historical time period; the first holiday state data includes: the state indication data of whether each day within the first historical time period is a holiday; the second weather state data includes: the daily weather state data within the first future time period; the second holiday state data includes: the state indication data of whether each day within the first future time period is a holiday.
[0035] Step S104, use the feature extraction module in the passenger flow prediction model to determine the first trend feature sequence, the first seasonal feature sequence, and the first periodic feature matrix based on a preset period corresponding to the first passenger flow time series data, and determine the first weather feature sequence corresponding to the first weather state data and the second weather state data, and determine the first holiday feature sequence corresponding to the first holiday state data and the second holiday state data.
[0036] Among them, the input of the feature extraction module in the passenger flow prediction model includes not only the passenger flow time series data, weather state data, and holiday state data in historical periods, but also the weather state data and holiday state data in future time periods. As an optional implementation manner, the trend feature and seasonal feature corresponding to the passenger flow time series data can be determined through the linear decomposition network in the feature extraction module, the periodic feature corresponding to the passenger flow time series data can be determined through patch recombination, and the weather feature and holiday feature corresponding to the relevant weather state data and holiday state data can be determined through time series analysis and one-hot encoding. These features are uniformly used for subsequent passenger flow prediction.
[0037] Step S106: Use the decoder module in the passenger flow prediction model to analyze the first trend feature sequence, the first seasonal feature sequence, the first periodic feature matrix, the first weather feature sequence, and the first holiday feature sequence to obtain the passenger flow prediction data in the first future time period.
[0038] In the technical solution provided in steps S102 - S106 of the present application, by comprehensively analyzing the historical passenger flow, weather state, and holiday information, as well as the future weather state and holiday information, and quantitatively considering various factors, various information is converted into feature sequences with time series characteristics, accurately capturing the internal laws of various influencing factors in the time series, so as to accurately predict the future passenger flow, effectively solving the technical problem of inaccurate prediction results caused by single consideration of passenger flow data elements in related passenger flow analysis and prediction scenarios.
[0039] The following explains each step of the passenger flow prediction method in combination with a specific implementation process.
[0040] In the technical solution provided in steps S102 - S106 of the present application, first, obtain the first passenger flow time series data, the first weather state data, the first holiday state data in the first historical time period, the second weather state data, and the second holiday state data in the first future time period as the input of the passenger flow prediction model; then, perform feature extraction on various data through the feature extraction module in the passenger flow prediction model to obtain the first feature sequences corresponding to various data; and then, perform decoding analysis on each first feature sequence through the decoder module in the passenger flow prediction model to obtain the passenger flow prediction data in the first future time period. It can be seen that the passenger flow prediction model is the key to the entire passenger flow prediction method. Therefore, training a mature and reliable passenger flow prediction model is of great significance to the accuracy of the final passenger flow prediction.
[0041] The embodiment of the present application provides an optional training scheme for the passenger flow prediction model, which specifically includes the following steps:
[0042] S1. Construct an initial model, where the initial model includes at least: a feature extraction module and a decoder module.
[0043] Among them, the feature extraction module is mainly used to determine the trend feature sequence, seasonal feature sequence, and periodic feature matrix corresponding to the passenger flow time series data, determine the weather feature sequence corresponding to the weather state data, and determine the holiday feature sequence corresponding to the holiday state data; while the decoder module is mainly used to analyze the trend feature sequence, seasonal feature sequence, periodic feature matrix, weather feature sequence, and holiday feature sequence to obtain the passenger flow prediction data for the future time period.
[0044] To achieve the above functions, the feature extraction module can adopt variants of convolutional neural networks or recurrent neural networks, such as long short-term memory networks or gated recurrent units, to process sequence data and capture time-dependent features; the decoder module can adopt the same type of recurrent neural network structure or use a more advanced Transformer model to handle long-term dependencies and relationships between sequences.
[0045] S2. Obtain the second passenger flow time series data, the third weather state data, and the third holiday state data within multiple second historical time periods, and obtain the third passenger flow time series data, the fourth weather state data, and the fourth holiday state data within the third historical time period after each second historical time period.
[0046] Among them, the above-mentioned second historical time period is usually the same as the duration of the first historical time period in the actual prediction stage, and the third historical time period is usually the same as the duration of the first future time period in the actual prediction stage. For example, if it is necessary to predict the passenger flow during the National Day holiday in a certain year, the third historical time period can be set to 7 days, and the corresponding second historical time period can be set to 1 year before these 7 days. Specifically, multiple sets of daily passenger flow, daily weather state, and daily holiday state with a duration of 1 year can be collected from multiple data sources such as the scenic spot ticketing system, entrance counters, weather stations, and public holiday calendars as the second passenger flow time series data, the third weather state data, and the third holiday state data corresponding to multiple second historical time periods; then for each second historical time period, obtain the daily passenger flow, daily weather state, and daily holiday state for 7 days after this second historical time period as the third passenger flow time series data, the fourth weather state data, and the fourth holiday state data within the corresponding third historical time period.
[0047] When actually obtaining data, it is necessary to consider issues such as whether there are missing values and outliers in data collection, and perform targeted data preprocessing operations to ensure the integrity and accuracy of the data.
[0048] S3. Take the second passenger flow time series data, the third weather state data, and the third holiday state data within each second historical time period, as well as the fourth weather state data and the fourth holiday state data within the corresponding third historical time period, as a training sample, and take the third passenger flow time series data within the corresponding third historical time period as the sample label of the training sample;
[0049] Still taking the relevant data collected in the example of step S2 as an example, when determining the training sample and the sample label, the passenger flow data, weather data, and holiday data for one year, as well as the weather data and holiday data for 7 days after one year, can be used as the training sample, and the passenger flow data for 7 days after one year can be used as the sample label of the training sample. These data are used for supervised learning during model training to enable the model to learn to predict future passenger flows from the input data.
[0050] S4. Divide the obtained multiple training samples and sample labels into a training set and a validation set;
[0051] Specifically, the constructed training samples and sample labels can be randomly divided into a training set and a validation set, and the ratio can be set to 80% (training set) and 20% (validation set). The training set is used for model learning, and the role of the validation set is to evaluate the model's prediction ability for new data, ensuring that the model not only performs well on the learned data but also can effectively process and predict data that did not appear during the training stage. This process helps prevent the model from overfitting to the characteristics of the training data, that is, to avoid overfitting.
[0052] S5. Use the training set to perform iterative training on the initial model, and use the validation set to verify the trained model at the end of each training batch. When the preset termination condition is met, use the trained model as the passenger flow prediction model.
[0053] Specifically, the preset termination conditions include the following situations: such as the prediction accuracy satisfied when the mean squared error is less than a certain threshold, the training round reaching the upper limit, and the model validation performance no longer improving, etc. When any termination condition is met, the training process ends, and the model at this time is the final passenger flow prediction model.
[0054] Through the steps S1 - S5 in the above embodiment, a passenger flow prediction model based on deep learning is constructed. The model can not only learn the passenger flow trends, seasonal and periodic characteristics from historical data but also comprehensively consider the influence of external factors such as weather and holidays on the passenger flow. Through a large amount of training data and strict model verification, the accuracy and generalization ability of the model are ensured, providing strong support for management and decision-making in the prediction scenario.
[0055] After obtaining a reliable passenger flow prediction model, it can be applied to real passenger flow prediction scenarios. The following describes the process of real passenger flow prediction in combination with the above steps S102-106.
[0056] As an alternative implementation, first perform step S102 to obtain the first passenger flow time series data, the first weather state data, and the first holiday state data within the first historical time period, and obtain the second weather state data and the second holiday state data within the first future time period.
[0057] Optionally, in the technical solution provided in step S104 of the present application, after obtaining the relevant data, the feature extraction module in the passenger flow prediction model can be used to determine the first trend feature sequence, the first seasonal feature sequence, and the first periodic feature matrix based on a preset period corresponding to the first passenger flow time series data.
[0058] Specifically, it can be achieved through the following steps: First, smooth the first passenger flow time series data using the moving average method to obtain the first trend passenger flow data; Second, determine the difference between the first passenger flow time series data and the first trend passenger flow data as the first seasonal passenger flow data; Then, use a linear network to encode the first trend passenger flow data and the first seasonal passenger flow data respectively to obtain the first trend feature sequence and the first seasonal feature sequence; Finally, encode and segmentally reorganize the first passenger flow time series data based on a preset period to obtain the first periodic feature matrix.
[0059] As an alternative implementation, when obtaining the first trend passenger flow data, it can be obtained by smoothing the first passenger flow time series data using the moving average method. Specifically, for each passenger flow volume data in the first passenger flow time series data, determine the average value of all passenger flow volume data within a preset length of time window including the passenger flow volume data as the passenger flow trend data corresponding to the passenger flow volume data; form the first trend passenger flow data by arranging the passenger flow trend data corresponding to all passenger flow volume data in time sequence.
[0060] Among them, when determining the length of the time window for calculating the average passenger flow, the choice of the window length is very critical. It should be long enough to eliminate short-term fluctuations, but not too long so as not to capture trend changes. For example, for daily passenger flow data, the time window can be set to one week, depending on the characteristics of the data and the period of seasonal fluctuations. The following combines Figure 2 An example is given to illustrate the determination process of the first trend passenger flow data.
[0061] For each passenger flow volume data point in the first passenger flow time series data, a preset-length time window centered on this point is constructed. For example, if the window length is set to one week (7 days), then for the passenger flow volume data on the nth day, we will consider the passenger flow volume data from the (n - 3)th day to the (n + 3)th day (a total of 7 days, centered on the nth day). After determining the time window, the next step is to calculate the average value of all passenger flow volume data within the window. This step is completed by adding up the passenger flow volume values of each data point within the window and then dividing by the number of data points within the window. The average value can reflect the central tendency of the passenger flow volume within the window, thereby eliminating the influence of short-term fluctuations; calculate the average value corresponding to each passenger flow volume data point, and rearrange these average values in time series to form the first trend passenger flow data.
[0062] Among them, when using the moving average processing method to process data, when n takes 1, the data on the (n - 3)th day is missing. For the situation where there are missing values within the window length, a fixed value (such as the average value, median, etc.) can be considered to fill the missing values.
[0063] Assume that the first passenger flow time series data is X. The first passenger flow time series data can be processed by moving average, and finally the first trend passenger flow data is obtained, which is specifically expressed by the following formula:
[0064] X trend = Padding(X)
[0065] Among them, X trend is the first trend passenger flow data.
[0066] After obtaining the first trend passenger flow data, by taking the difference between the first passenger flow time series data and the first trend passenger flow data, the first seasonal passenger flow data is obtained, which is specifically expressed by the following formula:
[0067] X season = X - X trend
[0068] Among them, X season is the first seasonal passenger flow data.
[0069] After that, the first trend passenger flow data and the first seasonal passenger flow data can be encoded respectively using a linear network to obtain the first trend feature sequence and the first seasonal feature sequence.
[0070] Specifically, the first trend feature sequence can be obtained by the linear transformation processing of the first trend passenger flow data X trend through the decomposition linear network, and the first seasonal feature sequence can be obtained by the decomposition linear transformation processing of the first seasonal passenger flow data X season through the decomposition linear transformation processing, which are specifically expressed as:
[0071] X trend_out = Linear1(X trend )
[0072] X season_out = Linear2(X season )
[0073] wherein, X trend_out is the first trend feature sequence, and X season_out is the first seasonal feature sequence.
[0074] As an alternative implementation, when determining the first periodic feature matrix, each passenger flow time series data in the first passenger flow time series data can be subjected to point convolution mapping encoding to obtain a first encoding result; with one week as the preset period, the first encoding result is split and reorganized to obtain a second periodic feature matrix, wherein each row in the second periodic feature matrix corresponds to the encoding result of the passenger flow data in one week; a transpose operation is performed on the second periodic feature matrix to obtain the first periodic feature matrix.
[0075] Figure 3 is a flowchart for obtaining an alternative periodic feature matrix according to an embodiment of the present application. The following combines Figure 3 to illustrate the determination process of the first periodic feature matrix by way of example. Assume that the input first passenger flow time series data is X ∈ R sl×c . First, perform point convolution mapping encoding operation on it. When using point convolution mapping encoding, it is necessary to define the size and type of the convolution kernel to capture the passenger flow patterns on specific days or time periods in a week. For example, a one-dimensional convolution kernel with a size of 3 can be used to capture the passenger flow trends for three consecutive days. The specific first encoding result X enc after convolution can be expressed by the following formula:
[0076] X enc = conv(X)
[0077] After that, based on the obtained first encoding result, perform a patch reorganization operation to obtain a second periodic feature matrix. For each split week of data, further reorganize it in the order of each day to facilitate the identification and processing of periodic patterns. The reorganized data structure is a two-dimensional matrix, where the rows represent each day in a week and the columns represent the positions of each data point in the time series. The reorganized week of data is used as the rows of the second periodic feature matrix, and each row contains the point convolution mapping encoding results of each day or time period within a week. The second periodic feature matrix X re can be expressed by the following formula:
[0078] X re = reshape(x enc , 7, -1)
[0079] Among them, 7 usually refers to the number of days in a week, that is, the reshaped tensor will have 7 rows, and each row represents a certain day of the week. -1 is a special value representing the specified length adjusted finally. When taking the value of -1, it means that the function will automatically calculate the size of this dimension to ensure that the total number of elements contained in the reshaped tensor is the same as that of the original tensor. To ensure the processing of subsequent deep learning models, a transpose operation is performed on the second periodic feature matrix to obtain the first periodic feature matrix x, which is specifically represented by the following formula:
[0080] x = Transpose(X re )
[0081] The transposed matrix x is the first periodic feature matrix. Each column will correspond to a complete encoded feature sequence of a day, and each row represents the passenger flow encoded features of a time point in different weeks.
[0082] As an alternative implementation, in the technical solution provided in step S104 of the present application above, after obtaining the relevant data, the first weather feature sequence corresponding to the first weather state data and the second weather state data, and the first holiday feature sequence corresponding to the first holiday state data and the second holiday state data can also be determined.
[0083] Specifically, the weather feature sequence and the holiday feature sequence can be determined respectively through the following steps: First, one-hot encoding is performed on each weather state data in the first weather state data and the second weather state data to obtain a second encoding result, and a long short-term memory network is used to analyze the second encoding result to obtain the first weather feature sequence; Second, one-hot encoding is performed on each state indication data in the first holiday state data and the second holiday state data to obtain a third encoding result, and a long short-term memory network is used to analyze the third encoding result to obtain the first holiday feature sequence.
[0084] Specifically, when implementing the one-hot encoding of the first weather state data and the second weather state data, assuming there are 5 weather states, the length of the one-hot encoding vector will be 5. For each weather state, we will assign an index value. For each weather state in the original data, we look up its index value and create a vector of length 5, where the position corresponding to the index value is set to 1 and the remaining positions are set to 0. The above steps realize the conversion of the weather state to the one-hot vector. The one-hot encoded vectors are arranged in chronological order to form the second encoding result.
[0085] Take the weather data represented by the second encoded result after the above one-hot encoding as the input sequence of the long short-term memory network. Each row of the encoding represents the weather state of one day. These data are arranged in chronological order to form a three-dimensional tensor, where the first dimension represents the time step (number of days), the second dimension represents the number of samples, and the third dimension represents the number of features (number of weather types). The long short-term memory network analyzes the second encoded result to obtain the first weather feature sequence.
[0086] Among them, one-hot encoding is performed on each status indication data in the holiday status data to obtain the third encoded result, which is illustrated by the following example:
[0087] Suppose the status indication data in the holiday status data are the indications of whether it is a working day, weekend, public holiday, and special festival (such as Spring Festival, National Day). Then, for the holiday status data from January 1, 2023 to December 31, 2023, the possible holiday status information is shown in the following table.
[0088] Table 1
[0089] Date Is it a working day Is it a weekend Is it a public holiday Is it the Spring Festival 2023-01-01 0 0 1 0 2023-01-02 1 0 0 0 … … … … … 2023-12-31 1 0 0 0
[0090] For the holiday status of each day, we convert it into a binary vector, and the vector length is equal to the number of holiday statuses (4 in this example). If a certain day is a working day, the vector is [1, 0, 0, 0]; if it is a weekend, it is [0, 1, 0, 0]; and so on. Apply the above process to the first holiday status data and the second holiday status data to obtain the third encoded result set. Then, the long short-term memory network analyzes the third encoded result to obtain the first holiday feature sequence.
[0091] After processing to obtain all the required feature data, the above step S106 can be executed. The decoder module in the passenger flow prediction model analyzes the first trend feature sequence, the first seasonal feature sequence, the first periodic feature matrix, the first weather feature sequence, and the first holiday feature sequence to obtain the passenger flow prediction data for the first future time period.
[0092] Specifically, when the decoder module of the passenger flow prediction model analyzes the input feature sequence, it can use the self-activation mechanism to adjust the weights to ensure that the model can automatically adjust its prediction strategy according to the dynamic changes of the input sequence. The self-activation mechanism calculates the activation degree of each feature sequence (i.e., the contribution degree to the predicted passenger flow), and dynamically adjusts the weights according to the activation degree, and finally gives the passenger flow prediction data based on the prediction strategy.
[0093] Through the above steps, the historical passenger flow, weather conditions, and holiday information are comprehensively analyzed, enabling more accurate prediction of future passenger flow. Technologies such as moving average, point convolution mapping encoding, and long short-term memory network are adopted, thereby realizing the effective extraction of each feature, improving the robustness and accuracy of the prediction model, and further solving the technical problem of inaccurate prediction results caused by considering a single passenger flow data element in relevant passenger flow analysis and prediction scenarios.
[0094] Embodiment 2
[0095] According to the embodiments of the present application, there is also provided a passenger flow prediction device for implementing the passenger flow prediction method in Embodiment 1. As Figure 4 shown, the passenger flow prediction device at least includes: a data acquisition module 41, a feature analysis module 42, and a passenger flow prediction module 43, where:
[0096] The data acquisition module 41 is configured to acquire first passenger flow time series data, first weather condition data, and first holiday status data within a first historical time period, and acquire second weather condition data and second holiday status data within a first future time period.
[0097] The feature analysis module 42 is configured to use the feature extraction module in the passenger flow prediction model to determine a first trend feature sequence, a first seasonal feature sequence, and a first periodic feature matrix based on a preset period corresponding to the first passenger flow time series data, and determine a first weather feature sequence corresponding to the first weather condition data and the second weather condition data, and determine a first holiday feature sequence corresponding to the first holiday status data and the second holiday status data.
[0098] The passenger flow prediction module 43 is configured to use the decoder module in the passenger flow prediction model to analyze the first trend feature sequence, the first seasonal feature sequence, the first periodic feature matrix, the first weather feature sequence, and the first holiday feature sequence to obtain passenger flow prediction data within the first future time period.
[0099] As an optional implementation manner, the passenger flow prediction device provided in the embodiments of the present application further includes a model training module, which is configured to train the required passenger flow prediction model through the following steps:
[0100] S1. Construct an initial model, where the initial model at least includes: a feature extraction module and a decoder module;
[0101] S2. The data acquisition module is configured to acquire second passenger flow time series data, third weather condition data, and third holiday status data within a plurality of second historical time periods, and acquire third passenger flow time series data, fourth weather condition data, and fourth holiday status data within a third historical time period after each second historical time period;
[0102] S3. Take the second passenger flow time series data, the third weather state data, and the third holiday state data within each second historical time period, as well as the fourth weather state data and the fourth holiday state data within the corresponding third historical time period, as a training sample, and take the third passenger flow time series data within the corresponding third historical time period as the sample label of the training sample;
[0103] S4. Divide the obtained multiple training samples and sample labels into a training set and a validation set;
[0104] S5. Use the training set to iteratively train the initial model, and use the validation set to verify the trained model at the end of each training batch. When the preset termination condition is met, take the trained model as the passenger flow prediction model.
[0105] In the actual application stage, the data acquisition module first acquires the following relevant data for passenger flow prediction: the first passenger flow time series data, including the daily passenger flow data within the first historical time period; in the first weather state data, including the daily weather state data within the first historical time period; the first holiday state data, including the status indication data of whether each day within the first historical time period is a holiday; in the second weather state data, including the daily weather state data within the first future time period; the second holiday state data, including the status indication data of whether each day within the first future time period is a holiday.
[0106] As an optional implementation manner, the feature analysis module can determine the first trend feature sequence, the first seasonal feature sequence, and the first periodic feature matrix corresponding to the first passenger flow time series data in the following manner: Use the moving average method to smooth the first passenger flow time series data to obtain the first trend passenger flow data; Determine the difference between the first passenger flow time series data and the first trend passenger flow data as the first seasonal passenger flow data; Use a linear network to encode the first trend passenger flow data and the first seasonal passenger flow data respectively to obtain the first trend feature sequence and the first seasonal feature sequence; Based on a preset period, encode and segmentally reorganize the first passenger flow time series data to obtain the first periodic feature matrix.
[0107] Among them, the feature analysis module can determine the first trend passenger flow data in the following manner: For each passenger flow data in the first passenger flow time series data, determine the average value of all passenger flow data within a preset length of time window including the passenger flow data as the passenger flow trend data corresponding to the passenger flow data; Arrange the passenger flow trend data corresponding to all passenger flow data in time sequence to form the first trend passenger flow data.
[0108] Optionally, the feature analysis module can also determine the first periodic feature matrix in the following manner: perform point convolution mapping encoding on each passenger flow volume data in the first passenger flow time series data to obtain a first encoding result; take one week as a preset period, split and reorganize the first encoding result to obtain a second periodic feature matrix, where each row in the second periodic feature matrix corresponds to the encoding result of the passenger flow volume data for one week; perform a transpose operation on the second periodic feature matrix to obtain the first periodic feature matrix.
[0109] Optionally, the feature analysis module can also determine the first weather feature sequence and the first holiday feature sequence in the following manner: perform one-hot encoding on each weather state data in the first weather state data and the second weather state data respectively to obtain a second encoding result, and use a long short-term memory network to analyze the second encoding result to obtain the first weather feature sequence; perform one-hot encoding on each status indication data in the first holiday state data and the second holiday state data respectively to obtain a third encoding result, and use a long short-term memory network to analyze the third encoding result to obtain the first holiday feature sequence.
[0110] Finally, the passenger flow prediction module uses the decoder module in the passenger flow prediction model to analyze the first trend feature sequence, the first seasonal feature sequence, the first periodic feature matrix, the first weather feature sequence, and the first holiday feature sequence to obtain the passenger flow prediction data for the first future time period.
[0111] It should be noted that each module in the passenger flow prediction device in the embodiments of the present application corresponds one-to-one to each implementation step of the passenger flow prediction method in Embodiment 1. Since a detailed description has been given in Embodiment 1, details not shown in this embodiment can be referred to Embodiment 1 and will not be elaborated here.
[0112] Embodiment 3
[0113] According to the embodiments of the present application, there is also provided a computer program product, which includes a computer program, where the computer program, when executed by a processor, implements the passenger flow prediction method in Embodiment 1.
[0114] According to the embodiments of the present application, there is also provided a non-volatile storage medium, which includes a stored computer program, where the device where the non-volatile storage medium is located executes the passenger flow prediction method in Embodiment 1 by running the computer program.
[0115] According to the embodiments of the present application, there is also provided a processor, which is used to run a computer program, where the computer program, when running, executes the passenger flow prediction method in Embodiment 1.
[0116] According to an embodiment of the present application, an electronic device is further provided. The electronic device includes: a memory and a processor. Among them, a computer program is stored in the memory, and the processor is configured to execute the passenger flow prediction method in Embodiment 1 through the computer program.
[0117] Specifically, when the computer program runs, it executes the following steps: obtaining first passenger flow time series data, first weather state data, and first holiday state data within a first historical time period, and obtaining second weather state data and second holiday state data within a first future time period; using the feature extraction module in the passenger flow prediction model to determine a first trend feature sequence, a first seasonal feature sequence, and a first periodic feature matrix based on a preset period corresponding to the first passenger flow time series data, and determining a first weather feature sequence corresponding to the first weather state data and the second weather state data, and determining a first holiday feature sequence corresponding to the first holiday state data and the second holiday state data; using the decoder module in the passenger flow prediction model to analyze the first trend feature sequence, the first seasonal feature sequence, the first periodic feature matrix, the first weather feature sequence, and the first holiday feature sequence to obtain passenger flow prediction data within the first future time period.
[0118] As an optional implementation manner, the above electronic device may exist in the form of a mobile terminal, a computer terminal, or a similar computing device. Figure 5 A hardware structure block diagram of an electronic device for implementing the passenger flow prediction method is shown. As Figure 5 shown, the electronic device 50 may include one or more (shown as 502a, 502b,..., 502n in the figure) processors 502 (the processor 502 may include, but is not limited to, a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory 504 for storing data, and a transmission device 506 for communication functions. In addition, it may further include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the BUS bus), a network interface, a power supply, and / or a camera. Those of ordinary skill in the art can understand that Figure 5 the structure shown is only schematic and does not limit the structure of the above electronic device. For example, the electronic device 50 may further include more or fewer components than Figure 5 shown, or have a different configuration from Figure 5 shown.
[0119] It should be noted that one or more of the above-mentioned processors 502 and / or other data processing circuits can generally be referred to as "data processing circuits" herein. The data processing circuit can be embodied in software, hardware, firmware, or any combination thereof, in whole or in part. In addition, the data processing circuit can be a single independent processing module, or be incorporated in whole or in part into any one of the other components in the electronic device 50. As involved in the embodiments of the present application, the data processing circuit is a kind of processor control (such as the selection of a variable resistor terminal path connected to an interface).
[0120] The memory 504 can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the passenger flow prediction method in the embodiments of the present application. The processor 502 executes various functional applications and data processing by running the software programs and modules stored in the memory 504, that is, implements the vulnerability detection method of the above-mentioned application program. The memory 504 can include a high-speed random access memory, and can also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memories. In some instances, the memory 504 can further include a memory remotely set relative to the processor 502, and these remote memories can be connected to the electronic device 50 through a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an enterprise intranet, a local area network, a mobile communication network, and combinations thereof.
[0121] The transmission device 506 is used to receive or send data via a network. Specific examples of the above-mentioned network can include the wireless network provided by the communication provider of the electronic device 50. In one instance, the transmission device 506 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices through a base station and thus can communicate with the Internet. In one instance, the transmission device 506 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0122] The display can be, for example, a touch-screen liquid crystal display (LCD), which enables the user to interact with the user interface of the electronic device 50.
[0123] The above-mentioned embodiment numbers are only for description and do not represent the advantages or disadvantages of the embodiments.
[0124] In the above embodiments of the present application, the descriptions of each embodiment have their own focuses. For the parts not detailed in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0125] In several embodiments provided in the present application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are merely illustrative. For example, the division of units can be a logical function division. In actual implementation, there can be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed couplings or direct couplings or communication connections to each other can be through some interfaces. The indirect couplings or communication connections of units or modules can be in electrical or other forms.
[0126] The units described as separate components may or may not be physically separated. The components displayed as units may or may not be physical units, that is, they can be located in one place or distributed to multiple units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0127] In addition, in each embodiment of the present application, each functional unit can be integrated in a processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit. The above-mentioned integrated units can be implemented in the form of hardware or in the form of software functional units.
[0128] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, or all or part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods in each embodiment of the present application. The aforementioned storage medium includes: USB flash drives, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), mobile hard disks, magnetic disks, or optical discs and other various media that can store program codes.
[0129] The above is only the preferred embodiment of the present application. It should be noted that for those of ordinary skill in the art, without departing from the principle of the present application, several improvements and refinements can be made, and these improvements and refinements should also be regarded as the protection scope of the present application.
Claims
1. A passenger flow prediction method, characterized in that: include: Acquire first passenger flow time series data, first weather status data, and first holiday status data in a first historical time period, and acquire second weather status data and second holiday status data in a first future time period; Determine a first trend feature sequence, a first seasonal feature sequence, and a first periodic feature matrix based on a preset period corresponding to the first passenger flow time series data by using a feature extraction module in the passenger flow prediction model, determine a first weather feature sequence corresponding to the first weather state data and the second weather state data, and determine a first holiday feature sequence corresponding to the first holiday state data and the second holiday state data; The decoder module in the passenger flow prediction model is used to analyze the first trend feature sequence, the first seasonal feature sequence, the first periodic feature matrix, the first weather feature sequence and the first holiday feature sequence to obtain passenger flow prediction data in the first future time period.
2. The method according to claim 1, characterized in that The first passenger flow time series data includes: daily passenger flow data in the first historical time period; The first weather status data includes: daily weather status data within the first historical time period; The first holiday status data includes: status indication data of whether each day in the first historical time period is a holiday; The second weather status data includes: daily weather status data in the first future time period; The second holiday status data includes: status indication data of whether each day in the first future time period is a holiday.
3. The method according to claim 2, characterized in that Determining a first trend feature sequence, a first seasonal feature sequence, and a first periodic feature matrix based on a preset period corresponding to the first passenger flow time series data by using a feature extraction module in the passenger flow prediction model includes: Smoothing the first passenger flow time series data using a sliding average method to obtain first trend passenger flow data; Determine the difference between the first passenger flow time series data and the first trend passenger flow data as first seasonal passenger flow data; Encoding the first trend passenger flow data and the first seasonal passenger flow data respectively by using a linear network to obtain the first trend feature sequence and the first seasonal feature sequence; The first passenger flow time series data is encoded and segmented based on a preset period to obtain the first periodic feature matrix.
4. The method according to claim 3, characterized in that The first passenger flow time series data is smoothed by using a sliding average method to obtain first trend passenger flow data, including: For each passenger flow data in the first passenger flow time series data, determining an average value of all passenger flow data within a time window of a preset length including the passenger flow data as passenger flow trend data corresponding to the passenger flow data; The passenger flow trend data corresponding to all passenger flow data are combined into the first trend passenger flow data in time series.
5. The method according to claim 3, characterized in that: The first passenger flow time series data is encoded and segmented based on a preset period to obtain the first periodic feature matrix, including: Performing point convolution mapping encoding on each passenger flow data in the first passenger flow time series data to obtain a first encoding result; Taking one week as the preset period, splitting and reorganizing the first encoding result to obtain a second periodic characteristic matrix, wherein each row in the second periodic characteristic matrix corresponds to the encoding result of passenger flow data for one week; A transposition operation is performed on the second periodic characteristic matrix to obtain the first periodic characteristic matrix.
6. The method according to claim 2, characterized in that Determining a first weather feature sequence corresponding to the first weather state data and the second weather state data, and determining a first holiday feature sequence corresponding to the first holiday state data and the second holiday state data, comprises: Performing one-hot encoding on each of the first weather state data and the second weather state data to obtain a second encoding result, and analyzing the second encoding result using a long short-term memory network to obtain the first weather feature sequence; Performing one-hot encoding on each status indication data in the first holiday status data and the second holiday status data respectively to obtain a third encoding result, and analyzing the third encoding result using a long short-term memory network to obtain the first holiday feature sequence.
7. The method according to claim 1, characterized in that The training process of the passenger flow prediction model includes: Constructing an initial model, wherein the initial model at least includes: the feature extraction module and the decoder module; Acquire the second passenger flow time series data, the third weather status data and the third holiday status data in a plurality of second historical time periods, and acquire the third passenger flow time series data, the fourth weather status data and the fourth holiday status data in a third historical time period after each second historical time period; The second passenger flow time series data, the third weather status data, the third holiday status data in each second historical time period and the fourth weather status data and the fourth holiday status data in the corresponding third historical time period are used as a training sample, and the third passenger flow time series data in the corresponding third historical time period is used as a sample label of the training sample; Divide the obtained multiple training samples and sample labels into a training set and a validation set; The initial model is iteratively trained using the training set, and the trained model is verified using the verification set when each training batch is completed. When a preset termination condition is met, the trained model is used as the passenger flow prediction model.
8. A passenger flow prediction device, characterized in that: include: A data acquisition module, used to acquire first passenger flow time series data, first weather status data and first holiday status data in a first historical time period, and to acquire second weather status data and second holiday status data in a first future time period; A feature analysis module, used to determine a first trend feature sequence, a first seasonal feature sequence, and a first periodic feature matrix based on a preset period corresponding to the first passenger flow time series data using a feature extraction module in the passenger flow prediction model, and to determine a first weather feature sequence corresponding to the first weather state data and the second weather state data, and to determine a first holiday feature sequence corresponding to the first holiday state data and the second holiday state data; A passenger flow prediction module is used to use the decoder module in the passenger flow prediction model to analyze the first trend feature sequence, the first seasonal feature sequence, the first periodic feature matrix, the first weather feature sequence and the first holiday feature sequence to obtain passenger flow prediction data in the first future time period.
9. A computer program product, characterized in that include: A computer program, wherein when the computer program is executed by a processor, the passenger flow prediction method according to any one of claims 1 to 7 is implemented.
10. An electronic device, characterized in that: include: A memory and a processor, wherein the memory stores a computer program, and the processor is configured to execute the passenger flow prediction method according to any one of claims 1 to 7 through the computer program.