Water quality prediction method based on machine learning and SWAT model

By building a self-learning mechanism based on LSTM and SVR, the computational complexity and insufficient precision of traditional water quality prediction models are solved, and efficient and real-time water quality prediction and early warning are achieved, which is suitable for river basin water quality monitoring and pollution control.

CN120654557APending Publication Date: 2025-09-16CHINA MCC17 GRP CO LTD
View PDF 0 Cites 4 Cited by

Patent Information

Application Number
CN202510744369.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-05
Publication Date
2025-09-16

AI Technical Summary

Technical Problem

Traditional water quality prediction models based on physical mechanisms have high requirements for basic data accuracy, cumbersome calculation processes and slow response speeds. The SWAT model faces problems of small sample data and noise interference during parameter calibration, making it difficult to ensure stable prediction accuracy.

Method used

A self-learning mechanism based on LSTM and SVR is constructed. By regularly updating model parameters and combining SVR for sensitivity analysis and particle swarm optimization, computing costs are reduced, prediction accuracy and response efficiency are improved, LSTM is used to capture the dynamic characteristics of water quality time series data, a water quality time series prediction model is constructed, and continuous optimization of the model is achieved through a self-learning mechanism.

Benefits of technology

It improves the adaptability and real-time performance of water quality prediction, reduces the cost of manual intervention, and improves monitoring efficiency and prediction accuracy. It is suitable for many practical scenarios such as river basin water quality monitoring, water environment early warning, and pollution control.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120654557A_ABST
    Figure CN120654557A_ABST
Patent Text Reader

Abstract

The invention discloses a water quality prediction method based on machine learning and an SWAT model, and belongs to the technical field of water environment simulation and water quality early warning. The method comprises the steps that S1, hydrology, water quality, meteorology, land utilization types, pollution sources and spatial elevation multi-temporal data are collected from multiple channels in a drainage basin, and noise reduction, normalization and missing value filling preprocessing methods are adopted for original data; s2, performing sensitivity analysis on the nonlinear relationship between the SWAT model parameters and the output by adopting SVR, and screening out key parameters with remarkable influence; s3, on the basis of the water quality monitoring data, constructing a water quality time sequence prediction model by adopting an LSTM model; and S4, constructing a self-learning mechanism based on the LSTM and the SVR model, and retraining the model by adjusting a learning time window and regularly utilizing latest data. The method is excellent in the aspects of model efficiency, prediction precision and application adaptability, and has remarkable engineering application value and popularization potential.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of water environment simulation and water quality early warning, and specifically to a water quality prediction method based on machine learning and a SWAT model. Background Art

[0002] The spatiotemporal distribution of water quality indicators such as COD, total nitrogen, and suspended solids exhibits complex nonlinear characteristics, and the overall water quality is deteriorating, necessitating the implementation of effective monitoring and early warning measures. Water quality simulation is crucial in water resource management, environmental protection, and ecological restoration. It facilitates a deeper understanding of the sources, transport processes, and influencing factors of water pollution, providing a basis for developing scientific water environment protection measures.

[0003] Among the many water quality simulation tools, the SWAT (Soil and Water Assessment Tool) model has attracted much attention due to its wide application in watershed water environment simulation. For example, Xie Pei et al. used the SWAT model to simulate the runoff process of the Longdu River Basin and proposed an ecological flow calculation method for rivers without measured flow. Wang Zhonggen et al. applied the SWAT model in the Haihe River Basin, conducted multi-objective calibration and evaluation of the model parameters, and explored the applicability and improvement methods of the model in different watersheds. However, traditional water quality prediction models based on physical mechanisms have high requirements for the accuracy of basic data, the calculation process is cumbersome and the response speed is slow. At the same time, the SWAT model often faces problems of small sample data and noise interference during the parameter calibration process, which makes it difficult to stably guarantee its prediction accuracy.

