Traffic prediction method, storage medium and computing device based on multi-layer K-nearest neighbor

By constructing highly correlated state vectors through the multi-layer K-nearest neighbor algorithm and screening neighbor data based on Euclidean distance and amplitude change trends, combined with the support vector regression algorithm, the problem of extracting spatiotemporal features of urban road networks is solved, and the accuracy of short-term traffic flow prediction is improved.

CN120355044BActive Publication Date: 2025-09-09CHANGAN UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510846564.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-06-24
Publication Date
2025-09-09
Estimated Expiration
2045-06-24

AI Technical Summary

Technical Problem

Existing technologies are difficult to effectively extract the spatiotemporal characteristics of urban road networks, resulting in low accuracy in short-term traffic flow prediction.

Method used

The multi-layer K-nearest neighbor algorithm is used to construct a highly correlated state vector, and the neighbor data is screened by Euclidean distance and amplitude change trend, and then the support vector regression algorithm is combined for prediction.

Benefits of technology

It improves the accuracy of short-term prediction of urban traffic flow, can effectively deal with the strong nonlinearity and randomness of urban traffic data, and improves the accuracy of the prediction algorithm.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120355044B_ABST
    Figure CN120355044B_ABST
Patent Text Reader

Abstract

The present invention belongs to the field of intelligent transportation technology and discloses a traffic prediction method, storage medium, and computing device based on a multi-layer K-nearest neighbor algorithm. The method comprises: S1, collecting traffic flow data; S2, calculating the correlation coefficient of time series data between sampling points, selecting #imgabs0# nearest neighbors using a K-nearest neighbor algorithm, and constructing current and historical state vectors; S3, selecting #imgabs1# nearest neighbors using a K-nearest neighbor algorithm based on Euclidean distance; S4, calculating the first-order difference of traffic flow data at the sampling points, constructing an amplitude change trend vector of the current state vector and the Euclidean distance nearest neighbor data; selecting #imgabs2# nearest neighbors using a K-nearest neighbor algorithm; and S5, predicting traffic flow using a support vector regression algorithm. By constructing a highly correlated state vector and dually screening the state vector based on Euclidean distance and amplitude change trend, the present invention can effectively address the strong nonlinearity and randomness of urban traffic data and improve the accuracy of the prediction algorithm.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of intelligent transportation technology, and in particular relates to a traffic prediction method, a storage medium and a computing device based on multi-layer K-nearest neighbors. Background Art

[0002] With the rapid growth of urban populations and motor vehicles, road traffic problems such as traffic congestion and traffic accidents are becoming increasingly prominent and have become a bottleneck restricting urban development. Intelligent Transportation Systems (ITS) are new transportation technologies proposed to improve the traffic environment. Short-term traffic forecasting, as a key component of ITS, is an indispensable tool for travel planning and traffic control, especially on highly congested urban roads with increased spatiotemporal complexity. Reliable and accurate forecasts can improve the operating efficiency of the entire transportation system while reducing the probability of traffic accidents. It is generally considered that short-term traffic forecasts are those with a time span of no more than 15 minutes. Therefore, accurate and rapid traffic forecasting is key to alleviating traffic congestion and reducing the occurrence of traffic accidents.

[0003] Currently, algorithms used for traffic forecasting can generally be divided into three categories. The first category is based on traditional statistical models, primarily including the historical mean method, Kalman filtering, and time series methods. These algorithms have simple structures and struggle to accurately model complex nonlinear and random traffic systems, particularly short-term traffic forecasting. The second category is based on deep learning models, primarily including long-short-term memory networks, convolutional neural networks, and graph neural networks. These algorithms can accurately model complex traffic scenarios and achieve high prediction accuracy, but they require high data quantity and quality, and also face challenges such as difficulty in parameter tuning and slow algorithm convergence. Specifically, re-tuning and retraining are often required for different scenarios, increasing prediction complexity. The third category is based on traditional machine learning models, primarily including the K-nearest neighbor method, support vector machine methods, and Bayesian networks. These algorithms can handle the nonlinearity and randomness in traffic forecasting and offer rapid computational speeds.

