Water quality prediction method, device, equipment and medium
By conducting principal component analysis and timing decomposition of water quality data, and training with combined models, a water quality prediction model is generated, which solves the problem of low universality of water quality prediction methods in the existing technology, and achieves higher accuracy of water quality prediction.
Patent Information
- Application Number
- CN202510326786.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-19
- Publication Date
- 2025-04-18
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The existing water quality prediction methods are not very universal, and the ARIMA model has poor fitting effects on samples with strong nonlinear characteristics. The gray model and regression model have strict requirements on data samples, making it difficult to adapt to the characteristics of different water quality data.
By obtaining water quality prediction training data, it is divided into predictor variables and influence variables, and principal component analysis is performed on the impact variables, time-series decomposition of the predictor variables, and training is combined with a combination of convolutional layer, maximum pooling layer, flattening layer, long and short-term memory network layer and fully connected layer to generate a water quality prediction model.
Effectively process redundant information in water quality data, eliminate variable correlation, use a combination model to capture the timing changes of water quality data, reduce lag, and improve the accuracy of water quality prediction.
Smart Images

Figure CN119849709A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of water quality protection, and in particular to a water quality prediction method, device, equipment and medium. Background Art
[0002] Water quality is an intuitive way to reflect the pollution status of water resources. Water quality prediction is an important part of water resource protection and development and is of great significance. Scientific and accurate water quality prediction can help scientifically and effectively manage and protect water resources, promote sustainable development, and mitigate the adverse effects of water pollution on the environment and humans.
[0003] Common methods for water quality prediction include ARIMA (Autoregressive Integrated Moving Average) model prediction, grey model prediction, and regression prediction. The ARIMA model does not fit samples with strong nonlinear characteristics well. The grey model requires that the data have certain regularity and trend, and the regression model requires a large amount of data and non-collinearity between variables. Both methods have certain requirements for data samples, so their universality is not high. Summary of the invention
[0004] The present invention provides a water quality prediction method, device, equipment and medium, the purpose of which is to improve the accuracy of water quality prediction.
[0005] In order to achieve the above object, the present invention provides a water quality prediction method, comprising: Step 1, obtaining water quality prediction training data; Step 2, dividing the water quality prediction training data into prediction variables and influencing variables, performing principal component analysis on the influencing variables to obtain a first processing result, and performing time series decomposition on the prediction variables to obtain a second processing result; Step 3, inputting the first processing result and the second processing result into the combined model for training to obtain a water quality prediction model; Step 4, the historical water quality data of the target water area is subjected to principal component analysis and time series decomposition, and then input into the water quality prediction model for prediction, so as to obtain the water quality prediction result of the target water area, and the water quality prediction result is used to evaluate the future water quality pollution degree of the target water area; The combined model includes sequentially connected convolutional layers, maximum pooling layers, flattening layers, long short-term memory network layers, and fully connected layers.
[0006] More specifically, step 1 includes: Water quality prediction training data is obtained through web crawler technology, and water quality data is downloaded from the environmental knowledge service system as supplementary data.
[0007] Furthermore, before dividing the water quality prediction training data into predictor variables and influencing variables, it also includes: Process missing values in water quality prediction training data; When the missing value in the water quality prediction training data is less than a preset threshold, the missing value in the water quality prediction training data is deleted to obtain training data with the missing value removed; When the missing value in the water quality prediction training data is greater than a preset threshold, the missing value in the water quality prediction training data is filled using the Lagrange interpolation method to obtain the filled training data; The Prophet algorithm is used to detect the training data with missing values removed or filled, to obtain outliers, and the outliers are treated as missing values to obtain the training data cleaning results; The training data cleaning results are normalized to obtain normalized training data.
[0008] More specifically, step 2 includes: The normalized training data is divided into prediction variables and influencing variables, the prediction variables are the water quality indicators to be predicted, and the influencing variables are the original water quality indicators; Use the principal component analysis method to perform dimension reduction processing on the influencing variables to obtain the first processing result; The prediction variables are decomposed into time series using a time series decomposition method to obtain a second processing result, which includes a seasonal component, a trend component and a residual component.
[0009] Specifically, the first processing result and the second processing result are input into the combined model for training to obtain a water quality prediction model, including: Inputting the first processing result and the second processing result into the long short-term memory network layer for training, and determining the number of neurons and the step length of the long short-term memory network layer; Determine the size and number of convolution kernels in the convolution layer by controlling the variable method; Select the Adam optimizer to optimize the network weights and obtain the network weights with the minimum training loss; The combined model is optimized based on the network weights with the minimum training loss to obtain the water quality prediction model.
[0010] The present invention also provides a water quality prediction device, comprising: An acquisition module, used to acquire water quality prediction training data; A processing module is used to divide the water quality prediction training data into prediction variables and influencing variables, perform principal component analysis on the influencing variables to obtain a first processing result, and perform time series decomposition on the prediction variables to obtain a second processing result; A training module, used for inputting the first processing result and the second processing result into the combined model for training to obtain a water quality prediction model; The prediction module is used to perform principal component analysis and time series decomposition on the historical water quality data of the target water area and then input it into the water quality prediction model for prediction to obtain the water quality prediction results of the target water area. The water quality prediction results are used to evaluate the future water quality pollution degree of the target water area; The combined model includes sequentially connected convolutional layers, maximum pooling layers, flattening layers, long short-term memory network layers, and fully connected layers.
[0011] The present invention also provides a terminal device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the water quality prediction method when executing the computer program.
[0012] The present invention also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the water quality prediction method is implemented.
[0013] The above scheme of the present invention has the following beneficial effects: The present invention obtains water quality prediction training data; divides the water quality prediction training data into prediction variables and influencing variables, performs principal component analysis on the influencing variables to obtain a first processing result, performs time series decomposition on the prediction variables to obtain a second processing result; inputs the first processing result and the second processing result into a combined model for training to obtain a water quality prediction model; performs principal component analysis and time series decomposition on historical water quality data of a target water area, and then inputs the data into the water quality prediction model for prediction to obtain a water quality prediction result of the target water area, and the water quality prediction result is used to evaluate the future water quality pollution degree of the target water area; compared with the prior art, the present invention can effectively process redundant information in water quality data, eliminate variable correlation, and use a combined model to capture the time series changes of water quality data respectively, thereby reducing hysteresis and improving the accuracy of water quality prediction.
[0014] Other beneficial effects of the present invention will be described in detail in the subsequent specific implementation section. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] Figure 1 It is a schematic diagram of a flow chart of an embodiment of the present invention; Figure 2 It is a structural schematic diagram of a combined model in an embodiment of the present invention; Figure 3 This is a comparison chart of prediction results in an embodiment of the present invention; Figure 4 Schematic diagram of the structure of a water quality prediction device in an embodiment of the present invention; Figure 5 Schematic diagram of the structure of a terminal device in an embodiment of the present invention. DETAILED DESCRIPTION
[0016] In order to make the technical problems, technical solutions and advantages to be solved by the present invention clearer, the following will be described in detail with reference to the accompanying drawings and specific embodiments. Obviously, the described embodiments are part of the embodiments of the present invention, rather than 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.
[0017] In the description of the present invention, it should be noted that, furthermore, the terms “first”, “second” and “third” are only used for descriptive purposes and cannot be understood as indicating or implying relative importance.
[0018] In the description of the present invention, it should be noted that, unless otherwise clearly specified and limited, the terms "installation", "connection" and "connection" should be understood in a broad sense, for example, it can be a locking connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection or an indirect connection through an intermediate medium, or it can be the internal communication of two components. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0019] In addition, the technical features involved in the different embodiments of the present invention described below can be combined with each other as long as they do not conflict with each other.
[0020] In view of the existing problems, the present invention provides a water quality prediction method, device, equipment and medium.
[0021] like Figure 1 As shown, an embodiment of the present invention provides a water quality prediction method, comprising: Step 1, obtaining water quality prediction training data; Step 2, dividing the water quality prediction training data into prediction variables and influencing variables, performing principal component analysis on the influencing variables to obtain a first processing result, and performing time series decomposition on the prediction variables to obtain a second processing result; Step 3, inputting the first processing result and the second processing result into the combined model for training to obtain a water quality prediction model; Step 4, the historical water quality data of the target water area is subjected to principal component analysis and time series decomposition, and then input into the water quality prediction model for prediction, so as to obtain the water quality prediction result of the target water area, and the water quality prediction result is used to evaluate the future water quality pollution degree of the target water area; The combined model includes sequentially connected convolutional layers, maximum pooling layers, flattening layers, long short-term memory network layers, and fully connected layers.
[0022] Specifically, step 1 includes: Water quality prediction training data is obtained through web crawler technology, and water quality data is downloaded from the environmental knowledge service system as supplementary data.
[0023] In an embodiment of the present invention, water quality data in the environmental monitoring center is accessed through web crawler technology to obtain all water quality information of all sites. In the system interface, three requests can be viewed using the Network function in Google Chrome. The code source for web page crawling is determined by selecting the third ashx file that can display all water quality information of the web page. In order to simulate the browser loading the web page and successfully obtain data, some necessary attributes need to be set in the request, such as Cookie, User_Agent, Host, Pageindex and Request_Method, etc.; detailed water quality data in JSON format is obtained using the requests library, and parsed using the Xpath tool; the obtained water quality labels are extracted, regular expressions are used to filter labels that are not related to the experiment, and redundant fields and symbols, such as province, watershed and section names, are cleaned, and finally the data is saved in a csv file; the BlockingScheduler() module in the apscheduler library is imported into the Python file, which can automatically start the crawler program within the set time. Considering that water quality data is updated every 4 hours, this experiment sets the startup cycle to 4 hours; the Python file is deployed on a RTX2080Ti (Graphics Processing Unit, GPU) server in a Linux environment, and a process is created using the screenS command to achieve timed crawling of background data, thereby constructing water quality prediction training data.
[0024] Specifically, before dividing the water quality prediction training data into predictor variables and influencing variables, it also includes: Process missing values in water quality prediction training data; When the missing value in the water quality prediction training data is less than a preset threshold, the missing value in the water quality prediction training data is deleted to obtain training data with the missing value removed; When the missing value in the water quality prediction training data is greater than a preset threshold, the missing value in the water quality prediction training data is filled using the Lagrange interpolation method to obtain the filled training data; The Prophet algorithm is used to detect the training data with missing values removed or filled, to obtain outliers, and the outliers are treated as missing values to obtain the training data cleaning results; The training data cleaning results are normalized to obtain normalized training data.
[0025] In an embodiment of the present invention, the data is converted into a Dataframe format through the Pandas module in Python. When the missing value in the water quality prediction training data is less than a preset threshold, the pd.dropna() function is used to delete the missing value in the water quality prediction training data; when the missing value in the water quality prediction training data is greater than the preset threshold, Lagrange interpolation is used to fill it.
[0026] It should be noted that the Lagrange interpolation method can achieve polynomial nonlinear fitting by establishing a single variable multi-order equation. In time series data, there is often a certain correlation and trend between data points, and the time span between data points may also be uneven. Therefore, the use of Lagrange interpolation has a better effect on filling in nonlinear water quality data. Assume that the function is a polynomial function, The interval is , then the Lagrange interpolation polynomial for: in, Represents the The independent variable value of each point, Represents the The value of the dependent variable at each point.
[0027] The embodiment of the present invention takes into account that various indicators in surface water are affected by natural meteorological changes and human activities, and their changes are characterized by periodicity, diversity and complexity. The data distribution does not conform to the normal distribution. The Prophet algorithm is used to process outliers in time series data.
[0028] It should be noted that the Prophet algorithm is an efficient Python language time series forecasting tool. It can automatically analyze and predict future trends with high accuracy. It can handle large-scale, small-granularity outliers and provide a reliable confidence interval, which makes it extremely stable when dealing with missing data and trend changes. At the same time, this method can fill the outliers in the data after outlier processing through trend changes. The specific process is as follows: Name the time column ds, name the corresponding data y, use the Prophet class to create a model instance, fit the model with historical data, use the fitted model to predict, and get the predicted value and confidence interval of the future time series. Points that fall outside the confidence interval of the original data can be considered as outliers of the time series. Outliers can be identified by comparing the confidence intervals (yhat_lower, yhat_upper) of the actual value y and the predicted value. For detected outliers, choose to backfill with the model predicted value.
[0029] The embodiment of the present invention uses the min_max normalization technology to scale the data to The calculation formula for interval is: in, represents the new sequence after normalization, is the original input sequence, and are the minimum and maximum values of the input sequence, respectively.
[0030] Specifically, step 2 includes: The normalized training data is divided into prediction variables and influencing variables, the prediction variables are the water quality indicators to be predicted, and the influencing variables are the original water quality indicators; Use the principal component analysis method to perform dimension reduction processing on the influencing variables to obtain the first processing result; The prediction variables are decomposed into time series using a time series decomposition method to obtain a second processing result, which includes a seasonal component, a trend component and a residual component.
[0031] Specifically, the principal component analysis method is used to reduce the dimension of the influencing variables to obtain the first processing result, including: Calculate the covariance matrix: Calculate the covariance matrix for the influencing variables. The covariance matrix can describe the correlation between data features; Eigenvalue decomposition: Perform eigenvalue decomposition on the covariance matrix to obtain the eigenvalues and corresponding eigenvectors; Select principal components: Sort the eigenvalues from large to small, and select the eigenvectors corresponding to the first k largest eigenvalues. These eigenvectors constitute a new feature space. Construct transformation matrix: Use the selected eigenvectors as column vectors to construct the transformation matrix ; Data projection: Project the original data into a new feature space composed of selected feature vectors to obtain the reduced-dimensional data; Interpret the reduced-dimensional data and analyze the original data characteristics represented by each principal component; Calculate the principal component scores: Get the scores of each sample on each principal component as the first processed data.
[0032] Specifically, the time series decomposition method is used to decompose the predicted variables in time series to obtain the second processing result, which includes seasonal components, trend components and residual components, including: The original data was decomposed using the STL module in Python. Considering that the frequency of change is once every 24 hours and the water quality data set is updated every 4 hours, the decomposition period parameter was set to 6 during the STL decomposition to properly capture the cyclical change trend within each day; the trend variables, seasonal variables and residual variables obtained by decomposition were tested using the autocorrelation function, and the residual term passed the normality test to indicate that the decomposition was effective.
[0033] In an embodiment of the present invention, the convolution layer and the maximum pooling layer constitute a convolutional neural network module. The convolution layer performs a convolution operation on the input sequence, so that the features in the original sequence can be amplified by the weight of the convolution kernel to obtain a new data with a feature sequence stronger than the original sequence; the maximum pooling layer pools the maximum value in the sequence through a sliding window to obtain a feature matrix with stronger expressive ability; the feature matrix is passed to the long short-term memory network layer through the flattening layer, and the related data is screened and updated through the forgetting and output characteristics of the long short-term memory network layer, and the long short-term memory network layer connects the output result to the fully connected layer to output the predicted value. At the same time, the combined model can also avoid overfitting through dropout and regularization techniques to improve the robustness of the model.
[0034] It should be noted that the hyperparameter setting of the combined model consists of two parts: The first part is to determine the parameters of the LSTM network layer. In order to determine the most appropriate number of neurons, the test set data needs to be put into the LSTM network layer for training to obtain the number of neurons that makes the model's evaluation indicators perform best. The second part is to determine the parameters of the convolutional neural network module. The kernel model uses the feature data extracted from the convolution layer and the pooling layer as the input of the long short-term memory network layer. Therefore, after determining the parameters of the long short-term memory network layer, it is necessary to determine the parameters of the convolution layer and the maximum pooling layer. The control variable method is used to train the sizes and numbers of different convolution kernels to select the optimal parameters.
[0035] Specifically, the first processing result and the second processing result are input into the combined model for training to obtain a water quality prediction model, including: Inputting the first processing result and the second processing result into the long short-term memory network layer for training, and determining the number of neurons and the step length of the long short-term memory network layer; Determine the size and number of convolution kernels in the convolution layer by controlling the variable method; Select the Adam optimizer to optimize the network weights and obtain the network weights with the minimum training loss; The combined model is optimized based on the network weights with the minimum training loss to obtain the water quality prediction model.
[0036] Specifically, step 4 includes: Perform principal component analysis on the historical water quality data of the target water area to obtain the scores of the historical water quality data on each principal component; Decompose the historical water quality data of the target water area into time series to obtain periodic components, trend components and residual components; The scores, periodic components, trend components and residual components of historical water quality data on each principal component are input into the water quality prediction model for prediction to obtain the water quality prediction results of the target water area. The water quality prediction results are used to evaluate the future water pollution degree of the target water area. The water quality prediction results include but are not limited to pH content, dissolved oxygen concentration and permanganate content.
[0037] Specifically, the embodiment of the present invention performs a denormalization process on the output water quality prediction result to restore it to the original numerical range, and uses index evaluation and curve evaluation to compare the model constructed by the embodiment of the present invention with other models, as follows: In order to evaluate the model effect, the embodiment of the present invention selects mean square error (MSE), root mean square error (RMSE), mean absolute percentage error (MAPE), and Pearson correlation coefficient (PCCs) as evaluation indicators, and compares the prediction results output by the water quality prediction model provided by the embodiment of the present invention with the ARIMA model, XGboost model, LSTM model, CNN-LSTM model, CEEMDANLSTM, and BiLSTM. The comparison results are shown in Table 1 below: Table 1 Comparison of water quality dissolved oxygen index prediction results
[0038] It can be seen from Table 1 above that the prediction results of the water quality detection model provided by the embodiment of the present invention are more excellent in all indicators.
[0039] The embodiment of the present invention also draws the prediction curve of the CNN-LSTM model and the water quality prediction model provided by the embodiment of the present invention through the Matplotlib module of python, such as Figure 3 As shown, compared with the actual curve, it is found that the water quality detection model provided by the embodiment of the present invention is closer to the actual value.
[0040] The embodiment of the present invention obtains water quality prediction training data; divides the water quality prediction training data into prediction variables and influencing variables, performs principal component analysis on the influencing variables to obtain a first processing result, performs time series decomposition on the prediction variables to obtain a second processing result; inputs the first processing result and the second processing result into a combined model for training to obtain a water quality prediction model; performs principal component analysis and time series decomposition on historical water quality data of a target water area and inputs the data into the water quality prediction model for prediction to obtain a water quality prediction result of the target water area, and the water quality prediction result is used to evaluate the future water quality pollution degree of the target water area; compared with the prior art, the embodiment of the present invention can effectively process redundant information in water quality data, eliminate variable correlation, and use a combined model to capture the time series changes of water quality data respectively, thereby reducing hysteresis, improving the accuracy of water quality prediction, and providing a scientific means for environmental governance.
[0041] Corresponding to the water quality prediction method described in the above embodiment, Figure 4 As shown, the present invention also provides a water quality prediction device 100, the water quality prediction device 100 comprising: An acquisition module 101 is used to acquire water quality prediction training data; The processing module 102 is used to divide the water quality prediction training data into prediction variables and influencing variables, perform principal component analysis on the influencing variables to obtain a first processing result, and perform time series decomposition on the prediction variables to obtain a second processing result; A training module 103, used for inputting the first processing result and the second processing result into a combined model for training to obtain a water quality prediction model; Prediction module 104, used to perform principal component analysis and time series decomposition on historical water quality data of target water area and input the data into water quality prediction model for prediction, so as to obtain water quality prediction results of target water area, and the water quality prediction results are used to evaluate the future water quality pollution degree of target water area; The combined model includes sequentially connected convolutional layers, maximum pooling layers, flattening layers, long short-term memory network layers, and fully connected layers.
[0042] It should be noted that the information interaction, execution process, etc. between the above-mentioned devices / units are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.
[0043] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0044] The embodiment of the present invention also provides a terminal device, such as Figure 5 As shown, the terminal device D10 of this embodiment includes: at least one processor D100 ( Figure 5 Only one processor is shown in the figure), a memory D101, and a computer program D102 stored in the memory D101 and executable on the at least one processor D100, wherein the above-mentioned water quality prediction method is implemented when the processor D100 executes the computer program D102.
[0045] The terminal device D10 may be a computing device such as a desktop computer, a notebook, a PDA, a server, a server cluster, a cloud server, etc. The terminal device may include, but is not limited to, a processor D100 and a memory D101. Those skilled in the art will appreciate that Figure 5 This is only an example of the terminal device D10 and does not constitute a limitation on the terminal device D10. The terminal device D10 may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, it may also include input and output devices, network access devices, etc.
[0046] The processor D100 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.
[0047] In some embodiments, the memory D101 may be an internal storage unit of the terminal device D10, such as a hard disk or memory of the terminal device D10. In other embodiments, the memory D101 may also be an external storage device of the terminal device D10, such as a plug-in hard disk, a smart memory card (SMC, SmartMedia Card), a secure digital (SD, Secure Digital) card, a flash card (Flash Card), etc. equipped on the terminal device D10. Further, the memory D101 may also include both an internal storage unit of the terminal device D10 and an external storage device. The memory D101 is used to store an operating system, an application program, a boot loader (BootLoader), data, and other programs, such as the program code of the computer program, etc. The memory D101 may also be used to temporarily store data that has been output or is to be output.
[0048] It should be noted that the information interaction, execution process, etc. between the above-mentioned devices / units are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.
[0049] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0050] The present invention also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the water quality prediction method is implemented.
[0051] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may at least include: any entity or device that can carry the computer program code to the construction device / terminal device, recording medium, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, RandomAccess Memory), electric carrier signal, telecommunication signal and software distribution medium. For example, a USB flash drive, a mobile hard disk, a disk or an optical disk.
[0052] The above is a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A water quality prediction method, characterized in that: include: Step 1, obtaining water quality prediction training data; Step 2, dividing the water quality prediction training data into prediction variables and influencing variables, performing principal component analysis on the influencing variables to obtain a first processing result, and performing time series decomposition on the prediction variables to obtain a second processing result; Step 3, inputting the first processing result and the second processing result into a combined model for training to obtain a water quality prediction model; Step 4, performing principal component analysis and time series decomposition on the historical water quality data of the target water area and inputting the data into the water quality prediction model for prediction to obtain the water quality prediction result of the target water area, and the water quality prediction result is used to evaluate the future water quality pollution degree of the target water area; The combined model includes a convolutional layer, a maximum pooling layer, a flattening layer, a long short-term memory network layer, and a fully connected layer connected in sequence.
2. The water quality prediction method according to claim 1, characterized in that: The step 1 comprises: Water quality prediction training data is obtained through web crawler technology, and water quality data is downloaded from the environmental knowledge service system as supplementary data.
3. The water quality prediction method according to claim 2, characterized in that: Before dividing the water quality prediction training data into prediction variables and influencing variables, the method further includes: Performing missing value processing on the water quality prediction training data; When the missing value in the water quality prediction training data is less than a preset threshold, the missing value in the water quality prediction training data is deleted to obtain training data with the missing value removed; When the missing value in the water quality prediction training data is greater than a preset threshold, the missing value in the water quality prediction training data is filled using the Lagrange interpolation method to obtain filled training data; The Prophet algorithm is used to detect the training data with missing values removed or the training data after filling to obtain outliers, and the outliers are processed as missing values to obtain training data cleaning results; The training data cleaning result is normalized to obtain normalized training data.
4. The water quality prediction method according to claim 3, characterized in that: The step 2 comprises: The normalized training data is divided into prediction variables and influencing variables, wherein the prediction variables are water quality indicators to be predicted, and the influencing variables are original water quality indicators; Performing dimensionality reduction processing on the influencing variables using a principal component analysis method to obtain a first processing result; The predicted variable is decomposed into time series using a time series decomposition method to obtain a second processing result, which includes a seasonal component, a trend component and a residual component.
5. The water quality prediction method according to claim 4, characterized in that: Inputting the first processing result and the second processing result into a combined model for training to obtain a water quality prediction model, including: Inputting the first processing result and the second processing result into the long short-term memory network layer for training, and determining the number of neurons and the step length of the long short-term memory network layer; Determine the size and number of convolution kernels in the convolution layer by controlling the variable method; Select the Adam optimizer to optimize the network weights and obtain the network weights with the minimum training loss; The combined model is optimized based on the network weight with the minimum training loss to obtain a water quality prediction model.
6. A water quality prediction device, characterized in that: include: An acquisition module, used to acquire water quality prediction training data; A processing module, used for dividing the water quality prediction training data into prediction variables and influencing variables, performing principal component analysis on the influencing variables to obtain a first processing result, and performing time series decomposition on the prediction variables to obtain a second processing result; A training module, used for inputting the first processing result and the second processing result into a combined model for training to obtain a water quality prediction model; A prediction module, for performing principal component analysis and time series decomposition on the historical water quality data of the target water area and inputting the data into the water quality prediction model for prediction to obtain a water quality prediction result of the target water area, wherein the water quality prediction result is used to evaluate the future water quality pollution degree of the target water area; The combined model includes a convolutional layer, a maximum pooling layer, a flattening layer, a long short-term memory network layer, and a fully connected layer connected in sequence.
7. A terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the water quality prediction method according to any one of claims 1 to 5 is implemented.
8. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the water quality prediction method according to any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
DWT-PCA-LSTM-based water supply quantity prediction device for water supply company
CN111079989A
Sewage treatment effluent prediction method and system based on deep neural network
CN116934167A
Power ramp event prediction method and device, equipment and storage medium
CN116960941A
Water area pollution prediction method based on multiple scales and multiple dimensions
CN118228923A
Marine ranch water quality multi-parameter prediction method
CN118553338A
Cited By
Water quality prediction network, water quality prediction model training method and device, and water quality prediction method and device
CN121306338A