Water quality forecasting method and system
By adopting multi-model joint training and discrete wavelet transform denoising treatment technology in water quality forecasting, the problem of insufficient accuracy of existing water quality forecasting is solved, and the accuracy and reliability of water quality forecasting are improved.
Patent Information
- Application Number
- CN202411226150.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Priority Date
- 2024-06-28
- Filing Date
- 2024-09-03
- Publication Date
- 2024-12-20
AI Technical Summary
The existing water quality forecasting models lack effective solutions in improving the accuracy of water quality forecasting, especially due to insufficient forecasting accuracy due to the complexity of parameter acquisition and model complexity.
By obtaining the time series water quality data of the target water area, determining the data type and selecting the corresponding machine learning model, the joint training of multiple models and discrete wavelet transform denoising processing are used to improve forecast accuracy. Specific steps include: training different models (such as LSTM and Prophet models) based on sample water quality data, comparing model parameters to select models with small prediction differences, and performing discrete wavelet transform denoising on the water quality data to reduce the noise impact.
The accuracy of water quality forecasting for different water quality data is improved, and the accuracy and reliability of forecasting are enhanced by selecting the optimal model and denoising technology.
Smart Images

Figure CN119168804A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present disclosure relate to the technical field of water environment monitoring, and in particular to a water quality forecasting method and system. Background Art
[0002] At present, water quality forecasting has become an important means of water environment management. Water quality forecasting is divided into time dimension forecasting and space dimension forecasting. Time dimension forecasting focuses on water quality in the next few days and is mainly used for water quality compliance management; space dimension forecasting focuses on the spatial distribution of water quality and is mainly used for emergency and engineering consulting and design. Time dimension water quality forecasting includes water quality forecasting based on statistical forecasting models and mechanism forecasting models. Statistical forecasting models are usually applied to a single section, and mechanism forecasting models are usually applied to the entire water body. The water quality forecasting technology of the mechanism forecasting model is complex, and the parameters are difficult to obtain, which affects the forecast accuracy; the statistical forecasting model has low complexity and can often achieve good forecasting results.
[0003] In the related technologies, the statistical forecasting model based on water quality data has improved the accuracy of water quality forecasting to a certain extent. However, there is no effective solution to further improve the accuracy of water quality forecasting on this basis. Summary of the invention
[0004] In order to solve the above technical problems or at least partially solve the above technical problems, the embodiments of the present disclosure provide a water quality forecasting method and system.
[0005] In a first aspect, the present disclosure provides a water quality forecasting method, comprising:
[0006] Acquire current water quality data of the target water area, wherein the water quality data is time series data;
[0007] Determine the data type of the water quality data, and select the corresponding first water quality prediction model based on the data type; wherein, water quality data of different data types correspond to different first water quality prediction models, and the method for determining the first water quality prediction model corresponding to the water quality data of each data type includes: training the first model and the second model respectively based on the sample water quality data of each data type, calculating the first parameter corresponding to the first model and the second parameter corresponding to the second model after the training, and comparing the first parameter and the second parameter to select the model with the smaller parameter as the first water quality prediction model; wherein, the first model and the second model are different and are both machine learning models for processing time series data; the first parameter and the second parameter are used to characterize the prediction difference of the first model and the second model for the sample water quality data after the training;
[0008] The water quality data is input into a first water quality forecast model to obtain first water quality forecast data within a first time period in the future.
[0009] In one embodiment, the method includes:
[0010] The water quality data is input into a second water quality forecast model to obtain second water quality forecast data within a second time period in the future; wherein the second water quality forecast model is obtained by training a third model based on sample water quality data, and the third model is a machine learning model for processing time series data; and the second time period is shorter than the first time period.
[0011] In one embodiment, the method includes:
[0012] The second water quality forecast model is updated based on the water quality data to obtain new water quality forecast data based on the updated second water quality forecast model and water quality data acquired in the future.
[0013] In one embodiment, the method includes:
[0014] Before inputting the water quality data into the first water quality prediction model or the second water quality prediction model, the water quality data is subjected to discrete wavelet transform denoising processing.
[0015] In one embodiment, the discrete wavelet transform denoising process includes:
[0016] Selecting a Dobesi wavelet corresponding to the data type; wherein water quality data of different data types correspond to different Dobesi wavelets, and the corresponding relationship is determined in advance based on the optimal denoising effect of different Dobesi wavelets on water quality data of each data type;
[0017] The water quality data is subjected to discrete wavelet transform denoising processing based on the Dobesi wavelet corresponding to the data type.
[0018] In one embodiment, before respectively training the first model and the second model based on the sample water quality data, the sample water quality data is denoised to obtain training data; the first model and the second model are iteratively trained based on the training data; or, before training the third model based on the sample water quality data, the sample water quality data is denoised to obtain training data; the third model is iteratively trained based on the training data; wherein the denoising process includes discrete wavelet transform denoising process.
[0019] In one embodiment, the sample water quality data includes multiple water quality data; the first parameter is determined based on multiple differences between multiple water quality data in the sample water quality data and multiple predicted data corresponding to the multiple water quality data output by the first model after training; the second parameter is determined based on multiple differences between multiple water quality data in the sample water quality data and multiple predicted data corresponding to the multiple water quality data output by the second model after training.
[0020] In a second aspect, the present disclosure provides a water quality forecasting system, including:
[0021] An acquisition module is used to acquire current water quality data of a target water area, wherein the water quality data is time series data;
[0022] A selection module is provided to determine the data type of the water quality data, and select a corresponding first water quality prediction model based on the data type; wherein water quality data of different data types correspond to different first water quality prediction models, and the method for determining the first water quality prediction model corresponding to the water quality data of each data type includes: training the first model and the second model respectively based on the sample water quality data of each data type, calculating the first parameter corresponding to the first model and the second parameter corresponding to the second model after the training, and comparing the first parameter and the second parameter to select the model with the smaller parameter as the first water quality prediction model; wherein the first model and the second model are different and are both machine learning models for processing time series data; the first parameter and the second parameter are used to characterize the prediction difference of the first model and the second model for the sample water quality data after the training;
[0023] A forecasting module is used to input the water quality data into a first water quality forecasting model to obtain first water quality forecasting data within a first time period in the future;.
[0024] In a third aspect, an embodiment of the present disclosure provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the water quality forecasting method described in any of the above embodiments.
[0025] In a fourth aspect, an embodiment of the present disclosure provides an electronic device, including:
[0026] Processor; and
[0027] Memory for storing computer programs;
[0028] Wherein, the processor is configured to execute the water quality forecasting method described in any of the above embodiments by executing the computer program.
[0029] Compared with the prior art, the technical solution provided by the embodiments of the present disclosure has the following advantages:
[0030] The water quality forecasting method and system provided by the disclosed embodiment obtain the current water quality data of the target water area, wherein the water quality data is time series data; determine the data type of the water quality data, and select the corresponding first water quality forecasting model based on the data type; wherein water quality data of different data types correspond to different first water quality forecasting models, and the determination method of the first water quality forecasting model corresponding to the water quality data of each data type includes: training the first model and the second model respectively based on the sample water quality data of each data type, calculating the first parameter corresponding to the first model and the second parameter corresponding to the second model after the training, and comparing the first parameter and the second parameter to select the model with the smaller parameter as the first water quality forecasting model; wherein the first model and the second model are different and are both machine learning models for processing time series data; the first parameter and the second parameter are used to characterize the prediction difference of the first model and the second model for the sample water quality data after the training; the water quality data is input into the first water quality forecasting model to obtain the first water quality forecasting data within the first time period in the future. In this embodiment, two joint models are used for the training of water quality data of each data type in advance, and the model with the best training result in the two models is used to actually predict the corresponding type of water quality data, thereby improving the water quality forecasting accuracy for different water quality data. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0032] 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, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0033] Figure 1 This is a flow chart of the water quality forecasting method according to an embodiment of the present disclosure;
[0034] Figure 2 It is a graph of pH daily data of water quality data of an embodiment of the present disclosure;
[0035] Figure 3 A flowchart of discrete wavelet transform denoising process according to an embodiment of the present disclosure;
[0036] Figure 4 is a schematic diagram of a water quality forecasting system according to an embodiment of the present disclosure;
[0037] Figure 5 Schematic diagram of an electronic device according to an embodiment of the present disclosure. DETAILED DESCRIPTION
[0038] In order to more clearly understand the above-mentioned objectives, features and advantages of the present disclosure, the scheme of the present disclosure will be further described below. It should be noted that the embodiments of the present disclosure and the features in the embodiments can be combined with each other without conflict.
[0039] In the following description, many specific details are set forth to facilitate a full understanding of the present disclosure, but the present disclosure may also be implemented in other ways different from those described herein; it is obvious that the embodiments in the specification are only part of the embodiments of the present disclosure, rather than all of the embodiments.
[0040] It should be understood that, in the following, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the associated objects before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.
[0041] Figure 1 The following is a flow chart of a water quality forecasting method according to an embodiment of the present disclosure. The method can be applied to a computing device such as a computer and may specifically include the following steps:
[0042] Step S101: Acquire current water quality data of the target water area, wherein the water quality data is time series data.
[0043] Exemplarily, the water area may be a river, lake, or sea. In this embodiment, the target water area may be a section of a river water area, and the monitoring water quality data of the section water area may be obtained. The water quality data may include but are not limited to pH, turbidity (NTU), dissolved oxygen (DO), water temperature, electrical conductivity (ORP), permanganate index (CODmn), ammonia nitrogen (NH3N), total phosphorus (TP), and total nitrogen (TN). In this embodiment, the daily water quality is used as the forecast object, and the water quality data of the automatic water quality monitoring station can be converted into daily water quality data by the mean method, for example, the pH values at different times of the day constitute a set of time series data.
[0044] Step S102: Determine the data type of the water quality data, and select the corresponding first water quality prediction model based on the data type; wherein water quality data of different data types correspond to different first water quality prediction models. The method for determining the first water quality prediction model corresponding to water quality data of each data type includes: training the first model and the second model respectively based on the sample water quality data of each data type, calculating the first parameter corresponding to the first model and the second parameter corresponding to the second model after the training, and comparing the first parameter and the second parameter to select the model with the smaller parameter as the first water quality prediction model; wherein the first model and the second model are different and are both machine learning models for processing time series data; the first parameter and the second parameter are used to characterize the prediction differences of the first model and the second model for the sample water quality data after the training.
[0045] Exemplarily, the first model can be a long short-term memory LSTM (Long Short-Term Memory) model. The LSTM model is a model developed based on a recurrent neural network (RNN). The LSTM model structure is provided with a forget gate, an update gate, and an output gate. During the training process, the previous step output is used as part of the input data. In addition, the output generated by the model during the training process is considered to be imperfect. In order to correct the output result, the current step output is corrected by a forget gate for dot product. During the training process, the information in the forget gate is continuously updated by the update gate, and the forget gate itself can also forget useless information through, for example, a Sigmoid function. After training with a large amount of data, the final state of the LSTM model is formed, so it can solve problems such as classification, translation, and prediction. These can be understood with reference to the prior art and will not be repeated here. The second model can be a Prophet model. The Prophet model is an open source prediction model of Facebook, which takes long time series data as the analysis object.
[0046] The sample water quality data of each data type may be the data type of the water quality data obtained in step S101. If it is pH data, the sample water quality data is historical pH data. In this embodiment, the sample water quality data is also time series data. According to the continuity, the monitoring daily data such as pH daily data within one year may be selected as training data. Figure 2 Some daily pH data are shown. In some cases, interpolation methods such as univariate linear interpolation can be used to supplement data for short-term missing and abnormal data.
[0047] After determining the sample water quality data such as multiple historical pH daily data, the first model such as the LSTM model and the second model such as the Prophet model are iteratively trained based on the sample water quality data such as multiple historical pH daily data. After the training is completed, the first parameter of the trained first model such as the LSTM model and the second parameter of the second model such as the Prophet model are calculated. The first parameter and the second parameter are used to characterize the difference in prediction of the sample water quality data by the first model and the second model after the training. The prediction accuracy of the trained model can be evaluated by the first parameter and the second parameter. For example, by comparing the size of the first parameter and the second parameter, the model with the smaller parameter is selected as the first water quality prediction model, that is, the model with better actual prediction effect is selected from the two trained models as the first water quality prediction model, thereby improving the accuracy of water quality prediction.
[0048] Here, it should be noted that during model training, different first models such as LSTM models and second models such as Prophet models have different prediction effects on different water quality data due to their own model performances. Moreover, since different types of water quality data such as pH and dissolved oxygen have different values, magnitudes and change patterns, when performing the above model training for each type of water quality data, the model with a small parameter determined may be a trained LSTM model or a trained Prophet model. That is, the model with a small model parameter may change with different water quality data, but for each type of water quality data, the model finally determined is a model with better prediction effect.
[0049] Step S103: inputting the water quality data into a first water quality forecasting model to obtain first water quality forecasting data within a first time period in the future.
[0050] Finally, when the training is completed, the actually acquired water quality data, such as daily pH data, is input into the first water quality forecast model corresponding to such pH data, and the model outputs water quality forecast data for the first time period in the future, such as within 30 days.
[0051] In this embodiment, two joint models are pre-trained for water quality data of each data type, and the model with the best training result among the two models is used to actually predict the water quality, thereby improving the accuracy of water quality forecasting for different water quality data.
[0052] In contrast, in traditional multi-model forecasting schemes, the forecast results of different models are mostly weighted averaged. Although the forecast accuracy is improved to a certain extent, while absorbing the advantages of different models, the model disadvantages are also included, which actually affects the forecast accuracy. Therefore, in this embodiment, for different water quality data, based on the above model training method, different corresponding models can be used for prediction, that is, the model with the best training results in the two models can be used for prediction for different water quality data, thereby improving the water quality forecast accuracy for different water quality data.
[0053] In order to further improve the accuracy of water quality forecast, in some embodiments, the number of hidden units in the first model such as the LSTM model can be pre-set for the specific application scenario of the present disclosure, namely water quality forecast and the forecast duration to be achieved. The number of hidden units can be determined based on the water quality forecast duration, for example, the two are positively correlated, so as to better establish the correlation between historical and forecast water quality data, thereby improving the water quality prediction accuracy of the final trained model.
[0054] In order to further improve the accuracy of water quality forecast, in some embodiments, the second model can be a target Prophet model, which is a model after removing the holiday term in the Prophet model. The Prophet model takes into account the influence of the trend term g(t), the seasonal term s(t) and the holiday term h(t). Since surface water quality is different from pollution sources, holidays have no obvious impact on surface water quality. Therefore, the holiday term is not considered in this embodiment, and the target Prophet model is obtained by removing the holiday term h(t). The above model training process is performed based on the target Prophet model to replace the Prophet model in the above embodiment. The final model trained and selected in this way can further improve the accuracy of water quality forecast.
[0055] In one embodiment, the method may further include the following steps: inputting the water quality data into a second water quality forecast model to obtain second water quality forecast data within a second time period in the future; wherein the second water quality forecast model is obtained by training a third model based on sample water quality data, and the third model is a machine learning model for processing time series data; the second time period is shorter than the first time period.
[0056] Exemplarily, the first water quality forecast data may be a water quality forecast for the next 30 days, and the second water quality forecast data may be a water quality forecast for the next day, that is, the next day. The third model may be an LSTM model, and the sample water quality data is the same as in the above embodiment, such as historical multiple pH day data. The trained second water quality forecast model, such as the LSTM water quality model, can be used for forecasting the next day, while the above-mentioned first water quality forecast model can be used for forecasting the next 30 days. In this way, a water quality joint forecasting scheme can be implemented, and the two water quality forecasting models respectively output the water quality forecast for the next day and the forecast for the next 30 days, which are suitable for different forecasting needs.
[0057] In one embodiment, the method may further include: updating the second water quality forecast model based on the water quality data, so as to obtain new water quality forecast data based on the updated second water quality forecast model and water quality data acquired in the future.
[0058] After establishing the LSTM model for the next day's water quality forecast in this embodiment, the actual new monitored water quality data, i.e., verification data, can be continuously used to update the LSTM model network state during the forecasting process. In the next forecast in the future, new water quality forecast data can be predicted based on the updated second water quality forecast model and the water quality data obtained in the future, so that the water quality forecast accuracy of the second water quality forecast model can be gradually and continuously improved.
[0059] In order to further improve the accuracy of water quality forecasting, in one embodiment, the method may include the following steps: before inputting the water quality data into the first water quality forecasting model or the second water quality forecasting model, performing discrete wavelet transform denoising processing on the water quality data.
[0060] Exemplarily, discrete wavelet transform DWT (Discrete wavelet transform) has the characteristics of multi-resolution analysis, and can decompose time series data through time-scale signals, and separate the low-frequency and high-frequency parts of the signal through the continuous change of time window and frequency window. Discrete wavelet transform denoising is to filter out high-frequency noise in the data through signal decomposition. The water quality data in this embodiment is time series data, so the use of discrete wavelet transform denoising can effectively remove noise signals such as high-frequency noise, avoid the influence of noise on model prediction, and further improve the accuracy of water quality forecasting.
[0061] In some embodiments, the discrete wavelet transform is used to filter out noise, which requires processes such as wavelet decomposition, scale coefficient threshold processing, and signal reconstruction. Among them, wavelet transform denoising requires determining the wavelet basis, the number of decomposition layers, and the threshold. The more wavelet transform decomposition layers there are, the better the noise can be separated, but it is also easy to cause distortion of the reconstructed signal, resulting in reduced accuracy of water quality forecasting. In this embodiment, the water quality data noise mainly comes from data processing. In order to filter out high-frequency noise as much as possible, the number of decomposition layers can be fixed to 3, but it is not limited to this and can be determined according to different noise sources.
[0062] In this embodiment, the water quality data is processed by discrete wavelet transform denoising, and then the denoised data is input into the first water quality prediction model or the second water quality prediction model. Setting the appropriate number of decomposition layers can effectively remove noise signals for the scenario disclosed in this disclosure, and combining the model prediction further improves the accuracy of water quality forecasting.
[0063] Since no wavelet can be applied to all denoising scenarios, in order to further improve the water quality forecast accuracy for the scenario disclosed in this disclosure, different wavelets should be used for different water quality data. Figure 3 As shown, when discrete wavelet transform denoising is adopted, the discrete wavelet transform denoising process may specifically include the following steps:
[0064] Step S301: selecting a Daubechies wavelet corresponding to the data type; wherein water quality data of different data types correspond to different Daubechies wavelets, and the corresponding relationship is preliminarily determined based on the optimal denoising effect of different Daubechies wavelets on water quality data of each data type;
[0065] Step S302: performing discrete wavelet transform denoising processing on the water quality data based on the Dobesi wavelet corresponding to the data type.
[0066] As an example, for nine types of water quality data monitored by an automatic water quality monitoring station, such as pH, turbidity (NTU), dissolved oxygen (DO), water temperature, electrical conductivity (ORP), permanganate index (CODmn), ammonia nitrogen (NH3N), total phosphorus (TP), and total nitrogen (TN), for each type of water quality data, such as pH, Daubechies' db2-db8 wavelets, i.e., 7 different wavelet functions, are used to pre-perform denoising tests of wavelet decomposition, threshold setting, and wavelet reconstruction, and the denoising effects of the 7 tests are evaluated using the calculated signal-to-noise ratio, and the wavelet with the best denoising effect, i.e., the highest signal-to-noise ratio, is selected as the Daubechies wavelet corresponding to pH, such as the db6 wavelet. The same experimental determination process is also used for other types of water quality data, such as water temperature, so that a corresponding relationship is pre-established, i.e., a corresponding relationship between water quality data of different data types and different Daubechies wavelets.
[0067] Afterwards, for each type of water quality data, the corresponding wavelet, namely the Daubechies wavelet with the highest signal-to-noise ratio, can be selected to perform denoising on the water quality data, such as the db6 wavelet for pH data and the db7 wavelet for temperature data.
[0068] With respect to the scenarios disclosed in the present invention, different wavelets are applicable to different water quality data. Therefore, when discrete wavelet transform denoising is adopted, the most suitable wavelet corresponding to the current water quality data can be selected based on the correspondence relationship established based on the adaptability test of different water quality data in advance. That is, for different water quality data, the wavelet with the best denoising effect corresponding to the data type of the current water quality data is selected based on the correspondence relationship determined in advance for the best denoising effect, and discrete wavelet transform denoising processing is performed. This can improve the denoising effect for different water quality data, and then combine the model prediction to obtain more accurate water quality forecast data, which further improves the accuracy of water quality forecast.
[0069] In one embodiment, before respectively training the first model and the second model based on the sample water quality data, the sample water quality data is denoised to obtain training data; based on the training data, the first model and the second model are iteratively trained; wherein the denoising process includes discrete wavelet transform denoising process.
[0070] In one embodiment, before training the third model based on sample water quality data, the sample water quality data is denoised to obtain training data; the third model is iteratively trained based on the training data; wherein the denoising process includes discrete wavelet transform denoising process.
[0071] That is to say, in each of the above model training stages, since the sample water quality data, i.e. the original monitored water quality data, is used as training data and has undergone pre-processing such as monitoring, transmission, and mean processing, noise exists in the water quality data, which has an impact on the model training and thus has a greater impact on the water quality forecast results. Therefore, in each model training stage, the above-mentioned discrete wavelet transform denoising processing can also be performed first, and then model training can be performed to improve the prediction accuracy of the trained model, thereby improving the water quality forecast accuracy of the finally selected model.
[0072] In one embodiment, the sample water quality data may include multiple water quality data; the first parameter is determined based on multiple differences between multiple water quality data in the sample water quality data and multiple predicted data corresponding to the multiple water quality data output by the first model after training; the second parameter is determined based on multiple differences between multiple water quality data in the sample water quality data and multiple predicted data corresponding to the multiple water quality data output by the second model after training.
[0073] It is understandable that since the first parameter and the second parameter are used to characterize the difference in predictions of the first model and the second model for the sample water quality data after the training, that is, the prediction accuracy of the trained model can be evaluated by the first parameter and the second parameter. Therefore, if the first parameter and the second parameter are determined inaccurately, the final model selected for the joint model training of water quality data of a certain data type will not match (for example, the first model should actually be selected but the second model is selected), resulting in a decrease in the water quality forecast accuracy of the water quality data of this data type.
[0074] Therefore, in this embodiment, the first parameter P is based on the multiple water quality data X in the sample water quality data. i (i=1, 2, ..., N) and multiple prediction data Y corresponding to multiple water quality data output by the first model after training i Multiple differences between (X i -Y i ) is determined. For the first model after training, a water quality data X is input i , then the corresponding prediction data Y is output i In one example, the first parameter P1 may be represented by, but not limited to, the following formula:
[0075]
[0076] It can be understood that the calculation method of the second parameter P2 is the same as that of the first parameter P1. Therefore, for each data type of water quality data, two more accurate evaluation parameters P1 and P2 corresponding to each of the two models can be calculated, such as the first parameter P1 and the second parameter P2 corresponding to the pH data, and then the size of the two is compared, and the model with the smaller parameter is selected as the first water quality prediction model corresponding to the pH data. In this way, the final model selected by the joint model training for each data type of water quality data is an accurate match, which improves the accuracy of water quality prediction for different water quality data.
[0077] In one embodiment, the training process of the first model or the second model may include: constructing a loss function of the first model or the second model respectively, inputting sample water quality data into the first model or the second model to output the corresponding predicted values respectively, and iteratively updating the first model or the second model respectively based on the predicted values respectively of the first model or the second model until the loss value of the loss function of the first model or the second model satisfies the preset conditions and the training is terminated; wherein, the loss function of the first model or the second model respectively includes a first loss function and a second loss function; the first loss function represents the difference between the sample water quality data and the predicted values of the first model or the second model respectively; the second loss function represents the degree of discreteness between the predicted values of the first model or the second model respectively and the sample water quality data.
[0078] That is to say, the specific training process of the first model can be the same as the specific training process of the second model, and both are specified by forming the first loss function and the second loss function. The loss function reflects the impact of the model training process on the accuracy of the predicted value of the sample water quality data from two different aspects. Therefore, based on the above-mentioned model training method, the training and updating model parameters can be constrained from different aspects at the same time. The water quality forecast model obtained by training can predict more accurate water quality forecast data when applied, that is, the water quality forecast accuracy is further improved for different water quality data.
[0079] It should be noted that, although the steps of the method in the present disclosure are described in a specific order in the accompanying drawings, this does not require or imply that the steps must be performed in this specific order, or that all the steps shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step for execution, and / or one step may be decomposed into multiple steps for execution, etc. In addition, it is also easy to understand that these steps may be, for example, executed synchronously or asynchronously in multiple modules / processes / threads.
[0080] like Figure 4 As shown, the embodiment of the present disclosure provides a water quality forecasting system, comprising:
[0081] An acquisition module 401 is used to acquire current water quality data of a target water area, wherein the water quality data is time series data;
[0082] Selection module 402 is used to determine the data type of the water quality data, and select the corresponding first water quality prediction model based on the data type; wherein water quality data of different data types correspond to different first water quality prediction models. The method for determining the first water quality prediction model corresponding to water quality data of each data type includes: training the first model and the second model respectively based on the sample water quality data of each data type, calculating the first parameter corresponding to the first model and the second parameter corresponding to the second model after the training, and comparing the first parameter and the second parameter to select the model with the smaller parameter as the first water quality prediction model; wherein the first model and the second model are different and are both machine learning models for processing time series data; the first parameter and the second parameter are used to characterize the prediction differences of the first model and the second model for the sample water quality data after the training.
[0083] The forecast module 403 is used to input the water quality data into a first water quality forecast model to obtain first water quality forecast data within a first time period in the future.
[0084] In one embodiment, the forecasting module can also be used to: input the water quality data into a second water quality forecasting model to obtain second water quality forecast data within a second time period in the future; wherein the second water quality forecasting model is obtained by training a third model based on sample water quality data, and the third model is a machine learning model for processing time series data; wherein the second time period is shorter than the first time period.
[0085] In one embodiment, the system may further include an updating module for updating the second water quality forecast model based on the water quality data to obtain new water quality forecast data based on the updated second water quality forecast model and water quality data acquired in the future.
[0086] In one embodiment, the system may further include a denoising module for performing discrete wavelet transform denoising processing on the water quality data before inputting the water quality data into the first water quality prediction model or the second water quality prediction model.
[0087] In one embodiment, the discrete wavelet transform denoising process includes: selecting a Dobesi wavelet corresponding to the data type; wherein water quality data of different data types correspond to different Dobesi wavelets, and the corresponding relationship is pre-determined based on the optimal denoising effect of different Dobesi wavelets on water quality data of each data type; and performing discrete wavelet transform denoising on the water quality data based on the Dobesi wavelet corresponding to the data type.
[0088] In one embodiment, before respectively training the first model and the second model based on the sample water quality data, the sample water quality data is denoised to obtain training data; the first model and the second model are iteratively trained based on the training data; or, before training the third model based on the sample water quality data, the sample water quality data is denoised to obtain training data; the third model is iteratively trained based on the training data; wherein the denoising process includes discrete wavelet transform denoising process.
[0089] In one embodiment, the sample water quality data includes multiple water quality data; the first parameter is determined based on multiple differences between multiple water quality data in the sample water quality data and multiple predicted data corresponding to the multiple water quality data output by the first model after training; the second parameter is determined based on multiple differences between multiple water quality data in the sample water quality data and multiple predicted data corresponding to the multiple water quality data output by the second model after training.
[0090] In one embodiment, the first model is a long short-term memory (LSTM) model, and the second model is a target Prophet model, wherein the target Prophet model is a model after removing the holiday term in the Prophet model. Exemplarily, the number of hidden units in the LSTM model is determined based on the duration of the water quality forecast. The number of hidden units is positively correlated with the duration of the water quality forecast.
[0091] In one embodiment, the training process of the first model or the second model includes: constructing a loss function of the first model or the second model respectively, inputting sample water quality data into the first model or the second model to output the corresponding predicted values respectively, and iteratively updating the first model or the second model respectively based on the predicted values respectively of the first model or the second model until the loss value of the loss function of the first model or the second model satisfies the preset conditions and the training is terminated; wherein, the loss function of the first model or the second model respectively includes a first loss function and a second loss function; the first loss function represents the difference between the sample water quality data and the predicted values of the first model or the second model respectively; the second loss function represents the degree of discreteness between the predicted values of the first model or the second model respectively and the sample water quality data.
[0092] Regarding the system in the above embodiment, the specific manner in which each module performs operations and the corresponding technical effects brought about have been described in detail in the embodiment of the method, and will not be elaborated here.
[0093] It should be noted that although several modules or units of the device for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiment of the present disclosure, the features and functions of two or more modules or units described above can be concretized in one module or unit. Conversely, the features and functions of a module or unit described above can be further divided into multiple modules or units for concretization. The components displayed as modules or units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the disclosed solution. Those of ordinary skill in the art can understand and implement it without paying creative work.
[0094] The embodiments of the present disclosure further provide a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the water quality forecasting method described in any one of the above embodiments is implemented.
[0095] Exemplarily, the readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination thereof. More specific examples of readable storage media (a non-exhaustive list) include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof.
[0096] The computer readable storage medium may include a data signal propagated in a baseband or as part of a carrier wave, wherein a readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The readable storage medium may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by an instruction execution system, an apparatus, or a device or used in combination with it. The program code contained on the readable storage medium may be transmitted with any appropriate medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination of the above.
[0097] The present disclosure also provides an electronic device, including a processor and a memory, wherein the memory is used to store a computer program, wherein the processor is configured to execute the water quality forecasting method in any of the above embodiments by executing the computer program.
[0098] Refer to the following Figure 5The electronic device 600 according to this embodiment of the present invention is described. Figure 5 The electronic device 600 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0099] like Figure 5 As shown, the electronic device 600 is in the form of a general computing device. The components of the electronic device 600 may include, but are not limited to: at least one processing unit 610, at least one storage unit 620, a bus 630 connecting different system components (including the storage unit 620 and the processing unit 610), a display unit 640, etc.
[0100] The storage unit stores program codes, which can be executed by the processing unit 610, so that the processing unit 610 performs the steps according to various exemplary embodiments of the present invention described in the above method embodiment section of this specification. For example, the processing unit 610 can perform the following steps: Figure 1 The steps of the method shown in .
[0101] The storage unit 620 may include a readable medium in the form of a volatile storage unit, such as a random access memory unit (RAM) 6201 and / or a cache memory unit 6202 , and may further include a read-only memory unit (ROM) 6203 .
[0102] The storage unit 620 may also include a program / utility 6204 having a set (at least one) of program modules 6205, such program modules 6205 including but not limited to: an operating system, one or more application programs, other program modules and program data, each of which or some combination may include the implementation of a network environment.
[0103] Bus 630 may represent one or more of several types of bus structures, including a memory unit bus or memory unit controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.
[0104] The electronic device 600 may also communicate with one or more external devices 700 (e.g., keyboards, pointing devices, Bluetooth devices, etc.), may also communicate with one or more devices that enable a user to interact with the electronic device 600, and / or communicate with any device that enables the electronic device 600 to communicate with one or more other computing devices (e.g., routers, modems, etc.). Such communication may be performed via an input / output (I / O) interface 650. Furthermore, the electronic device 600 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) via a network adapter 660. The network adapter 660 may communicate with other modules of the electronic device 600 via a bus 630. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 600, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0105] Through the description of the above implementation methods, it is easy for those skilled in the art to understand that the example implementation methods described here can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the implementation methods of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, and includes several instructions to enable a computing device (which can be a personal computer, a server, or a network device, etc.) to execute the method steps of the above-mentioned embodiments according to the implementation methods of the present disclosure.
[0106] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0107] The above description is only a specific embodiment of the present disclosure, so that those skilled in the art can understand or implement the present disclosure. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present disclosure. Therefore, the present disclosure will not be limited to the embodiments described herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A water quality forecasting method, characterized in that: include: Acquire current water quality data of the target water area, wherein the water quality data is time series data; Determine the data type of the water quality data, and select the corresponding first water quality prediction model based on the data type; wherein, water quality data of different data types correspond to different first water quality prediction models, and the method for determining the first water quality prediction model corresponding to the water quality data of each data type includes: training the first model and the second model respectively based on the sample water quality data of each data type, calculating the first parameter corresponding to the first model and the second parameter corresponding to the second model after the training, and comparing the first parameter and the second parameter to select the model with the smaller parameter as the first water quality prediction model; wherein, the first model and the second model are different and are both machine learning models for processing time series data; the first parameter and the second parameter are used to characterize the prediction difference of the first model and the second model for the sample water quality data after the training; The water quality data is input into a first water quality forecast model to obtain first water quality forecast data within a first time period in the future.
2. The method according to claim 1, characterized in that The method includes: The water quality data is input into a second water quality forecast model to obtain second water quality forecast data within a second time period in the future; wherein the second water quality forecast model is obtained by training a third model based on sample water quality data, and the third model is a machine learning model for processing time series data; and the second time period is shorter than the first time period.
3. The method according to claim 2, characterized in that The method includes: The second water quality forecast model is updated based on the water quality data to obtain new water quality forecast data based on the updated second water quality forecast model and water quality data acquired in the future.
4. The method according to claim 2, characterized in that: The method includes: Before inputting the water quality data into the first water quality prediction model or the second water quality prediction model, the water quality data is subjected to discrete wavelet transform denoising processing.
5. The method according to claim 4, characterized in that The discrete wavelet transform denoising process comprises: Selecting a Dobesi wavelet corresponding to the data type; wherein water quality data of different data types correspond to different Dobesi wavelets, and the corresponding relationship is determined in advance based on the optimal denoising effect of different Dobesi wavelets on water quality data of each data type; The water quality data is subjected to discrete wavelet transform denoising processing based on the Dobesi wavelet corresponding to the data type.
6. The method according to claim 5, characterized in that Before respectively training the first model and the second model based on the sample water quality data, denoising the sample water quality data to obtain training data; Iteratively training the first model and the second model based on the training data; Alternatively, before training the third model based on the sample water quality data, the sample water quality data is subjected to denoising to obtain training data; Iteratively training the third model based on the training data; Wherein, the denoising process includes the discrete wavelet transform denoising process.
7. The method according to any one of claims 1 to 6, characterized in that: The sample water quality data includes multiple water quality data; the first parameter is determined based on multiple differences between multiple water quality data in the sample water quality data and multiple predicted data corresponding to the multiple water quality data output by the first model after training; the second parameter is determined based on multiple differences between multiple water quality data in the sample water quality data and multiple predicted data corresponding to the multiple water quality data output by the second model after training.
8. A water quality forecasting system, characterized in that: include: An acquisition module is used to acquire current water quality data of a target water area, wherein the water quality data is time series data; A selection module is provided to determine the data type of the water quality data, and select a corresponding first water quality prediction model based on the data type; wherein water quality data of different data types correspond to different first water quality prediction models, and the method for determining the first water quality prediction model corresponding to the water quality data of each data type includes: training the first model and the second model respectively based on the sample water quality data of each data type, calculating the first parameter corresponding to the first model and the second parameter corresponding to the second model after the training, and comparing the first parameter and the second parameter to select the model with the smaller parameter as the first water quality prediction model; wherein the first model and the second model are different and are both machine learning models for processing time series data; the first parameter and the second parameter are used to characterize the prediction difference of the first model and the second model for the sample water quality data after the training; The forecast module is used to input the water quality data into a first water quality forecast model to obtain first water quality forecast data within a first time period in the future.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the water quality forecasting method according to any one of claims 1 to 7 is implemented.
10. An electronic device, characterized in that: include: processor; as well as Memory for storing computer programs; Wherein, the processor is configured to execute the water quality forecasting method according to any one of claims 1 to 7 by executing the computer program.
Citation Information
Patent Citations
Wavelet analysis coupled LSTM neural network water quality prediction method
CN114154583A
Long short-term memory network water quality parameter prediction method based on sparse label
CN116341705A
Multi-Level Time Series Forecaster
US20230022401A1
Cited By
Water quality pollution monitoring system and method
CN120522145A
Water pollution monitoring system and methods
CN120522145B