[0004] At the same time, machine learning methods have achieved remarkable results in the fields of hydrological and water environment prediction. Their high sensitivity, data-driven "black box" advantages, and rapid response capabilities have enabled them to demonstrate high accuracy and strong generalization capabilities in the prediction of runoff, sediment, and water quality indicators. For example, Liu Yu et al. simulated and made multi-step predictions of runoff in the Yajiang River Basin in the upper reaches of the Yalong River based on the ForecastNet model, achieving good results. Wang et al. used the SVR method to study the relationship between multi-band remote sensing data and COD and ammonia nitrogen concentrations in the Weihe River Basin in China, demonstrating that the SVR method is superior to traditional multivariate regression methods in this task. Hafeez et al. used artificial neural networks, support vector regression, and other models to predict water quality indicators such as suspended matter concentration, chlorophyll, and turbidity in coastal areas based on remote sensing data. The study showed that the prediction accuracy of the artificial neural network model basically reached over 90%.

[0005] There are numerous machine learning algorithms, each with its own unique focus on applicable scenarios, structural characteristics, learning methods, and learning capabilities. In practical applications, the appropriate algorithm must be selected based on the specific context. SVR and LSTM each offer advantages in structural characteristics and application scenarios, making them suitable for dynamic water quality modeling and prediction. SVR possesses strong nonlinear modeling capabilities, effectively overcoming issues such as the curse of dimensionality and local extrema. It offers excellent global optimality and requires a low sample size, making it suitable for calibrating complex model parameters. LSTM, as an improved form of recurrent neural network, is capable of handling long-sequence dependencies and demonstrates excellent performance in capturing dynamic features in water quality time series data. It is particularly well-suited for predicting water environment indicators with hysteresis and cyclical variations. Therefore, combining SVR and LSTM demonstrates significant advantages in small-sample modeling and time series prediction, offering a new approach to improving the response efficiency and predictive power of traditional SWAT models in water quality early warning applications. Summary of the Invention

[0006] The purpose of the present invention is to provide a water quality prediction method based on machine learning and the SWAT model, construct a self-learning mechanism based on LSTM and SVR, and ensure that the system has high adaptability and real-time performance when responding to climate change and the impact of human activities by regularly updating model parameters; it exhibits higher computing efficiency and prediction accuracy in data preprocessing, parameter updating, and early warning response, which can effectively reduce the cost of manual intervention and improve monitoring efficiency, and has broad application prospects to address the shortcomings of existing technologies.

[0007] To achieve the above object, the present invention provides the following technical solutions:

[0008] The water quality prediction method based on machine learning and SWAT model includes the following steps:

[0009] S1: Multi-temporal data, including hydrological, water quality, meteorological, land use type, pollution sources, and spatial elevation data, are collected from multiple channels within the basin. Preprocessing methods such as noise reduction, normalization, and missing value filling are applied to the raw data to establish a temporally and spatially consistent basic dataset, providing high-quality input for subsequent model training and parameter optimization. Furthermore, ArcSWAT is used to delineate sub-basins, which are further divided into hydrological response units.

[0010] S2: Using SVR to conduct sensitivity analysis on the nonlinear relationship between SWAT model parameters and output, we screened out key parameters with significant impact, and based on this, we constructed an SVR proxy model, achieving high-precision predictions while reducing the number of SWAT runs. We also used particle swarm optimization to calibrate key parameters, making the model output closer to actual monitoring data, significantly improving calibration efficiency and reducing computational costs.

[0011] S3: Based on water quality monitoring data, an LSTM model is used to build a water quality time series prediction model. By learning the dynamic characteristics of water quality indicators over time, it can predict the water quality trend in the short term in the future and generate early warning signals.

[0012] S4: Build a self-learning mechanism based on LSTM and SVR models. By adjusting the learning time window and regularly retraining the model with the latest data, the SWAT model parameters can be continuously updated and optimized, thereby ensuring that the water quality early warning system has high adaptability and real-time performance in response to climate change and the impact of human activities.

[0013] Furthermore, the data cleaning algorithm is used in S1 to reduce the noise of the original data, and the normalization method is used to unify the data from different sources to the same scale; the missing value interpolation algorithm is used to ensure the continuity of the data, thereby constructing a basic data set that is consistent in time and space.

[0014] Furthermore, the watershed division tool in ArcSWAT software is used in S1 to divide the sub-watersheds. This step includes loading the digital elevation model and the actual river network data, setting the river threshold area, loading the water inlet location data, and setting the watershed outlet location.

