Traffic flow prediction method based on deep learning and multi-scale clustering unit
By constructing multi-scale clustering units and fusing multi-source data, the problems of single data source and single clustering scale in existing traffic flow prediction methods are solved, achieving high-precision and fine-grained traffic flow prediction and improving the model's generalization ability and interpretability.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- XIAMEN UNIV OF TECH
- Filing Date
- 2026-04-23
- Publication Date
- 2026-05-22
AI Technical Summary
Existing traffic flow prediction methods suffer from limitations such as single data sources, single clustering scales, and a lack of understanding of urban functional semantics, resulting in insufficient prediction accuracy and weak generalization ability, and failing to effectively reflect the dynamic changes in traffic conditions and the differences in functional areas.
By constructing multi-scale clustering units, integrating multi-source heterogeneous data (such as traffic trajectories, POIs, road networks, and population data), and introducing travel time distance and POI semantic features, an end-to-end deep learning model is built to predict traffic flow.
It achieves higher accuracy and more interpretable traffic flow prediction, can dynamically identify traffic pattern differences in different functional areas, improves model training efficiency and prediction practicality, and provides fine-grained traffic management support.
Smart Images

Figure CN122073077A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of intelligent transportation technology, and in particular to a traffic flow prediction method based on deep learning and multi-scale clustering units. Background Technology
[0002] With the deepening of smart city construction, accurate traffic flow forecasting has become one of the key technologies for achieving intelligent traffic management and alleviating road congestion. Traditional traffic management systems rely on static models and rules of thumb, which often struggle to effectively cope with the dynamic changes and complexities of traffic flow. Especially during peak hours, special events, or extreme weather conditions, the unpredictability of traffic conditions increases significantly. This not only affects people's daily travel efficiency but also has a negative impact on urban economic activities. Therefore, accurate traffic flow forecasting is crucial for alleviating traffic pressure and improving road utilization efficiency.
[0003] Existing traffic flow prediction methods primarily rely on historical traffic data and extrapolate using various mathematical models. In recent years, with advancements in data acquisition technology and the development of artificial intelligence, significant progress has been made in this field. Deep learning models, especially recurrent neural networks (such as LSTM), convolutional neural networks (CNN), and graph neural networks (GNN), have demonstrated superior performance in processing time-series data, spatial information, and complex network structures due to their powerful pattern recognition capabilities and effective handling of high-dimensional data. These technologies make it possible to extract spatiotemporal features from large amounts of traffic data and subsequently predict future traffic flow.
[0004] However, many limitations remain. A common approach is to pre-divide urban areas into fixed, regular geographical units, such as uniform grids or areas defined by administrative boundaries. Then, historical traffic flow within each unit is statistically analyzed, and predictions are made using time-series models or machine learning models. Deep learning models, such as convolutional neural networks, are increasingly used to capture spatial dependencies between grids, combined with recurrent neural networks to handle temporal dependencies. However, all these methods suffer from rigid spatial structures. Fixed grid divisions (e.g., 500m × 500m) cannot reflect the true, dynamically changing traffic patterns and urban functional distribution. Some studies have attempted to use clustering algorithms (such as K-Means and DBSCAN) to cluster traffic data (mainly trajectory points or origin-destination points) into irregular analytical units. These units are considered to be more homogeneous in terms of traffic patterns. Existing practices typically only perform clustering at a single spatial or temporal scale, without addressing multi-scale clustering analysis. Another drawback is that most methods only focus on the traffic itself, completely ignoring the functional attributes of the area that generates the traffic. Whether it is the grid division of the analysis unit or single-scale clustering, they rarely integrate with semantic information such as city POIs. The model cannot understand and utilize this semantic pattern that is closely related to POIs.
[0005] Chinese patent application CN116153089 discloses a traffic flow prediction system and method based on spatiotemporal convolution and dynamic graphs. This method characterizes the spatial relationships between nodes over time using a dynamic adjacency matrix and innovatively uses a continuous-time model (Hawks process) to predict the evolution of the network structure. It then combines inductive graph learning to capture node dynamics, ultimately forming an end-to-end prediction framework aimed at improving prediction accuracy and stability. However, this approach has the following limitations: The data source is singular, and its modeling relies entirely on historical traffic flow data (such as vehicle speed and flow rate) without incorporating external semantic information such as city POIs (points of interest). Due to the lack of support from POI and other data, the model cannot distinguish the differences in traffic patterns of functional areas such as commercial areas, residential areas, and industrial areas at different times, which limits its generalization ability and depth of understanding of complex scenarios, and makes it unable to understand the functional motivations behind traffic generation.
[0006] Using road network distance to measure the distance between sample points has the following limitations: it treats the road network as a static and homogeneous system, assuming that the travel cost (time) of all roads at any given time is only related to their physical length, failing to reflect dynamic changes in traffic efficiency caused by congestion, accidents, traffic lights, or weather. It lacks a temporal dimension, being a purely spatial distance that cannot capture the dynamic evolution of traffic conditions over time. Two paths of the same physical length may offer vastly different travel experiences at different times, but road network distance cannot distinguish between these. Furthermore, it is insufficient in characterizing functional similarity, primarily based on physical connectivity. Two areas may be connected briefly by expressways or for extended periods by urban roads; road network distance cannot effectively differentiate the underlying functional connections between these two scenarios.
[0007] The clustering scale is singular, and its spatial analysis units are fixed sensor nodes, road network nodes, or regular grid units. It lacks explicit, multi-scale dynamic division of urban functional areas and makes it difficult to capture spatial interaction patterns based on travel purposes that transcend the physical road network. Summary of the Invention
[0008] To address the problems existing in the prior art, the purpose of this invention is to provide a traffic flow prediction method based on deep learning and multi-scale clustering units. This invention divides and analyzes urban dynamic functional areas by constructing multi-scale clustering units, thereby achieving high-precision, fine-grained traffic flow prediction.
[0009] To achieve the above objectives, the technical solution adopted by this invention is: a traffic flow prediction method based on deep learning and multi-scale clustering units, comprising the following steps: Step 1: Multi-source heterogeneous data acquisition and preprocessing: Collect raw data from multiple channels and perform cleaning, standardization and spatiotemporal alignment; Step 2: Construct multi-scale dynamic traffic clustering units: First, construct a multi-scale feature matrix, and then perform dynamic clustering to construct analysis units that reflect the dynamic functional areas of the city. Step 3, Feature Engineering and Fusion: Prepare input features for the deep learning model and fuse traffic features with POI semantic features; Step 4: Construction and training of a traffic prediction model based on deep learning: Use the fused features to train an end-to-end traffic prediction model; Step 5: Use the traffic flow prediction model to predict and output traffic flow.
[0010] Furthermore, in step 1, the raw data includes traffic trajectory data, urban point of interest (POI) data, urban road network data, building data, and urban population data.
[0011] Furthermore, in step 1, spatiotemporal alignment includes spatial alignment and temporal alignment; wherein, spatial alignment first uses multi-scale clustering to cluster the starting points and starting point OD flows of all trajectories into a grid cell, and then associates them with the corresponding reference grid according to the latitude and longitude coordinates of the built environment; temporal alignment divides a day into continuous time slices and aggregates all traffic data into the corresponding time slices according to timestamps.
[0012] Furthermore, in step 2, the multi-scale feature matrix includes traffic flow features, internal traffic features, and POI semantic features.
[0013] Furthermore, in step 2, the dynamic clustering is specifically as follows: First, a time scale is selected, and cluster analysis is performed on the feature matrices of all grids in the study area at representative time scales. Second, a clustering algorithm is executed, using an algorithm that automatically determines the number of clusters. Finally, clustering units are generated, and each cluster is regarded as a dynamic traffic clustering unit. Variable standardization, multicollinearity test, and spatial autocorrelation test are performed on the multi-scale clustering units.
[0014] Furthermore, step 3 specifically includes: (1) Unit-level feature extraction: Spatial association features: Construct a spatial relationship graph between units, treating each dynamic traffic cluster unit as a node in the graph. If two units are spatially adjacent or have significant OD flow connections, an edge is established between them, and the weight of the edge is determined by the magnitude of the OD flow. For the traffic analysis units obtained based on the clustering algorithm, the data of each analysis unit is processed to obtain the Euclidean distance matrix, the road network distance matrix, and the travel time matrix. The Euclidean distance is established by the centroids between the cluster units, as shown in the following formula: ; in, Represents a cell The coordinates of the centroid, Represents a cell centroid coordinates, Euclidean distance matrix It is A symmetric matrix with the following elements: ; The road network distance matrix is constructed by calculating the average vehicle mileage from a given cluster unit to its destination within that cluster unit, as shown in the following formula: ; in, Indicates the starting cell, Indicates the target cell, Indicates starting from the first cell to the destination cell The number of vehicles, Indicates the first The car from Drive to The driving distance, of which, =1, 2, ... Distance matrix of the entire road network It is Let S be a matrix, and S be a set of spatial cells, whose elements are: ; The travel time matrix is established by calculating the average travel time of vehicles from the starting point to the end point of a certain cluster, as shown in the following formula: ; in, Indicates the starting cell, Indicates the target cell, Indicates starting from the first cell to the destination cell The number of vehicles, Indicates the first The car from Drive to The passage time, among which, =1, 2, ... The entire travel time distance matrix It is The matrix has the following elements: ; POI semantic embedding features: Input the POI category vector in each unit into an embedding layer, or normalize the vector to obtain a low-dimensional, dense semantic feature vector to characterize the core function of the unit. (2) Feature fusion: The sequence features, POI semantic embedding features, and node representations in the spatial relationship graph of each dynamic traffic clustering unit are concatenated to form the final fused feature vector of that unit.
[0015] Furthermore, in step 4, the method for constructing the traffic prediction model specifically includes: 1) Spatial feature modeling: Neural networks are used to process the constructed spatial relationship graph and capture the spatial associations between different dynamic traffic clustering units; 2) Geographically Weighted Regression Modeling: A geographically weighted regression model is used to explore the impact of different built environments on the spatial nonstationarity of vehicle density. The geographically weighted regression model is as follows: ; Will Substituting the ordinary linear regression estimate into the above equation, we get: ; in, or Indicates spatial location The predicted value of the dependent variable; Representing the The spatial coordinates of each observation point are used to identify its geographical location; Indicates the location First Local coefficient estimates of the independent variables; Indicates the first The observation point The actual values of the independent variables; Indicates the location First The weights of the independent variables; Indicates the first Global coefficient estimates for ordinary linear regression of 1 independent variables.
[0016] Furthermore, in step 4, when training the traffic prediction model, the loss function adopts the mean squared error (MSE) or the mean absolute error (MAE) to minimize the gap between the predicted traffic and the actual traffic; the optimizer uses the Adam optimizer to iteratively update the model parameters; the real traffic data of the fused feature vector and its corresponding future time slice are used as training samples and divided into training set, validation set and test set according to a preset ratio.
[0017] Furthermore, in step 5, traffic flow prediction includes: predicting traffic flow in the test set and predicting traffic flow at random target points within the study area; specifically, predicting traffic flow in the test set is as follows: Input real-time / historical data, process the multi-source data of the current moment according to steps 1 to 3, and generate the fused feature vector of each dynamic traffic cluster unit at the current moment; Model training, train the model with data in the training set, and verify the accuracy of the model with data in the validation set after training; Execute prediction, input the fused feature vector generated from the multi-source data in the test set into the deep learning model trained in step 4; Output results, the model outputs the predicted inflow and outflow of each dynamic traffic cluster unit in the test set; The traffic flow prediction for random target points within the study area is as follows: The traffic flow forecast for a target location is obtained by using Kriging interpolation. First, N traffic analysis units around the target point are selected. Traffic flow data for the area is obtained through the model. Then, the traffic flow forecast for the target location is obtained by using Kriging interpolation.
[0018] This invention addresses the core problems of existing prediction schemes, namely insufficient prediction accuracy and weak generalization ability due to single data sources, single clustering scales, and a lack of understanding of urban functional semantics; specifically, it is reflected in: (1) The solution to the problem of single data source aims to break through the limitation of existing technology that only relies on historical traffic flow data. By innovatively integrating urban POI (point of interest) data, population density data, taxi trajectory data and OD (originating point) data, a multi-source and heterogeneous data foundation is constructed to provide rich information dimensions for a deep understanding of the generation mechanism of traffic flow.
[0019] (2) It overcomes the limitations of using road network distance to measure the distance between sample points by creatively proposing travel time distance. Compared with Euclidean distance, it completely abandons the unrealistic linear assumption and anchors the measurement basis from "geometric space" to the real "traffic network", thus accurately reflecting the basic laws that traffic flow must follow in the movement of the road network. Compared with road network distance, it breaks through the framework of static path length and elevates "distance" from a fixed physical quantity to a dynamic "spatiotemporal cost". It can not only identify whether two points are connected, but also judge the "efficiency" and "cost" of connection at a specific time, thus accurately depicting the propagation and dissipation of traffic congestion and the changes in accessibility at different times.
[0020] (3) The solution to the problem of single clustering scale is to introduce multi-scale clustering units to dynamically and adaptively divide urban areas into analysis units with different traffic function characteristics, so that the model can distinguish and identify (such as commercial areas, residential areas, transportation hubs, etc.) the differences in traffic patterns in different time periods, and fundamentally understand the intrinsic driving force of traffic generation and change, rather than just learning the surface correlation of traffic data.
[0021] In summary, this invention constructs a system that can more accurately capture the spatiotemporal evolution of traffic, achieving more accurate and interpretable short-term traffic flow prediction, and providing more reliable technical support for traffic management, congestion mitigation, and route planning in smart cities.
[0022] The beneficial effects of this invention are: 1. This invention provides more granular and interpretable prediction results to aid in in-depth decision-making: By constructing multi-scale dynamic traffic clustering units, it elevates traffic flow prediction from physical space to functional space situational awareness, giving the prediction results operational interpretability. This provides direct and powerful data support for implementing differentiated traffic control strategies (such as targeted regional flow restrictions and tidal lane settings). Therefore, the output of this invention is no longer isolated traffic flow figures, but prediction results bound to "dynamic clustering units" with clear functional semantics. Traffic managers can clearly see the congestion trends of the "financial district cluster" and the "university town cluster" at different times in the future, rather than just the traffic flow at a single intersection.
[0023] 2. This invention improves model training efficiency and engineering practicality: Through "multi-scale clustering," clustering preserves core spatial information while achieving data dimensionality reduction and abstraction, reducing the spatial complexity of the model and thus reducing computational overhead. Multi-scale clustering aggregates thousands of original grids into hundreds of functional units, significantly reducing the number of spatial nodes that deep learning models need to process. In practical deployments, compared to models processing fixed grids in the same area, the training time of this invention's model can be shortened by approximately 20%–40%, and the inference speed can be increased by approximately 25%, making it more suitable for large-scale urban traffic prediction scenarios with high real-time requirements. Attached Figure Description
[0024] Figure 1 This is a flowchart of an embodiment of the present invention; Figure 2 This is a schematic diagram illustrating the algorithm implementation process of the road network matrix and travel time matrix in an embodiment of the present invention; Figure 3 This is a model framework diagram in an embodiment of the present invention; Figure 4 This is a diagram showing the results of a multi-scale clustering analysis unit in an embodiment of the present invention; Figure 5 This is a visualization of some of the influence factor coefficients in an embodiment of the present invention. Detailed Implementation
[0025] The embodiments of the present invention will now be described in detail with reference to the accompanying drawings.
[0026] Example 1 like Figure 1 As shown, a traffic flow prediction method based on deep learning and multi-scale clustering units is presented, the method comprising the following steps: Step 1: Multi-source heterogeneous data acquisition and preprocessing: This step aims to collect raw data from multiple sources and perform cleaning, alignment, and standardization to provide a high-quality data foundation for subsequent analysis; specifically, it includes: 1. Traffic trajectory data preprocessing: Data source: GPS trajectory data obtained from the city's taxi platform. The raw data fields should include at least: vehicle ID, timestamp, longitude, latitude, driving status (empty / carrying passengers), and mileage.
[0027] Data cleaning: Remove abnormal coordinate points that are significantly outside the geographical range; smooth the trajectory and filter out noise points caused by GPS signal drift.
[0028] 1) Invalid Data Removal: A Python script is used to batch check the data attribute table to determine whether attribute values such as the latitude and longitude coordinates of the pick-up and drop-off points, pick-up and drop-off times, and mileage contain empty values, zero values, or garbled characters. If any of these conditions are found, the order data is considered invalid and removed.
[0029] 2) Abnormal Data Handling: The conditions for abnormal data in the original order data are defined as follows: the mileage is less than 250 meters or greater than 40 kilometers; the travel time is less than 1 minute or more than 4 hours. Order data that meets any of the above conditions is identified as abnormal and removed.
[0030] 3) Coordinate Transformation: The latitude and longitude coordinates of the pick-up and drop-off points use the GCJ02 coordinate system, which is a geographic coordinate system obtained by the China National Bureau of Surveying and Mapping through an encryption of the WGS84 coordinate system. This results in a mismatch between the latitude and longitude coordinates of the taxi pick-up and drop-off points and their actual map locations. To ensure coordinate consistency and facilitate subsequent geographic data matching and calculation, this study uses a Python script to convert the latitude and longitude coordinates in the data from the GCJ02 coordinate system to the WGS84 coordinate system.
[0031] 4) Data filtering: After coordinate transformation, the vectors of boarding and alighting points are matched with the vectors of the boundary of the study area to extract the vector data of boarding and alighting points within the study area.
[0032] 5) Construction of multi-period datasets: The morning peak (07:00~11:00), noon peak (12:00~16:00), and evening peak (16:00~20:00) were selected as the research periods. After the above data processing steps, the morning peak taxi order dataset, noon peak taxi order dataset, evening peak taxi order dataset, and all-day taxi order dataset were constructed.
[0033] 6) Trip Segment Recognition: Based on changes in vehicle status, identify independent "trip" segments from continuous trajectories, i.e., a single passenger journey. Extract the origin and destination of each trip segment to form OD data.
[0034] 2. City POI Data and Preprocessing: Data source: Obtain city-wide POI data from the open platforms of electronic map service providers (such as Gaode Maps and Baidu Maps). Data fields should include at least: POI name, category (such as catering services, shopping services, companies and enterprises, residential communities), longitude, and latitude.
[0035] Data standardization: Map POI categories to a unified classification system, for example, dividing them into primary categories such as residential POI, commercial POI, office POI, and public service POI.
[0036] 3. Other relevant data preprocessing: Data sources: Urban road network data, building data, urban population data, etc., obtained from service providers such as Open Street Map and WorldPop.
[0037] Preprocessing: Road network data includes road type, length, width, direction, connectivity, and intersection features. However, road network data may contain geographic coordinate errors, missing road segment information, inaccurate road network connections, and outdated information. Data cleaning is necessary to ensure accuracy. Furthermore, road network data optimization is required, including merging functionally similar road segments, removing redundant nodes, and identifying and completing missing connections to simplify the road network structure and improve model usability and performance. Preprocessing also includes attribute information such as building type, number of floors, and building area, using the WGS_1984 coordinate system. The preprocessing steps primarily involve verifying vector geometry using the "Check Validity" function in QGIS software, removing erroneous or abnormal vectors. Population data is converted from raster data to vector data represented by points using the raster-to-point tool in QGIS software.
[0038] 4. Data spatiotemporal alignment: Spatial alignment: First, multi-scale clustering is used to cluster the starting points of all trajectories and OD flows into a grid cell. Then, based on the latitude and longitude coordinates of the built environment, it is associated with the corresponding reference grid.
[0039] Time alignment: Divide the day into consecutive time slices. Aggregate all traffic data (trajectory points, OD flows) into the corresponding time slices according to their timestamps.
[0040] Step 2: Construct multi-scale dynamic traffic clustering units: This step aims to move beyond fixed geographic grids and construct analytical units that reflect the dynamic functional zones of a city; specifically, it includes: 1. Construction of multi-scale feature matrices: 1) Traffic flow characteristics: including OD flow originating from the grid and OD flow arriving at the grid.
[0041] 2) Internal traffic characteristics: including average vehicle speed, vehicle passenger status, and trajectory point density within the grid.
[0042] 3) POI semantic features: The number (or area ratio) of each category of POI within the grid is used to construct a vector representing the functional area attributes.
[0043] 2. Dynamic cluster analysis: 1) Time scale selection: Cluster analysis was performed on the feature matrix of all grids in the city at representative time scales such as weekday morning peak, weekday evening peak, weekday off-peak, and weekend.
[0044] 2) Clustering algorithm execution: Use a density clustering algorithm (such as HDBSCAN) or spectral clustering algorithm that can automatically determine the number of clusters.
[0045] 3) Generation of Clustering Units: After clustering, each cluster is considered a dynamic traffic clustering unit. These units are spatially irregular and change dynamically at different time scales. For example, during the morning rush hour, a unit may behave as a typical "commuter-generating area" (residential area), while during the evening rush hour it may become a "commuter-attracting area" (business area).
[0046] Variable standardization, multicollinearity testing, and spatial autocorrelation testing are performed on multi-scale clustering units. This reduces the errors that data may introduce into subsequent modeling and analysis, ensuring the accuracy and reliability of the research results.
[0047] Step 3: Feature Engineering and Integration This step prepares input features for the deep learning model, and the key lies in fusing traffic features with POI semantic features; specifically, it includes: 1. Unit-level feature extraction: Spatial Relationship Features: Constructing a spatial relationship graph between units. Each dynamic traffic cluster unit is considered a node in the graph. If two units are spatially adjacent or have significant OD flow connections, an edge is established between them. The weight of the edge can be determined by the magnitude of the OD flow.
[0048] For the traffic analysis units obtained based on the clustering algorithm, the data of each analysis unit is processed to obtain the Euclidean distance matrix, the road network distance matrix, and the travel time matrix. The Euclidean distance is directly established through the centroids between the cluster units, as shown in the following formula:
[0049] in, Represents a cell The coordinates of the centroid, Represents a cell centroid coordinates, Euclidean distance matrix It is A symmetric matrix with the following elements:
[0050] The road network distance matrix is constructed by calculating the average vehicle mileage from a given cluster unit to its destination within that cluster unit, as shown in the following formula:
[0051] in, This indicates the starting cell (belonging to the set of spatial cells S). This represents the destination cell (which belongs to the set of spatial cells S). Indicates starting from the first cell to the destination cell The number of vehicles, Indicates the first The car from Drive to The driving distance (of which) =1, 2, ... ), the distance matrix of the entire road network It is The matrix has the following elements:
[0052] The travel time matrix is established by calculating the average travel time of vehicles from the starting point to the end point of a certain cluster, as shown in the following formula:
[0053] in, This indicates the starting cell (belonging to the set of spatial cells S). This represents the destination cell (which belongs to the set of spatial cells S). Indicates starting from the first cell to the destination cell The number of vehicles, Indicates the first The car from Drive to The passage time (of which) =1, 2, ... ), the entire travel time distance matrix It is The matrix has the following elements:
[0054] POI semantic embedding features: Input the POI category vector in each unit into an embedding layer, or normalize the vector to obtain a low-dimensional, dense semantic feature vector, which is used to characterize the core function of the unit.
[0055] 2. Feature fusion: The sequence features, POI semantic embedding features, and node representations in the spatial relationship graph of each dynamic traffic clustering unit are concatenated to form the final fused feature vector of that unit.
[0056] Step 4: Building and training a traffic prediction model based on deep learning: This step utilizes the fused features to train an end-to-end traffic prediction model; specifically, it includes: 1. Model Architecture Design: 1) Spatial Feature Modeling: A neural network is used to process the spatial relationship graph constructed in step three. This component is responsible for capturing the spatial associations between different dynamic traffic clustering units.
[0057] 2) Geographically Weighted Regression Modeling: A geographically weighted regression model is used to explore the spatial nonstationarity of vehicle density under different built environments, giving the model results better geospatial interpretability. The core calculation formulas of the entire model are as follows:
[0058] Will Substituting the ordinary linear regression estimate into the above equation, we get:
[0059] in, or Indicates spatial location Predicted values for dependent variables (such as traffic flow). Representing the The spatial coordinates (such as latitude and longitude) of an observation point are used to identify its geographical location. Indicates the location First The local coefficient estimates of each independent variable. In the GNNWR model, these coefficients vary with spatial location, capturing spatial heterogeneity. Indicates the first The observation point The actual values of the independent variables. Indicates the location First The weights of the independent variables. These weights are generated by the neural network model and are used to adjust for the influence of the ordinary linear regression coefficients at different positions. It reflects the strength of spatial dependence. Indicates the first Global coefficient estimates for ordinary linear regression (ORL) with 10 independent variables.
[0060] 2. Model Training: 1) Loss function: The mean squared error (MSE) or mean absolute error (MAE) is used as the loss function to minimize the difference between the predicted flow and the actual flow.
[0061] 2) Optimizer: The Adam optimizer is used to iteratively update the model parameters.
[0062] 3) Training data: The fused feature vector generated in step 3 and its corresponding real traffic data of future time slices are used as training samples and divided into training set, validation set and test set according to a certain ratio (e.g., 8:1:1).
[0063] 3. Model Prediction: The unit representations containing spatial information output by the neural network are input into the geographic weighted regression model to obtain the coefficients of each influencing factor, and finally regression prediction is performed through a fully connected layer.
[0064] Step 5: Traffic Flow Forecasting and Output: This step is the final application stage of the method; specifically, it includes: 1. Traffic flow prediction for the test set: Input real-time / historical data. Process the multi-source data (consistent with the model input length) at the current moment according to steps 1 to 3 to generate fused feature vectors for each dynamic traffic cluster unit at the current moment. Model training: Train the model using data from the training set. After training, validate the model's accuracy using data from the validation set. Execute prediction: Input the fused feature vectors generated from the multi-source data in the test set into the deep learning model trained in step 4. Output results: The model outputs the predicted inflow and outflow traffic for each dynamic traffic cluster unit in the test set. These results can be visualized on a map or provided to a traffic management platform via an API for real-time traffic guidance and decision support.
[0065] 2. Traffic flow prediction for a randomly selected target point within the study area: The Kriging interpolation method is used to obtain traffic flow predictions for a given location. First, N traffic analysis units (selected by distance or travel time) are chosen around the location. Traffic flow data for these areas is obtained through a model. Then, Kriging interpolation is used to obtain the predicted traffic flow for the target location. The core of Kriging interpolation lies in its statistical basis and the utilization of spatial autocorrelation. It is based on the first law of geography: things that are close together are more similar than things that are far apart. Kriging quantifies this spatial correlation through a mathematical model. Its core objective is to provide an optimal linear unbiased estimate. Compared to other deterministic interpolation methods, Kriging's significant advantage is that it not only provides the predicted value but also an estimate of the prediction error, thus quantifying the uncertainty of the prediction.
[0066] Example 2 This invention provides a method for predicting traffic flow by fusing multi-source urban data and constructing multi-scale clustering units to divide and analyze dynamic urban functional zones. For example... Figure 1 As shown, it includes the following steps: S1: First, preprocess the multi-source data by cleaning the population density, road density, POI data, transportation hub accessibility data, and spatiotemporal big data of taxi orders within a certain city island. Then, perform coordinate transformation and filtering on the cleaned spatiotemporal big data of taxi orders to construct taxi order datasets for morning, noon, and evening peak hours. Simultaneously, based on the "5D" dimensions, construct datasets for built environment factors such as population density, road density, various POI densities, and transportation hub accessibility.
[0067] S2: Multi-scale traffic analysis unit partitioning. Based on the origin and departure point data of taxis within a city island, multi-scale clustering is performed using clustering algorithms (density clustering or spectral clustering) to generate traffic analysis units (KTAZ) at different scales. The clustering results are as follows: Figure 4 As shown.
[0068] S3: Traffic analysis unit validation requires standardization, multicollinearity testing, and spatial autocorrelation testing of existing traffic analysis units. Standardization is a commonly used data preprocessing method in data analysis, aiming to unify the value ranges of different variables and eliminate biases caused by differences in units of measurement. In this example, Z-score standardization is used. By calculating the difference between each observation and the variable's mean, and then dividing by the standard deviation, the variable is converted to a standard normal distribution with a mean of 0 and a standard deviation of 1. This method eliminates data skewness, unifies units of measurement, facilitates cross-dimensional comparisons, and enhances the accuracy of distance-based algorithms, ensuring a true reflection of the distance between Z-score values. The formulas for standardizing the independent and dependent variables using Z-score standardization are as follows:
[0069]
[0070] In the formula, and These are the standardized values of the independent and dependent variables; and The sample means of the independent and dependent variables; and To study spatial units The actual values of the independent and dependent variables; and represents the sample standard deviation of the independent and dependent variables.
[0071] This example uses the variance inflation factor (VIF) to test for multicollinearity, as shown in the following formula:
[0072] VIF represents the ratio of the variance of the estimated regression coefficients to the variance if there were no linear correlation between the explanatory variables. When the VIF value is greater than 10, it indicates that the variable has significant multicollinearity. When it exists, it may reduce the explanatory power of the model, leading to unstable regression coefficients, increased standard error, or even erroneous results.
[0073] Moran's I is one of the most commonly used methods to study spatial autocorrelation, and its calculation formula is shown below:
[0074] Moran's I index ranges from -1 to 1. A value closer to +1 indicates a positive spatial correlation, while a value closer to -1 indicates a negative spatial correlation. A value of 0 indicates a spatially random distribution. In spatial autocorrelation testing, in addition to calculating Moran's I index, the statistical significance of the test must be evaluated, which is achieved through the p-value. The p-value represents the probability of Moran's I index or a more extreme case occurring when the null hypothesis (spatial randomness) is true. If the p-value is below a set threshold (e.g., 0.05), the null hypothesis is rejected, indicating significant spatial autocorrelation. If the p-value is high, the spatial distribution is considered random, and there is no significant spatial autocorrelation.
[0075] S4: Construct various distance matrices. Using taxi order datasets from morning, noon, and evening peak hours, construct Euclidean distance matrices, road network distance matrices, and travel time distance matrices for different spatial units during these peak hours. The steps and methods for constructing these distance matrices are as follows: Figure 2As shown, the specific method is as follows: For the Euclidean distance matrix, first find the centroid of each spatial cell, then calculate the distance between the centroids of different cells. The resulting distance matrix is the Euclidean distance matrix, which is a symmetric matrix. For the road network distance matrix, first find the distance from all vehicles within a spatial cell to other cells, then average this distance for different destination cells. This averages the distance from one cell to another, and so on, to obtain the road network distance matrix of the study area. This matrix is asymmetric. Construct a... The passage time matrix is defined, where m represents the total number of spatial units, and the elements in the passage time matrix are set. The value is the average travel time for all orders with a uniquely coded spatial cell i as the boarding point and a uniquely coded spatial cell j as the alighting point. This matrix is asymmetric.
[0076] S5: Using the travel time-distance matrix as input, the model is used to determine the relationship between taxi traffic and the urban built environment. Specific influencing factor coefficients can be obtained from the model and output as a heatmap. The model framework diagram is as follows: Figure 3 As shown, the heatmap of the influence factor coefficients is as follows: Figure 5 As shown in the figure, this graph can reflect that the same influencing factor has different effects on traffic flow in different analysis units. At the same time, when analyzed at different scales, it can be found that the intensity of the same influencing factor will also change, but whether its influence is positive or negative generally remains unchanged.
[0077] S6: When predicting traffic flow in a specific traffic unit, a model is used to combine the influence factor coefficients of N nearby traffic units with their traffic flow. The model's prediction principle is to calculate the influence factor coefficients of the target traffic unit based on a trained weight matrix, and then further calculate the traffic flow of that traffic unit using these influence factor coefficients. For traffic flow prediction at any target point within the study area, Kriging interpolation is used. For each point to be predicted, based on its spatial relationship (distance and direction) with surrounding known points, a Kriging equation system is established using a fitted variogram model. Solving the equation system yields the optimal weights for each known point, and then the predicted value for that point is calculated using a weighted average. The weights depend not only on the distance but also on the spatial configuration relationship between known points. The establishment of the variogram model first calculates the empirical semivariogram, i.e., the semivariogram of all known point pairs within different distance intervals (lag distances). Then, a theoretical semivariogram model is fitted, fitting the empirical semivariogram points into a continuous theoretical model. Commonly used models include spherical models, exponential models, and Gaussian models.
[0078] Based on multi-source data such as taxi trajectory data and built environment POI data of a certain city, this study investigates the spatiotemporal distribution and heterogeneity of taxis in the city. Then, based on traffic flow data in the study area, it predicts traffic flow in the target area, providing a scientific basis for optimizing urban transportation resources and analyzing travel patterns. This will facilitate the effective management and planning of transportation resources, improve travel patterns, reduce congestion, and enhance urban travel efficiency.
[0079] The embodiments described above are merely illustrative of specific implementations of the present invention, and while the descriptions are detailed, they should not be construed as limiting the scope of the present invention. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of the present invention, and these modifications and improvements all fall within the scope of protection of the present invention.
Claims
1. A traffic flow prediction method based on deep learning and multi-scale clustering units, characterized in that, Includes the following steps: Step 1: Multi-source heterogeneous data acquisition and preprocessing: Collect raw data from multiple channels and perform cleaning, standardization and spatiotemporal alignment; Step 2: Construct multi-scale dynamic traffic clustering units: First, construct a multi-scale feature matrix, and then perform dynamic clustering to construct analysis units that reflect the dynamic functional areas of the city. Step 3, Feature Engineering and Fusion: Prepare input features for the deep learning model and fuse traffic features with POI semantic features; Step 4: Construction and training of a deep learning-based traffic prediction model: Using the fused features, train an end-to-end traffic prediction model. Step 5: Use the traffic flow prediction model to predict and output traffic flow.
2. The traffic flow prediction method based on deep learning and multi-scale clustering units according to claim 1, characterized in that, In step 1, the raw data includes traffic trajectory data, city point of interest (POI) data, city road network data, building data, and city population data.
3. The traffic flow prediction method based on deep learning and multi-scale clustering units according to claim 1, characterized in that, In step 1, spatiotemporal alignment includes spatial alignment and temporal alignment. Spatial alignment first uses multi-scale clustering to cluster the starting points and OD flows of all trajectories into a grid cell, and then associates them with the corresponding reference grid according to the latitude and longitude coordinates of the built environment. Temporal alignment divides a day into continuous time slices and aggregates all traffic data into the corresponding time slices according to the timestamp.
4. The traffic flow prediction method based on deep learning and multi-scale clustering units according to claim 3, characterized in that, In step 2, the multi-scale feature matrix includes traffic flow features, internal traffic features, and POI semantic features.
5. The traffic flow prediction method based on deep learning and multi-scale clustering units according to claim 4, characterized in that, In step 2, the dynamic clustering is specifically as follows: First, a time scale is selected, and cluster analysis is performed on the feature matrices of all grids in the study area at representative time scales. Second, a clustering algorithm is executed, using an algorithm that automatically determines the number of clusters. Finally, clustering units are generated, and each cluster is regarded as a dynamic traffic clustering unit. Variable standardization, multicollinearity test, and spatial autocorrelation test are performed on the multi-scale clustering units.
6. The traffic flow prediction method based on deep learning and multi-scale clustering units according to claim 5, characterized in that, Step 3 specifically includes: (1) Unit-level feature extraction: Spatial association features: Construct a spatial relationship graph between units, treating each dynamic traffic cluster unit as a node in the graph. If two units are spatially adjacent or have significant OD flow connections, an edge is established between them, and the weight of the edge is determined by the magnitude of the OD flow. For the traffic analysis units obtained based on the clustering algorithm, the data of each analysis unit is processed to obtain the Euclidean distance matrix, the road network distance matrix, and the travel time matrix. The Euclidean distance is established by the centroids between the cluster units, as shown in the following formula: ; in, Represents a cell The coordinates of the centroid, Represents a cell centroid coordinates, Euclidean distance matrix It is A symmetric matrix with the following elements: ; The road network distance matrix is constructed by calculating the average vehicle mileage from a given cluster unit to its destination within that cluster unit, as shown in the following formula: ; in, Indicates the starting cell, Indicates the target cell, Indicates starting from the first cell to the destination cell The number of vehicles, Indicates the first The car from Drive to The driving distance, of which, =1, 2, ... Distance matrix of the entire road network It is Let S be a matrix, and S be a set of spatial cells, whose elements are: ; The travel time matrix is established by calculating the average travel time of vehicles from the starting point to the end point of a certain cluster, as shown in the following formula: ; in, Indicates the starting cell, Indicates the target cell, Indicates starting from the first cell to the destination cell The number of vehicles, Indicates the first The car from Drive to The passage time, among which, =1, 2, ... The entire travel time distance matrix It is The matrix has the following elements: ; POI semantic embedding features: Input the POI category vector in each unit into an embedding layer, or normalize the vector to obtain a low-dimensional, dense semantic feature vector to characterize the core function of the unit. (2) Feature fusion: The sequence features, POI semantic embedding features, and node representations in the spatial relationship graph of each dynamic traffic clustering unit are concatenated to form the final fused feature vector of that unit.
7. The traffic flow prediction method based on deep learning and multi-scale clustering units according to claim 6, characterized in that, In step 4, the method for constructing the traffic prediction model specifically includes: 1) Spatial feature modeling: Neural networks are used to process the constructed spatial relationship graph and capture the spatial associations between different dynamic traffic clustering units; 2) Geographically Weighted Regression Modeling: A geographically weighted regression model is used to explore the impact of different built environments on the spatial nonstationarity of vehicle density. The geographically weighted regression model is as follows: ; Will Substituting the ordinary linear regression estimate into the above equation, we get: ; in, or Indicates spatial location The predicted value of the dependent variable; Representing the The spatial coordinates of each observation point are used to identify its geographical location; Indicates the location First Local coefficient estimates of the independent variables; Indicates the first The observation point The actual values of the independent variables; Indicates the location First The weights of the independent variables; Indicates the first Global coefficient estimates for ordinary linear regression of 1 independent variables.
8. The traffic flow prediction method based on deep learning and multi-scale clustering units according to claim 7, characterized in that, In step 4, when training the traffic prediction model, the loss function uses the mean squared error (MSE) or the mean absolute error (MAE) to minimize the difference between the predicted traffic and the actual traffic. The optimizer uses the Adam optimizer to iteratively update the model parameters; it uses the fused feature vector and its corresponding real traffic data of future time slices as training samples, and divides them into training set, validation set and test set according to a preset ratio.
9. The traffic flow prediction method based on deep learning and multi-scale clustering units according to claim 7 or 8, characterized in that, In step 5, traffic flow prediction includes: predicting traffic flow in the test set and predicting traffic flow at random target points within the study area; specifically, predicting traffic flow in the test set is as follows: Input real-time / historical data, process the multi-source data of the current moment according to steps 1 to 3, and generate the fused feature vector of each dynamic traffic cluster unit at the current moment; Model training, train the model with data in the training set, and verify the accuracy of the model with data in the validation set after training; Execute prediction, input the fused feature vector generated from the multi-source data in the test set into the deep learning model trained in step 4; Output results, the model outputs the predicted inflow and outflow of each dynamic traffic cluster unit in the test set; The traffic flow prediction for random target points within the study area is as follows: The traffic flow forecast for a target location is obtained by using Kriging interpolation. First, N traffic analysis units around the target point are selected. Traffic flow data for the area is obtained through the model. Then, the traffic flow forecast for the target location is obtained by using Kriging interpolation.
Citation Information
Patent Citations
Smart city operation and maintenance management method and system based on artificial intelligence, and storage medium
CN116758744A
Community traffic flow prediction and optimization system based on artificial intelligence
CN118982927A
Holographic road network and Internet of Vehicles fusion method and device, equipment and storage medium
CN119397480A
Traffic prediction method based on mixed LSTM-GCN architecture
CN119992833A
Urban traffic flow prediction method and system
CN120279728A