[0004] K-nearest-neighbor nonparametric regression is a common traffic flow prediction algorithm, achieving excellent results on urban expressways and highways. However, for urban road networks, which have a more complex spatiotemporal structure and strong time-varying scene dynamics, the traditional K-nearest-neighbor method can only match state vectors using Euclidean distance, making it difficult to effectively extract spatiotemporal features of the road network. Therefore, how to quickly and effectively extract spatiotemporal features of the road network to improve the accuracy of short-term traffic flow prediction is an urgent problem to be solved. Summary of the Invention

[0005] The purpose of the present invention is to provide a traffic prediction method, storage medium and computing device based on multi-layer K nearest neighbor, so as to effectively solve the problem that the above-mentioned existing technologies are difficult to effectively extract the spatiotemporal characteristics of the road network. Specifically, first, the multi-layer K nearest neighbor algorithm is used to perform spatiotemporal correlation analysis on the traffic data of the collected road network sections to construct a strongly correlated state vector; secondly, the Euclidean distance of the neighboring data is selected by the Euclidean distance between the current state vector and the historical state vector; on this basis, the amplitude change trend state vector is constructed by the first-order difference of the Euclidean distance neighboring data, and finally the neighboring data with the most similar Euclidean distance and amplitude change trend is selected. Finally, based on the finally selected neighboring data, the next moment true value of the neighboring data and the data to be predicted is obtained respectively, the input and output data are constructed, and the prediction is performed in combination with the support vector regression algorithm to improve the short-term prediction accuracy of urban traffic flow.

[0006] In order to achieve the above object, the present invention adopts the following technical solutions:

[0007] In a first aspect, the present invention provides a traffic prediction method based on multi-layer K-nearest neighbor, comprising the following steps:

[0008] S1. Set up one sampling point on each road section in the target area and collect traffic flow data at each sampling point in real time;

[0009] S2. Based on the traffic flow data of all sampling points obtained in S1, characterize the time series data of different sampling points under different delay periods; calculate the correlation coefficient of the time series data between sampling points under different delay periods, and select neighbors; according to the selected The nearest neighbors construct the current state vector and the historical state vector;

[0010] S3, calculate the Euclidean distance between the current state vector and the historical state vector, and select the K nearest neighbor algorithm based on the Euclidean distance. Euclidean distance neighbor data;

[0011] S4. Calculate any sampling point b At the moment Traffic flow data The first-order difference value of , and normalize the positive and negative parts of the difference value respectively; according to the normalized result of the first-order difference value, calculate the corresponding difference value when the cumulative distribution function of the difference value is taken in the range of 10%~90% with a step size of 10%; define the corresponding difference value according to the obtained The amplitude change trend of the current state vector is calculated by calculating the first-order difference value of the current state vector and S3. The first-order difference value of the Euclidean distance neighbor data is used to construct the current state vector and S3 The amplitude change trend vector of the Euclidean distance neighboring data; obtained based on the current state vector and S3 The Euclidean distance of the amplitude change trend vector of the Euclidean distance neighboring data is finally selected using the K nearest neighbor algorithm. a close neighbor;

[0012] S5, based on the final selection of S4 Neighbor data, obtain this in the historical feature database sample The first element of the historical state vector of the final neighbor data at the next moment; the selected The elements are sorted from small to large as the input of the support vector regression algorithm, and the support vector regression algorithm is used to treat the predicted sampling points a exist Traffic flow prediction at each moment.

[0013] In a second aspect, the present invention provides a computer-readable storage medium storing a program, comprising:

[0014] The program includes instructions, and when the instructions are executed by a computing device, the computing device is caused to execute the traffic prediction method based on multi-layer K nearest neighbors of the present invention.

[0015] In a third aspect, the present invention provides a computing device, comprising:

[0016] A processor, a memory, and a program, wherein the program is stored in the memory and configured to be executed by the processor, and the program includes instructions for executing the traffic prediction method based on multi-layer K nearest neighbors of the present invention.

