Machine learning-based rural water quality pollution early warning method and system
By dynamically deploying monitoring points in rural water areas and fusing multimodal data, combined with causal risk inference, precise early warning and intelligent treatment of pollution in rural water areas have been achieved. This solves the problems of unscientific deployment of monitoring points, insufficient data fusion, and delayed early warning response in existing technologies, and improves the scientific nature and real-time performance of water quality monitoring.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- GUANGZHOU CITY CONSTR COLLEGE
- Filing Date
- 2026-04-16
- Publication Date
- 2026-07-14
AI Technical Summary
Existing technologies for monitoring rural water areas suffer from several problems, including a lack of scientific basis for monitoring point deployment, insufficient integration of multi-source data, a lack of causal inference ability for pollution risk prediction, and a disconnect between early warning response and governance measures. These issues lead to a waste of monitoring resources and delayed response.
A rural water pollution early warning system based on machine learning is adopted. Key monitoring points are dynamically deployed through adaptive optimization algorithms, a multimodal data adaptive fusion network is constructed, causal adversarial joint risk inference is performed, and pollution source location and treatment are combined with three-dimensional point cloud reconstruction technology.
It has enabled precise early warning and intelligent handling of pollution in rural water areas, improved the utilization rate of monitoring resources and the efficiency of early warning response, and ensured the scientific nature and real-time performance of water quality monitoring.
Smart Images