[0015] Furthermore, the SVR in S2 transforms the input feature x into i and the corresponding water quality observation value y i Through the kernel mapping function Mapped to a high-dimensional feature space, the model is fitted by solving the following optimization problem:

[0016]

[0017] The objective function aims to achieve the optimal solution by minimizing the loss function and the regularization term, where C is the penalty factor, ξ and ξ * Is a slack variable used to control the error, and the constraints are as follows:

[0018]

[0019] Among them, ε is the tolerance error, is the kernel mapping function. Through this optimization process, SVR can effectively identify the key parameters that have a significant impact on the water quality simulation results.

[0020] Furthermore, in the parameter calibration process of S2, the Nash efficiency coefficient (NSE) and the determination coefficient (R 2) and other evaluation indicators to comprehensively evaluate the prediction accuracy and fit of the model. These evaluation indicators can effectively reflect the difference between the model output and the measured data, thereby ensuring the high accuracy and reliability of the model. The specific calculation formula is as follows:

[0021]

[0022] Once the initial parameters are determined, an SVR-based regression model is used, with the deviation between the SWAT simulation results and the actual observation data as the training target. By adjusting the kernel function parameters and penalty factors, a mapping relationship between the key SWAT parameters (such as runoff distribution, pollutant mobility, etc.) and the observation error is established. The adaptive correction of the model parameters is then performed using the following update formula:

[0023] P t+1 =P t +α(Y obs -Y sim ) (7)

[0024] Among them, P t is the SWAT parameter at time t, and α is the learning rate parameter. By gradually adjusting the model parameters, the difference between the simulated value and the measured value can be continuously narrowed, and ultimately an accurate prediction of the water quality change trend can be achieved.

[0025] Furthermore, the core calculation of the LSTM unit in S3 includes the forget gate, input gate and output gate, which are mathematically expressed as follows:

[0026] f t =o(W f x t +U f h t-1 +b f ) (8)

[0027] i t =σ(W i x t +U i h t-1 +b i ) (9)

[0028]

[0029] o t =σ(W o x t +U o h t-1 +b o ) (12)

[0030] h t =o t☉tanhC t (13)

[0031] Among them, x t represents the input data at time t, h t is the hidden state, C t is the cell state, and σ and tanh are sigmoid and hyperbolic tangent activation functions respectively. During the model training process, the network weights and biases are continuously optimized through historical data, and the K-fold cross-validation method is used to ensure the robustness of the model. The training goal is to minimize the predicted value Y pred and the actual observed value Y obs The Nash coefficient between .

[0032] Furthermore, the mechanism in S4 sets a dynamic learning time window to store the latest observation data D new Automatically merge into the original training set D train , forming the updated data set D updated =D train ∪D new Based on this updated data, the LSTM and SVR models are retrained, and their parameter update process can be optimized using the gradient descent method. The specific expression is:

[0033]

[0034] Among them, η is the learning rate, E is the error function (for example, the sum of the squares of the errors between the observed value and the predicted value), and during the real-time operation of the system, the water quality index predicted value Y output by the model is pred Compare with the preset safety threshold θ, when the predicted value meets Y pred When ≥θ, the system automatically triggers the early warning mechanism; to prevent false alarms caused by short-term data fluctuations, the early warning condition can be set to exceed the threshold for k consecutive moments. Only when this condition is met will an early warning signal be issued to the water resources management department.

[0035] Compared with the prior art, the present invention has the following beneficial effects:

[0036] The water quality prediction method based on machine learning and SWAT model of the present invention preprocesses multi-source data to construct a unified standard data input set, and uses ArcSWAT to divide the watershed into sub-basins and hydrological response units; on this basis, SVR is used to perform sensitivity analysis and proxy modeling on the key parameters of the SWAT model, and the particle swarm optimization algorithm is combined to realize automatic calibration of the parameters, effectively reducing the number of model runs and lowering the computing cost; subsequently, LSTM is introduced to construct a water quality time series prediction model to accurately capture the dynamic change trend of water quality indicators and enhance the short-term early warning capability; in addition, a self-learning mechanism based on SVR and LSTM is further constructed to realize continuous optimization of model parameters by regularly introducing the latest monitoring data, thereby improving the system's adaptability and real-time response level in the face of climate change and human activity interference; it performs well in terms of model efficiency, prediction accuracy and application adaptability, and is suitable for a variety of practical scenarios such as watershed water quality monitoring, water environment early warning and pollution control, and has significant engineering application value and promotion potential. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] Figure 1 is a flow chart of the method of the present invention;