[0017] Compared with the prior art, the present invention has at least the following beneficial effects:

[0018] (1) The traffic prediction method based on multi-layer K-nearest neighbor of the present invention. The multi-layer K-nearest neighbor algorithm is used to construct a highly correlated state vector, extract neighbor data of Euclidean distance and amplitude change trend, and combine it with the support vector regression algorithm to achieve short-term prediction of traffic flow. Compared with the existing technology, this method can construct a highly correlated state vector and perform dual screening of the state vector based on Euclidean distance and amplitude change trend, effectively addressing the strong nonlinearity and randomness of urban traffic data and improving the accuracy of the prediction algorithm.

[0019] (2) This paper uses the K-nearest neighbor method and Pearson correlation to quantify the correlation between sampling points at different delay periods, thereby constructing a highly correlated state vector. Compared with traditional traffic prediction methods based on the K-nearest neighbor algorithm, this method can improve the speed and accuracy of state vector construction.

[0020] (3) The neighbor matching mechanism designed in this invention uses the Euclidean distance between the current state vector and the historical state vector to filter the Euclidean distance neighbor data. Compared with the existing technology, this method can fully utilize the spatiotemporal characteristics of the road network and improve the accuracy of neighbor data screening.

[0021] (4) Based on the selected Euclidean distance neighbor data, the first-order difference of the Euclidean distance neighbor data is calculated to construct the amplitude change trend state vector. Then, the K-nearest neighbor method is used to select the neighbor data with the most similar Euclidean distance and amplitude change trend for prediction. Compared with the existing technology, this method can double-screen the Euclidean distance and amplitude change trend of the state vector, improve the quality of the K-nearest neighbor method neighbor data, and improve the accuracy of the prediction.

[0022] (5) Based on the final selected nearest neighbor data, the support vector regression algorithm is combined to achieve short-term traffic flow prediction. This method can effectively address the strong nonlinearity and randomness of urban traffic data and improve the accuracy of the prediction algorithm.

[0023] In summary, the traffic prediction method based on multi-layer K-nearest neighbors disclosed in the present invention can effectively cope with the strong nonlinearity and randomness of urban traffic data by constructing highly correlated state vectors and performing dual screening of the state vectors based on Euclidean distance and amplitude change trend, thereby improving the accuracy of the prediction algorithm. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] Figure 1 Schematic diagram of sampling location;

[0025] Figure 2 This is a schematic diagram of the actual road network structure of the experimental data of the present invention;

[0026] Figure 3 The present invention has different neighbor values The prediction error result diagram of downsampling point 1 in the training set; the left half and the right half are the MAE and MSE results, respectively.

[0027] Figure 4 The present invention has different neighbor values and The prediction error results of downsampling point 1 in the training set are shown in the figure. The left and right halves are the MAE and MSE results, respectively.

[0028] The present invention is further explained below with reference to the accompanying drawings and specific embodiments. DETAILED DESCRIPTION

[0029] The traffic prediction method based on multi-layer K-nearest neighbor of the present invention first uses the traffic sampling information of the target road network as a basis, and uses the K-nearest neighbor algorithm to quantify the correlation between sampling points under different delay periods in the road network to construct a strongly correlated state vector; secondly, the K-nearest neighbor algorithm is used again to select Euclidean distance neighbor data through the Euclidean distance between the current state vector and the historical state vector; on this basis, the amplitude change trend state vector is designed by calculating the first-order difference of the Euclidean distance neighbor data, and the K-nearest neighbor algorithm is used to finally select neighbor data whose distance and amplitude change trends are most similar; finally, based on the finally selected neighbor data, the support vector regression algorithm is combined to realize short-term traffic data prediction.

[0030] The traffic prediction method based on multi-layer K-nearest neighbor provided by the present invention comprises the following steps:

[0031] S1. Set up one sampling point on each road section in the target area and collect traffic flow data at each sampling point in real time. The traffic flow data of all sampling points in the target area is expressed as:

[0032]

[0033]