Figure CN122392715A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of water environment monitoring and artificial intelligence technology, and more specifically, to a method and system for early warning of rural water pollution based on machine learning. Background Technology
[0002] With the rapid development of the rural economy and the intensification of agricultural production activities, rural waterways are facing increasingly severe pollution threats. Non-point source pollution, such as pesticide and fertilizer runoff, domestic sewage discharge, and livestock waste, leads to the deterioration of water quality in rural rivers and lakes, directly affecting the safety of drinking water for rural residents and the quality of the ecological environment. Traditional rural water quality monitoring mainly relies on regular manual sampling and laboratory analysis, which suffers from problems such as long monitoring cycles, narrow coverage, and delayed response, making it difficult to promptly detect sudden pollution events and take effective measures.
[0003] In recent years, machine learning technology has been widely used in the field of water environment monitoring. It involves deploying sensor networks to collect water quality data in real time and combining this with deep learning models for pollution risk prediction. However, existing technologies still have the following shortcomings: First, the deployment of monitoring points lacks scientific basis and often relies on experience, leading to wasted monitoring resources or monitoring blind spots. Second, the integration of multi-source monitoring data is insufficient; heterogeneous information such as water quality parameters, hydrological data, and video surveillance is not effectively integrated, making it difficult to comprehensively reflect the pollution status of water areas. Third, risk prediction models are mostly based on correlation analysis, lacking the ability to infer causal causes of pollution, resulting in insufficient reliability and interpretability of prediction results. Fourth, pollution source location relies on manual investigation, which is inefficient, and the early warning response is disconnected from treatment measures, failing to achieve automatic coordinated response.
[0004] Therefore, how to achieve the scientific deployment of monitoring points in rural water areas, the deep integration of multi-source data, the causal inference of pollution risks, and the automatic linkage of early warning and response are technical problems that urgently need to be solved by those skilled in the art. Summary of the Invention
[0005] The purpose of this invention is to provide a method and system for early warning of rural water pollution based on machine learning, so as to solve the above-mentioned problems existing in the prior art.
[0006] The application is as follows: A machine learning-based early warning system for rural water pollution includes: The data acquisition module is used to acquire water quality status monitoring data of rural water areas through automatic monitoring equipment deployed at key monitoring points; the water quality status monitoring data of rural water areas includes water quality parameter data, hydrological status data, environmental monitoring data, and water area video surveillance data; The data preprocessing module is used to preprocess the acquired rural water quality status monitoring data to obtain a comprehensive water quality status feature dataset. The causal adversarial joint risk inference module is used to train a water pollution risk assessment model based on a comprehensive water quality status feature dataset, predict the water pollution risk rate based on the water pollution risk assessment model, and determine whether there is a water pollution risk in rural water areas based on the water pollution risk rate. The dynamic early warning module can issue graded early warnings for water pollution risks in rural water areas and trigger corresponding alarm commands. The pollution source location and treatment module is used to acquire spatial location data of pollution sources, combine it with water area video monitoring data to locate the pollution source, and upload pollution information to the user terminal. The locations of the key monitoring points are dynamically determined by an adaptive optimization algorithm based on maximizing information gain. This algorithm analyzes the spatiotemporal variation characteristics of historical monitoring data and iteratively searches for a monitoring point layout scheme that minimizes the overall information entropy of the monitoring network.
[0007] Furthermore, the water quality parameter data includes pH value, dissolved oxygen concentration, chemical oxygen demand, ammonia nitrogen concentration, total phosphorus concentration, and turbidity data obtained by the acid-base detection alarm sensor; hydrological status data includes water level data, water pressure data, flow velocity data, and flow rate data obtained by the electronic float valve sensor; environmental monitoring data includes air temperature data, humidity data, light intensity data, and rainfall data; and water area video monitoring data includes video monitoring data of oil film or abnormal color areas on the water surface. The locations of the key monitoring points are dynamically determined using an adaptive optimization algorithm based on maximizing information gain, specifically including: Obtain historical water quality monitoring data for the target rural water area and construct an initial monitoring point set S={s1,s2,...,s...} i}, where s i This represents the monitoring data corresponding to monitoring point i; Change point detection was performed on the historical time series data of each monitoring point to identify abrupt changes in pollutant concentration, and the abrupt change frequency f of each monitoring point was obtained. i and mutation magnitude a i ; Calculate the spatial representativeness R of each monitoring point i The spatial representativeness is used to characterize the ability of the monitoring point to represent the surrounding unmonitored areas: , Where, N i d represents the number of grid points within a preset radius centered on monitoring point i; ij ρ is the Euclidean distance from monitoring point i to the j-th grid point; σ is the spatial influence scale parameter; ρ ijw is the topographic-hydrological correlation coefficient between monitoring point i and the j-th grid point; ij The weighting coefficients from monitoring point i to the j-th grid point; Based on the mutation frequency f of each monitoring point i Mutation amplitude a i and spatial representativeness R i Construct the information gain function for the monitoring points: , Where α, β, λ are balance coefficients; σ ij Let |S| be the redundancy scale parameter between monitoring point i and the j-th grid point; |S| represents the total number of monitoring points contained in set S. With the objective of maximizing the information gain function G(S), the particle swarm optimization algorithm is used to search for the optimal layout scheme of monitoring points in the candidate monitoring point space, thereby obtaining the optimal set of locations for key monitoring points. .
[0008] Furthermore, the optimized layout location set of the key monitoring points Once determined, it also includes a dynamic adjustment mechanism for the density of monitoring points: Obtain real-time hydrological and water quality data for the target rural water area, and calculate the rate of change of pollutant concentration gradient in the area represented by each monitoring point at the current time t: , where C i This represents the pollutant concentration gradient at the i-th monitoring point. Based on the rate of change of pollutant concentration gradient ▽C i (t) and historical average gradient C d The ratio of the monitoring points s is used to calculate the monitoring points s. i Weighting adjustment factor: Where δ is the sensitivity adjustment coefficient; Based on the weighting adjustment factor γ of each monitoring point i (t), construct the monitoring density function: , Where, σ i (t) represents the dynamic influence radius, σ i (t)=σ0*(1+γ i (t)), σ0 represents the initial dynamic influence radius value, |S * | indicates retrieving the set of optimal deployment locations. The total quantity; When the value of the monitoring density function D(x,y,t) in a certain region is lower than the preset first density threshold, a temporary encrypted monitoring point is automatically added at the center of that region; when the weight adjustment factor γ of a certain monitoring point is lower than the preset first density threshold for T consecutive time periods... iWhen (t) is less than the preset second density threshold, the monitoring point is marked as a redundant monitoring point and enters a dormant state, where (x,y) represents the two-dimensional plane coordinates of any point, (x i ,y i ) represents the two-dimensional plane coordinates of the i-th monitoring point.
[0009] Furthermore, the data preprocessing module preprocesses the acquired rural water quality monitoring data to obtain a comprehensive water quality characteristic dataset, including: Construct a multimodal data adaptive fusion network, which includes a modality-specific encoder, a cross-modal attention interaction layer, and an adaptive fusion layer; Water quality parameter data, hydrological status data, environmental monitoring data, and water area video surveillance data are input into the corresponding modality-specific encoders to obtain the initial features of each mode. The initial features of each mode include the initial features F of the water quality parameter data. q Initial features F of hydrological state data h Initial characteristics F of environmental monitoring data e Initial features F of waterway video surveillance data v Where q, h, e, and v represent the subscript numbers corresponding to the initial characteristics of water quality parameter data, initial characteristics of hydrological state data, initial characteristics of environmental monitoring data, and initial characteristics of water area video surveillance data, respectively. The initial feature representations of each modality are input into the cross-modal attention interaction layer. The correlation weights between different modalities are calculated through a multi-head attention mechanism to generate the enhanced features after interaction.
[0010] Where Attention(·) is the multi-head attention function, These represent the enhancement features of water quality parameter data, hydrological status data, environmental monitoring data, and water area video surveillance data, respectively. The enhanced features of each modality after interaction enhancement are input into the adaptive fusion layer. The fusion weights of each modality are dynamically learned through a gating mechanism to generate fusion features.
[0011] Where σ is the sigmoid activation function, W g and b g Both represent learnable parameters, g k For the fusion weights of the k-th mode, g k ∈g; For fusion feature F fusion Temporal convolution and residual connection are performed to obtain a comprehensive water quality status feature dataset.
[0012] Furthermore, the feature extraction of the waterway video surveillance data is achieved by constructing a spatiotemporal attention convolutional network, including: A three-dimensional convolutional backbone network is constructed. The video monitoring data of the water area is input into the three-dimensional convolutional backbone network to extract the spatiotemporal features of the video frame sequence, thereby obtaining the initial video feature tensor U1∈R. T1×H×W1×C1 Where T1 is the time dimension; H and W1 are the spatial dimensions, representing the height and width of the feature map, respectively; C1 is the number of channels; and R represents the set of real numbers. The initial video feature tensor U1 is input into the spatial attention module. The spatial attention module focuses on key regions in the video frame to generate spatial attention weights. These spatial attention weights are then multiplied element-wise with the initial video feature tensor to obtain spatially enhanced features. The calculation method of the spatial attention module is as follows: A spatial =softmax(W2*ReLU(W3*U1+b2)+b3), V spatial = U1⊙A spatial Where ⊙ represents element-wise multiplication, W2, W3, b2, b3 all represent learnable parameters, and A spatial V represents the spatial attention weights. spatial Represents spatially enhanced features; The spatial enhancement features are input into the temporal attention module, which captures the temporal dynamics of pollutant diffusion, generates temporal attention weights, and uses these weights to perform a weighted summation of the spatial enhancement features along the time dimension to obtain the spatiotemporal enhancement features. The calculation method of the temporal attention module is as follows: A temporal =softmax(tanh(W4·V spatial +b4)), V temporal = , in, This represents the attention weight at time d1. V represents the d1-th spatial augmentation feature. temporal Represents spatiotemporal augmentation features; W4, b4 represent learnable parameters; A temporal Indicates time attention weights; The spatiotemporal enhancement features are input into a fully connected layer, and feature mapping is performed through the fully connected layer to obtain the preliminary feature vector of the water video surveillance data. The spatiotemporal attention convolutional network is pre-trained using a contrastive learning approach. The initial feature vector is then input into the pre-trained spatiotemporal attention convolutional network for optimization, resulting in the final water area video surveillance feature vector.
[0013] Furthermore, feature extraction from water quality parameter data, hydrological status data, and environmental monitoring data is achieved by constructing a multi-scale temporal feature extraction network, specifically including: The water quality parameter data, the hydrological status data, and the environmental monitoring data are acquired, and time-aligned processing is performed on the water quality parameter data, the hydrological status data, and the environmental monitoring data to obtain input time series data. A multi-scale temporal feature extraction network consisting of stacked dilated convolutions is constructed, and the input time series data is fed into the multi-scale temporal feature extraction network. The multi-scale temporal feature extraction network contains multiple parallel dilated convolutional layers, each of which uses a different dilation rate to capture change patterns at different time scales. F (r) =Conv1D r (q) where Conv1D r (·) represents a one-dimensional convolution with an expansion rate of r; F (r) This represents the time-series feature extracted corresponding to the expansion rate r, and q represents the time series data; The temporal features extracted at different expansion rates are concatenated along the channel dimension to obtain a multi-scale feature representation: F multi =[F (1) ;F (2) ;F (4) ;F (8) ], where r = 1,2,4,8; The multi-scale feature is represented by F multi The input is fed into the temporal self-attention module, which captures long-distance temporal dependencies to obtain the self-attention enhancement feature F. self The calculation of the temporal self-attention module is as follows: F self =LayerNorm(F multi +MultiHeadAttention(F multi ,F multi ,F multi )), F ts =LayerNorm(F self +FFN(F selfIn this context, MultiHeadAttention(·) is the multi-head attention mechanism, FFN(·) is the feedforward neural network, and LayerNorm(·) is the layer normalization operation. The normalized feature F output by the temporal self-attention module ts Global average pooling is performed to obtain a joint feature vector of water quality parameters, hydrological status, and environmental monitoring data; The multi-scale temporal feature extraction network is pre-trained using a self-supervised learning approach. The joint feature vector output by the pre-trained multi-scale temporal feature extraction network is used as the feature representation of water quality parameters, hydrological status, and environmental monitoring modes.
[0014] Furthermore, the causal adversarial joint risk inference module includes a causal structure learning unit, a causal intervention calculation unit, an adversarial generation enhancement unit, and a dynamic risk fusion unit; The causal structure learning unit is used to learn the causal relationships between variables from the comprehensive feature data of water quality status, and to construct a structured causal graph of water pollution G=(V,E), where V is the set of variable nodes, including pollutant concentration variables, environmental variables, hydrological variables and human activity variables; E is the set of causal edges, representing the causal relationship between variables; The causal intervention calculation unit, based on the learned causal graph G, eliminates the influence of confounding factors through do-calculus intervention quantization, calculates the causal effect of each intervention variable on pollutant concentration, and obtains the causal risk rate. , Among them, R causal Let C(t) represent the causal risk rate, and let X1 represent the pollutant concentration at time t, which is the target variable for risk prediction. X1 is the intervention variable, representing the factor for which control is applied. x1 is a specific value of the intervention variable X. Z is the confounding factor. P(C(t),X1=x1,Z) is the joint probability distribution. P(X1=x1|Z) is the conditional probability that the intervention variable X1 takes the value x1 given the confounding factor Z. The adversarial generation enhancement unit is used to construct an adversarial game model between the generator and the discriminator. The adversarial game model obtains the adversarial enhancement risk rate through adversarial training. , Where Q is the generator network, used to generate simulated water quality data samples from random noise; D is the discriminator network, used to determine whether the input sample is real data or generated data; pdata is the distribution of real monitoring data; p z The distribution of random noise; This represents the expected value calculation; λ1 is the consistency constraint coefficient; For L2 distance constraints; Radv This indicates an increased risk rate due to increased confrontation. The dynamic risk fusion unit dynamically weights and fuses the causal risk rate and the adversarial enhancement risk rate to obtain the final water pollution risk rate: Rt=ω·R causal +(1-ω)·R adv , where ω is the dynamic weighting coefficient and Rt represents the water pollution risk rate.
[0015] Furthermore, the dynamic early warning module receives the water pollution risk rate output by the causal adversarial joint risk inference module, and generates a graded early warning instruction in conjunction with the support vector machine prediction controller; The support vector machine predictive controller uses the water pollution risk rate and real-time monitoring data as input to construct the optimal classification hyperplane and generate dynamic early warning thresholds and early warning indices.
[0016] Furthermore, the pollution source location and treatment module acquires spatial location data of the pollution source and, in conjunction with water area video surveillance data, locates the pollution source, including: GPS positioning was used to obtain the three-dimensional spatial coordinates of the water collection pool and key upstream nodes; The pollutant diffusion image feature dataset is reconstructed into a point cloud using 3D reconstruction technology to generate a 3D point cloud model of pollutant diffusion. The three-dimensional spatial coordinates of the upstream node are registered with the three-dimensional point cloud model of pollutant diffusion using a three-dimensional reconstruction algorithm. The region with the largest pollutant concentration gradient is calculated, thereby locating the pollution source. (X1 source Y1 source Z1 source )=arg max (X1,Y1,Z1) ||▽A(X1,Y1,Z1,t2||, where (X1,Y1,Z1) represents the original three-dimensional spatial coordinates, (X1,Y1,Z1) represents the coordinates of the original position in space, and (X1,Y1,Z1) represents the coordinates of the original position in space. source Y1 source Z1 source ) represents the target's three-dimensional spatial coordinates, t2 represents the current time, and arg max (X1,Y1,Z1) This indicates that among all spatial locations (X1,Y1,Z1), the point where the gradient magnitude ||▽A(X1,Y1,Z1,t2|| is maximized is found; ▽A represents the gradient of pollutant concentration.
[0017] A machine learning-based method for early warning of rural water pollution, used to implement any of the machine learning-based rural water pollution early warning systems described above, includes the following steps: S1. Set up a data acquisition module to acquire water quality monitoring data of rural water areas through automatic monitoring equipment deployed at key monitoring points; S2. Set up a data preprocessing module to preprocess the acquired rural water quality status monitoring data to obtain a comprehensive water quality status feature dataset. S3. Set up a causal adversarial joint risk inference module to train a water pollution risk assessment model based on a comprehensive water quality status feature dataset, predict the water pollution risk rate based on the water pollution risk assessment model, and determine whether there is a water pollution risk in rural water areas based on the water pollution risk rate. S4. Set up a dynamic early warning module. If there is a risk of water pollution in rural water areas, the module will issue a graded early warning for the water pollution risk and trigger the corresponding alarm command. S5. Set up a pollution source location and treatment module to obtain spatial location data of pollution sources, locate the pollution source location by combining water area video monitoring data, and upload pollution information to the user terminal. The locations of the key monitoring points are dynamically determined by an adaptive optimization algorithm based on maximizing information gain. This algorithm analyzes the spatiotemporal variation characteristics of historical monitoring data and iteratively searches for a monitoring point layout scheme that minimizes the overall information entropy of the monitoring network.
[0018] Compared with the prior art, the embodiments of the present invention achieve the following beneficial effects: This invention includes a data acquisition module that obtains water quality monitoring data for rural water areas by deploying at key monitoring points; a data preprocessing module that constructs a multimodal data adaptive fusion network to extract and fuse features from the monitoring data, resulting in a comprehensive water quality feature dataset; a causal adversarial joint risk inference module that learns the causal relationships between variables from the comprehensive feature data, and dynamically fuses the data to obtain a water pollution risk rate through causal intervention calculation and adversarial generation enhancement; a dynamic early warning module that provides tiered early warnings based on the risk rate and triggers alarm commands; and a pollution source location and treatment module that uses 3D point cloud reconstruction technology to locate pollution sources. This invention achieves precise early warning and intelligent treatment of rural water pollution through a risk assessment mechanism combining causal inference and adversarial training, as well as adaptive optimization of monitoring point deployment. Attached Figure Description
[0019] Figure 1 This is a system architecture diagram of a rural water pollution early warning system based on machine learning provided in an embodiment of the present invention; Figure 2 This is a flowchart illustrating the rural water pollution early warning method based on machine learning provided in this embodiment of the invention. Detailed Implementation
[0020] The present invention will now be described in detail with reference to the accompanying drawings.
[0021] Example 1
[0022] This invention provides a rural water pollution early warning system based on machine learning, such as... Figure 1 ,include: The data acquisition module is used to acquire water quality status monitoring data of rural water areas through automatic monitoring equipment deployed at key monitoring points; the water quality status monitoring data of rural water areas includes water quality parameter data, hydrological status data, environmental monitoring data, and water area video surveillance data; The data preprocessing module is used to preprocess the acquired rural water quality status monitoring data to obtain a comprehensive water quality status feature dataset. The causal adversarial joint risk inference module is used to train a water pollution risk assessment model based on a comprehensive water quality status feature dataset, predict the water pollution risk rate based on the water pollution risk assessment model, and determine whether there is a water pollution risk in rural water areas based on the water pollution risk rate. The dynamic early warning module can issue graded early warnings for water pollution risks in rural water areas and trigger corresponding alarm commands. The pollution source location and treatment module is used to acquire spatial location data of pollution sources, combine it with water area video monitoring data to locate the pollution source, and upload pollution information to the user terminal. The locations of the key monitoring points are dynamically determined by an adaptive optimization algorithm based on maximizing information gain. This algorithm analyzes the spatiotemporal variation characteristics of historical monitoring data and iteratively searches for a monitoring point layout scheme that minimizes the overall information entropy of the monitoring network.
[0023] Specifically, this embodiment includes a data acquisition module that acquires water quality monitoring data for rural water areas by deploying at key monitoring points; a data preprocessing module that constructs a multimodal data adaptive fusion network to extract and fuse features from the monitoring data, obtaining a comprehensive water quality feature dataset; a causal adversarial joint risk inference module that learns the causal relationships between variables from the comprehensive feature data, and dynamically fuses the data to obtain the water pollution risk rate through causal intervention calculation and adversarial generation enhancement; a dynamic early warning module that provides graded early warnings and triggers alarm commands based on the risk rate; and a pollution source location and treatment module that uses 3D point cloud reconstruction technology to locate pollution sources. This invention achieves accurate early warning and intelligent treatment of rural water pollution through a risk assessment mechanism combining causal inference and adversarial training, as well as adaptive optimization of monitoring point deployment.
[0024] In the above embodiments, specifically, the water quality parameter data includes pH value, dissolved oxygen concentration, chemical oxygen demand, ammonia nitrogen concentration, total phosphorus concentration, and turbidity data obtained by the acid-base detection alarm sensor; hydrological status data includes water level data, water pressure data, flow velocity data, and flow rate data obtained by the electronic float valve sensor; environmental monitoring data includes air temperature data, humidity data, light intensity data, and rainfall data; and water area video monitoring data includes video monitoring data of oil film or abnormal color areas on the water surface. The locations of the key monitoring points are dynamically determined using an adaptive optimization algorithm based on maximizing information gain, specifically including: Obtain historical water quality monitoring data for the target rural water area and construct an initial monitoring point set S={s1,s2,...,s...} i}, where s i This represents the monitoring data corresponding to monitoring point i; Change point detection was performed on the historical time series data of each monitoring point to identify abrupt changes in pollutant concentration, and the abrupt change frequency f of each monitoring point was obtained. i and mutation magnitude a i ; Calculate the spatial representativeness R of each monitoring point i The spatial representativeness is used to characterize the ability of the monitoring point to represent the surrounding unmonitored areas: , Where, N i d represents the number of grid points within a preset radius centered on monitoring point i; ij ρ is the Euclidean distance from monitoring point i to the j-th grid point; σ is the spatial influence scale parameter; ρ ij w is the topographic-hydrological correlation coefficient between monitoring point i and the j-th grid point; ij The weighting coefficients from monitoring point i to the j-th grid point; Based on the mutation frequency f of each monitoring point i Mutation amplitude a i and spatial representativeness R i Construct the information gain function for the monitoring points: , Where α, β, λ are balance coefficients; σ ij Let |S| be the redundancy scale parameter between monitoring point i and the j-th grid point; |S| represents the total number of monitoring points contained in set S. With the objective of maximizing the information gain function G(S), the particle swarm optimization algorithm is used to search for the optimal layout scheme of monitoring points in the candidate monitoring point space, thereby obtaining the optimal set of locations for key monitoring points. .
[0025] It should be noted that Particle Swarm Optimization (PSO) is a swarm intelligence optimization algorithm that simulates the foraging behavior of bird flocks. It searches for the optimal solution in the solution space through cooperation and competition among particles. The specific implementation process of the PSO algorithm in the optimized deployment of the key monitoring points is as follows: L1. Define each potential deployment scheme in the candidate monitoring point space as a particle. Let the number of monitoring points to be deployed be K = |S|, then the position vector of each particle is represented as X. p =[x1,y1,x2,y2,...,x K ,y K ], where (x k ,y k () represents the two-dimensional spatial coordinates of the k-th monitoring point. The particle's position vector has a dimension of 2K, with each dimension taking values within the geographical boundary of the target water area; L2. Within the geographical boundaries of the target water area, randomly generate the positions {X} of P initial particles. 1 (0),X 2 (0),...,X P (0)}, and at the same time, randomly initialize the velocity vector {V} of each particle. 1 (0),V 2 (0),...,V P (0)}, the velocity vector has the same dimension as the position vector, and is used to control the direction and step size of the particle's movement in the solution space; L3. Use the constructed monitoring point information gain function G(S) as the fitness function. For each particle's monitoring point layout scheme, calculate its information gain value: , where f i a i R i It needs to be calculated by interpolation from historical monitoring data based on the location of the monitoring point represented by the particle; L4. Update the velocity and position of each particle according to the PSO standard formula:
[0026] Where ω is the inertia weight, which controls the particle's ability to maintain its original velocity. It is usually set between 0.4 and 0.9 and decreases with the number of iterations. c1 and c2 are learning factors, which represent the degree to which the particle learns towards the individual optimum and the global optimum, respectively. They are usually set to c1=c2=2. r1 and r2 are random numbers in the interval [0,1] to increase the randomness of the search. Representing the individual optimality, it records the position with the largest fitness function value in the particle's historical positions; G tThis represents the global optimum, recording the position with the largest fitness function value among all historical positions of all particles in the entire particle swarm; This represents the current velocity of each particle; This represents the velocity of each particle at the previous moment; L5. When the particle position exceeds the geographical boundary of the target water area, a boundary absorption or rebound strategy is adopted to ensure that all monitoring points are within the effective range. Repeat steps L3-L5 above until the preset maximum number of iterations T is reached. max The iteration stops when the change in the globally optimal fitness value is less than a preset threshold ϵ after multiple consecutive iterations. At this point, the globally optimal G(T) is... max The corresponding position vector is the optimal monitoring point layout scheme S. ∗ .
[0027] It should be noted that the above implementation steps construct an information gain function that integrates mutation frequency, mutation amplitude, and spatial representativeness, and then use particle swarm optimization (PSO) to search for the optimal layout scheme globally. The location of each monitoring point is iteratively optimized to ensure that it has the maximum spatial representativeness of the surrounding area, effectively capturing information on mutations in pollutant concentrations and eliminating monitoring blind spots at the source. The combination of PSO and information gain functions enables the scientific and intelligent deployment of monitoring points in rural water areas, effectively solving the problems of monitoring blind spots and resource waste inherent in traditional deployment methods, and laying a solid data foundation for subsequent multi-source data fusion, risk inference, and automatic linkage response.
[0028] In the above embodiments, specifically, the optimized layout location set of the key monitoring points Once determined, it also includes a dynamic adjustment mechanism for the density of monitoring points: Obtain real-time hydrological and water quality data for the target rural water area, and calculate the rate of change of pollutant concentration gradient in the area represented by each monitoring point at the current time t: , where C i This represents the pollutant concentration gradient at the i-th monitoring point. Based on the rate of change of pollutant concentration gradient ▽C i (t) and historical average gradient C d The ratio of the monitoring points s is used to calculate the monitoring points s. i Weighting adjustment factor: Where δ is the sensitivity adjustment coefficient; Based on the weighting adjustment factor γ of each monitoring point i (t), construct the monitoring density function: , Where, σ i(t) represents the dynamic influence radius, σ i (t)=σ0*(1+γ i (t)), σ0 represents the initial dynamic influence radius value, |S * | indicates retrieving the set of optimal deployment locations. The total quantity; When the value of the monitoring density function D(x,y,t) in a certain region is lower than the preset first density threshold, a temporary encrypted monitoring point is automatically added at the center of that region; when the weight adjustment factor γ of a certain monitoring point is lower than the preset first density threshold for T consecutive time periods... i When (t) is less than the preset second density threshold, the monitoring point is marked as a redundant monitoring point and enters a dormant state, where (x,y) represents the two-dimensional plane coordinates of any point, (x i ,y i () represents the two-dimensional plane coordinates of the i-th monitoring point; Through the aforementioned dynamic adjustment mechanism, the monitoring resources can be adaptively and optimally configured in both time and space dimensions.
[0029] It should be noted that (x,y) in the monitoring density function D(x,y,t) represents two-dimensional plane coordinates. This is determined by the function's functional positioning (evaluating plane coverage density). In the scenario of rural water monitoring, two-dimensional modeling not only meets engineering requirements but also avoids unnecessary computational complexity, which is a reasonable design of this technical solution.
[0030] In the above embodiments, specifically, the data preprocessing module preprocesses the acquired rural water quality status monitoring data to obtain a comprehensive water quality status feature dataset, including: Construct a multimodal data adaptive fusion network, which includes a modality-specific encoder, a cross-modal attention interaction layer, and an adaptive fusion layer; Water quality parameter data, hydrological status data, environmental monitoring data, and water area video surveillance data are input into the corresponding modality-specific encoders to obtain the initial features of each mode. The initial features of each mode include the initial features F of the water quality parameter data. q Initial features F of hydrological state data h Initial characteristics F of environmental monitoring data e Initial features F of waterway video surveillance data v Where q, h, e, and v represent the subscript numbers corresponding to the initial characteristics of water quality parameter data, initial characteristics of hydrological state data, initial characteristics of environmental monitoring data, and initial characteristics of water area video surveillance data, respectively. The initial feature representations of each modality are input into the cross-modal attention interaction layer. The correlation weights between different modalities are calculated through a multi-head attention mechanism to generate the enhanced features after interaction.
[0031] Where Attention(·) is the multi-head attention function, These represent the enhancement features of water quality parameter data, hydrological status data, environmental monitoring data, and water area video surveillance data, respectively. The enhanced features of each modality after interaction enhancement are input into the adaptive fusion layer. The fusion weights of each modality are dynamically learned through a gating mechanism to generate fusion features.
[0032] Where σ is the sigmoid activation function, W g and b g Both represent learnable parameters, g k For the fusion weights of the k-th mode, g k ∈g; For fusion feature F fusion Temporal convolution and residual connections are performed to obtain a comprehensive water quality status feature dataset; It should be noted that the network parameters of the cross-modal attention interaction layer and the adaptive fusion layer are optimized through end-to-end joint training, with the training objective being to minimize the loss function of the downstream water pollution risk prediction task.
[0033] In the above embodiments, specifically, the feature extraction of the water area video surveillance data is achieved by constructing a spatiotemporal attention convolutional network, including: A three-dimensional convolutional backbone network is constructed. The video monitoring data of the water area is input into the three-dimensional convolutional backbone network to extract the spatiotemporal features of the video frame sequence, thereby obtaining the initial video feature tensor U1∈R. T1×H×W1×C1 Where T1 is the time dimension; H and W1 are the spatial dimensions, representing the height and width of the feature map, respectively; C1 is the number of channels; and R represents the set of real numbers. The initial video feature tensor U1 is input into the spatial attention module. The spatial attention module focuses on key regions in the video frame to generate spatial attention weights. These spatial attention weights are then multiplied element-wise with the initial video feature tensor to obtain spatially enhanced features. The calculation method of the spatial attention module is as follows: A spatial =softmax(W2*ReLU(W3 * U1+b2)+b3), V spatial = U1⊙A spatial Where ⊙ represents element-wise multiplication, W2, W3, b2, b3 all represent learnable parameters, and A spatial V represents the spatial attention weights. spatial Represents spatially enhanced features; The spatial enhancement features are input into the temporal attention module, which captures the temporal dynamics of pollutant diffusion, generates temporal attention weights, and uses these weights to perform a weighted summation of the spatial enhancement features along the time dimension to obtain the spatiotemporal enhancement features. The calculation method of the temporal attention module is as follows: A temporal =softmax(tanh(W4·V spatial +b4)), V temporal = , in, This represents the attention weight at time d1. V represents the d1-th spatial augmentation feature. temporal Represents spatiotemporal augmentation features; W4, b4 represent learnable parameters; A temporal Indicates time attention weights; The spatiotemporal enhancement features are input into a fully connected layer, and feature mapping is performed through the fully connected layer to obtain the preliminary feature vector of the water video surveillance data. The spatiotemporal attention convolutional network is pre-trained using a contrastive learning approach. By constructing positive and negative sample pairs, the spatiotemporal attention convolutional network can better distinguish the visual feature differences between normal water areas and abnormally polluted areas. The positive sample pairs consist of normal monitoring videos of the same water area at different time periods, and the negative sample pairs consist of monitoring videos of normal water areas and monitoring videos of areas where pollution events have occurred. The initial feature vector is input into the pre-trained spatiotemporal attention convolutional network for optimization to obtain the final water area video surveillance feature vector.
[0034] In the above embodiments, specifically, feature extraction of water quality parameter data, hydrological state data, and environmental monitoring data is achieved by constructing a multi-scale temporal feature extraction network, specifically including: The water quality parameter data, the hydrological status data, and the environmental monitoring data are acquired, and time-aligned processing is performed on the water quality parameter data, the hydrological status data, and the environmental monitoring data to obtain input time series data. A multi-scale temporal feature extraction network consisting of stacked dilated convolutions is constructed. The input time series data is fed into the multi-scale temporal feature extraction network. The multi-scale temporal feature extraction network contains multiple parallel dilated convolutional layers, each of which uses a different dilation rate r∈{1,2,4,8} to capture change patterns at different time scales. F (r) =Conv1D r (q) where Conv1Dr (·) represents a one-dimensional convolution with an expansion rate of r; F (r) This represents the time-series feature extracted corresponding to the expansion rate r, and q represents the time series data; The temporal features extracted at different expansion rates are concatenated along the channel dimension to obtain a multi-scale feature representation: F multi =[F (1) ;F (2) ;F (4) ;F (8) ], where r = 1, 2, 4, 8; The multi-scale feature is represented by F multi The input is fed into the temporal self-attention module, which captures long-distance temporal dependencies to obtain the self-attention enhancement feature F. self The calculation of the temporal self-attention module is as follows: F self =LayerNorm(F multi +MultiHeadAttention(F multi ,F multi ,F multi )), F ts =LayerNorm(F self +FFN(F self In this context, MultiHeadAttention(·) is the multi-head attention mechanism, FFN(·) is the feedforward neural network, and LayerNorm(·) is the layer normalization operation. The normalized feature F output by the temporal self-attention module ts Global average pooling is performed to obtain a joint feature vector of water quality parameters, hydrological status, and environmental monitoring data; The multi-scale temporal feature extraction network is pre-trained using a self-supervised learning approach. It learns the inherent patterns and anomalies of time series data through a mask reconstruction task. The mask reconstruction task involves randomly masking the input data at a certain time step, and training the multi-scale temporal feature extraction network to reconstruct the masked data. The joint feature vector output by the pre-trained multi-scale temporal feature extraction network is used as the feature representation of water quality parameters, hydrological status, and environmental monitoring modes.
[0035] In the above embodiments, specifically, the causal adversarial joint risk inference module includes a causal structure learning unit, a causal intervention calculation unit, an adversarial generation enhancement unit, and a dynamic risk fusion unit; The causal structure learning unit is used to learn the causal relationships between variables from the comprehensive feature data of water quality status, and to construct a structured causal graph of water pollution G=(V,E), where V is the set of variable nodes, including pollutant concentration variables, environmental variables, hydrological variables and human activity variables; E is the set of causal edges, representing the causal relationship between variables; The causal intervention calculation unit, based on the learned causal graph G, eliminates the influence of confounding factors through do-calculus intervention quantization, calculates the causal effect of each intervention variable on pollutant concentration, and obtains the causal risk rate. , Among them, R causal Let C(t) represent the causal risk rate, and let X1 represent the pollutant concentration at time t, which is the target variable for risk prediction. X1 is the intervention variable, representing the factor that exerts control. x1 is a specific value of the intervention variable X. Z is a confounding factor, referring to other variables that simultaneously affect the intervention variable X and the outcome variable C(t). P(C(t),X1=x1,Z) is the joint probability distribution. P(X1=x1|Z) is the conditional probability that the intervention variable X1 takes the value x1 given a confounding factor Z; The adversarial generation enhancement unit is used to construct an adversarial game model between the generator and the discriminator. The generator is used to simulate water quality change trajectories under different pollution scenarios, and the discriminator is used to distinguish between real monitoring data and generated data. The adversarial game model, through adversarial training, makes the risk prediction model robust to abnormal disturbances and unknown scenarios, resulting in the adversarial enhancement risk rate: , Where Q is the generator network, used to generate simulated water quality data samples from random noise; D is the discriminator network, used to determine whether the input sample is real data or generated data; pdata is the distribution of real monitoring data; p z The distribution of random noise; This represents the expected value calculation; λ1 is the consistency constraint coefficient; For L2 distance constraints; R adv This indicates an increased risk rate due to increased confrontation. The dynamic risk fusion unit dynamically weights and fuses the causal risk rate and the adversarial enhancement risk rate to obtain the final water pollution risk rate: Rt=ω·R causal +(1-ω)·R adv , where ω is the dynamic weighting coefficient and Rt represents the water pollution risk rate.
[0036] In the above embodiments, specifically, the dynamic warning module receives the water quality pollution risk rate output by the causal adversarial joint risk inference module, and generates a hierarchical warning instruction in combination with the support vector machine prediction controller; The support vector machine prediction controller takes the water quality pollution risk rate and real-time monitoring data as inputs, constructs an optimal classification hyperplane, and generates a dynamic warning threshold and a warning index.
[0037] First, construct the objective function of the support vector machine prediction controller:
[0038] Where J SVM is the objective function, w and b are the normal vector and bias of the optimal classification hyperplane; C is the penalty parameter; ξ m is the slack variable; y m is the warning level label of the m-th training sample; is the kernel function mapping; G m is the feature vector of the m-th training sample, which is composed of the comprehensive feature data of the water quality state and the water quality pollution risk rate spliced together; Then, input the feature vector F(t) at the current moment into the trained support vector machine prediction controller to generate a dynamic warning index: , The support vector machine prediction controller also has a threshold adaptive update mechanism, and dynamically adjusts the hierarchical warning threshold according to the distribution characteristics of the water quality pollution risk rate R(t): P1(t)=μ R (t)+σ R (t) P2(t)=μ R (t)+2σ R (t) P3(t)=μ R (t)+3σ R (t) Where μ R (t) and σ R (t) are the moving average and standard deviation of the risk rate R(t) within the t time period, respectively; The hierarchical warning trigger compares the dynamic warning index Palert(t) with the adaptive threshold: If Palert(t) < P1(t), it is determined as no risk or low risk, and the system maintains the normal monitoring state; If P1(t) ≤ Palert(t) < P2(t), it is determined as medium risk, triggers a yellow warning instruction, sends a attention reminder to the administrator's mobile APP through the 5G network, and recommends strengthening the monitoring frequency; If P2(t) ≤ Palert(t) < P3(t), it is determined as a high risk, triggering an orange warning instruction. The system automatically increases the sampling frequency and recommends on-site inspections by the management personnel; If Palert(t) ≥ P3(t), it is determined as a severe risk, triggering a red warning instruction. The system immediately automatically links and controls the downstream purification power generation system for emergency disposal.
[0039] In the above embodiment, specifically, the pollution source location and disposal module obtains the spatial position data of the pollution source, and locates the pollution source position in combination with the water area video monitoring data, including: Using GPS positioning to obtain the three-dimensional spatial position coordinates of the sump and upstream key nodes; Through three-dimensional reconstruction technology, point cloud reconstruction is performed on the pollutant diffusion image feature dataset to generate a three-dimensional point cloud model of pollutant diffusion; Through a three-dimensional reconstruction algorithm, registration is performed on the three-dimensional spatial position coordinates of the upstream nodes and the three-dimensional point cloud model of pollutant diffusion, and the area with the maximum pollutant concentration gradient is calculated, and then the pollution source position is located: (X1 source ,Y1 source ,Z1 source ) = arg max (X1,Y1,Z1) ||▽A(X1,Y1,Z1,t2||, where (X1,Y1,Z1) represents the original three-dimensional spatial position coordinates, (X1 source ,Y1 source ,Z1 source ) represents the target three-dimensional spatial position coordinates, t2 represents the current time, arg max (X1,Y1,Z1) means finding the position point that makes the gradient amplitude ||▽A(X1,Y1,Z1,t2|| reach the maximum among all spatial positions (X1,Y1,Z1); ▽A represents the gradient of pollutant concentration.
[0040] Embodiment 2 A rural water quality pollution warning method based on machine learning includes the following steps: S1. Set a data acquisition module for obtaining rural water area water quality status monitoring data through automatic monitoring devices deployed at key monitoring points; <000048 S4. Set up a dynamic early warning module. If there is a risk of water pollution in rural water areas, the module will issue a graded early warning for the water pollution risk and trigger the corresponding alarm command. S5. Set up a pollution source location and treatment module to obtain spatial location data of pollution sources, locate the pollution source location by combining water area video monitoring data, and upload pollution information to the user terminal. The locations of the key monitoring points are dynamically determined by an adaptive optimization algorithm based on maximizing information gain. This algorithm analyzes the spatiotemporal variation characteristics of historical monitoring data and iteratively searches for a monitoring point layout scheme that minimizes the overall information entropy of the monitoring network.
[0041] It should be understood that the above embodiments are one or more embodiments of the present invention, and there are many other embodiments and variations based on the present invention; any variations and modifications made by those skilled in the art through the present invention without making pioneering innovations are all within the protection scope of the present invention.
Claims
1. A rural water pollution early warning system based on machine learning, characterized in that, include: The data acquisition module is used to acquire water quality monitoring data of rural water areas through automatic monitoring equipment deployed at key monitoring points; The water quality monitoring data for rural water areas includes water quality parameter data, hydrological status data, environmental monitoring data, and water area video surveillance data. The data preprocessing module is used to preprocess the acquired rural water quality status monitoring data to obtain a comprehensive water quality status feature dataset. The causal adversarial joint risk inference module is used to train a water pollution risk assessment model based on a comprehensive water quality status feature dataset, and to predict the water pollution risk rate based on the water pollution risk assessment model. Determine whether there is a risk of water pollution in rural water areas based on the water pollution risk rate; The dynamic early warning module can classify and issue early warnings for water pollution risks in rural water areas and trigger corresponding alarm commands if such risks exist. The pollution source location and treatment module is used to acquire spatial location data of pollution sources, combine it with water area video monitoring data to locate the pollution source, and upload pollution information to the user terminal. The locations of the key monitoring points are dynamically determined by an adaptive optimization algorithm based on maximizing information gain. This algorithm analyzes the spatiotemporal variation characteristics of historical monitoring data and iteratively searches for a monitoring point layout scheme that minimizes the overall information entropy of the monitoring network.
2. The rural water pollution early warning system based on machine learning according to claim 1, characterized in that, The water quality parameter data includes pH value, dissolved oxygen concentration, chemical oxygen demand, ammonia nitrogen concentration, total phosphorus concentration, and turbidity data obtained by the acid-base detection alarm sensor; hydrological status data includes water level data, water pressure data, flow velocity data, and flow rate data obtained by the electronic float valve sensor; environmental monitoring data includes air temperature data, humidity data, light intensity data, and rainfall data; and water area video monitoring data includes video monitoring data of oil film or abnormal color areas on the water surface. The locations of the key monitoring points are dynamically determined using an adaptive optimization algorithm based on maximizing information gain, specifically including: Obtain historical water quality monitoring data for the target rural water area and construct an initial monitoring point set S={s1,s2,...,s...} i }, where s i This represents the monitoring data corresponding to monitoring point i; Change point detection was performed on the historical time series data of each monitoring point to identify abrupt changes in pollutant concentration, and the abrupt change frequency f of each monitoring point was obtained. i and mutation magnitude a i ; Calculate the spatial representativeness R of each monitoring point i The spatial representativeness is used to characterize the ability of the monitoring point to represent the surrounding unmonitored areas: , Where, N i d represents the number of grid points within a preset radius centered on monitoring point i; ij ρ is the Euclidean distance from monitoring point i to the j-th grid point; σ is the spatial influence scale parameter; ρ ij w is the topographic-hydrological correlation coefficient between monitoring point i and the j-th grid point; ij The weighting coefficients from monitoring point i to the j-th grid point; Based on the mutation frequency f of each monitoring point i Mutation amplitude a i and spatial representativeness R i Construct the information gain function for monitoring points: , Where α, β, λ are balance coefficients; σ ij Let |S| be the redundancy scale parameter between monitoring point i and the j-th grid point; |S| represents the total number of monitoring points contained in set S. With the objective of maximizing the information gain function G(S), the particle swarm optimization algorithm is used to search for the optimal layout scheme of monitoring points in the candidate monitoring point space, thereby obtaining the optimal set of locations for key monitoring points. .
3. The rural water pollution early warning system based on machine learning according to claim 2, characterized in that, The optimized layout location set of the key monitoring points Once determined, it also includes a dynamic adjustment mechanism for the density of monitoring points: Obtain real-time hydrological and water quality data for the target rural water area, and calculate the rate of change of pollutant concentration gradient in the area represented by each monitoring point at the current time t: , where C i This represents the pollutant concentration gradient at the i-th monitoring point. Based on the pollutant concentration gradient change rate ∇C i (t) and historical average gradient C d The ratio of the monitoring points s is used to calculate the monitoring points s. i Weighting adjustment factor: Where δ is the sensitivity adjustment coefficient; Based on the weighting adjustment factor γ of each monitoring point i (t), construct the monitoring density function: , Where, σ i (t) represents the dynamic influence radius, σ i (t)=σ0*(1+γ i (t)), σ0 represents the initial dynamic influence radius value, |S * | indicates retrieving the set of optimal deployment locations. The total quantity; When the value of the monitoring density function D(x,y,t) in a certain region is lower than the preset first density threshold, a temporary encrypted monitoring point is automatically added at the center of that region; when the weight adjustment factor γ of a certain monitoring point is lower than the preset first density threshold for T consecutive time periods... i When (t) is less than the preset second density threshold, the monitoring point is marked as a redundant monitoring point and enters a dormant state, where (x,y) represents the two-dimensional plane coordinates of any point, (x i ,y i ) represents the two-dimensional plane coordinates of the i-th monitoring point.
4. The rural water pollution early warning system based on machine learning according to claim 1, characterized in that, The data preprocessing module preprocesses the acquired rural water quality monitoring data to obtain a comprehensive water quality feature dataset, including: Construct a multimodal data adaptive fusion network, which includes a modality-specific encoder, a cross-modal attention interaction layer, and an adaptive fusion layer; Water quality parameter data, hydrological status data, environmental monitoring data, and water area video surveillance data are input into the corresponding modality-specific encoders to obtain the initial features of each mode. The initial features of each mode include the initial features F of the water quality parameter data. q Initial features F of hydrological state data h Initial characteristics F of environmental monitoring data e Initial features F of waterway video surveillance data v Where q, h, e, and v represent the subscript numbers corresponding to the initial characteristics of water quality parameter data, initial characteristics of hydrological state data, initial characteristics of environmental monitoring data, and initial characteristics of water area video surveillance data, respectively. The initial feature representations of each modality are input into the cross-modal attention interaction layer. The correlation weights between different modalities are calculated through a multi-head attention mechanism to generate the enhanced features after interaction. Where Attention(·) is the multi-head attention function, These represent the enhancement features of water quality parameter data, hydrological status data, environmental monitoring data, and water area video surveillance data, respectively. The enhanced features of each modality after interaction enhancement are input into the adaptive fusion layer. The fusion weights of each modality are dynamically learned through a gating mechanism to generate fusion features. Where σ is the sigmoid activation function, W g and b g Both represent learnable parameters, g k For the fusion weights of the k-th mode, g k ∈g; For fusion feature F fusion Temporal convolution and residual connection are performed to obtain a comprehensive water quality status feature dataset.
5. The rural water pollution early warning system based on machine learning according to claim 4, characterized in that, Feature extraction of the waterway video surveillance data is achieved by constructing a spatiotemporal attention convolutional network, including: A three-dimensional convolutional backbone network is constructed. The video monitoring data of the water area is input into the three-dimensional convolutional backbone network, and the spatiotemporal features of the video frame sequence are extracted to obtain the initial video feature tensor U1∈R. T1×H×W1×C1 Where T1 is the time dimension; H and W1 are the spatial dimensions, representing the height and width of the feature map, respectively; C1 is the number of channels; and R represents the set of real numbers. The initial video feature tensor U1 is input into the spatial attention module. The spatial attention module focuses on key regions in the video frame to generate spatial attention weights. These spatial attention weights are then multiplied element-wise with the initial video feature tensor to obtain spatially enhanced features. The calculation method of the spatial attention module is as follows: A spatial =softmax(W2*ReLU(W3 * U1+b2)+b3), V spatial = U1⊙A spatial Where ⊙ represents element-wise multiplication, W2, W3, b2, b3 all represent learnable parameters, and A spatial V represents the spatial attention weights. spatial Represents spatially enhanced features; The spatial enhancement features are input into the temporal attention module, which captures the temporal dynamics of pollutant diffusion, generates temporal attention weights, and uses these weights to perform a weighted summation of the spatial enhancement features along the time dimension to obtain the spatiotemporal enhancement features. The calculation method of the temporal attention module is as follows: A temporal =softmax(tanh(W4·V spatial +b4)), V temporal = , in, This represents the attention weight at time d1. V represents the d1-th spatial augmentation feature. temporal Represents spatiotemporal augmentation features; W4, b4 represent learnable parameters; A temporal Indicates time attention weights; The spatiotemporal enhancement features are input into a fully connected layer, and feature mapping is performed through the fully connected layer to obtain the preliminary feature vector of the water video surveillance data. The spatiotemporal attention convolutional network is pre-trained using a contrastive learning approach. The initial feature vector is then input into the pre-trained spatiotemporal attention convolutional network for optimization, resulting in the final water area video surveillance feature vector.
6. The rural water pollution early warning system based on machine learning according to claim 4, characterized in that, Feature extraction from water quality parameter data, hydrological status data, and environmental monitoring data is achieved by constructing a multi-scale temporal feature extraction network, specifically including: The water quality parameter data, the hydrological status data, and the environmental monitoring data are acquired, and time-aligned processing is performed on the water quality parameter data, the hydrological status data, and the environmental monitoring data to obtain input time series data. A multi-scale temporal feature extraction network consisting of stacked dilated convolutions is constructed, and the input time series data is fed into the multi-scale temporal feature extraction network. The multi-scale temporal feature extraction network contains multiple parallel dilated convolutional layers, each of which uses a different dilation rate to capture change patterns at different time scales. F (r) =Conv1D r (q) where Conv1D r (·) represents a one-dimensional convolution with an expansion rate of r; F (r) This represents the time-series feature extracted corresponding to the expansion rate r, and q represents the time series data; The temporal features extracted at different expansion rates are concatenated along the channel dimension to obtain a multi-scale feature representation: F multi =[F (1) ;F (2) ;F (4) ;F (8) ], where r = 1,2,4,8; The multi-scale feature is represented by F multi The input is fed into the temporal self-attention module, which captures long-distance temporal dependencies to obtain the self-attention enhancement feature F. self The calculation of the temporal self-attention module is as follows: F self =LayerNorm(F multi +MultiHeadAttention(F multi ,F multi ,F multi )), F ts =LayerNorm(F self +FFN(F self In this context, MultiHeadAttention(·) is the multi-head attention mechanism, FFN(·) is the feedforward neural network, and LayerNorm(·) is the layer normalization operation. The normalized feature F output by the temporal self-attention module ts Global average pooling is performed to obtain a joint feature vector of water quality parameters, hydrological status, and environmental monitoring data; The multi-scale temporal feature extraction network is pre-trained using a self-supervised learning approach. The joint feature vector output by the pre-trained multi-scale temporal feature extraction network is used as the feature representation of water quality parameters, hydrological status, and environmental monitoring modes.
7. The rural water pollution early warning system based on machine learning according to claim 1, characterized in that, The causal adversarial joint risk inference module includes a causal structure learning unit, a causal intervention calculation unit, an adversarial generation enhancement unit, and a dynamic risk fusion unit. The causal structure learning unit is used to learn the causal relationships between variables from the comprehensive feature data of water quality status, and to construct a structured causal graph of water pollution G=(V,E), where V is the set of variable nodes, including pollutant concentration variables, environmental variables, hydrological variables and human activity variables; E is the set of causal edges, representing the causal relationship between variables; The causal intervention calculation unit, based on the learned causal graph G, eliminates the influence of confounding factors through do-calculus intervention quantization, calculates the causal effect of each intervention variable on pollutant concentration, and obtains the causal risk rate. , Among them, R causal Let C(t) represent the causal risk rate, and let X1 represent the pollutant concentration at time t, which is the target variable for risk prediction. X1 is the intervention variable, representing the factor for which control is applied. x1 is a specific value of the intervention variable X. Z is the confounding factor. P(C(t),X1=x1,Z) is the joint probability distribution. P(X1=x1|Z) is the conditional probability that the intervention variable X1 takes the value x1 given the confounding factor Z. The adversarial generation enhancement unit is used to construct an adversarial game model between the generator and the discriminator. The adversarial game model obtains the adversarial enhancement risk rate through adversarial training. , Where Q is the generator network, used to generate simulated water quality data samples from random noise; D is the discriminator network, used to determine whether the input sample is real data or generated data; pdata is the distribution of real monitoring data; p z The distribution of random noise; This represents the expected value calculation; λ1 is the consistency constraint coefficient; For L2 distance constraints; R adv This indicates an increased risk rate due to increased confrontation. The dynamic risk fusion unit dynamically weights and fuses the causal risk rate and the adversarial enhancement risk rate to obtain the final water pollution risk rate: Rt=ω·R causal +(1-ω)·R adv , where ω is the dynamic weighting coefficient and Rt represents the water pollution risk rate.
8. The rural water pollution early warning system based on machine learning according to claim 7, characterized in that, The dynamic early warning module receives the water pollution risk rate output by the causal adversarial joint risk inference module and generates a graded early warning instruction in conjunction with the support vector machine prediction controller. The support vector machine predictive controller uses the water pollution risk rate and real-time monitoring data as input to construct the optimal classification hyperplane and generate dynamic early warning thresholds and early warning indices.
9. The rural water pollution early warning system based on machine learning according to claim 1, characterized in that, The pollution source location and treatment module acquires spatial location data of the pollution source and, in conjunction with water area video surveillance data, locates the pollution source, including: GPS positioning was used to obtain the three-dimensional spatial coordinates of the water collection pool and key upstream nodes; The pollutant diffusion image feature dataset is reconstructed into a point cloud using 3D reconstruction technology to generate a 3D point cloud model of pollutant diffusion. The three-dimensional spatial coordinates of the upstream node are registered with the three-dimensional point cloud model of pollutant diffusion using a three-dimensional reconstruction algorithm. The region with the largest pollutant concentration gradient is calculated, thereby locating the pollution source. (X1 source Y1 source Z1 source )=arg max (X1,Y1,Z1) ||▽A(X1,Y1,Z1,t2||, where (X1,Y1,Z1) represents the original three-dimensional spatial coordinates, (X1,Y1,Z1) represents the coordinates of the original position in space, and (X1,Y1,Z1) represents the coordinates of the original position in space. source Y1 source Z1 source ) represents the target's three-dimensional spatial coordinates, t2 represents the current time, and arg max (X1,Y1,Z1) This indicates that among all spatial locations (X1,Y1,Z1), the point where the gradient magnitude ||▽A(X1,Y1,Z1,t2|| is maximized is found; ▽A represents the gradient of pollutant concentration.
10. A machine learning-based method for early warning of rural water pollution, used to execute the machine learning-based rural water pollution early warning system according to any one of claims 1-9, characterized in that, Includes the following steps: S1. Set up a data acquisition module to acquire water quality monitoring data of rural water areas through automatic monitoring equipment deployed at key monitoring points; S2. Set up a data preprocessing module to preprocess the acquired rural water quality status monitoring data to obtain a comprehensive water quality status feature dataset. S3. Set up a causal adversarial joint risk inference module, which is used to train and obtain a water pollution risk assessment model based on the comprehensive water quality status feature dataset, and predict the water pollution risk rate based on the water pollution risk assessment model. Determine whether there is a risk of water pollution in rural water areas based on the water pollution risk rate; S4. Set up a dynamic early warning module. If there is a risk of water pollution in rural water areas, the module will issue a graded early warning for the water pollution risk and trigger the corresponding alarm command. S5. Set up a pollution source location and treatment module to obtain spatial location data of pollution sources, locate the pollution source location by combining water area video monitoring data, and upload pollution information to the user terminal. The locations of the key monitoring points are dynamically determined by an adaptive optimization algorithm based on maximizing information gain. This algorithm analyzes the spatiotemporal variation characteristics of historical monitoring data and iteratively searches for a monitoring point layout scheme that minimizes the overall information entropy of the monitoring network.