[0038] Figure 2 The Zhuanghe City water system distribution map of the present invention;

[0039] Figure 3 This is the Zhuanghe sub-basin division result diagram of the present invention;

[0040] Figure 4 This is a graph showing the annual average values ​​of the Zhuanghe total nitrogen measured data and the SWAT simulation data of the present invention;

[0041] Figure 5 This is a graph showing the annual average values ​​of the Zhuanghe total nitrogen measured data and the LSTM predicted data of the present invention. DETAILED DESCRIPTION

[0042] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.

[0043] See also Figure 1 The water quality prediction method based on machine learning and SWAT model provided by the embodiment of the present invention includes the following steps:

[0044] S1. Data collection and preprocessing

[0045] First, multiple data sources were extracted from watershed monitoring stations, remote sensing data platforms, and socioeconomic databases, including meteorological data, hydrological data, water quality parameters (such as chemical oxygen demand (COD), ammonia nitrogen, and suspended solids concentration), and landscape change data. A data cleaning algorithm was used to reduce the noise of the raw data, and a normalization method was used to unify data from different sources to the same scale. A missing value interpolation algorithm was used to ensure data continuity, thereby constructing a temporally and spatially consistent basic data set.

[0046] Next, the watershed delineation tool in ArcSWAT software was used to delineate the sub-watersheds. This step included loading the digital elevation model (DEM) and actual river network data, setting the river threshold area, loading the water inlet location data, and setting the watershed outlet location.

[0047] Given the diverse underlying surface conditions resulting from the presence of a variety of land use and soil type combinations within the sub-watershed, the sub-watershed was further subdivided into hydrological response units (HRUs). The HRU analysis tool in ArcSWAT software was used to define HRUs based on different combinations of land use, soil type, and slope, enabling a more comprehensive and accurate reflection of changes in surface characteristics.

[0048] S2. Calibration of key parameters of SWAT model and optimization of water quality simulation

[0049] To improve the accuracy and computational efficiency of the SWAT model in water quality simulation, we combined the SVR algorithm with the particle swarm optimization (PSO) algorithm to automatically calibrate and optimize parameters. First, we used SVR to analyze the nonlinear relationship between the key parameters of the SWAT model and the output results, identifying the parameters with the most significant impact on water quality simulation. This process accurately screened key parameters by mapping input features into a high-dimensional space and constructing an optimization problem for sensitivity analysis.

[0050] Specifically, SVR transforms the input feature x into i and the corresponding water quality observation value y i Through the kernel mapping function Mapped to a high-dimensional feature space, the model is fitted by solving the following optimization problem:

[0051]

[0052] The objective function aims to achieve the optimal solution by minimizing the loss function and the regularization term, where C is the penalty factor, ξ and ξ * Is a slack variable used to control the error, and the constraints are as follows:

[0053]

[0054] Among them, ε is the tolerance error, is the kernel mapping function. Through this optimization process, SVR can effectively identify the key parameters that have a significant impact on the water quality simulation results.

[0055] After completing the sensitivity analysis, a particle swarm optimization algorithm was used to globally search and calibrate these key parameters. PSO iteratively optimizes parameter values ​​to ensure that the SWAT model's simulation results are as consistent as possible with the actual monitoring data, thereby improving the model's accuracy and efficiency. This step significantly reduces the number of SWAT model runs while achieving highly accurate water quality predictions.

[0056] In the process of parameter calibration, the Nash efficiency coefficient (NSE) and the coefficient of determination (R) were introduced by comparing the simulation results with the measured data. 2 ) and other evaluation indicators to comprehensively evaluate the prediction accuracy and fit of the model. These evaluation indicators can effectively reflect the difference between the model output and the measured data, thereby ensuring the high accuracy and reliability of the model. The specific calculation formula is as follows:

[0057]

[0058] Once the initial parameters are determined, a regression model based on SVR is used, with the deviation between the SWAT simulation results and the actual observation data as the training target. By adjusting the kernel function parameters and penalty factors, a mapping relationship between key SWAT parameters (such as runoff distribution and pollutant mobility) and observation errors is established. Then, the model parameters are adaptively corrected using the following update formula:

[0059] P t+1 =P t +a(Y obs -Y sim ) (7)

[0060] Among them, P t is the SWAT parameter at time t, and α is the learning rate parameter. By gradually adjusting the model parameters, the difference between the simulated and measured values ​​can be continuously narrowed, ultimately achieving accurate prediction of water quality trends.

[0061] S3. Establishment and training of LSTM water quality time series prediction model

[0062] Based on processed water quality time series data, a multi-layer long short-term memory (LSTM) network structure was designed to capture the nonlinear dynamic characteristics of water quality indicators over time. Through its internal memory mechanism, the LSTM network effectively addresses the vanishing gradient problem of traditional recurrent neural networks in long-sequence learning. The core calculation of the LSTM unit includes the forget gate, input gate, and output gate, and its mathematical expression is as follows:

[0063] f t =σ(W f x t +U f h t-1 +b f ) (8)

[0064] i t =σ(W i x t +U i h t-1 +b i ) (9)

[0065]

[0066] σ t =σ(W o x t +U o h t-1 +b o ) (12)

[0067] h t =o t ☉tanhC t (13)

[0068] Among them, x t represents the input data at time t, h t is the hidden state, C t is the cell state, and σ and tanh are sigmoid and hyperbolic tangent activation functions respectively. During the model training process, the network weights and biases are continuously optimized through historical data, and the K-fold cross-validation method is used to ensure the robustness of the model. The training goal is to minimize the predicted value Y pred and the actual observed value Y obs The Nash coefficient between .

[0069] Through iterative optimization, the network gradually learns the inherent laws of changes in water quality indicators, thereby achieving accurate prediction of future short-term water quality change trends.

[0070] S4. Construction of self-learning mechanism and early warning system

[0071] In order to ensure that the model can adapt to the environment and data changes in the long run, a self-learning mechanism based on regularly updated data is established. This mechanism sets a dynamic learning time window and stores the latest observation data D new Automatically merge into the original training set D train , forming the updated data set D updated =D train ∪D newBased on this updated data, the LSTM and SVR models are retrained, and their parameter update process can be optimized using the gradient descent method. The specific expression is:

[0072]

[0073] Where η is the learning rate, and E is the error function (e.g., the sum of squares of the errors between the observed value and the predicted value). pred Compare with the preset safety threshold θ, when the predicted value meets Y pred When the value of the water quality indicator exceeds the threshold, the system automatically triggers an early warning mechanism. To prevent false alarms caused by short-term data fluctuations, the early warning condition can be set to exceed the threshold for k consecutive moments. Only when this condition is met will an early warning signal be issued to the water resources management department. This not only ensures a high degree of consistency between the SWAT model parameters and actual water quality changes, but also provides timely and accurate risk warning information for decision-making.

[0074] Implementation Cases

[0075] As one of the major rivers in Zhuanghe City, Liaoning Province, Zhuanghe River lies between 122°37′ and 123°01′ east longitude and 39°40′ and 40°03′ north latitude. Its geographical location and river system are unique. In recent years, the water quality of Zhuanghe River has deteriorated significantly, with an overall deterioration trend. Therefore, a scientific water quality monitoring and early warning system is urgently needed to facilitate effective management and response.