[0034] Where:

[0035] —Traffic flow data of sampling points within the target area;

[0036] —Sampling points i Traffic flow data;

[0037] m —The number of sampling points within the target area;

[0038] j — sampling time;

[0039] —Sampling points i exist j Traffic flow data at all times;

[0040] —The number of sampling moments.

[0041] See also Figure 1 ,The red circle represents the road intersection, the black line segment represents the road segment, the arrow represents the road driving direction, and there is a sampling point on each road segment, with a total of 13 sampling points.

[0042] S2. Based on the traffic flow data of all sampling points obtained in S1, characterize the time series data of different sampling points under different delay periods; calculate the correlation coefficient of the time series data between sampling points under different delay periods, and select neighbors; according to the selected The current state vector and the historical state vector are constructed by the nearest neighbors.

[0043] S2 specifically includes the following sub-steps:

[0044] S201, based on the traffic flow data of the sampling points obtained in S1, the sampling points to be predicted a In the delay period The following time series data is represented as:

[0045]

[0046] Where:

[0047] a —the sampling point to be predicted, ;

[0048] t — the current moment;

[0049] τ —delay period;

[0050] —Time series length. Since traffic flow data has a strong periodicity, The value does not need to be too large. The present invention selects the historical data of the previous week for subsequent calculation of the correlation size;

[0051] —Sampling point to be predicted a exist Traffic flow data at all times;

[0052] —Sampling point to be predicted a In the delay period The following time series data;

[0053] S202, in order to quantify the correlation between sampling points under different delay periods, calculate and Pearson correlation coefficient , the calculation formula is as follows:

[0054]

[0055] Where:

[0056] b—Sampling point, which can refer to any sampling point in the road network and can be compared with the sampling point to be predicted a same;

[0057] —Time series data and covariance of

[0058] —Sampling point to be predicted a In the delay period Time series data below 0 (i.e. original time series data);

[0059] —Sampling points b In the delay period The following time series data;

[0060] 、 — 、 The standard deviation of

[0061] — and The correlation coefficient represents the correlation between the two. In particular, when When and Correlation coefficient of

[0062] S203, is the current state vector, is the historical state vector, the absolute value of the Pearson correlation coefficient is the distance between the current state vector and the historical state vector ( The larger the value, the stronger the correlation). ( is the maximum delay period) and (Sampling point b It is necessary to traverse all sampling points in the road network (including the sampling points to be predicted a )) When the K nearest neighbor algorithm is used to select the historical state vector from large to small Neighbors , , , , , ,according to The nearest neighbors correspond to the set of sampling points under different delay periods:

[0063]

[0064] Where:

[0065] —A collection of time series data of sampling points at different delay periods, where the elements in the collection are highly correlated;

[0066] —In all historical state vectors, the sampling point In the delay period The time series data below is The correlation is the largest i , among which ;

[0067] S204, the state vector used for prediction is composed of the set It is composed of elements in , which can effectively reflect the similarity and change trend of the current state in historical data. Specifically, the current state vector and the historical state vector Expressed as:

[0068]

[0069]

[0070]

[0071] Where:

[0072] — historical feature database capacity ratio, ;

[0073] —Sampling points exist Traffic flow data at all times;

[0074] —Number of samples in the historical feature database. In the present invention, the previous data as historical feature database samples, where is the number of sampling moments.

[0075] In particular, since the selection in S203 is from large to small, the sampling points to be predicted are a In the delay period Time series data below 0 With itself ( ) , the correlation is the strongest. Therefore, the current state vector The first element in The variable to be predicted , the current state vector and the historical state vector They are represented as follows:

[0076]

[0077]

[0078] Reasonable construction of the state vector is the key to accurate prediction of the K-nearest neighbor algorithm, and S2 provides the necessary foundation for algorithm prediction.

[0079] S3. Calculate the current state vector With the historical state vector The Euclidean distance between them is selected using the K nearest neighbor algorithm based on the Euclidean distance. Euclidean distance neighbor data.

