KNN-Attention-LSTM winter road surface temperature prediction method based on stacking integration
Through the KNN-Attention-LSTM method based on Stacking integration, the problem of limited accuracy in winter road temperature prediction is solved, and higher prediction accuracy and stability are achieved, especially the prediction effect in the critical area of the phase change is significantly improved.
Patent Information
- Application Number
- CN202510622540.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-15
- Publication Date
- 2025-06-13
- Estimated Expiration
- 2045-05-15
AI Technical Summary
Traditional winter road meter temperature prediction methods are difficult to effectively capture the dynamic changes and nonlinear characteristics of road meter temperature, resulting in limited prediction accuracy, especially in the critical temperature interval of phase change, which needs to be improved.
The KNN-Attention-LSTM winter road table temperature prediction method based on Stacking integration is adopted. By obtaining historical traffic meteorological data, quality control and feature screening, two basic learners, KNN-LSTM and Attention-LSTM, and meta-learners are constructed through Stacking integration technology, and weighted summing or combinations are performed to obtain the final prediction results.
It significantly improves the prediction accuracy and stability of road surface temperature in winter, especially in the critical phase transition zone, which significantly improves the prediction accuracy, which can provide timely and accurately, and supports traffic safety management and deicing and anti-slip measures.
Smart Images

Figure CN120144939A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of meteorological applications, and particularly to a method for predicting winter road surface temperature based on stacking integrated KNN-Attention-LSTM. Background Technique
[0002] The evolution mechanism of road surface temperature (RST) is significantly correlated with traffic risks. Under the critical condition of winter thermodynamic equilibrium, the phase change threshold of road surface temperature directly determines the condensation form of road surface water vapor. When the temperature drops to the critical freezing point value, the road surface friction coefficient will undergo a stepwise decline. This phase change triggers three cascading effects: ① The adhesion force between the tire and the road surface contact area decays by more than 40%; ② The vehicle braking performance curve shows a non-linear distortion; ③ The traffic flow stability parameter breaks through the safety threshold. By establishing a dynamic model of road surface temperature and other meteorological elements, high-resolution forecasting of future road surface temperature can be achieved.
[0003] Precise short-term prediction of road surface temperature faces many challenges. First, road surface temperature is comprehensively affected by various meteorological factors, including air temperature, humidity, precipitation, wind speed, etc. There are complex non-linear relationships and time lags among these factors. Second, road surface temperature has significant spatio-temporal heterogeneity, and the temperature change patterns vary greatly in different road sections and different time periods. Especially under the condition of changing meteorological conditions, the difficulty of precise short-term prediction is further increased. Traditional winter road surface temperature prediction methods mostly rely on physical models or simple linear regression analysis, and it is difficult to effectively capture the dynamic changes and non-linear characteristics of winter road surface temperature, resulting in limited prediction accuracy. In recent years, the successful application of deep learning technology in the field of time series prediction provides a new idea for winter road surface temperature prediction. In particular, the long short-term memory network (LSTM) and its improved models perform excellently in dealing with complex time dependencies, bringing new possibilities for improving the prediction accuracy of road surface temperature.
[0004] However, the standard LSTM model still has many deficiencies in practical applications, including insufficient flexibility in feature processing, limited spatio-temporal feature fusion ability, and untimely response to sudden meteorological events. In particular, the prediction accuracy in the phase change critical temperature range needs to be improved. These limitations restrict the practical application effect of the LSTM model in road surface temperature prediction. Summary of the Invention
[0005] The purpose of the present invention is to solve the above technical problems and provide a method for predicting winter road surface temperature based on stacking integrated KNN-Attention-LSTM.
[0006] To achieve the above object, the technical solution adopted by the present invention is: a KNN-Attention-LSTM winter road surface temperature prediction method based on Stacking integration, which is characterized by including the following steps: Step S1, obtain the historical data of the traffic meteorological monitoring station, including visibility, air temperature, humidity, precipitation, wind speed, wind direction and road surface temperature; Step S2, perform quality control on the data, including time alignment, outlier processing and missing value filling; Step S3, calculate the Spearman rank correlation coefficient between the winter road surface temperature and other meteorological elements, and screen out the features with strong correlation; Step S4, use the Stacking integration technology to construct a KNN-Attention-LSTM prediction model, specifically: Step S41, use two basic learners, KNN-LSTM and Attention-LSTM, to learn and predict the input data respectively; Step S42, on the basis of Step S41, Stacking constructs a meta-learner by using the prediction results of KNN-LSTM and Attention-LSTM as feature inputs, and uses linear regression to perform weighted summation or combination on the outputs of the two basic models; Step S43, use the scaler_target.inverse_transform function to inverse-standardize the prediction results of the meta-model to obtain the final prediction results; Step S5, input real-time meteorological data and output the predicted values of the road surface temperature for the next 1-72 hours.
[0007] As a preference of the present invention, the specific method of Step S41 is: Use the KNN-LSTM model to capture the long-term dependencies of the time series, extract the physical boundaries through KNN, and add these boundaries as constraint terms to the LSTM loss function: ; Among them, is the weight of the physical constraint, which controls the influence degree of the physical constraint loss; The Attention-LSTM model adjusts the weights of the time steps through the self-attention mechanism on the basis of the LSTM output, learns which time steps have a greater impact on the prediction results, and enhances the feature capture ability of the model through the multi-head attention mechanism: ; Among them, Q is the query matrix, K is the key matrix, and V is the value matrix, It is the dimension of the key. By calculating the similarity between the query and the key, the attention weights are obtained, and the weighted sum is calculated to obtain the final output.
[0008] For each input data sample, each base model gives a predicted value: ; ; Among them, and are the predicted values obtained through the KNN-LSTM and Attention-LSTM models respectively.
[0009] As a preference of the present invention, the specific method of the step S42 is: Using the meta-learner to take the prediction results of the two models in the first layer as input features: ; Then, use the linear regression meta-model to learn how to combine the prediction results of these two base models: ; Among them, , , are the parameters obtained through linear regression training.
[0010] As a preference of the present invention, the above steps further include: Step S6, the system regularly evaluates the prediction performance of the model, calculates the mean absolute error MAE and root mean square error RMSE of the prediction results; when the MAE exceeds the preset threshold or the prediction accuracy drops, the system will automatically trigger the update mechanism and re-perform feature selection and model training using the latest collected traffic meteorological historical data.
[0011] As a preference of the present invention, in the step S6, during each update, the system analyzes the contribution of features to the prediction of winter road surface temperature according to the Spearman rank correlation coefficient, automatically screens out the meteorological factors with greater contributions, eliminates the features with poor prediction effects, retrains and optimizes the KNN-Attention-LSTM model and the Stacking integration strategy. After the model update is completed, the system obtains the measured data every minute in real time for rolling prediction.
[0012] As a preference of the present invention, the method for quality control of data in the step S2 includes: Outlier detection: Using descriptive statistical analysis and boxplots to identify abnormal data points, setting reasonable thresholds for meteorological elements, and marking the data outside the range as abnormal; Outlier handling: For single-point outliers, interpolation using the average value of the previous and subsequent moments is adopted; for continuous outliers, if they conform to meteorological laws, they are retained and marked; if they are obviously incorrect, the sliding window average method is used for correction. Missing value filling: For continuous missing values, linear interpolation is used. For non-continuous missing values, a combination of forward filling and backward filling is used, and the average of the two is taken.
[0013] Time alignment: Check whether the timestamps are arranged at the set time intervals. If there are minor deviations, align them to the standard time point nearby. Data consistency guarantee: Unify the units to ensure that all meteorological elements adopt standard units.
[0014] In summary, the present application includes at least one of the following beneficial technical effects: The present invention relates to a method for predicting the road surface temperature in winter on expressways. This method utilizes data such as visibility, air temperature, humidity, precipitation, wind direction, wind speed, and road surface temperature from highway traffic meteorological monitoring stations, as well as the constructed sliding window optimization, physical constraints, Attention mechanism, and LSTM, etc., to accurately predict the road surface temperature in winter and provide timely and accurate prediction results. Through innovative model design and optimized data processing strategies, this method provides timely and accurate prediction results for traffic safety management, deicing and anti-skid measures, and traffic command departments, significantly improving the prediction performance and system practicality. The present invention integrates and optimizes multiple deep learning models, dynamically adjusts the weights of key meteorological elements through the Attention mechanism, and solves the problem of rigid feature processing in traditional LSTM; combines the KNN-LSTM hybrid architecture to synchronously capture spatio-temporal features and overcomes the defect of insufficient spatio-temporal modeling ability of a single LSTM; introduces physical constraints to significantly improve the prediction accuracy in the phase change critical region, and the prediction accuracy and stability are significantly improved.
[0015] In terms of data processing and method optimization, the present invention adopts a systematic strategy to improve the prediction accuracy and calculation efficiency. Feature selection is carried out through the Spearman rank correlation coefficient, redundant variables are eliminated, and the input data is streamlined; at the same time, the application of time series cross-validation and the rolling window strategy ensures the generalization ability of the model in the time series and significantly shortens the response time to sudden meteorological events.
[0016] The present invention has strong portability, can be fine-tuned according to the meteorological data of different stations, supports the addition of new data to optimize the model parameters, and can perform rolling prediction of the road surface temperature in winter for the next 1 hour to 72 hours to meet the business requirements. By accurately predicting the road surface temperature in winter, the present invention provides a prediction data basis for highway meteorological guarantee and decision-making management. The traffic command department can timely discover the risk of road icing, optimize resource allocation, reduce traffic accidents, and is of great significance for reducing maintenance costs, improving traffic quality, and operation benefits. Description of the Drawings
[0017] Figure 1 is the flowchart of the embodiment of the present invention. Detailed Description of the Invention
[0018] The following further elaborates on the present invention in conjunction with the attached Figure 1 drawings.
[0019] Refer to Figure 1 , this embodiment discloses a KNN-Attention-LSTM winter road surface temperature prediction method based on stacking integration, including the following steps: Step S1, obtaining traffic meteorological historical data: Use the observation data of the M9393 traffic meteorological station west of the Longhai Railway Bridge. The data is stored in a database with a time interval of 5 minutes. The data includes: visibility, air temperature, humidity, precipitation, wind speed, wind direction, and road surface temperature.
[0020] Step S2, perform data quality control on the obtained data, specifically: Step 2.1 Data quality inspection Step 2.1.1 Outlier detection: Use descriptive statistical analysis (mean, standard deviation, quantile) and boxplots (box-and-whisker plots) to identify abnormal data points. Set reasonable thresholds for meteorological elements (such as temperature range [-30°C, 50°C], wind speed range [0, 30 m / s]). Data outside the range is marked as abnormal. Special processing is performed on consecutive outliers (such as more than 3 consecutive 5-minute data points exceeding the threshold) to avoid misjudging extreme weather events.
[0021] Step 2.1.2 Missing value identification: Detect missing values in the data (such as invalid identifiers like -999, NaN, NULL, etc.). Distinguish short-term missing (single-point or a small number of discontinuous missing) and long-term missing (consecutive multiple time points missing) to adopt different filling strategies.
[0022] Step 2.2 Data quality control Step 2.2.1 Time alignment: Check whether the timestamps are strictly arranged at the set time interval (such as 5 minutes). If there are minor deviations (such as 5 minutes and 10 seconds), align them to the standard time point nearby.
[0023] Step 2.2.2 Outlier processing: Single-point outliers: Use the mean interpolation of the previous and next moments (i.e., replace with the average of the previous moment and the next moment).
[0024] Consecutive outliers: If they conform to meteorological laws (such as extreme weather), retain and mark them; if they are obviously incorrect, use the moving window mean method to correct them.
[0025] Step 2.2.3 Missing value filling: For continuous missing values (short-term missing values), linear interpolation (based on the fitting of valid data before and after) is used. For non-continuous missing values (sporadic points), forward filling (FFill) and backward filling (BFill) are combined to take the average of the two (if both are valid). For long-term missing values (≥3 points), regression estimation is performed using the correlation between meteorological elements (such as the relationship between temperature and humidity, wind speed), or filling is performed by referring to the data of neighboring stations.
[0026] Step 2.3 Data consistency assurance: Unify units to ensure that all meteorological elements use standard units (such as temperature °C, wind speed m / s). Eliminate invalid data, directly eliminate long-term missing measurements or abnormal values that cannot be repaired, and record logs. Data distribution correction: For data that obviously does not conform to meteorological laws (such as -20 °C in summer), adjust it in combination with historical data for the same period.
[0027] Step S3: Extracting meteorological features related to road surface temperature: The Spearman rank correlation coefficient was used to analyze the correlation between meteorological characteristics and winter road surface temperature, and the characteristics with low correlation with the target variable (winter road surface temperature) were removed to improve the prediction accuracy of the model. Finally, the following characteristics were selected as the input of the model: air temperature, humidity, precipitation, wind speed, wind direction and road surface temperature.
[0028] Step S4, KNN-Attention-LSTM integrated model construction: Based on the selected features, the KNN-Attention-LSTM prediction model is constructed using the Stacking integration method: First layer: Use two basic learners, KNN-LSTM and Attention-LSTM, to learn and predict the input data respectively.
[0029] The KNN-LSTM model combines the KNN (K-Nearest Neighbors) algorithm with the LSTM model to capture the long-term dependencies of time series, extract physical boundaries (constraints) through KNN, and add these boundaries as constraints to the LSTM loss function: ; in, It is the weight of the physical constraint, which controls the influence of the physical constraint loss.
[0030] Based on the LSTM output, the Attention-LSTM model adjusts the weight of the time step through the self-attention mechanism, learns which time steps have a greater impact on the prediction results, and enhances the model's feature capture ability through the multi-head attention mechanism: ; Among them, Q is the query matrix, K is the key matrix, and V is the value matrix. is the dimension of the key. By calculating the similarity between the query and the key, the attention weights are obtained, and the final output is obtained by weighted summation.
[0031] For each input data sample, each base model in the first layer will give a predicted value: ; ; Among them, and are the predicted values obtained through the KNN-LSTM and Attention-LSTM models respectively.
[0032] Second layer: On the basis of the first layer, Stacking constructs a meta-learner by using the prediction results of KNN-LSTM and Attention-LSTM as feature inputs, and uses linear regression to perform weighted summation or combination on the outputs of the two base models.
[0033] The task of this meta-model is to obtain a more accurate final prediction by learning how to combine the prediction results of multiple models in the first layer.
[0034] The meta-learner in the second layer takes the prediction results of the two models in the first layer as input features: ; Then, a linear regression meta-model is used to learn how to combine the prediction results of these two base models: ; Among them, , , are the parameters obtained through linear regression training.
[0035] Inverse normalization: Since the predicted output is processed by standardization, the scaler_target.inverse_transform function needs to be used to inverse normalize the prediction results of the meta-model to obtain the final prediction results: ; Step S5, Performance Analysis and Application of the Model: In the actual application of the road surface temperature prediction model, the system inputs minute-level meteorological monitoring data in real time, including key features such as air temperature, humidity, precipitation, and wind speed. Through the KNN-Attention-LSTM model based on Stacking integration, the system can predict the road surface temperature values for the next 1 to 72 hours and output the prediction results, providing a scientific basis for road icing risk warning, anti-icing and anti-skid measure deployment, and decision-making by traffic management departments, and at the same time providing a reliable reference for public travel information services.
[0036] In terms of model training and updating, the system regularly evaluates the prediction performance of the model and calculates indicators such as the mean absolute error (MAE) and root mean square error (RMSE) of the prediction results. When the MAE exceeds the preset threshold (0.6) or the prediction accuracy decreases, the system will automatically trigger the update mechanism and re-perform feature selection and model training using the latest collected traffic meteorological historical data. In each update, the system analyzes the contribution of features to winter road surface temperature prediction according to the Spearman rank correlation coefficient, automatically screens out meteorological factors with greater contributions (such as air temperature, humidity), eliminates features with poor prediction effects, and re-trains and optimizes the KNN-Attention-LSTM model and the Stacking integration strategy. After the model update is completed, the system obtains the measured data minute by minute in real time for rolling prediction to ensure the timeliness and accuracy of the prediction results, thus meeting the dynamic requirements in road safety management.
[0037] The above are all the preferred embodiments of this application. The protection scope of this application is not limited thereby. Therefore, all equivalent changes made according to the structure, shape, and principle of this application shall be covered within the protection scope of this application.
Claims
1. A KNN-Attention-LSTM winter road surface temperature prediction method based on stacking integration, characterized in that: The following steps are involved: Step S1, obtaining historical data from a traffic weather monitoring station, including visibility, temperature, humidity, precipitation, wind speed, wind direction and road surface temperature; Step S2: Perform quality control on the data, including time alignment, outlier processing and missing value filling; Step S3, calculating the Spearman rank correlation coefficient between winter road surface temperature and other meteorological elements, and screening out features with strong correlation; Step S4: Use Stacking integration technology to build a KNN-Attention-LSTM prediction model, specifically: Step S41: Use two basic learners, KNN-LSTM and Attention-LSTM, to learn and predict the input data respectively; Step S42: Based on step S41, Stacking constructs a meta-learner by taking the prediction results of KNN-LSTM and Attention-LSTM as feature inputs, and uses linear regression to perform weighted summation or combination of the outputs of the two basic models. Step S43: Use the scaler_target.inverse_transform function to denormalize the prediction result of the meta-model to obtain the final prediction result; Step S5: Input real-time meteorological data and output the road surface temperature forecast value for the next 1-72 hours.
2. The KNN-Attention-LSTM winter road surface temperature prediction method based on stacking integration according to claim 1 is characterized in that: The specific method of step S41 is: The KNN-LSTM model is used to capture the long-term dependencies of the time series, and the physical boundaries are extracted through KNN, and these boundaries are added as constraints to the LSTM loss function: ; in, is the weight of the physical constraint, which controls the influence of the physical constraint loss; Based on the LSTM output, the Attention-LSTM model adjusts the weight of the time step through the self-attention mechanism, learns which time steps have a greater impact on the prediction results, and enhances the model's feature capture ability through the multi-head attention mechanism: ; Among them, Q is the query matrix (Query), K is the key matrix (Key), V is the value matrix (Value), is the dimension of the key. By calculating the similarity between the query and the key, the attention weight is obtained, and the weighted sum is used to obtain the final output. For each input data sample, each base model gives a predicted value: ; ; in, and They are the predicted values obtained by KNN-LSTM and Attention-LSTM models respectively.
3. The KNN-Attention-LSTM winter road surface temperature prediction method based on stacking integration according to claim 2 is characterized in that: The specific method of step S42 is: The two model prediction results of the first layer are used as input features by the meta-learner: ; Then, a linear regression meta-model is used to learn how to combine the predictions of these two base models: ; in, , , are the parameters obtained through linear regression training.
4. The KNN-Attention-LSTM winter road surface temperature prediction method based on stacking integration according to claim 1 is characterized in that: It also includes: step S6, the system regularly evaluates the prediction performance of the model, calculates the mean absolute error MAE and root mean square error RMSE of the prediction results; when the MAE exceeds the preset threshold or the prediction accuracy decreases, the system will automatically trigger the update mechanism and use the latest collected traffic meteorological historical data to re-select features and re-train the model.
5. The KNN-Attention-LSTM winter road surface temperature prediction method based on stacking integration according to claim 4 is characterized in that: In step S6, during each update, the system analyzes the contribution of features to the winter road surface temperature prediction based on the Spearman rank correlation coefficient, automatically selects meteorological factors with greater contributions, removes features with poor prediction effects, retrains and optimizes the KNN-Attention-LSTM model and the Stacking integration strategy. After the model update is completed, the system obtains real-time measured data minute by minute for rolling prediction.
6. The KNN-Attention-LSTM winter road surface temperature prediction method based on stacking integration according to claim 4 is characterized in that: The method for performing quality control on data in step S2 includes: Outlier detection: Descriptive statistical analysis and box-and-whisker plots are used to identify abnormal data points, reasonable thresholds for meteorological elements are set, and data outside the range are marked as abnormal; Outlier processing: Single-point outliers are interpolated using the mean of the previous and next moments; continuous outliers are retained and marked if they conform to meteorological laws; if they are obviously wrong, they are corrected using the sliding window mean method; Missing value filling: For continuous missing values, linear interpolation is used. For non-continuous missing values, forward filling and backward filling are combined, and the average of the two is taken; Time alignment: Check whether the timestamps are arranged at the set time interval. If there is a slight deviation, align them to the nearest standard time point; Data consistency assurance: Unify units to ensure that all meteorological elements use standard units.
Citation Information
Patent Citations
Road surface temperature short-term and temporary prediction method and system based on feature engineering and LSTM
CN113536665A
Winter asphalt pavement surface temperature prediction method based on integrated deep learning
CN115495816A
Improved LSTM combined attention mechanism distiller's yeast pit temperature prediction method
CN118585933A
Expressway pavement temperature forecasting method based on physical constraint
CN119249075A