[0076] The test was carried out in Zhuanghe area, and the Zhuanghe River basin was divided into 37 sub-basins (such as Figure 3 The study set the period of rate measurement from 2013 to 2020 and the verification period from 2021 to 2022. The measured water quality data were obtained through field sampling and laboratory analysis, and analyzed in combination with the water quality model. By using the SWAT model to compare the simulated and measured data of total nitrogen, the study found that the R 2 reached 0.72, the Nash coefficient was 0.70, and the R 2 The Nash coefficient is 0.64 and 0.62, which indicates that the model fits well. Calculate the annual average values ​​of the measured data and simulated data from 2013 to 2022 and draw Figure 4 , indicating that the simulation effect of the present invention is relatively stable in different time periods. In addition, for the prediction of total nitrogen, the LSTM model is used for further prediction. After the prediction by the LSTM model, the calculated Nash coefficient is 0.71, indicating that the prediction method has high accuracy and is very close to the measured value. By calculating the average value of each year and plotting Figure 5,It can be seen that the prediction results not only accurately reflect the actual situation, but also effectively predict the future trend of water quality changes to a certain extent.

[0077] Research results show that the water quality monitoring and early warning system based on machine learning and the SWAT model can be effectively applied to the long-term monitoring of water bodies and ecological environmental assessment in the Zhuanghe River Basin. It not only has high prediction accuracy, but also provides valuable practical experience for the monitoring and management of other water bodies, and has important application value.

[0078] In summary: The water quality prediction method based on machine learning and SWAT model of the present invention, on the basis of constructing a multi-source heterogeneous hydrological and water quality data set, uses ArcSWAT to realize the sub-basin and hydrological response unit division, uses SVR to build an agent model, and performs sensitivity analysis and automatic calibration on the key parameters affecting water quality, effectively reducing the number of SWAT model runs and improving efficiency; subsequently, a water quality time series prediction model is constructed based on LSTM to capture the dynamic change trend of water quality indicators and generate short-term water quality warning information; in order to improve the adaptability and real-time performance of the system, a self-learning mechanism jointly driven by SVR and LSTM is further constructed, and the model parameters are updated by regularly introducing the latest monitoring data to realize the dynamic coupling of the SWAT model with actual water quality changes; while improving the prediction accuracy, the computational cost is significantly reduced, and the method is suitable for various application scenarios such as watershed water quality monitoring, early warning and pollution prevention and control, and has good promotion prospects and practical application value.

[0079] The above description is only a preferred specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any technician familiar with the technical field, within the technical scope disclosed by the present invention, who makes equivalent replacements or changes based on the technical solution and inventive concept of the present invention, should be covered by the scope of protection of the present invention.

Claims

1. A water quality prediction method based on machine learning and SWAT model, characterized in that: The following steps are involved: S1: Multi-temporal data, including hydrological, water quality, meteorological, land use type, pollution sources, and spatial elevation data, are collected from multiple channels within the basin. Preprocessing methods such as noise reduction, normalization, and missing value filling are applied to the raw data to establish a temporally and spatially consistent basic dataset, providing high-quality input for subsequent model training and parameter optimization. Furthermore, ArcSWAT is used to delineate sub-basins, which are further divided into hydrological response units. S2: Using SVR to conduct sensitivity analysis on the nonlinear relationship between SWAT model parameters and output, we screened out key parameters with significant impact, and based on this, we constructed an SVR proxy model, achieving high-precision predictions while reducing the number of SWAT runs. We also used particle swarm optimization to calibrate key parameters, making the model output closer to actual monitoring data, significantly improving calibration efficiency and reducing computational costs. S3: Based on water quality monitoring data, an LSTM model is used to build a water quality time series prediction model. By learning the dynamic characteristics of water quality indicators over time, it can predict the water quality trend in the short term in the future and generate early warning signals. S4: Build a self-learning mechanism based on LSTM and SVR models. By adjusting the learning time window and regularly retraining the model with the latest data, the SWAT model parameters can be continuously updated and optimized, thereby ensuring that the water quality early warning system has high adaptability and real-time performance in response to climate change and the impact of human activities.

2. The water quality prediction method based on machine learning and SWAT model according to claim 1, characterized in that: In S1, a data cleaning algorithm is used to reduce the noise of the original data, and a normalization method is used to unify the data from different sources to the same scale; a missing value interpolation algorithm is used to ensure the continuity of the data, thereby constructing a basic data set that is consistent in time and space.

3. The water quality prediction method based on machine learning and SWAT model as claimed in claim 1, characterized in that: In the above S1, the watershed division tool in ArcSWAT software is used to divide the sub-watershed. This step includes loading the digital elevation model and the actual river network data, setting the river threshold area, loading the water inlet location data, and setting the watershed outlet location.

4. The water quality prediction method based on machine learning and SWAT model as claimed in claim 1, characterized in that: The SVR in S2 transforms the input feature x through the kernel function i and the corresponding water quality observation value y i Through the kernel mapping function Mapped to a high-dimensional feature space, the model is fitted by solving the following optimization problem: The objective function aims to achieve the optimal solution by minimizing the loss function and the regularization term, where C is the penalty factor, ξ and ξ * Is a slack variable used to control the error, and the constraints are as follows: Among them, ε is the tolerance error, is the kernel mapping function. Through this optimization process, SVR can effectively identify the key parameters that have a significant impact on the water quality simulation results.

5. The water quality prediction method based on machine learning and SWAT model according to claim 1, characterized in that: In the parameter calibration process of S2, the Nash efficiency coefficient (NSE) and the determination coefficient (R) were introduced by comparing the simulation results with the measured data. 2 ) and other evaluation indicators to comprehensively evaluate the prediction accuracy and fit of the model. These evaluation indicators can effectively reflect the difference between the model output and the measured data, thereby ensuring the high accuracy and reliability of the model. The specific calculation formula is as follows: Once the initial parameters are determined, an SVR-based regression model is used, with the deviation between the SWAT simulation results and the actual observation data as the training target. By adjusting the kernel function parameters and penalty factors, a mapping relationship between the key SWAT parameters (such as runoff distribution, pollutant mobility, etc.) and the observation error is established. The adaptive correction of the model parameters is then performed using the following update formula: P t+1 =P t +α(Y obs -AND sim ) (7) Among them, P t is the SWAT parameter at time t, and α is the learning rate parameter. By gradually adjusting the model parameters, the difference between the simulated value and the measured value can be continuously narrowed, and ultimately an accurate prediction of the water quality change trend can be achieved.