[0080] Specifically, calculate the current state vector With the historical state vector The Euclidean distance between them is arranged from small to large, and the Euclidean distances between them are selected. The smallest Euclidean distance between Historical state vector As Euclidean distance neighbor data. The Euclidean distance of the nearest neighbor data s The corresponding time of the Euclidean distance neighbor data j for ,but The Euclidean distance of the nearest neighbor data is expressed as:

[0081] .

[0082] in, refer to The Euclidean distance of the nearest neighbor data s The index of the time corresponding to the Euclidean distance neighbor data.

[0083] S4. Calculate sampling points b At the moment Traffic flow data The first-order difference value of , and normalize the positive and negative parts of the difference value respectively; according to the normalized result of the first-order difference value, calculate the corresponding difference value when the cumulative distribution function of the difference value is taken in the range of 10%~90% with a step size of 10%; define the corresponding difference value according to the obtained The amplitude change trend of the current state vector is calculated by calculating the first-order difference value of the current state vector and S3. The first-order difference value of the Euclidean distance neighbor data is used to construct the current state vector and S3 The amplitude change trend vector of the Euclidean distance neighboring data; obtained based on the current state vector and S3 The Euclidean distance of the amplitude change trend vector of the Euclidean distance neighboring data is finally selected using the K nearest neighbor algorithm. A close neighbor.

[0084] S4 specifically includes the following sub-steps:

[0085] S401, when , Calculate sampling points b At the moment Traffic flow data The first-order difference value of is expressed as , obtaining all differential values; preferably, all differential values ​​may be normalized to obtain normalized differential values, specifically normalizing the positive and negative parts of the differential values ​​to between 0 and 1 and between -1 and 0, respectively;

[0086] S402. Calculate the corresponding difference values ​​of the cumulative distribution function of the difference values ​​when the cumulative distribution function of all the difference values ​​is 10%, 20%, 30%, 40%, 50%, 60%, 70%, 80%, and 90% respectively based on all the difference values ​​obtained in S401. 、 、 、 、 、 、 、 、 , as shown in Table 1, where the cumulative distribution function , x represents the difference value, i ∈1~9; Table 1 reflects the cumulative distribution of the state variable amplitude change trend.

[0087] Table 1 Cumulative distribution of state variable amplitude change trend

[0088]

[0089] S403: The corresponding difference value of the cumulative distribution function obtained in step S402 is used to define the sampling point b exist j Traffic flow data at all times The amplitude change trend is:

[0090] ;

[0091] in, —Sampling points b exist j Traffic flow data at all times The amplitude change trend of

[0092] S404, calculate the current state vector respectively The first-order difference value and S3 are obtained The first-order difference values ​​of the Euclidean distance neighbor data are expressed as: and ;

[0093] S405: Construct the current state vector according to the definition of S403 and the first-order difference value obtained in S404. and S3 gets The amplitude change trend vectors of the Euclidean distance neighboring data are expressed as:

[0094]

[0095]

[0096] Where:

[0097] —Current state vector The amplitude change trend vector of ;

[0098] —S3 got The amplitude change trend vector of the Euclidean distance neighboring data, ;

[0099] S406: Calculate the amplitude change trend vector of the current state vector obtained in step S405 and The amplitude change trend vector of the Euclidean distance neighboring data Euclidean distance between , and arrange them from small to large. Finally, select the Euclidean distance smallest ( ) as the final nearest neighbor data, whose distance and amplitude change trends are most similar to the target sampling point. The nearest neighbor data g The corresponding time of the Euclidean distance neighbor data j for , then the final selected indivual( ) The neighbor data is represented as:

[0100] .

[0101] S5, based on the final selection of S4 Neighbor data, obtain this in the historical feature database sample The first element of the historical state vector of the final neighbor data at the next moment; the selected The elements are sorted from small to large as the input of the support vector regression algorithm, and the support vector regression algorithm is used to treat the predicted sampling points a exist Traffic flow prediction at each moment.

[0102] S5 specifically includes the following sub-steps:

