Method and device for predicting rainstorm days, equipment and storage medium
By modeling the number of rainstorm days and factor data in the target area, a prediction model for rainstorm days was generated, which solved the problem that the existing technology could not predict the number of rainstorm days in the future, and achieved accurate prediction of the number of rainstorm days in the future and early prevention measures.
Patent Information
- Application Number
- CN202411772895.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-04
- Publication Date
- 2025-03-14
- Estimated Expiration
- 2044-12-04
AI Technical Summary
The existing technology cannot effectively predict the number of rainstorms in the future, resulting in the inability to take precautions in advance to reduce the adverse effects of rainstorms.
By obtaining the historical rainstorm day dataset and rain factor dataset in the target area, the preset initial model is trained to generate a rainstorm day prediction model, and the model is used to predict the rainstorm day number in the future time.
Accurate prediction of the number of rainstorms in the future has been achieved, and preventive measures can be taken in advance when there are too many rainstorms in the future to reduce the harm of continuous rainstorms to production and life.
Smart Images

Figure CN119620239A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of model prediction technology, and in particular to a prediction method and device, equipment and storage medium for the number of rainstorm days. Background Art
[0002] Continuous heavy rains have a great impact on both the natural environment and human life. For the natural environment, continuous heavy rains will affect water bodies, soil and ecology. For example, heavy rains will cause the water level of rivers, lakes and other water bodies to rise rapidly, and may even cause floods. Long-term heavy rains may also cause water pollution because rainwater will wash away pollutants on the surface and bring them into the water. For human life, continuous heavy rains will have a great impact on agriculture, transportation, cities and the economy. For example, heavy rains may destroy infrastructure such as farmland, roads, and bridges, causing huge economic losses. Therefore, it is necessary to predict the number of heavy rain days in the future so that corresponding preventive measures can be taken based on the predicted number of heavy rain days to reduce the adverse effects of heavy rains.
[0003] At present, there is no effective method to predict the number of days with heavy rain in the future, which makes it impossible to obtain information about future heavy rain conditions and make targeted preventive measures impossible. Summary of the invention
[0004] Based on this, it is necessary to propose a prediction method and device, equipment and storage medium for the number of heavy rain days in response to the above problems, so as to accurately obtain the number of heavy rain days in the future.
[0005] To achieve the above-mentioned purpose, the first aspect of the present application provides a method for predicting the number of rainstorm days, the method comprising:
[0006] Obtain a historical rainstorm day data set of a target area and a rainstorm factor data set corresponding to the historical rainstorm day data set;
[0007] Training a preset initial model according to the historical rainstorm days data set and the rainstorm factor data set corresponding to the historical rainstorm days data set to generate a rainstorm days prediction model;
[0008] Collect target rainstorm factor data for target forecast time;
[0009] The target rainstorm factor data is input into the rainstorm days prediction model to obtain the predicted rainstorm days at the target prediction time output by the rainstorm days prediction model.
[0010] Furthermore, the acquisition of a historical rainstorm day data set of the target area and a rainstorm factor data set corresponding to the historical rainstorm day data set specifically includes:
[0011] Obtain the number of rainstorm days in the forecast time of each year in the past N years to generate a historical rainstorm day number data set, wherein the forecast time is any consecutive number of months in a preset year, and the historical rainstorm day number data set includes the number of rainstorm days in the forecast time of the past N years;
[0012] The monthly value of the rainstorm impact factor of each month from the starting month of the historical target year to several months before the starting month is used as the rainstorm factor data corresponding to the historical target year, and the rainstorm factor data corresponding to all historical target years are used to generate the rainstorm factor data set corresponding to the historical rainstorm days data set, wherein the historical target year is any year in the past N years, and the starting month is any month before the preset forecast time.
[0013] Furthermore, the training of a preset initial model according to the historical rainstorm days data set and the rainstorm factor data set corresponding to the historical rainstorm days data set to generate a rainstorm days prediction model specifically includes:
[0014] Conduct a correlation analysis based on the number of rainstorm days in the forecast time of the historical target year and the rainstorm factor data of the historical target year to determine the target month with the highest correlation with the number of rainstorm days in the forecast time;
[0015] Deleting the rainstorm factor data of non-target months in the rainstorm factor data set to obtain a target rainstorm factor data set;
[0016] The preset initial model is trained according to the historical rainstorm day number data set and the target rainstorm factor data set to generate a rainstorm day number prediction model.
[0017] Furthermore, the training of a preset initial model according to the historical rainstorm days data set and the target rainstorm factor data set to generate a rainstorm days prediction model specifically includes:
[0018] Using a preset optimization method, the rainstorm factor types in the target rainstorm factor data set are screened according to the historical rainstorm days data set and the target rainstorm factor data set to obtain the top M target rainstorm factor types that have the greatest impact on the number of rainstorm days in the forecast time;
[0019] Deleting data corresponding to non-target rainstorm factor types in the target rainstorm factor data set to obtain a standard rainstorm factor data set;
[0020] The initial model is trained according to the historical rainstorm days data set and the standard rainstorm factor data set to generate a rainstorm days prediction model.
[0021] Furthermore, the preset optimization method is used to screen the rainstorm factor types in the target rainstorm factor data set according to the historical rainstorm days data set and the target rainstorm factor data set, and obtain the top M target rainstorm factor types that have the greatest impact on the rainstorm days in the forecast time, specifically including:
[0022] Using a preset linear algorithm, the rainstorm factor types in the target rainstorm factor data set are screened according to the historical rainstorm days data set and the target rainstorm factor data set, so as to obtain the top M first target rainstorm factor types that have the greatest impact on the number of rainstorm days in the forecast time;
[0023] Using a preset nonlinear algorithm, the rainstorm factor types in the target rainstorm factor data set are screened according to the historical rainstorm days data set and the target rainstorm factor data set to obtain the top M second target rainstorm factor types that have the greatest impact on the rainstorm days in the forecast time;
[0024] The step of deleting data corresponding to non-target rainstorm factor types in the target rainstorm factor data set to obtain a standard rainstorm factor data set specifically includes:
[0025] Deleting data not corresponding to the first target rainstorm factor type in the target rainstorm factor data set to obtain a first standard rainstorm factor data set;
[0026] Deleting data not corresponding to the second target rainstorm factor type in the target rainstorm factor data set to obtain a second standard rainstorm factor data set;
[0027] The training of the initial model according to the historical rainstorm days data set and the standard rainstorm factor data set to generate a rainstorm days prediction model specifically includes:
[0028] The initial model is trained according to the historical rainstorm days data set, the first standard rainstorm factor data set and the second standard rainstorm factor data set to generate a rainstorm days prediction model.
[0029] Furthermore, the training of the initial model according to the historical rainstorm days data set, the first standard rainstorm factor data set and the second standard rainstorm factor data set to generate a rainstorm days prediction model specifically includes:
[0030] The initial model is trained according to the historical rainstorm days data set and the first standard rainstorm factor data set to generate a first rainstorm days prediction model;
[0031] The initial model is trained according to the historical rainstorm days data set and the second standard rainstorm factor data set to generate a second rainstorm days prediction model;
[0032] The step of inputting the target rainstorm factor data into the rainstorm days prediction model to obtain the predicted rainstorm days at the target prediction time output by the rainstorm days prediction model specifically includes:
[0033] Inputting the target rainstorm factor data into the first rainstorm days prediction model to obtain a first predicted rainstorm days output by the first rainstorm days prediction model;
[0034] Inputting the target rainstorm factor data into the second rainstorm days prediction model to obtain the second predicted rainstorm days output by the second rainstorm days prediction model;
[0035] The predicted number of heavy rain days at the target prediction time is calculated based on the first predicted number of heavy rain days and the second predicted number of heavy rain days.
[0036] Furthermore, the step of calculating the predicted number of heavy rain days at the target prediction time according to the first predicted number of heavy rain days and the second predicted number of heavy rain days specifically includes:
[0037] Obtaining prediction qualification rates of the first rainstorm days prediction model and the second rainstorm days prediction model;
[0038] According to the prediction qualification rates of the first and second rainstorm days prediction models, weights are assigned to the first and second rainstorm days prediction models, namely, a first weight of the first and second weights of the second rainstorm days prediction model;
[0039] A weighted average is taken according to the first predicted number of heavy rain days, the second predicted number of heavy rain days, the first weight and the second weight to obtain the predicted number of heavy rain days at the target prediction time.
[0040] To achieve the above-mentioned purpose, the second aspect of the present application provides a device for predicting the number of rainstorm days, the device comprising a data acquisition unit, a model training unit and a rainstorm prediction unit;
[0041] The data acquisition unit is used to acquire a historical rainstorm day data set of a target area and a rainstorm factor data set corresponding to the historical rainstorm day data set;
[0042] The model training unit is used to train a preset initial model according to the historical rainstorm days data set and the rainstorm factor data corresponding to the historical rainstorm days data set to generate a rainstorm days prediction model;
[0043] The rainstorm prediction unit is used to collect target rainstorm factor data at a target prediction time;
[0044] The target rainstorm factor data is input into the rainstorm days prediction model to obtain the predicted rainstorm days at the target prediction time output by the rainstorm days prediction model.
[0045] To achieve the above-mentioned purpose, the third aspect of the present application provides a computer-readable storage medium storing a computer program, characterized in that when the computer program is executed by a processor, the processor executes the steps of the method described in the first aspect.
[0046] To achieve the above-mentioned purpose, the fourth aspect of the present application provides a computer device, including a memory and a processor, characterized in that the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of the method described in the first aspect.
[0047] The embodiments of the present invention have the following beneficial effects:
[0048] The embodiment of the present invention proposes a method for predicting the number of rainstorm days, which includes: obtaining a historical rainstorm day data set and a rainstorm factor data set corresponding to the historical rainstorm day data set in a target area; training a preset initial model according to the historical rainstorm day data set and the rainstorm factor data corresponding to the historical rainstorm day data set to generate a rainstorm day prediction model; collecting target rainstorm factor data for a target prediction time; inputting the target rainstorm factor data into the rainstorm day prediction model to obtain the predicted rainstorm days for the target prediction time output by the rainstorm day prediction model. By obtaining the rainstorm influencing factors that affect the number of rainstorm days, and training the model based on the historical rainstorm day data set and the rainstorm factor data set corresponding to the historical rainstorm day data set, a rainstorm day prediction model is obtained, so that the future rainstorm days can be predicted based on the rainstorm day prediction model, so as to achieve targeted preventive measures when there are too many rainstorm days in the future. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0050] in:
[0051] Figure 1 Schematic diagram of a method for predicting the number of rainstorm days according to an embodiment of the present invention;
[0052] Figure 2 This is a comparison chart of the prediction results of the first rainstorm days prediction model constructed with 5 factors selected by the Lasso regression algorithm in an embodiment of the present invention;
[0053] Figure 3 This is a comparison chart of the prediction results of the second rainstorm days prediction model constructed with 5 factors selected by the random forest algorithm in an embodiment of the present invention;
[0054] Figure 4 This is a comparison chart of prediction results obtained by screening 5 factors using the Lasso regression algorithm and the random forest algorithm in an embodiment of the present invention;
[0055] Figure 5 This is a comparison chart of prediction results of the first rainstorm days prediction model constructed with 10 factors selected by the Lasso regression algorithm in an embodiment of the present invention;
[0056] Figure 6 This is a comparison chart of prediction results of the second rainstorm days prediction model constructed with 10 factors selected by the random forest algorithm in an embodiment of the present invention;
[0057] Figure 7 This is a comparison chart of prediction results obtained by screening 10 factors using the Lasso regression algorithm and the random forest algorithm in an embodiment of the present invention;
[0058] Figure 8 This is a comparison chart of the prediction results of the first rainstorm days prediction model constructed with 15 factors selected by the Lasso regression algorithm in an embodiment of the present invention;
[0059] Fig. 9 This is a comparison chart of prediction results of the second rainstorm days prediction model constructed with 15 factors selected by the random forest algorithm in an embodiment of the present invention;
[0060] Fig.10 This is a comparison chart of prediction results obtained by screening 15 factors using the Lasso regression algorithm and the random forest algorithm in an embodiment of the present invention;
[0061] Fig.11 This is a structural block diagram of a device for predicting the number of rainstorm days according to an embodiment of the present invention;
[0062] Fig.12 1 is a diagram showing the internal structure of a computer device in an embodiment of the present invention. DETAILED DESCRIPTION
[0063] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0064] Existing forecasts for precipitation in a certain region or river basin mainly focus on precipitation intensity, and there are few studies that take the number of precipitation days or even the number of rainstorm days as the forecast object.
[0065] Since continuous heavy rain in a certain area or basin will have a great impact on production and life, the embodiment of the present invention proposes a method for predicting the number of heavy rain days. Figure 1 , Figure 1 The flowchart of the method for predicting the number of rainstorm days in an embodiment of the present invention is as follows:
[0066] Step 120: Obtain a historical rainstorm day data set of the target area and a rainstorm factor data set corresponding to the historical rainstorm day data set.
[0067] In an embodiment of the present invention, the target area may be an area with heavy rainfall throughout the year. By predicting the number of rainstorm days in the target area with heavy rainfall, relevant departments can take targeted preventive measures in the target area to avoid major losses and safety issues caused by continuous heavy rainfall.
[0068] A rainstorm day can be defined as a day when the rainfall is greater than the preset rainfall threshold, for example, a day with a rainfall greater than 50 mm / d is considered a rainstorm day. The number of rainstorm days is the total number of rainstorm days in a certain period of time, which can be the number of rainstorm days in a year, the number of rainstorm days in a month, or the number of rainstorm days in several months. There is no restriction here. For example, the rainy season in Yunnan is from April to October every year, so the number of rainstorm days in April to October every year in the past can be obtained as a historical rainstorm day data set.
[0069] There are many factors that affect the rainfall degree in the target area, for example, there are 130 types of rainstorm factors such as atmospheric circulation, sea temperature, and teleconnection index. The relevant data corresponding to the rainstorm factor type is the rainstorm factor data. By obtaining the rainstorm factor data corresponding to the number of rainstorm days, the rainstorm factor data set corresponding to the historical rainstorm day data set is obtained.
[0070] In one embodiment of the present invention, the rainstorm factor data may be the monthly value of each rainstorm factor type in a certain month. For example, the rainstorm factor type may be the Western Pacific Subtropical High Intensity Index, and the rainstorm factor data may be the average air pressure value of the Western Pacific Subtropical High Intensity Index in a certain month.
[0071] Step 140: training a preset initial model based on the historical rainstorm days data set and the rainstorm factor data set corresponding to the historical rainstorm days data set to generate a rainstorm days prediction model.
[0072] In the implementation of the present invention, training samples and test samples are generated based on the historical rainstorm days data set and the rainstorm factor data set corresponding to the historical rainstorm days data set, and each sample contains the historical rainstorm days and the rainstorm factor data corresponding to the historical rainstorm days. The preset initial model is trained based on the training samples to generate an initial rainstorm days prediction model, and then the initial rainstorm days prediction model is tested and adjusted using the test samples to obtain the final rainstorm days prediction model.
[0073] Step 160: Collect target rainstorm factor data for the target forecast time.
[0074] In an embodiment of the present invention, the target prediction time for the number of rainstorm days to be predicted is determined, for example, 2024.4-2024.10, and the rainstorm factor data for the target prediction time is obtained, such as relevant data on 130 types of rainstorm factors such as atmospheric circulation, sea temperature, and teleconnection index.
[0075] Step 180: Input the target rainstorm factor data into the rainstorm days prediction model to obtain the predicted rainstorm days at the target prediction time output by the rainstorm days prediction model.
[0076] The embodiment of the present invention predicts the number of heavy rain days in the target area in the future in advance through a heavy rain day number prediction model, which is conducive to making important decision-making references in power dispatching, disaster prevention and other aspects of the target area, and minimizing the harm caused by continuous heavy rain to production and life.
[0077] In one embodiment of the present invention, step 120, obtaining a historical rainstorm day data set of a target area and a rainstorm factor data set corresponding to the historical rainstorm day data set, specifically includes:
[0078] Step 210, obtain the number of heavy rain days in the forecast time of each year in the past N years to generate a historical heavy rain day number data set, wherein the forecast time is any consecutive months in a preset year, and the historical heavy rain day number data set includes the number of heavy rain days in the forecast time of the past N years.
[0079] In the embodiment of the present invention, the time to be predicted is the number of rainstorm days in a year or one or more months in a year. For example, if the time to be predicted is April to October each year, April to October each year is used as the forecast time, and the number of rainstorm days in April to October each year in the past N years is obtained as the historical rainstorm day number data set. Therefore, the historical rainstorm day number data set contains the number of rainstorm days in the forecast time each year in the past N years.
[0080] Step 220, the monthly value of the rainstorm impact factor of each month from the starting month of the historical target year to several months before the starting month is used as the rainstorm factor data corresponding to the historical target year. The rainstorm factor data corresponding to all historical target years are used to generate the rainstorm factor data set corresponding to the historical rainstorm day data set, where the historical target year is any year in the past N years, and the starting month is any month before the preset forecast time.
[0081] In an embodiment of the present invention, the rainstorm factor data corresponding to the forecast time of each year in the past N years is obtained. Specifically, any year in the past N years is taken as the historical target year. For example, if the current year is 2024, 2020 can be selected as the historical target year, and the rainstorm factor data corresponding to the forecast time of 2020 (such as April to October) is obtained.
[0082] Since we want to predict the number of rainstorm days in the target area, there will be a time difference between the time corresponding to the rainstorm factor data and the forecast time. It can also be understood that if we want to predict the number of rainstorm days within the forecast time, we need to obtain the rainstorm factor data before the forecast time. Therefore, we first need to determine the starting time according to the forecast time. The starting time is any month before the forecast time, which is determined by the actual situation. After determining the starting month, we determine the sampling interval. The sampling interval can be several months. We obtain the rainstorm factor data for each month in the sampling interval from the starting month. These rainstorm factor data are the rainstorm factor data corresponding to the forecast time in the year to be predicted. For example, if we want to predict the number of rainstorm days from April to October in 2024, the starting month can be determined in the year and month before March 2024. Assuming the sampling period is 60 months, we need to obtain the monthly value of the rainstorm factor for each month in the 60 months before March 2024. These rainstorm factor data are the rainstorm factor data corresponding to April-October 2024. The rainstorm factor data corresponding to each year in the past N years can be obtained through the above method, and then the rainstorm factor data set corresponding to the historical rainstorm day data set is generated.
[0083] In one embodiment of the present invention, step 140, training a preset initial model according to a historical rainstorm days data set and a rainstorm factor data set corresponding to the historical rainstorm days data set to generate a rainstorm days prediction model, specifically includes:
[0084] Step 410: Perform a correlation analysis based on the number of rainstorm days in the forecast time of the historical target year and the rainstorm factor data of the historical target year to determine the target month with the highest correlation with the number of rainstorm days in the forecast time.
[0085] In the embodiment of the present invention, considering that the heavy rain factor data contains the monthly values of the heavy rain factors of several months, in order to reduce the calculation pressure and improve the prediction efficiency, and avoid the error of the heavy rain factor monthly values of the months with less influence on the prediction results, by analyzing the correlation between the number of heavy rain days in the forecast time and the month where the heavy rain factor is located, the target month where the heavy rain factor data with the greatest influence on the number of heavy rain days in the forecast time is located is determined.
[0086] Specifically, a correlation analysis is performed based on the number of rainstorm days in the historical target year and the monthly value of the rainstorm factor in each month in the rainstorm factor data corresponding to the historical target year to determine the month with the highest correlation. For example, if this year is 2024, the number of rainstorm days corresponding to April to October in the past 10 years (i.e., 2014-2023) and the corresponding rainstorm factor data for each year are obtained. The rainstorm factor data contains the monthly value of the rainstorm factor for the five months before March each year. The correlation between the monthly value of the rainstorm factor and the number of rainstorm days is analyzed for each month, and the target month with the monthly value of the rainstorm factor with the highest correlation with the number of rainstorm days is determined.
[0087] Step 420, delete the rainstorm factor data of non-target months in the rainstorm factor data set to obtain the target rainstorm factor data set.
[0088] In the embodiment of the present invention, only the monthly value of the rainstorm factor of the target month in the rainstorm factor dataset corresponding to each year is retained. For example, if the monthly value of the rainstorm factor with the greatest correlation with April to October each year is calculated through Step 410, then only the monthly value of the rainstorm factor of February in the rainstorm factor dataset corresponding to the forecast time each year is retained, and then the target rainstorm factor dataset corresponding to the historical rainstorm days dataset is obtained.
[0089] Step 430, train the preset initial model according to the historical rainstorm days data set and the target rainstorm factor data set to generate a rainstorm days prediction model.
[0090] The embodiment of the present invention performs a preliminary screening of the rainstorm factor data set to remove the monthly values of the rainstorm factors that have a small impact on the forecast time, thereby preventing these data from affecting the accuracy of the rainstorm day prediction model. In addition, it can also reduce the computing pressure and improve the efficiency of model training.
[0091] In one embodiment of the present invention, Step 430, training a preset initial model according to a historical rainstorm days data set and a target rainstorm factor data set to generate a rainstorm days prediction model, specifically includes:
[0092] Step 431. Using the preset optimization method, the rainstorm factor types in the target rainstorm factor data set are screened according to the historical rainstorm days data set and the target rainstorm factor data set, and the top M target rainstorm factor types that have the greatest impact on the rainstorm days in the forecast time are obtained.
[0093] In the embodiment of the present invention, the target rainstorm factor data set is screened again to retain more meaningful monthly values of rainstorm factors. Since there are many types of rainstorm factors obtained, up to 130 items, in order to reduce the computational burden and improve the prediction efficiency, and to avoid the influence of factors with less influence on the number of rainstorm days on the prediction results, the rainstorm factor types in the target rainstorm factor data set can be screened to determine the target rainstorm factor types with greater influence on the number of rainstorm days in the forecast time.
[0094] Specifically, a suitable optimization algorithm may be selected to determine the target rainstorm factor types having the top M highest correlations with the number of rainstorm days in the forecast time. It is understandable that M is determined according to the actual situation.
[0095] Step 432, delete the data corresponding to the non-target rainstorm factor type in the target rainstorm factor data set to obtain the standard rainstorm factor data set.
[0096] In the embodiment of the present invention, only the rainstorm factor data corresponding to the target rainstorm factor type in the target rainstorm factor data set is retained to generate a standard rainstorm factor data set.
[0097] Step 433, train the initial model based on the historical rainstorm days data set and the standard rainstorm factor data set to generate a rainstorm days prediction model.
[0098] The embodiment of the present invention further screens the target rainstorm factor data set to remove the rainstorm factor types that have little impact on the number of rainstorm days in the forecast time, thereby preventing the rainstorm factor thresholds corresponding to these rainstorm factor types from affecting the accuracy of the rainstorm day prediction model. In addition, the calculation pressure can be reduced and the efficiency of model training can be improved.
[0099] In one embodiment of the present invention, Step 431, using a preset optimization method, the rainstorm factor types in the target rainstorm factor data set are screened according to the historical rainstorm days data set and the target rainstorm factor data set, and the top M target rainstorm factor types that have the greatest impact on the rainstorm days in the forecast time are obtained, specifically including:
[0100] Step 431, using a preset linear algorithm, the rainstorm factor types in the target rainstorm factor data set are screened according to the historical rainstorm days data set and the target rainstorm factor data set, and the top M first target rainstorm factor types that have the greatest impact on the rainstorm days in the forecast time are obtained.
[0101] In the embodiment of the present invention, screening the rainstorm factor types through a linear algorithm can obtain a relatively stable regression relationship through a regression model, and can more intuitively explain the effect of each rainstorm factor type on the number of rainstorm days in the forecast time at the physical level.
[0102] In one embodiment of the present invention, the linear algorithm may be a Lasso regression algorithm, and the rainstorm factor type is screened by Lasso regression. A screening target may be set, such as 5, 10 or 15 rainstorm factor types, and the Lasso regression algorithm reduces the complexity of the model by introducing L1 regularization to achieve the selection of the rainstorm factor type.
[0103] The correlation coefficient of each rainstorm factor type is calculated through the objective function of Lasso regression, and the rainstorm factor type corresponding to the M correlation coefficients with the largest absolute value of the correlation coefficient is taken as the first target rainstorm factor type.
[0104] In the embodiment of the present invention, the objective function of Lasso regression is:
[0105]
[0106] In the formula, the mean square error is: L1 regularization term:
[0107] Among them, w is the coefficient vector, n is the number of samples, and y i is the number of rainstorm days in the sample, To predict the number of rainstorm days, λ is the regularization intensity hyperparameter, and p is the total number of rainstorm factor types.
[0108] Step 432, using a preset nonlinear algorithm, the rainstorm factor types in the target rainstorm factor data set are screened according to the historical rainstorm days data set and the target rainstorm factor data set, and the top M second target rainstorm factor types that have the greatest impact on the rainstorm days in the forecast time are obtained.
[0109] In the embodiment of the present invention, since the number of rainstorm days is affected by the complexity of atmospheric movement, and the nonlinear algorithm can grasp the nonlinear relationship between atmospheric circulation and precipitation, such as exponential and power exponential, etc. Therefore, the nonlinear algorithm can be selected to screen the rainstorm factor type to improve the effectiveness of the rainstorm factor type.
[0110] In one embodiment of the present invention, the nonlinear algorithm may be a random forest algorithm. The random forest algorithm calculates the importance of the rainstorm factor type and selects the top M second target rainstorm factor types with greater contributions. M may take values such as 5, 10 or 15.
[0111] The present invention obtains the main factors that have the greatest impact on the number of rainstorm days in the forecast time of the target area through these two rainstorm factor type screening methods, thereby providing a scientific basis for rainstorm forecasting and disaster prevention and mitigation.
[0112] Based on this, Step 432 deletes the data corresponding to the non-target rainstorm factor type in the target rainstorm factor data set to obtain a standard rainstorm factor data set, which specifically includes:
[0113] Step 4321. Delete the data corresponding to non-first target rainstorm factor types in the target rainstorm factor data set to obtain the first standard rainstorm factor data set.
[0114] After the first target rainstorm factor type is obtained by screening based on the linear algorithm, only the monthly values of the rainstorm factors corresponding to the first target rainstorm factor type in the target rainstorm factor data set are retained to generate the first standard rainstorm factor data set.
[0115] Step 4322, delete the data corresponding to non-second target rainstorm factor types in the target rainstorm factor data set to obtain the second standard rainstorm factor data set.
[0116] After the second target rainstorm factor type is obtained by screening based on the nonlinear algorithm, only the monthly values of the rainstorm factor corresponding to the second target rainstorm factor type in the target rainstorm factor data set are retained to generate the second standard rainstorm factor data set.
[0117] Based on this, Step 433 trains the initial model based on the historical rainstorm days data set and the standard rainstorm factor data set to generate a rainstorm days prediction model, which specifically includes:
[0118] Step 4331. Train the initial model based on the historical rainstorm days data set, the first standard rainstorm factor data set and the second standard rainstorm factor data set to generate a rainstorm days prediction model.
[0119] Specifically, the initial model can be trained based on the union or intersection of the first standard rainstorm factor data set and the second standard rainstorm factor data set and the historical rainstorm day number data set to generate a rainstorm day number prediction model. The embodiment of the present invention trains the initial model with the rainstorm factor types screened by two linear and nonlinear algorithms, and can accurately obtain the rainstorm factor type that has the greatest impact on the number of rainstorm days in the forecast time, so that the model can be trained based on the accurate standard rainstorm factor data set to generate a more accurate rainstorm day number prediction model.
[0120] In one embodiment of the present invention, Step 4331, training the initial model according to the historical rainstorm days data set, the first standard rainstorm factor data set and the second standard rainstorm factor data set to generate a rainstorm days prediction model, specifically includes:
[0121] Step 43311. Train the initial model based on the historical rainstorm days data set and the first standard rainstorm factor data set to generate the first rainstorm days prediction model.
[0122] Step 43312. Train the initial model based on the historical rainstorm days data set and the second standard rainstorm factor data set to generate the second rainstorm days prediction model.
[0123] In the embodiment of the present invention, a first rainstorm day prediction model is constructed based on the historical rainstorm day data set and the first standard rainstorm factor data set through a preset reverse neural network; a second rainstorm day prediction model is constructed based on the historical rainstorm day data set and the second standard rainstorm factor data set through a preset reverse neural network. The two rainstorm day prediction models can take into account the differences caused by the screening factors of different methods.
[0124] Based on this, step 180, inputting the target rainstorm factor data into the rainstorm days prediction model, and obtaining the predicted rainstorm days at the target prediction time output by the rainstorm days prediction model, specifically includes:
[0125] Step 811, input the target rainstorm factor data into the first rainstorm day prediction model to obtain the first predicted rainstorm day output by the first rainstorm day prediction model.
[0126] Step 812, input the target rainstorm factor data into the second rainstorm day prediction model to obtain the second predicted rainstorm day output by the second rainstorm day prediction model.
[0127] Step 813, calculate the predicted number of heavy rain days at the target prediction time according to the first predicted number of heavy rain days and the second predicted number of heavy rain days.
[0128] In an embodiment of the present invention, the target prediction time is first determined, and the target prediction time is the target prediction year. For example, the target prediction year is 2024, which means that the number of rainstorm days in the forecast time (such as April to October) in 2024 needs to be predicted. Secondly, the target rainstorm factor data for the target prediction time is obtained. For example, assuming that the monthly value of the rainstorm factor with the highest correlation with the forecast time is in February, and the target rainstorm factor types with the highest correlation with the forecast time are A, B, C, D and E, then the monthly values of the rainstorm factor types A, B, C, D and E in February 2024 are obtained as the target rainstorm factor data corresponding to the target prediction time.
[0129] After obtaining the target rainstorm factor data, the target rainstorm factor data are respectively input into the first rainstorm day prediction model and the second rainstorm day prediction model to obtain the first predicted rainstorm day and the second predicted rainstorm day output by the two rainstorm day prediction models, and then the predicted rainstorm day for the target prediction time is calculated based on the first predicted rainstorm day and the second predicted rainstorm day. For example, the predicted rainstorm day for the target prediction time may be the mean, maximum, minimum and other characteristic values of the first predicted rainstorm day and the second predicted rainstorm day.
[0130] In one embodiment of the present invention, Step 813, calculating the predicted number of heavy rain days at the target prediction time according to the first predicted number of heavy rain days and the second predicted number of heavy rain days, specifically includes:
[0131] Step 8131, obtain the prediction pass rate of the first rainstorm day prediction model and the second rainstorm day prediction model.
[0132] In the embodiment of the present invention, a set of standard samples is used to test the pass rate of the prediction results of the first rainstorm days prediction model and the second rainstorm days prediction model.
[0133] Specifically, the relative error between the predicted number of heavy rain days and the actual number of heavy rain days is calculated, relative error = (predicted number of heavy rain days - actual number of heavy rain days) ÷ actual number of heavy rain days × 100%. When the relative error is less than the preset error threshold, it is considered qualified. Each heavy rain day prediction model is tested based on a set of standard samples, and the prediction pass rate of each heavy rain day prediction model is calculated.
[0134] Step 8132, weights are assigned to the first rainstorm days prediction model and the second rainstorm days prediction model according to their prediction qualification rates, namely, the first weight of the first rainstorm days prediction model and the second weight of the second rainstorm days prediction model.
[0135] Specifically, the weights of each rainstorm day prediction model are calculated by the following formula:
[0136]
[0137] Wherein, γ1 is the target heavy rain days prediction model, the target heavy rain days prediction model is any one of the first heavy rain days prediction model and the second heavy rain days prediction model, φ1 is the prediction qualification rate of the target heavy rain days prediction model, and φ2 is the prediction qualification rate of the other heavy rain days prediction model.
[0138] Step 8133, perform weighted average based on the first predicted number of heavy rain days, the second predicted number of heavy rain days, the first weight and the second weight to obtain the predicted number of heavy rain days at the target prediction time.
[0139] Specifically, the predicted number of heavy rain days and weights of each heavy rain prediction model are weighted averaged to obtain the predicted number of heavy rain days at the target prediction time.
[0140] The embodiment of the present invention predicts the number of heavy rain days in the future by using the heavy rain day prediction model corresponding to the two screening factor algorithms, so as to improve the accuracy of the heavy rain day prediction.
[0141] To prove the advantages of the present invention, the following experiments are performed:
[0142] (1) For reference Figure 2 , Figure 2 This is a comparison chart of the prediction results of the first rainstorm days prediction model constructed with 5 factors selected by the Lasso regression algorithm in the embodiment of the present invention. It can be seen that the overall trend of the overall prediction value is relatively consistent with the actual measurement, and the correlation coefficient reaches 0.66; Figure 3 This is a comparison chart of the prediction results of the second rainstorm days prediction model constructed by the 5 factors selected by the random forest algorithm in the embodiment of the present invention. It can be seen that the overall prediction effect is slightly lower than Figure 1 , the correlation coefficient reached 0.58; Figure 4 This is a comparison chart of the prediction results obtained by using the Lasso regression algorithm and the random forest algorithm to screen 5 factors in the embodiment of the present invention. The Lasso regression and random forest algorithm are used to screen 5 factors. It can be seen that the combined prediction effect is slightly better than Figure 2 ,and Figure 1 The correlation coefficient is 0.68.
[0143] (2) For reference Figure 5 , Figure 5 This is a comparison chart of the prediction results of the first rainstorm days prediction model constructed by the 10 factors selected by the Lasso regression algorithm in the embodiment of the present invention. It can be seen that the overall trend of the overall prediction value is relatively consistent with the actual measurement, and the prediction effect of the 10 factors is slightly better than that of the 5 factors, with a correlation coefficient of 0.68; Figure 6 This is a comparison chart of the prediction results of the second rainstorm days prediction model constructed by the 10 factors selected by the random forest algorithm in the embodiment of the present invention, and the prediction effect of the 10 factors is slightly better than that of the 5 factors. It can be seen that the overall prediction effect is slightly lower than that of the Lasso regression algorithm, and the correlation coefficient reaches 0.62; Figure 7 This is a comparison chart of the prediction results obtained by screening 10 factors using the Lasso regression algorithm and the random forest algorithm in the embodiment of the present invention. It can be seen that the ensemble prediction effect is better than Figure 5 and Figure 6 , and the prediction effect of 10 factors is slightly better than that of 5 factors, with a correlation coefficient of 0.77.
[0144] (3) For reference Figure 8 , Figure 8 This is a comparison chart of the prediction results of the first rainstorm days prediction model constructed with 15 factors selected by the Lasso regression algorithm in the embodiment of the present invention. It can be seen that the overall trend of the overall prediction value is relatively consistent with the actual measurement, and the prediction effect of the 15-factor is slightly better than that of the 5-factor and 10-factor predictions, with a correlation coefficient of 0.83; Fig. 9 This is a comparison chart of the prediction results of the second rainstorm days prediction model constructed with 15 factors selected by the random forest algorithm in the embodiment of the present invention. It can be seen that the overall prediction effect is slightly higher than Figure 8 , and the prediction effect of 15 factors is slightly better than that of 5 factors and 10 factors, with a correlation coefficient of 0.87; Fig.10 This is a comparison chart of the prediction results obtained by using the Lasso regression algorithm and the random forest algorithm to screen 15 factors in the embodiment of the present invention. The Lasso regression and random forest algorithm are used to screen 15 factors. It can be seen that the combined prediction effect is slightly better than Figure 8 and Fig. 9 , and the prediction effect of 15 factors is slightly better than that of 5 factors and 10 factors, with a correlation coefficient of 0.91.
[0145] The above two sets of experiments show that the advantage of building a model based on linear screening factors is that when the number of retained factors is small, the prediction model effect is better than the nonlinear screening factors, and when the number of retained factors is large, the advantage of nonlinear screening factors is better than that of linear screening factors. The prediction method based on weight set can take into account the influence of linear factors and nonlinear factors on the prediction object and produce the best prediction effect.
[0146] The present invention also provides a device for predicting the number of rainstorm days. Fig.11 , Fig.11 11 is a structural block diagram of a device for predicting the number of rainstorm days in an embodiment of the present invention. The device includes a data acquisition unit 1101, a model training unit 1102 and a rainstorm prediction unit 1103.
[0147] The data acquisition unit 1101 is used to acquire a historical rainstorm day data set of a target area and a rainstorm factor data set corresponding to the historical rainstorm day data set.
[0148] The model training unit 1102 is used to train a preset initial model according to the historical rainstorm day data set and the rainstorm factor data corresponding to the historical rainstorm day data set to generate a rainstorm day prediction model.
[0149] The rainstorm prediction unit 1103 is used to collect target rainstorm factor data at a target prediction time.
[0150] The target rainstorm factor data is input into the rainstorm days prediction model to obtain the predicted rainstorm days at the target prediction time output by the rainstorm days prediction model.
[0151] The embodiment of the present invention obtains a rainstorm influencing factor that affects the number of rainstorm days, and performs model training based on a historical rainstorm day data set and a rainstorm factor data set corresponding to the historical rainstorm day data set, to obtain a rainstorm day prediction model, so that the future rainstorm days can be predicted based on the rainstorm day prediction model, so as to implement targeted preventive measures when there are too many rainstorm days in the future.
[0152] Fig.12 FIG. 1 shows an internal structure diagram of a computer device in one embodiment of the present invention. The computer device may be a terminal or a system. Fig.12 As shown, the computer device includes a processor, a memory and a network interface connected via a system bus. The memory includes a non-volatile storage medium and an internal memory. The non-volatile storage medium of the computer device stores an operating system and may also store a computer program. When the computer program is executed by the processor, the processor may implement each step in the above method embodiment. The internal memory may also store a computer program. When the computer program is executed by the processor, the processor may implement each step in the above method embodiment. Those skilled in the art will understand that Fig.12 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0153] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes each step in the above method embodiment.
[0154] In one embodiment, a computer-readable storage medium is provided, which stores a computer program. When the computer program is executed by a processor, the processor executes each step in the above method embodiment.
[0155] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the program can be stored in a non-volatile computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0156] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0157] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A method for predicting the number of rainstorm days, characterized in that: The method comprises: Obtain a historical rainstorm day data set of a target area and a rainstorm factor data set corresponding to the historical rainstorm day data set; Training a preset initial model according to the historical rainstorm days data set and the rainstorm factor data set corresponding to the historical rainstorm days data set to generate a rainstorm days prediction model; Collect target rainstorm factor data for target forecast time; The target rainstorm factor data is input into the rainstorm days prediction model to obtain the predicted rainstorm days at the target prediction time output by the rainstorm days prediction model.
2. The method according to claim 1, characterized in that The step of obtaining a historical rainstorm day data set of a target area and a rainstorm factor data set corresponding to the historical rainstorm day data set specifically includes: Obtain the number of rainstorm days in the forecast time of each year in the past N years to generate a historical rainstorm day number data set, wherein the forecast time is any consecutive number of months in a preset year, and the historical rainstorm day number data set includes the number of rainstorm days in the forecast time of the past N years; The monthly value of the rainstorm impact factor of each month from the starting month of the historical target year to several months before the starting month is used as the rainstorm factor data corresponding to the historical target year, and the rainstorm factor data corresponding to all historical target years are used to generate the rainstorm factor data set corresponding to the historical rainstorm days data set, wherein the historical target year is any year in the past N years, and the starting month is any month before the preset forecast time.
3. The method according to claim 2, characterized in that The training of a preset initial model according to the historical rainstorm days data set and the rainstorm factor data set corresponding to the historical rainstorm days data set to generate a rainstorm days prediction model specifically includes: Conduct a correlation analysis based on the number of rainstorm days in the forecast time of the historical target year and the rainstorm factor data of the historical target year to determine the target month with the highest correlation with the number of rainstorm days in the forecast time; Deleting the rainstorm factor data of non-target months in the rainstorm factor data set to obtain a target rainstorm factor data set; The preset initial model is trained according to the historical rainstorm day number data set and the target rainstorm factor data set to generate a rainstorm day number prediction model.
4. The method according to claim 3, characterized in that The step of training a preset initial model according to the historical rainstorm days data set and the target rainstorm factor data set to generate a rainstorm days prediction model specifically includes: Using a preset optimization method, the rainstorm factor types in the target rainstorm factor data set are screened according to the historical rainstorm days data set and the target rainstorm factor data set to obtain the top M target rainstorm factor types that have the greatest impact on the number of rainstorm days in the forecast time; Deleting data corresponding to non-target rainstorm factor types in the target rainstorm factor data set to obtain a standard rainstorm factor data set; The initial model is trained according to the historical rainstorm days data set and the standard rainstorm factor data set to generate a rainstorm days prediction model.
5. The method according to claim 4, characterized in that The preset optimization method is used to screen the rainstorm factor types in the target rainstorm factor data set according to the historical rainstorm days data set and the target rainstorm factor data set, and obtain the top M target rainstorm factor types that have the greatest impact on the rainstorm days in the forecast time, specifically including: Using a preset linear algorithm, the rainstorm factor types in the target rainstorm factor data set are screened according to the historical rainstorm days data set and the target rainstorm factor data set, so as to obtain the top M first target rainstorm factor types that have the greatest impact on the number of rainstorm days in the forecast time; Using a preset nonlinear algorithm, the rainstorm factor types in the target rainstorm factor data set are screened according to the historical rainstorm days data set and the target rainstorm factor data set to obtain the top M second target rainstorm factor types that have the greatest impact on the rainstorm days in the forecast time; The step of deleting data corresponding to non-target rainstorm factor types in the target rainstorm factor data set to obtain a standard rainstorm factor data set specifically includes: Deleting data not corresponding to the first target rainstorm factor type in the target rainstorm factor data set to obtain a first standard rainstorm factor data set; Deleting data not corresponding to the second target rainstorm factor type in the target rainstorm factor data set to obtain a second standard rainstorm factor data set; The training of the initial model according to the historical rainstorm days data set and the standard rainstorm factor data set to generate a rainstorm days prediction model specifically includes: The initial model is trained according to the historical rainstorm days data set, the first standard rainstorm factor data set and the second standard rainstorm factor data set to generate a rainstorm days prediction model.
6. The method according to claim 5, characterized in that The training of the initial model according to the historical rainstorm days data set, the first standard rainstorm factor data set and the second standard rainstorm factor data set to generate a rainstorm days prediction model specifically includes: The initial model is trained according to the historical rainstorm days data set and the first standard rainstorm factor data set to generate a first rainstorm days prediction model; The initial model is trained according to the historical rainstorm days data set and the second standard rainstorm factor data set to generate a second rainstorm days prediction model; The step of inputting the target rainstorm factor data into the rainstorm days prediction model to obtain the predicted rainstorm days at the target prediction time output by the rainstorm days prediction model specifically includes: Inputting the target rainstorm factor data into the first rainstorm days prediction model to obtain a first predicted rainstorm days output by the first rainstorm days prediction model; Inputting the target rainstorm factor data into the second rainstorm days prediction model to obtain the second predicted rainstorm days output by the second rainstorm days prediction model; The predicted number of heavy rain days at the target prediction time is calculated based on the first predicted number of heavy rain days and the second predicted number of heavy rain days.
7. The method according to claim 6, characterized in that The step of calculating the predicted number of heavy rain days at the target prediction time according to the first predicted number of heavy rain days and the second predicted number of heavy rain days specifically includes: Obtaining prediction qualification rates of the first rainstorm days prediction model and the second rainstorm days prediction model; According to the prediction qualification rates of the first and second rainstorm days prediction models, weights are assigned to the first and second rainstorm days prediction models, namely, a first weight of the first and second weights of the second rainstorm days prediction model; A weighted average is taken according to the first predicted number of heavy rain days, the second predicted number of heavy rain days, the first weight and the second weight to obtain the predicted number of heavy rain days at the target prediction time.
8. A device for predicting the number of rainstorm days, characterized in that: The device comprises a data acquisition unit, a model training unit and a rainstorm prediction unit; The data acquisition unit is used to acquire a historical rainstorm day data set of a target area and a rainstorm factor data set corresponding to the historical rainstorm day data set; The model training unit is used to train a preset initial model according to the historical rainstorm days data set and the rainstorm factor data corresponding to the historical rainstorm days data set to generate a rainstorm days prediction model; The rainstorm prediction unit is used to collect target rainstorm factor data at a target prediction time; The target rainstorm factor data is input into the rainstorm days prediction model to obtain the predicted rainstorm days at the target prediction time output by the rainstorm days prediction model.
9. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the processor is caused to perform the steps of the method according to any one of claims 1 to 7.
10. A computer device comprising a memory and a processor, characterized in that: The memory stores a computer program, and when the computer program is executed by the processor, the processor is caused to perform the steps of the method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Daily water consumption prediction method based on big data
CN111210093A
Method and system for predicting rain and snow weather, storage medium and equipment
CN118091797A
Sea temperature-based rainstorm prediction method and system, storage medium and equipment
CN118210083A
Atmospheric precipitable water filling method fusing sounding data and reanalysis data
CN118467946A
Meteorological disaster risk early warning method, system, equipment and medium
CN118732088A