Method for predicting formation and maintenance time of fog droplets based on random forest-transformer fusion
By fusing random forest and Transformer models, and combining SMOTE and dynamic window sampling strategies, a collaborative forecasting method for rime formation and duration is constructed. This method solves the problems of low temporal resolution and neglected duration in rime forecasting, and achieves accurate forecasting of the entire life cycle of rime.
Patent Information
- Application Number
- CN202510548163.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-28
- Publication Date
- 2025-11-04
- Estimated Expiration
- 2045-04-28
AI Technical Summary
Existing rime forecasting methods cannot accurately capture the formation period and meteorological changes of rime, and ignore the duration of rime, resulting in inaccurate forecasts. Furthermore, traditional methods fail to effectively consider the complex coupling effects between meteorological elements.
We employ a fusion of random forest and Transformer models to construct a collaborative forecasting method for the formation and duration of rime ice using hourly meteorological data. We utilize the SMOTE method for data upsampling and combine a dynamic window sampling strategy and cross-validation to optimize the model, outputting a forecast for the entire life cycle of rime ice.
It has achieved accurate forecasting of the formation and duration of rime ice, improved the accuracy and practicality of rime ice life cycle prediction, solved the problem of predicting the duration of rime ice processes, and significantly improved the model's ability to identify rime ice events.
Smart Images