[0103] S501, selected according to S4 The final neighbor data , , obtain this in the historical feature database sample The final historical state vector of the neighbor data at the next moment ,according to Get The first element of the historical state vector of the final neighbor data at the next moment , and group them into variables :

[0104]

[0105] Where, — The moment corresponding to the historical state vector of the final neighbor data;

[0106] S502, will middle The elements are sorted from small to large as the input of the support vector regression algorithm, and then the support vector regression algorithm is used to treat the predicted sampling points a exist Traffic flow prediction at each moment.

[0107] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings herein can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present invention provided in the drawings is not intended to limit the scope of the claimed invention, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.

[0108] The data used in this experiment includes 20 days of traffic flow data of 13 sections (sampling points) connected by four intersections in the local road network of Furong District, Changsha City. The actual road network distribution is as follows: Figure 2 As shown in the figure, the data collection interval is 5 minutes, and 288 data points are collected daily. This records the traffic flow data for 20 days from September 17, 2013 to October 6, 2013, at 13 sampling points. Short-term prediction generally uses a 15-minute interval. Therefore, the present invention accumulates the three data points collected every 15 minutes to form one data point, thus obtaining data for a 15-minute sampling period. Each sampling point has 96 data points per day, for a total of 1920 data points over 20 days.

[0109] The present invention uses 1440 data (1-1440) of the first 15 days to build a historical feature database; the first 280 data (1441-1720) of the last 5 days are used as a training set to determine 、 and The value of and training support vector regression algorithm; the last 200 (1721-1920) as the test set for the evaluation of the algorithm prediction results. In addition, the present invention selects the RBF radial basis kernel function as the support vector regression algorithm kernel function, the penalty factor and kernel parameters Set to 0.5, The present invention selects sampling point 1 as the sampling point to be predicted, and selects three metric functions, namely, mean absolute error (MAE), mean absolute percentage error (MAPE), and mean square error (MSE), as evaluation indicators of model performance. The formulas of the three metric functions are defined as:

[0110]

[0111]

[0112]

[0113] in, represents the true value; The smaller the MAE, MSE, and MAPE values, the better the prediction effect of the method.

[0114] To determine The present invention is different in The corresponding state vector is constructed under the value, the K nearest neighbor algorithm is used to select the nearest neighbor data in the training set, and the mean of the nearest neighbor data is calculated as the prediction result for comparing different Impact on forecast accuracy. Figure 3 , showing that when , the prediction error results when the nearest neighbor value is 5, 10, 15, 20, 25 and 30 respectively (because the change trends of the three errors are basically the same, only the performance of MAE and MSE is analyzed). From the results, we can see that the prediction error is from tends to be stable and the minimum error is appears, so it is determined The value is 11, and an 11-dimensional state vector is constructed. Specifically, sampling point 1 is delayed by cycles 0 and 1, sampling point 2 is delayed by cycle 0, sampling point 3 is delayed by cycles 0 and 1, sampling point 4 is delayed by cycle 0, sampling point 6 is delayed by cycle 0, sampling point 9 is delayed by cycles 0, 1, and 2, and sampling point 12 is delayed by cycle 0. The cumulative distribution results of the state variable amplitude change are shown in Table 2:

[0115] Table 2 Cumulative distribution of state variable amplitude change trend

[0116]

[0117] Therefore, the amplitude change trend can be expressed as follows:

[0118]