6. The water quality prediction method based on machine learning and SWAT model according to claim 1, characterized in that: The core calculation of the LSTM unit in S3 includes the forget gate, input gate and output gate, which are mathematically expressed as follows: f t =σ(W f x t +U f h t-1 +b f ) (8) i t =σ(W i x t +U i h t-1 +b i ) (9) the t =σ(W o x t +U o h t-1 +b o ) (12) h t =o t ⊙tanh C t (13) Among them, x t represents the input data at time t, h t is the hidden state, C t is the cell state, and σ and tanh are sigmoid and hyperbolic tangent activation functions respectively. During the model training process, the network weights and biases are continuously optimized through historical data, and the K-fold cross-validation method is used to ensure the robustness of the model. The training goal is to minimize the predicted value Y pred and the actual observed value Y obs The Nash coefficient between .

7. The water quality prediction method based on machine learning and SWAT model according to claim 1, characterized in that: In the S4, the mechanism sets a dynamic learning time window to store the latest observation data D new Automatically merge into the original training set D train , forming the updated data set D updated =D train ∪D new , based on this updated data, the LSTM and SVR models are retrained, and their parameter update process can be optimized using the gradient descent method. The specific expression is: Among them, η is the learning rate, E is the error function (for example, the sum of the squares of the errors between the observed value and the predicted value), and during the real-time operation of the system, the water quality index predicted value Y output by the model is pred Compare with the preset safety threshold θ, when the predicted value meets Y pred When ≥θ, the system automatically triggers the early warning mechanism; to prevent false alarms caused by short-term data fluctuations, the early warning condition can be set to exceed the threshold for k consecutive moments. Only when this condition is met will an early warning signal be issued to the water resources management department.

Citation Information

Cited By

  • Industrial-grade water quality telemetering method and terminal

    CN120877966A

  • Sewage harmful pollutant ultra-trace monitoring system based on intelligent parameter adjustment

    CN121165504A

  • Water quality parameter change trend prediction method, system and equipment based on time sequence prediction model and storage medium

    CN121457319A

  • Soil constitutive parameter inversion method based on sequence modeling thought

    CN121920212A