Figure CN120428358B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of weather forecasting, and in particular to a method for predicting the formation and maintenance time of rime based on random forest-Transformer fusion. BACKGROUND
[0002] Rime refers to the direct condensation of water vapor into ice and snow at low temperatures, and is usually found in cold mountainous and valley environments. Rime landscapes not only have high ornamental value, but also have important influences on transportation, safety, and tourism.
[0003] Currently, the analysis and prediction of rime meteorological conditions mainly rely on daily statistical data from meteorological observation stations, such as daily minimum temperature and daily average humidity. However, this method has low time resolution and cannot capture the precise rime formation period and meteorological changes, making it difficult to accurately determine the specific time of rime formation.
[0004] In addition, many current rime prediction methods use static threshold methods, which fail to consider the complex coupling effects between meteorological elements. For example, the interaction between temperature, humidity, and wind speed has an important influence on rime formation, but static threshold methods fail to effectively capture the synergy between these meteorological elements. Moreover, static threshold methods often fail to capture the mutation characteristics of meteorological elements in real time, resulting in inaccurate prediction results.
[0005] The above-mentioned existing rime prediction methods mostly only focus on whether rime will form, ignoring the prediction of the maintenance time of rime after its formation. Traditional methods can only determine whether rime will appear, but cannot track and predict the duration of rime. As rime goes from formation to melting, the changes in meteorological conditions are continuous and complex, which requires a full-life-cycle prediction system, rather than a single "rime" or "no rime" determination.
[0006] Therefore, accurately predicting the formation and maintenance time of rime is crucial for related industries. SUMMARY
[0007] The purpose of the present application is to fuse random forest and Transformer models to achieve accurate prediction of rime formation and maintenance time using hourly meteorological data, thereby improving the accuracy and practicality of rime full-life-cycle prediction.
[0008] The technical solution of the present application is to provide a method for predicting the formation and maintenance time of rime based on random forest-Transformer fusion, which comprises:
[0009] S1, collect the meteorological elements of the target area from the records of the target area ground meteorological elements, space meteorological elements of each layer and the presence of rime, and organize these data into an hourly data set containing ground meteorological elements, space meteorological elements and rime occurrence records;
[0010] S2, extract rime formation prediction factors from the hourly data set, use the SMOTE method to upsample the data to expand the sample size, use the random forest method to build a rime formation prediction model, use the samples in the hourly data set to train the rime formation prediction model, and use cross-validation and grid search to evaluate and optimize the model in the rime formation prediction model;
[0011] S3, extract rime maintenance prediction factors from the hourly data set, use the Transformer method to build a rime maintenance prediction model, and use the dynamic window sampling strategy to increase the number of samples with rime occurrence in the training set, use the samples in the hourly data set to train the rime maintenance prediction model;
[0012] S4, combine the rime formation prediction model and the rime maintenance prediction model to process the meteorological data of the target area in the prediction period, and finally output the hourly rime presence prediction and the duration of the entire rime process;
[0013] Specifically, step S4 includes:
[0014] S41, according to the mode prediction product or the meteorological element deterministic prediction product, obtain the hourly ground meteorological prediction data of the target area, and use the data to build a prediction period feature vector;
[0015] S42, input the feature vector into the rime formation prediction model to obtain the rime formation probability P form , and calculate the rime formation prediction probability T dynamic ;
[0016] S43, continuously monitor the rime judgment dynamic threshold T dynamic , when the rime judgment dynamic threshold T dynamic > 0.65 for 6 consecutive hours, input the feature vector into the rime maintenance prediction model to obtain the rime maintenance prediction probability P maintain of the next 6 hours, if the rime maintenance prediction probability P maintain of the next 6 hours is greater than 0.65, input the feature vector into the rime maintenance prediction model again to obtain the rime maintenance prediction probability of a longer time in the future, until its value is less than 0.65;
[0017] In the above process, when a time t has both rime formation prediction probability T dynamic and rime maintenance prediction probability P maintain , the final rime probability Pfinal(t) T dynamic , P maintain , the maximum value in both, the time instance final fog probability P final(t) > 0.65, it is determined that the time instance has fog, otherwise no, thereby obtaining the forecast period hour by hour fog forecast; interval not more than 2 hours is regarded as the same fog process, the total duration of fog from formation to ablation is calculated, and the fog duration forecast is output.
[0018] In any of the above technical solutions, further, the calculation formula of the fog formation forecast probability T dynamic is:
[0019] T dynamic = P form + 0.05 x RH min - 0.02 x (T current + 2);
[0020] Wherein, RH min is the minimum humidity value in the past 6 hours of the forecast time, T current is the air temperature of the forecast time.
[0021] In any of the above technical solutions, further, step S1 specifically comprises:
[0022] S11, selecting a target area and obtaining ground hourly meteorological observation data from meteorological observation stations in the target area, the ground hourly meteorological observation data including air temperature, dew point temperature, relative humidity, wind speed, precipitation and records of fog presence or absence, with 1 for fog and 0 for no fog;
[0023] S12, data cleaning is performed on the obtained ground hourly meteorological observation data, including eliminating values beyond the reasonable range of meteorological elements and filling in missing data of meteorological observation stations, and the missing data is filled in by regression interpolation method;
[0024] S13, based on the reanalysis data set of the same meteorological type as the target area, spatial layer meteorological element data is obtained by interpolation method, including air temperature, relative humidity, wind speed of upper layer, current layer and lower layer, low cloud amount and total cloud amount data;
[0025] S14, the ground hourly meteorological observation data cleaned in step S12 and the spatial layer meteorological element data obtained in step S13 are processed in a unified format;
[0026] S15, the data after format unification is arranged in time sequence to ensure that the ground meteorological element data and spatial meteorological element data at each time and the record of fog presence or absence are matched, and the arranged data form a complete hourly data set within a time period;
[0027] S16, retrieve the time label satisfying the condition index as "formation event" in the hourly data set, the condition index including: rime, relative humidity > 98%, air temperature < 0℃.
[0028] In any of the technical solutions above, further, the step S2 specifically comprises:
[0029] S21, obtain the ground temperature T and the dew point temperature T d The data is processed to calculate the temperature dew point difference and the temperature stratification, and the calculation processes are as follows:
[0030] Calculate the temperature dew point difference T-T d : T-T d = T 2m -T d2m ; wherein, T 2m is the temperature at 2m above the ground, and T d2m is the dew point temperature at 2m above the ground;
[0031] Calculate the temperature stratification T s : T s = T 下层 -T 当前层 ;
[0032] S22, add the temperature dew point difference and the temperature stratification in the hourly data set, and extract the rime formation prediction factor;
[0033] S23, use the SMOTE method to perform up-sampling processing on the data, and the up-sampling processing specifically comprises:
[0034] For each minority class sample, select its nearest neighbor other minority class sample, and generate a new sample point between them, and the generation formula is: X new = X minority + λ × (X neighbor -X monority ); wherein, λ is a random number with a value range of [0, 1], X minority represents the feature vector of a certain sample in the minority class sample, X neighbor represents the feature vector of another sample which is the nearest neighbor of X minority in the minority class sample, and X new is a new sample generated according to X minority and X neighbor , and the feature vector thereof is obtained by linear interpolation between the two samples;
[0035] S24, divide the sample into a training set and a test set in a ratio of 7:3, and use the random forest algorithm to build a glaze formation prediction model on the training set, the output of the model being a glaze formation prediction probability, the random forest model being composed of multiple decision trees, each decision tree being independently built on a randomly selected sample subset and feature subset, and using the K-fold cross-validation method to train and validate the training set multiple times, dividing the training set evenly into K subsets, each time selecting one as the validation set and the remaining K-1 as the training set, repeating K times to obtain the average performance of the model under each set of parameter configurations in different data divisions;
[0036] During the completion of the cross-validation process, the key hyperparameters in the glaze formation prediction model, including the number of trees, the maximum depth, and the minimum number of split samples, are comprehensively searched, specifically, the candidate value range of each hyperparameter is preset to form a parameter grid, and then each combination of hyperparameters in the grid is subjected to K-fold cross-validation, and the performance indicators on the validation set are recorded, including accuracy and TS score, the TS score calculation formula being: TS = hit number / (hit number + false positive number + false negative number), wherein the hit number is the number of events that occur both in prediction and in reality, the false positive number is the number of events that occur in prediction but not in reality, and the false negative number is the number of events that do not occur in prediction but do occur in reality;
[0037] After traversing all candidate parameter combinations, the best set of hyperparameters is selected in terms of performance indicators, and the glaze formation prediction model is retrained on the entire training set using the best configuration.
[0038] In any of the above technical solutions, further, the glaze formation prediction factors include: month, day, ground temperature, temperature dew point difference, relative humidity, wind speed, precipitation, total cloud cover, low cloud cover, temperature stratification, and air temperature, relative humidity, and wind speed in each layer, totaling 19 factors.
[0039] In any of the above technical solutions, further, step S3 specifically includes:
[0040] S31, extracting glaze maintenance prediction factors from the hourly data set, the glaze maintenance prediction basic factors including: time, air temperature, relative humidity, wind speed, precipitation, and glaze records, totaling 6 factors;
[0041] S32, constructing derived factors based on the glaze maintenance prediction basic factors, calculating the moving average and variance of air temperature and humidity in the previous 24 hours to capture the statistical characteristics of short-term meteorological data; the glaze maintenance prediction factors include all glaze maintenance prediction basic factors and derived factors, i.e., time, air temperature, relative humidity, wind speed, precipitation, air temperature average, air temperature variance, relative humidity average, relative humidity variance, and glaze records, totaling 10 factors;
[0042] S33, a sine / cosine transformation is performed on the time variable to retain the periodicity feature and enhance the learning ability of the model for the diurnal cycle rule, and the transformed time Enc(t) is expressed as:
[0043]
[0044] The numerical features outside the fog record are subjected to Z-Score standardization processing to ensure the consistency of different features in the numerical scale, and the processing formula is:
[0045]
[0046] Wherein, Z is the result of Z-Score standardization processing, x represents the processed feature, μ represents the mean of the training set, and σ represents the standard deviation of the training set;
[0047] S34, a dynamic window sampling strategy is used to solve the class imbalance problem, and the positive sample window is defined as the period from 24 hours before the fog event to the end of the event, which is densely sampled with 1 hour step in this area; The negative sample area is sparsely sampled with a 6-hour step, so that the number of fog samples is effectively supplemented, and the imbalance problem of data class distribution is improved;
[0048] S35, the data set is divided into training set, validation set and test set in time sequence to ensure the time sequence integrity, and the proportion of training set, validation set and test set is 7:2:1; The fog maintenance prediction model is constructed by using the Transformer method and trained by using the training set, and the output of the model is the fog maintenance prediction probability.
[0049] In any of the above technical solutions, further, the working method of the fog maintenance prediction model comprises:
[0050] First, stack the feature vectors of 24 consecutive hours in time sequence to form a two-dimensional feature matrix of 24 rows and 10 columns as the model input, wherein each row corresponds to one hour of meteorological data, and each column represents a different prediction factor;
[0051] A learnable position encoding matrix is introduced in the input layer, which is added to the input features after linear transformation, so that the model can explicitly perceive the time sequence of meteorological data; A plurality of parallel attention heads are set, each head independently calculates the attention weight of the query, key and value vectors, and the correlation strength of each time step is calculated by scaling dot product; The outputs of multiple heads are spliced and subjected to linear transformation to fuse the feature representations of different subspaces; Two fully connected networks are connected after the self-attention layer, and ReLU is used as the activation function; Residual connection is implemented after each self-attention layer and feedforward network layer, and the output of the sublayer is added to the original input, followed by layer normalization processing;
[0052] The 24-hour meteorological feature sequence input by the training set is captured through a neural network model containing a self-attention mechanism to capture the long-range dependence relationship between the space-time features, and the last layer hidden state is mapped to the future 6-hour hourly rime maintenance probability through a full connection layer.
[0053] In any of the technical solutions above, further, the rime maintenance prediction model implements a phased parameter optimization strategy in the training process:
[0054] The first phase determines the structural parameter combination of the attention mechanism in the preset parameter space through a global search algorithm, and the second phase dynamically adjusts the learning rate parameter and the gradient constraint condition based on the feedback of the validation set;
[0055] The generalization ability of the model to unknown time series data is continuously monitored through the validation set, and when the sliding standard deviation of the validation set TS score is lower than the set threshold for consecutive N training periods, the early stopping mechanism is triggered, and the periodic learning rate scheduling algorithm is combined to balance the model convergence process;
[0056] From the multiple model snapshots saved in the training process, the optimal model architecture is selected based on the comprehensive evaluation index of the validation set.
[0057] The beneficial effects of the present application are:
[0058] The technical solution in the present application firstly models through hourly data, accurately captures the critical meteorological conditions for rime formation, proposes a rime maintenance time prediction method, solves the problem of rime process duration prediction, and a hybrid model (random forest + Transformer) considers feature extraction in the formation stage and time series dependence in the maintenance stage, outputs rime full life cycle (appearance-maintenance-melting) prediction products, and improves the accuracy of rime process prediction, better serving scenes such as scenic area opening time planning and tourist sightseeing arrangement.
[0059] In the implementation process of the technical solution of the present application, the SMOTE algorithm is introduced to perform up-sampling processing on the minority class samples, which alleviates the sample imbalance problem caused by the scarcity of rime data, and significantly improves the model's ability to identify rime events. BRIEF DESCRIPTION OF DRAWINGS
[0060] The advantages of the above and additional aspects of the present application will become apparent and easily understood in connection with the following description of the embodiments, in conjunction with the accompanying drawings, in which:
[0061] Figure 1 is a schematic flow chart of a rime formation and maintenance time collaborative prediction method based on random forest-Transformer fusion according to an embodiment of the present application;
[0062] Figure 2is a model fusion architecture diagram of a random forest-Transformer fusion-based ice accretion formation and maintenance time collaborative prediction method according to an embodiment of the present application. DETAILED DESCRIPTION
[0063] In order to enable a more clear understanding of the above-mentioned objects, features and advantages of the present application, the present application will be further described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be noted that the embodiments of the present application and the features in the embodiments can be combined with each other without conflict.
[0064] In the following description, a large number of specific details are set forth in order to facilitate a thorough understanding of the present application, however, the present application can also be implemented in other manners different from those described herein, and therefore, the protection scope of the present application is not limited by the specific embodiments disclosed below.
[0065] As shown in Figure 1 the present embodiment provides a random forest-Transformer fusion-based ice accretion formation and maintenance time collaborative prediction method, which comprises:
[0066] S1, collecting meteorological elements of a target area from multi-source data, and arranging these data into an hourly data set containing ground meteorology, space meteorology and ice accretion occurrence records; by judging the meteorological conditions in the data, marking the time period meeting the specific conditions as an ice accretion “formation event”, laying a data foundation for subsequent model training.
[0067] The multi-source data includes ground meteorological elements of the target area, space meteorological elements of each layer and records of the presence or absence of ice accretion.
[0068] Step S1 specifically comprises:
[0069] S11, selecting a target area and obtaining ground hourly meteorological observation data from meteorological observation stations in the target area, the ground hourly meteorological observation data including air temperature, dew point temperature, relative humidity, wind speed, precipitation and records of the presence or absence of ice accretion, with ice accretion recorded as 1 and no ice accretion recorded as 0.
[0070] S12, data cleaning of the obtained ground hourly meteorological observation data, including eliminating values beyond the reasonable range of meteorological elements and filling in missing data of meteorological observation stations, and the missing data is filled in by a regression interpolation method.
[0071] S13, based on the reanalysis data set of the same meteorological type as the target area, obtaining space meteorological element data of each layer by an interpolation method, the data including air temperature, relative humidity and wind speed of the upper layer, the layer and the lower layer, and obtaining low cloud amount and total cloud amount data.
[0072] For example, based on the global atmospheric reanalysis dataset (ERA5) dataset, the analysis of the top of Emei Mountain is carried out, and the upper layer can be selected as 600 hPa or above, the layer is 700 hPa, and the lower layer can be selected as 850 hPa.
[0073] S14, the ground surface after cleaning in step S12 Hourly weather observation data and spatial weather element data obtained in step S13 are processed in a unified format, and these weather data are converted into a unified standard format including but not limited to:
[0074] Time format unification: unify the time of all data to Beijing time to ensure the consistency of time between different data sources.
[0075] Unit format unification: such as temperature unit unification to Celsius, wind speed unification to meters per second, and humidity and other weather element units also need to be unified.
[0076] S15, the data after format unification are arranged in time sequence to ensure that the ground weather element and spatial weather element data at each time are matched with the record of fog and ice formation, and the arranged data form a complete hourly data set within a time period.
[0077] S16, in the hourly data set, the time marked as "event formation" that meets the condition index is retrieved, and the condition index includes: fog and ice, relative humidity > 98%, and air temperature < 0℃.
[0078] S2, the fog and ice formation prediction factors are extracted from the hourly data set, the random forest method is used to construct the fog and ice formation prediction model, the samples in the hourly data set are used to train the fog and ice formation prediction model, and the cross-validation and grid search are combined to realize more comprehensive model evaluation and hyperparameter optimization, improve the reliability and generalization ability of the model.
[0079] Step S2 specifically includes:
[0080] S21, the ground temperature T and dew point temperature T d are processed, and the temperature dew point difference and temperature stratification are calculated, and the calculation processes are as follows:
[0081] Calculate the temperature dew point difference (T-T d ): T-T d = T 2m -T d2m ; wherein, T 2m is the temperature at 2m of the ground, and T d2m is the dew point temperature at 2m of the ground.
[0082] Calculate the temperature stratification T s : T s = T 下层 -T当前层 ; Take the Emei Mountain Jinding as an example, i.e. T s = T 850 -T 700 , T 850 is the temperature at 850 hPa, and T 700 is the temperature at 700 hPa.
[0083] S22, add the temperature dew point difference and temperature stratification in the hourly data set, and extract the rime formation prediction factors, which include 19 factors such as month, day, ground temperature, temperature dew point difference, relative humidity, wind speed, precipitation, total cloud cover, low cloud cover, temperature stratification, and air temperature, relative humidity, and wind speed of each layer.
[0084] S23, since the rime formation events are relatively rare in actual data, in order to improve the learning ability of the model to the minority class samples, the SMOTE (synthetic minority over-sampling technique) method is used for up-sampling processing of the data, and the specific method is:
[0085] For each minority class sample, select its nearest neighbor other minority class sample, and generate a new sample point between them, and the generation formula is: X new = X minority + λ × (X neighbor -X minority ); wherein λ is a random number with a value range of [0, 1], X minority represents the feature vector of a certain sample in the minority class sample, X neighbor represents the feature vector of another sample in the minority class sample which is the nearest neighbor of X minority , and X new is a new sample generated according to X minority and X neighbor , and the feature vector thereof is obtained by linear interpolation between the two samples.
[0086] Through this method, the number of rime formation event samples is effectively supplemented, thereby improving the imbalance problem of data class distribution.
[0087] S24, according to the proportion of 7:3, the samples are divided into a training set and a test set, and a rime formation prediction model is constructed on the training set by using the random forest algorithm. The output of the model is the rime formation prediction probability, and the random forest model is composed of multiple decision trees. Each decision tree is independently constructed on a randomly selected sample subset and feature subset. The K-fold cross-validation method is used to train and verify the training set multiple times. The training set is evenly divided into K subsets. Each time, one of them is selected as the validation set, and the remaining K-1 are used as the training set. Repeat K times to obtain the average performance of the model in different data divisions under each parameter configuration.
[0088] In the process of completing cross-validation, key hyperparameters in the prediction model of rime formation are comprehensively searched, including the number of trees, maximum depth, minimum number of split samples, etc. Specifically, the candidate value range of each hyperparameter is preset to form a parameter grid, and then K-fold cross-validation is performed for each combination of hyperparameters in the grid. The performance indicators on the validation set are recorded, including accuracy and TS (Threat Score) score. The TS score calculation formula is: TS = hit number / (hit number + false alarm number + false negative number), where the hit number is the number of events that occur and are predicted to occur, the false alarm number is the number of events that are predicted to occur but do not actually occur, and the false negative number is the number of events that are not predicted to occur but actually occur.
[0089] After traversing all candidate parameter combinations, the best set of hyperparameter configurations is selected based on the performance indicators, and the optimal configuration is used to retrain the rime formation prediction model on the entire training set.
[0090] Finally, the rime formation prediction model optimized by cross-validation and grid search not only has high prediction accuracy on the training set, but also shows good generalization ability and robustness on the test set, which can accurately capture the mutation characteristics in the hourly meteorological data and achieve accurate prediction of rime formation events.
[0091] S3, extract rime maintenance prediction factors from the hourly data set, and use the Transformer method to build a rime maintenance prediction model. The samples in the hourly data set are used to train the rime maintenance prediction model.
[0092] Step S3 specifically includes:
[0093] S31, extract rime maintenance prediction factors from the hourly data set, and the rime maintenance prediction basic factors include: time, air temperature, relative humidity, wind speed, precipitation, and rime records, a total of 6 factors.
[0094] S32, based on the rime maintenance prediction basic factors, construct derived factors, calculate the moving average and variance of air temperature and humidity in the previous 24 hours to capture the statistical characteristics of short-term meteorological data; the rime maintenance prediction factors include all rime maintenance prediction basic factors and derived factors, i.e., time, air temperature, relative humidity, wind speed, precipitation, air temperature average, air temperature variance, relative humidity average, relative humidity variance, and rime records, a total of 10 factors.
[0095] S33, perform sine / cosine transformation on the time variable to preserve periodic characteristics and enhance the model's learning ability for the day-night cycle, and the transformed time Enc(t) is expressed as:
[0096]
[0097] The numerical features outside the fog record are subjected to Z-Score standardization processing to ensure consistency of different features in numerical scale, and the processing formula is:
[0098]
[0099] Wherein, Z is the result of Z-Score standardization processing, x represents the processed feature, μ represents the mean of the training set, and σ represents the standard deviation of the training set.
[0100] S34, due to the fact that the fog sample is relatively rare in actual data, in order to improve the learning ability of the model to the minority class sample, a dynamic window sampling strategy is used to solve the class imbalance problem, and the specific method is:
[0101] The positive sample window is defined as the period from 24 hours before the fog event to the end of the event, and the area is densely sampled with 1 hour step; The negative sample area is sparsely sampled with 6 hour step. By this method, the number of fog samples is effectively supplemented, so as to improve the imbalance problem of data class distribution.
[0102] S35, the data set is divided into training set, validation set and test set in time sequence to ensure the integrity of time sequence, and the proportion of training set, validation set and test set is 7:2:1; The fog maintenance prediction model is constructed by using the method of Transformer, and the training set is used for training. The output of the model is the fog maintenance prediction probability. The Transformer model has strong time sequence dependence capture ability and is suitable for processing continuous meteorological data and its complex dynamic change characteristics.
[0103] Specifically, the working method of the fog maintenance prediction model includes:
[0104] First, stack the 24-hour continuous feature vectors in time sequence to form a two-dimensional feature matrix of 24 rows and 10 columns as the model input, wherein each row corresponds to one hour of meteorological data, and each column represents different prediction factors.
[0105] The learnable position encoding matrix is introduced into the input layer, and is added to the input features after linear transformation, so that the model can explicitly perceive the time sequence of meteorological data. Multiple parallel attention heads are set, each head independently calculates the attention weight of the query, key and value vectors, and the correlation strength of each time step is calculated by scaling dot product. The outputs of multiple heads are spliced and then linearly transformed to fuse the feature representations of different subspaces and enhance the model's ability to capture key patterns such as temperature sudden change and humidity continuous change. A two-layer fully connected network is connected after the self-attention layer, and a ReLU activation function is used to introduce a nonlinear transformation to improve the model's representation ability for complex meteorological feature combinations. After each self-attention layer and feedforward network layer, a residual connection is implemented to add the output of the sublayer to the original input, followed by layer normalization processing, which effectively alleviates the gradient vanishing problem and accelerates model convergence.
[0106] The 24-hour meteorological feature sequence input by the training set is used to capture the long-range dependence between spatio-temporal features through a neural network model containing a self-attention mechanism, and the last layer of hidden state is mapped to the future 6-hour hourly rime maintenance probability through a fully connected layer. During the training process, a phased parameter optimization strategy is implemented: in the first phase, the structural parameter combination of the attention mechanism is determined within the preset parameter space through a global search algorithm, and in the second phase, the learning rate parameter and gradient constraint condition are dynamically adjusted based on the feedback of the validation set; the generalization ability of the model to unknown time series data is continuously monitored through the validation set, and when the sliding standard deviation of the validation set TS score is lower than the set threshold for consecutive N training periods, the early stopping mechanism is triggered, and the periodic learning rate scheduling algorithm is used to balance the model convergence process. From the multiple model snapshots saved during the training process, the optimal model architecture is selected based on the comprehensive evaluation index of the validation set. Finally, the rime maintenance prediction model not only has high prediction accuracy on the validation set, but also shows good generalization ability on the test set.
[0107] S4, the meteorological data of the target area in the prediction period is processed by combining the rime formation prediction model and the rime maintenance prediction model, and finally the hourly rime presence or absence prediction and the entire rime process duration are output.
[0108] Step S4 specifically includes:
[0109] S41, according to the mode prediction product or the meteorological element deterministic prediction product, the hourly ground meteorological prediction data of the target area is obtained, including temperature, dew point temperature, relative humidity, wind speed, precipitation, and the temperature, relative humidity, wind speed, low cloud amount and total cloud amount data of the upper layer, the layer and the lower layer; meanwhile, the temperature dew point difference and the temperature stratification feature vector are calculated, and all the above data are used to construct the prediction period feature vector.
[0110] S42, input the feature vector into the rime formation prediction model to obtain the rime formation probability P form, calculate the fog formation prediction probability T dynamic , the calculation formula is:
[0111] T dynamic = P form + 0.05 x RH min - 0.02 x (T current + 2);
[0112] Wherein, RH min is the minimum humidity value in the past 6 hours of the prediction time, T current is the temperature at the prediction time.
[0113] S43, continuously monitor the fog judgment dynamic threshold T dynamic , when the fog judgment dynamic threshold T dynamic > 0.65 for 6 consecutive hours, input the feature vector to the fog maintenance prediction model, obtain the fog maintenance prediction probability P maintain of the next 6 hours, if the fog maintenance prediction probability P maintain > 0.65 for the next 6 hours, input the feature vector to the fog maintenance prediction model again to obtain the fog maintenance prediction probability for a longer time, until the value is less than 0.65.
[0114] In the above process, when a time t has two prediction results of fog formation prediction probability T dynamic and fog maintenance prediction probability P maintain , the final fog probability P final(t) of the time is the maximum value of T dynamic , P maintain , when the final fog probability P final(t) > 0.65, it is determined that there is fog at this time, otherwise there is no fog, so as to obtain the hourly fog prediction in the prediction period; interval no more than 2 hours is regarded as the same fog process, the total duration of the fog from formation to ablation is calculated, and the fog duration prediction is output.
[0115] In summary, the present application proposes a fog formation and maintenance time collaborative prediction method based on random forest-Transformer fusion, which comprises:
[0116] S1, collect meteorological elements of the target area from target area ground meteorological elements, space meteorological elements of each layer and records of fog presence, and arrange these data into hourly data sets containing ground meteorology, space meteorology and fog occurrence records.
[0117] S2, extract the fog formation prediction factor from the hourly data set, use the random forest method to construct the fog formation prediction model, use the samples in the hourly data set to train the fog formation prediction model, and combine the cross-validation and grid search to evaluate and optimize the model.
[0118] S3, extract the fog-mantle maintenance prediction factor from the hourly data set, adopt the Transform method to construct the fog-mantle maintenance prediction model, and use the samples in the hourly data set to train the fog-mantle maintenance prediction model.
[0119] S4, process the meteorological data of the target area in the prediction period in combination with the fog-mantle formation prediction model and the fog-mantle maintenance prediction model, and finally output the hourly fog-mantle presence prediction and the whole fog-mantle process duration.
[0120] The steps in the application can be adjusted in sequence, combined and reduced according to actual needs.
[0121] The units in the device of the application can be combined, divided and reduced according to actual needs.
[0122] Although the application has been disclosed with reference to the attached drawings, it should be understood that these descriptions are merely exemplary and are not intended to limit the application. The scope of protection of the application is defined by the appended claims, and can include various modifications, improvements and equivalent arrangements made to the application without departing from the scope and spirit of the application.
Claims
1. A method for co-predicting the formation and duration of rime ice based on random forest-Transformer fusion, characterized in that, The method includes: S1. Collect meteorological elements of the target area from the data of surface meteorological elements, spatial meteorological elements and records of the presence or absence of rime in the target area, and organize these data into an hourly dataset containing surface meteorology, spatial meteorology and records of rime occurrence; S2. Extract rime formation forecasting factors from the hourly dataset, expand the sample size by upsampling the data using the SMOTE method, construct a rime formation forecasting model using the random forest method, train the rime formation forecasting model using samples from the hourly dataset, and evaluate and optimize the model by combining cross-validation and grid search. S3. Extract rime persistence forecast factors from the hourly dataset, construct a rime persistence forecast model using the Transformer method, increase the number of samples with rime occurrence in the training set through a dynamic window sampling strategy, and train the rime persistence forecast model using samples from the hourly dataset. S4. Combine the rime formation forecast model and the rime maintenance forecast model to process the meteorological data of the target area during the forecast period, and finally output the hourly rime presence forecast and the duration of the entire rime process; Specifically, step S4 includes: S41. Based on model forecast products or meteorological element deterministic forecast products, obtain hourly surface meteorological forecast data for the target area, and use this data to construct a feature vector for the forecast period. S42. Input the feature vector into the rime formation prediction model to obtain the rime formation probability P. form Calculate the predicted probability T of rime formation. dynamic ; S43. Continuously monitor rime ice to determine the dynamic threshold T dynamic When the rime ice lasts for 6 consecutive hours, the dynamic threshold T is determined. dynamic When the value is greater than 0.65, the feature vector is input into the rime ice persistence forecast model to obtain the rime ice persistence forecast probability P for the following 6 hours. maintain If the rime ice persists for the next 6 hours, the predicted probability P maintain If the value is greater than 0.65, the feature vector is input into the rime persistence forecast model again to obtain the rime persistence forecast probability for a longer period of time, until the value is less than 0.
65. In the above process, when there is a predicted probability T of frost formation at a certain time t... dynamic The probability P of maintaining the rime ice forecast maintain When there are two forecast results, the final probability P of rime ice at that time is... final(t) For T dynamic P maintain The maximum of the two values represents the final probability P of frost formation at that time. final(t) If the value is greater than 0.65, it is determined that there is rime ice at that time; otherwise, there is none. This allows us to obtain an hourly forecast of whether or not rime ice will occur during the forecast period. If the interval is no more than 2 hours, it is considered as the same rime ice process. The total duration of rime ice from formation to dissipation is calculated, and the rime ice duration forecast is output.
2. The method for co-predicting the formation and duration of rime ice based on random forest-Transformer fusion as described in claim 1, characterized in that, The predicted probability T of rime formation dynamic The calculation formula is: T dynamic =P form +0.05×RH min -0.02×(T current +2); Among them, RH min To forecast the lowest humidity value in the past 6 hours, T current The temperature for the forecast time.
3. The method for co-predicting the formation and duration of rime ice based on random forest-Transformer fusion as described in claim 1, characterized in that, Step S1 specifically includes: S11. Select the target area and obtain hourly ground meteorological observation data from the meteorological observation station in the target area. The hourly ground meteorological observation data includes records of air temperature, dew point temperature, relative humidity, wind speed, precipitation, and whether there is frost. The presence of frost is recorded as 1, and the absence of frost is recorded as 0. S12. Perform data cleaning on the acquired hourly ground meteorological observation data. Data cleaning includes removing values that exceed the reasonable range of meteorological elements and supplementing missing data from meteorological observation stations. The missing data is supplemented by regression interpolation. S13. Based on the reanalysis dataset with the same meteorological type as the target area, obtain the meteorological element data of each spatial layer through interpolation. This data includes the temperature, relative humidity, and wind speed of the upper layer, the current layer, and the lower layer, and obtain the low cloud cover and total cloud cover data. S14. Perform format unification processing on the hourly ground meteorological observation data cleaned in step S12 and the spatial meteorological element data obtained in step S13. S15. Organize the data after unifying the format according to the time order to ensure that the ground meteorological element and space meteorological element data at each moment match the records of whether or not there is rime. The organized data forms a complete hourly dataset within a time period. S16. Retrieve time events that meet the criteria in the hourly dataset and label them as "formation events". The criteria include: frost, relative humidity > 98%, and temperature < 0℃.
4. The method for co-predicting the formation and duration of rime ice based on random forest-Transformer fusion as described in claim 1, characterized in that, Step S2 specifically includes: S21, regarding ground temperature T and dew point temperature T d The data is processed to calculate the temperature-dew point difference and temperature stratification. The calculation processes for both are as follows: Calculate the temperature-dew point difference TT d TT d =T 2m -T d2m Among them, T 2m The temperature at 2m above the ground, T d2m The dew point temperature is 2m above the ground. Calculate the temperature layer T s :T s =T 下层 -T 当前层 ; S22. Add temperature-dew point difference and temperature stratification to the hourly dataset to extract rime formation forecasting factors; S23. Upsampling the data using the SMOTE method, specifically including: For each minority class sample, select its nearest neighbor other minority class samples, and generate new sample points between them. The generation formula is: X new =X minority +λ×(X neighbor -X minority ); where λ is a random number taking values in the range [0,1], and X minority X represents the feature vector of a single sample in the minority class. neighbor Indicates that in the minority class samples, X minority The feature vector of the nearest neighbor sample, X new It is based on X minority and X neighbor The feature vector of the generated new sample is obtained by linear interpolation between the two samples. S24. Divide the samples into training and test sets in a 7:3 ratio. On the training set, use the random forest algorithm to build a rime formation prediction model. The output of this model is the rime formation prediction probability. The random forest model consists of multiple decision trees. Each decision tree is independently built on a randomly selected subset of samples and a subset of features. Use the K-fold cross-validation method to train and validate the training set multiple times. Divide the training set evenly into K subsets. Each time, select one subset as the validation set and the remaining K-1 subsets as the training set. Repeat this process K times to obtain the average performance of the model under different data partitions for each parameter configuration. During the cross-validation process, a comprehensive search was conducted on the key hyperparameters in the rime formation prediction model, including the number of trees, maximum depth, and minimum number of split samples. Specifically, candidate value ranges for each hyperparameter were pre-defined to form a parameter grid. Then, K-fold cross-validation was performed on each combination of hyperparameters in the grid, and its performance metrics on the validation set were recorded. The performance metrics included accuracy and TS score. The TS score was calculated as follows: TS = number of hits / (number of hits + number of false alarms + number of false alarms), where the number of hits is the number of events that were predicted to occur and actually occurred, the number of false alarms is the number of events that were predicted to occur but did not actually occur, and the number of false alarms is the number of events that were predicted not to occur but actually occurred. After iterating through all candidate parameter combinations, the set of hyperparameters with the best performance index is selected, and the hoarfrost formation prediction model is retrained on the entire training set using this best configuration.
5. The method for co-predicting the formation and duration of rime ice based on random forest-Transformer fusion as described in claim 4, characterized in that, The rime formation forecast factors include: monthly, daily, surface air temperature, temperature-dew point difference, relative humidity, wind speed, precipitation, total cloud cover, low cloud cover, temperature stratification, and air temperature, relative humidity, and wind speed at each layer.
6. The method for co-predicting the formation and duration of rime ice based on random forest-Transformer fusion as described in claim 1, characterized in that, Step S3 specifically includes: S31. Extract the rime ice maintenance forecast factors from the hourly dataset. The basic factors for rime ice maintenance forecast include: time, temperature, relative humidity, wind speed, precipitation, and rime ice record, totaling 6 factors. S32. Based on the basic factors of rime ice maintenance forecast, construct derived factors and calculate the moving average and variance of temperature and humidity in the previous 24 hours to capture the statistical characteristics of meteorological data in the short term. The rime ice maintenance forecast factors include all basic and derived factors of rime ice maintenance forecast, namely: time, temperature, relative humidity, wind speed, precipitation, mean temperature, temperature variance, mean relative humidity, relative humidity variance, and rime ice record, a total of 10 factors. S33. Apply a sine / cosine transform to the time variable to preserve its periodicity and enhance the model's ability to learn from diurnal cycles. The transformed time Enc(t) is expressed as: Numerical features other than those recorded in rime ice are subjected to Z-Score standardization to ensure consistency in numerical scale across different features. The formula for this standardization is as follows: Where Z is the result of Z-Score standardization, x represents the feature being processed, μ represents the mean of the training set, and σ represents the standard deviation of the training set. S34. A dynamic window sampling strategy is adopted to solve the class imbalance problem. The positive sample window is defined as the period from 24 hours before the occurrence of the rime event to the end of the event. In this area, dense sliding sampling is carried out with a step size of 1 hour. The negative sample area is sparsely sampled with a step size of 6 hours, so that the number of rime samples can be effectively supplemented and the imbalance of data class distribution can be improved. S35. The dataset is divided into training set, validation set and test set in chronological order to ensure the integrity of the time series. The ratio of training set, validation set and test set is 7:2:
1. The rime ice maintenance forecast model is constructed using the Transformer method and trained on the training set. The output of the model is the rime ice maintenance forecast probability.
7. The method for co-predicting the formation and duration of rime ice based on random forest-Transformer fusion as described in claim 6, characterized in that, The working method of the rime ice persistence forecast model includes: First, the feature vectors of 24 consecutive hours are stacked in chronological order to form a 24-row, 10-column two-dimensional feature matrix as the model input, where each row corresponds to one hour of meteorological data and each column represents different forecast factors; A learnable location encoding matrix is introduced into the input layer and added to the linearly transformed input features, enabling the model to explicitly perceive the temporal order of meteorological data. Multiple parallel attention heads are set up, each independently calculating the attention weights of the query, key, and value vectors, and the association strength at each time step is obtained by scaling the dot product. The outputs of multiple heads are concatenated and then linearly transformed to fuse the feature representations of different subspaces. Two fully connected networks are connected after the self-attention layer, using ReLU as the activation function. Residual connections are implemented after each self-attention layer and feedforward network layer, adding the sub-layer output to the original input, followed by layer normalization. Using a 24-hour meteorological feature sequence as input from the training set, a neural network model incorporating a self-attention mechanism is used to capture the long-range dependencies between spatiotemporal features. The last hidden state is mapped to the hourly rime persistence probability for the next 6 hours via a fully connected layer.
8. The method for co-predicting the formation and duration of rime ice based on random forest-Transformer fusion as described in claim 7, characterized in that, The hoarfrost persistence forecasting model implements a phased parameter optimization strategy during training: The first stage uses a global search algorithm to determine the combination of structural parameters of the attention mechanism in a preset parameter space. The second stage dynamically adjusts the learning rate parameter and gradient constraints based on feedback from the validation set. By continuously monitoring the model's generalization ability to unknown time series data through the validation set, an early stop mechanism is triggered when the sliding standard deviation of the validation set TS score is lower than a set threshold for N consecutive training cycles, and the model convergence process is balanced by combining a periodic learning rate scheduling algorithm. The optimal model architecture is selected from multiple model snapshots saved during training, based on a comprehensive evaluation metric from the validation set.
Citation Information
Patent Citations
Local cloud and fog prediction method and system
CN114926744A
Rime meteorological landscape forecasting method and system, electronic equipment and medium
CN117518296A