[0119] for and For the value of Figure 4 , it can be seen that when , The prediction error MAE and MSE results of sampling point 1 on the training set at time . The red line represents In the case of different values ​​from 1 to 50, The error of the multi-layer K nearest neighbor algorithm under the optimal condition is taken; the degenerate multi-layer K nearest neighbor represented by the blue line, that is, when The error of the multi-layer K nearest neighbor algorithm when the amplitude change trend is lost. When, due to is very small, so the amplitude change trend of the selected Euclidean distance neighbor data is also closest to the current state vector, so the two curves basically coincide; when When the amplitude change trend matching comes into play, Among the Euclidean distance neighbor data, further select The nearest neighbor data that is most similar to the change trend of the current state vector is used for prediction, so the subsequent multi-layer K nearest neighbor errors are all smaller than the degenerate multi-layer K nearest neighbor errors; When the K value is too large, too many interference data with little correlation are selected. The error of increasing the multi-layer K-nearest neighbor algorithm and the error of degenerating the multi-layer K-nearest neighbor algorithm both show an increasing trend. Starting MAE and MSE errors as The MAE and MSE errors of the degenerate multi-layer K-nearest neighbor and multi-layer K-nearest neighbor algorithms are respectively and ( ) reaches its minimum. Therefore, the degenerate multi-layer K nearest neighbor , multi-layer K-nearest neighbor ( ) to make predictions.

[0120] Finally, in the model of the present invention 、 and The values ​​are 11, 15 and 13. The prediction performance of the present invention is verified on the test set, and the prediction error results are shown in Table 3.

[0121] Table 3 Prediction errors of different prediction algorithms at sampling point 1

[0122]

[0123] The above analysis demonstrates that the proposed method utilizes a multi-layer K-nearest neighbor algorithm to extract the spatiotemporal characteristics of the road network, construct a strongly correlated state vector, and extract the nearest neighbor data with the most similar Euclidean distance and amplitude change trends. This, combined with the support vector regression algorithm, produces more accurate prediction results. The results show that the proposed prediction algorithm achieves MAE = 6.0396, MSE = 61.4873, and MAPE = 0.0884, outperforming traditional K-nearest neighbor-based prediction algorithms in all three metrics.

[0124] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware. Furthermore, the present application may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0125] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 a process or multiple processes and / or boxes Figure 1A device that provides the functions specified in a block or multiple blocks.

[0126] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.

[0127] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0128] The above content is only for explaining the technical idea of ​​the present invention and cannot be used to limit the protection scope of the present invention. Any changes made on the basis of the technical solution in accordance with the technical idea proposed by the present invention shall fall within the protection scope of the claims of the present invention.

Claims

1. A traffic prediction method based on multi-layer K-nearest neighbor, characterized in that: The following steps are involved: S1. Set up one sampling point on each road section in the target area and collect traffic flow data at each sampling point in real time; S2. Based on the traffic flow data of all sampling points obtained in S1, characterize the time series data of different sampling points under different delay periods; calculate the correlation coefficient of the time series data between sampling points under different delay periods, and select k1 nearest neighbors using the K-nearest neighbor algorithm based on the correlation coefficient; construct the current state vector and the historical state vector based on the selected k1 nearest neighbors; S3, calculate the Euclidean distance between the current state vector and the historical state vector, and select k2 Euclidean distance nearest neighbor data using the K nearest neighbor algorithm based on the Euclidean distance; S4. Calculate the traffic flow data q at any sampling point b at time j b (j) first-order difference value, and normalize the positive and negative parts of the difference value respectively; According to the normalization result of the first-order difference value, the corresponding difference value when the cumulative distribution function of the difference value is taken in the range of 10% to 90% with a step size of 10% is calculated; Define q according to the corresponding difference value obtained b (j) Amplitude variation trend; Calculate the first-order difference value of the current state vector and the first-order difference value of the k2 Euclidean distance neighbor data obtained by S3, and construct the amplitude change trend vector of the current state vector and the k2 Euclidean distance neighbor data obtained by S3; Based on the Euclidean distance of the amplitude change trend vector of the current state vector and the k2 Euclidean distance neighbor data obtained by S3, use the K-nearest neighbor algorithm to finally select k3 neighbors; S5. Based on the k3 nearest neighbor data finally selected in S4, obtain the first element of the historical state vector of these k3 final nearest neighbor data at the next moment in the historical feature database sample; sort the selected k3 elements from small to large and use them as the input of the support vector regression algorithm, and use the support vector regression algorithm to predict the traffic flow of the sampling point a to be predicted at time t+1.

2. The traffic prediction method based on multi-layer K-nearest neighbor as claimed in claim 1, characterized in that: In S1, the traffic flow data of all sampling points in the target area is expressed as: S=[S1,S2,…,S i ,…,S m ] S i =[q i (1),q i (2),…,q i (j),…,q i (n)] Where: S—traffic flow data of sampling points within the target area; S i —Traffic flow data at sampling point i; m—the number of sampling points within the target area; j—sampling time; q i (j)—traffic flow data of sampling point i at time j; n—the number of sampling moments.

3. The traffic prediction method based on multi-layer K-nearest neighbor as claimed in claim 2, characterized in that: S2 specifically includes the following sub-steps: S201. Based on the traffic flow data of the sampling point obtained in S1, the time series data of the sampling point a to be predicted under the delay period τ is expressed as: S a (τ)=[q a (t-τ),q a (t-τ-1),…,q a (t-τ-(l-1))] Where: a—the sampling point to be predicted, a∈{1,2,…,m}; t—current moment; τ—delay period; l—time series length; q a (t-τ)—the traffic flow data of the sampling point a to be predicted at time t-τ; S a (τ)—time series data of the sampling point a to be predicted under the delay period τ; S202, to quantify the correlation between sampling points under different delay periods, calculate S a (0) and S b Pearson correlation coefficient R of (τ) b,τ : Where: b—any sampling point in the road network; cov(S a (0),S b (τ))—time series data S a (0) and S b covariance of (τ); S a (0)—time series data of the sampling point a to be predicted when the delay period τ is 0; S b (τ)—time series data of sampling point b under the delay period τ; —S a (0), S b Standard deviation of (τ); R b,τ —S a (0) with S b (τ) correlation coefficient; when b=a, it means S a (0) with S a (τ) correlation coefficient; S203, S a (0) is the current state vector, S b (τ) is the historical state vector, the absolute value of the Pearson correlation coefficient |R b,τ | is the distance between the current state vector and the historical state vector, when 0≤τ≤τ max When 1≤b≤m, τ max For the maximum delay period, the K nearest neighbor algorithm is used to select k1 nearest neighbors from the historical state vector from large to small According to the k1 nearest neighbors, we can get the set of sampling points under different delay periods: Where: H—the collection of time series data of sampling points at different delay periods; (b i ,τ i )—In all historical state vectors, sampling point b i In the delay period τ i The time series data under S a (0) has the largest correlation of the i-th one, where 1≤i≤k1; S204, the current state vector X(t) and the historical state vector X h (j) is expressed as: 1≤j≤n h ,n h =p h ×n Where: p h — historical feature database capacity ratio, 0 <p h <1; —Sampling points In j-τ k1 Traffic flow data at all times; n h —Number of samples in the historical feature database; The first element in the current state vector X(t) is the variable to be predicted q a (t), the current state vector X(t) and the historical state vector X h (j) are respectively represented as follows:

4. The traffic prediction method based on multi-layer K-nearest neighbor as claimed in claim 3, characterized in that: S3 specifically includes the following operations: Calculate the current state vector X(t) and the historical state vector X h (j), and sort all the obtained Euclidean distances from small to large, and select the k2 historical state vectors X with the smallest Euclidean distance from the current state vector X(t) h (j) as Euclidean distance neighbor data.

5. The traffic prediction method based on multi-layer K-nearest neighbor as claimed in claim 4, characterized in that: The values ​​of k1, k2 and k3 are 11, 15 and 13 respectively.

6. A computer-readable storage medium storing a program, characterized in that: include: The program includes instructions, and when the instructions are executed by a computing device, the computing device executes the traffic prediction method based on multi-layer K-nearest neighbors according to any one of claims 1 to 5.

7. A computing device, characterized in that include: A processor, a memory, and a program, wherein the program is stored in the memory and configured to be executed by the processor, and the program includes instructions for executing the traffic prediction method based on multi-layer K nearest neighbors according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Urban road vehicle running speed forecasting method based on road network characteristics

    CN104464304A

  • Highway pavement rainfall distribution estimation method, storage medium and computing equipment

    CN112036630A