A water pollution early warning method and device

The abnormal identification of water quality parameter data through the isolated forest algorithm is solved, and the problem of water quality sensors in the water supply pipeline network failing to effectively warn, realizing timely warning and accurate identification of water quality pollution, which is suitable for detection scenarios of unknown pollution events.

CN112861770BActive Publication Date: 2024-11-01TSINGHUA UNIVERSITY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110232689.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-03-02
Publication Date
2024-11-01
Estimated Expiration
2041-03-02

AI Technical Summary

Technical Problem

The water quality sensors in the existing water supply pipeline network fail to effectively play the monitoring and early warning function, resulting in a timely investigation of sudden water quality pollution accidents in the pipeline network and trace the pollution source, affecting the formulation and implementation of pollution source control and elimination strategies.

Method used

The isolated forest algorithm is used to identify and warn the water quality parameter data abnormally. By collecting historical data of water quality parameters, a pollution warning feature library is constructed, the water quality feature vector is extracted, and the water quality feature vector to be detected is combined with the warning feature library to be detected to perform abnormal identification.

Benefits of technology

It realizes timely warning of water quality pollution, makes full use of the coordinated feedback phenomenon of multiple water quality parameters, retains the original information of the monitoring data, and does not require a large amount of data accumulation and data of different pollution categories, which is suitable for detection scenarios of unknown pollution events.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112861770B_ABST
    Figure CN112861770B_ABST
Patent Text Reader

Abstract

The present disclosure provides a water pollution early warning method and device, the water pollution early warning method includes: collecting water quality parameter historical data, building a water pollution early warning feature library; collecting water quality parameter data at the time to be detected, building a water quality feature vector at the time to be detected, and the water quality feature vector at the time to be detected and the water pollution early warning feature library together constitute a sample set to be detected; using an isolation forest algorithm to identify and warn the water quality parameter data in the sample set to be detected. Using the present disclosure, the extraction of water quality feature vectors can make full use of the collaborative feedback phenomenon of multiple water quality parameters on pollution events, while retaining the original information of the monitoring data; the isolation forest algorithm is a purely unsupervised method, which does not require a large amount of data accumulation, especially does not require data of various pollution categories, and has no requirements for data distribution. In fact, it is more suitable for the scene of detecting unknown pollution events.
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 pollution early warning, and in particular to a method and device for early warning of water pollution caused by sudden pollution of a water supply network. Background Art

[0002] Sudden water pollution accidents in pipe networks are hidden, sudden, discontinuous and uncertain. Once they occur, they are very likely to cause economic losses and environmental damage. When water pollution accidents occur, timely investigation of accidents and tracing of pollution sources have become the bottleneck of current environmental emergency response work, directly affecting the formulation and implementation of pollution source control and elimination strategies.

[0003] At present, most of my country's water supply networks have installed water quality sensors to monitor water quality changes in real time, making it possible to quickly discover sudden pollution. However, due to the operation and management of water supply companies or technical conditions, these water quality sensors have not been able to effectively play the monitoring and early warning functions. Summary of the invention

[0004] 1. Technical issues to be resolved

[0005] In view of this, the main purpose of the present disclosure is to provide a water pollution early warning method and device to at least partially solve the technical problems mentioned above.

[0006] (II) Technical solution

[0007] According to one aspect of the present disclosure, a water pollution warning method is provided, including: collecting historical data of water quality parameters and constructing a water pollution warning feature library; collecting water quality parameter data at a time to be detected, constructing a water quality feature vector at the time to be detected, and the water quality feature vector at the time to be detected and the water pollution warning feature library together constitute a sample set to be detected; and using an isolation forest algorithm to identify anomalies and issue warnings in the water quality parameter data in the sample set to be detected.

[0008] According to an embodiment of the present disclosure, the collecting of historical data of water quality parameters and the construction of a water pollution early warning feature library include:

[0009] Step A1: Collect all historical data of water quality parameters at time t and the previous k times, calculate the correlation coefficient between n water quality parameter data at time t, and the mean of n water quality parameter historical data from time tk to time t, a total of k+1 data, and construct the water quality feature vector at time t, recorded as Realize the extraction of data features and the construction of feature vectors;

[0010] Step A2: According to step A1, the historical data of water quality parameters at m moments are constructed into a water quality pollution early warning feature library containing mk water quality feature vectors.

[0011] According to an embodiment of the present disclosure, the correlation coefficient in step A1 is any one of a Pearson correlation coefficient, a Spearman correlation coefficient, a Kendall correlation coefficient or a covariance.

[0012] According to an embodiment of the present disclosure, the correlation coefficient is a Pearson correlation coefficient, and the Pearson correlation coefficient r is calculated using the following formula:

[0013]

[0014] In the formula, x i and i They represent data at the same time on different days. and They represent the mean of the data in the same time period on different days, and n is the number of data in a certain time period; the value range of r is [-1, 1]. r is greater than or less than zero, which indicates that the two water quality parameters have a certain synergistic feedback phenomenon, and the larger the absolute value of r, the more obvious the synergistic feedback phenomenon.

[0015] According to an embodiment of the present disclosure, in the step of collecting water quality parameter data at the time to be detected, constructing a water quality feature vector at the time to be detected, and forming a sample set to be detected together with the water quality pollution warning feature library, the water quality feature vector at the time to be detected is constructed according to step A1, the water quality feature vector at the time to be detected is the sample to be detected, and the sample to be detected and the water quality pollution warning feature library together constitute the sample set to be detected.

[0016] According to an embodiment of the present disclosure, the use of the isolation forest algorithm to perform abnormal identification and early warning on the water quality parameter data in the sample set to be detected includes:

[0017] Step 1: Replace with replacement from n s From the detection sample set, ψ samples are extracted to construct a data subset, where n s =m-k+1;

[0018] Step 2: Randomly select an attribute in the data subset, which is any column in the test sample set;

[0019] Step 3: Randomly select a value Value of the attribute;

[0020] Step 4: Use iTree with a binary tree structure to split each data sample according to the selected attribute. If the data sample x is less than Value, put it into the left subtree, otherwise put it into the right subtree;

[0021] Step 5: Repeat steps 3 and 4 to recursively construct the left subtree and the right subtree until all leaf nodes have only one data sample, that is, the data sample cannot be split any more, and iTree stops growing;

[0022] Step 6: Repeat steps 1 to 5 to build n t iTree, forming an iForest;

[0023] Step 7: Calculate the value of each data sample in n t The average path length in an iTree and the p-quantile of the average path length. If the average path length of the sample to be tested is greater than the p-quantile of the average path length, the water quality is abnormal, otherwise the water quality is normal.

[0024] According to an embodiment of the present disclosure, the p quantile of the average path length in step 7 is related to the average path length and the sampling size. Assume that the path length of the data sample x on an iTree is h(x). t The average path length on an iTree is E(h(x)), then the p-quantile s(x, ψ) of the data sample x is:

[0025]

[0026]

[0027] H(ψ-1) in formula (3) is the harmonic number, H(ψ-1)=ln(ψ-1)+0.5772156649. The closer E(h(x)) is to 0, the closer s(x, ψ) is to 1, and the easier it is for a data sample to be judged as abnormal.

[0028] According to an embodiment of the present disclosure, the isolation forest algorithm includes two stages, wherein:

[0029] Steps 1 to 6 are the training phase, which is to build iForest based on a training data set;

[0030] Step 7 is the evaluation phase, which is to detect abnormal data in the training data set based on the established iForest, and can detect abnormal data in new data.

[0031] According to another aspect of the present disclosure, a water pollution early warning device is provided, including: a monitoring module 1, including a water quality sensor 8, which monitors the water quality of water entering the monitoring module 1 in real time to obtain water quality data; a data acquisition and transmission module 2, which is used to transmit the water quality data monitored by the water quality sensor 8 to a data display and early warning module 4; the data display and early warning module 4 is used to store and display in real time the water quality data input by the data acquisition and transmission module 2, and judge the water quality based on the water quality data, and issue an early warning when the water quality is abnormal; and a power supply module 3, which is equipped with a DC power supply and an AC power supply, and is used to power the monitoring module 1, the data acquisition and transmission module 2 and the data display and early warning module 4.

[0032] According to an embodiment of the present disclosure, the monitoring module 1 further includes a water inlet pipe 6 and a water outlet pipe 7 , water enters the monitoring module 1 from the water inlet pipe 6 , and the monitored water is discharged from the water outlet pipe 7 .

[0033] According to an embodiment of the present disclosure, the water quality data includes at least two of pH value, temperature, conductivity, ORP, residual chlorine, turbidity, and COD.

[0034] According to an embodiment of the present disclosure, the data acquisition and transmission module 2 also wirelessly transmits the water quality data monitored by the water quality sensor 8 to the cloud server.

[0035] According to an embodiment of the present disclosure, the data display and warning module 4 issues a warning when the water quality is abnormal, including: the data display and warning module 4 triggers the alarm 9 to flash red light when the water quality is abnormal, and sends the alarm information to the cloud server or pushes it to the mobile device.

[0036] According to an embodiment of the present disclosure, the water pollution warning device further includes: a box 5 for accommodating and protecting the monitoring module 1 , the data acquisition and transmission module 2 , the power supply module 3 and the data display and warning module 4 .

[0037] According to an embodiment of the present disclosure, the box 5 includes at least four wheels 10 to facilitate movement.

[0038] (III) Beneficial effects

[0039] It can be seen from the above technical solutions that the water pollution early warning method and device provided by the present disclosure have at least one of the following beneficial effects:

[0040] 1. The water pollution early warning method and device provided by the present disclosure can fully utilize the collaborative feedback phenomenon of multiple water quality parameters on pollution events by extracting water quality feature vectors, while retaining the original information of the monitoring data.

[0041] 2. The water pollution early warning method and device provided by the present invention, the isolation forest algorithm is a purely unsupervised method, which does not require a large amount of data accumulation, especially does not require data of various pollution categories, and has no requirements for data distribution. In fact, it is more suitable for the scenario of detecting unknown pollution events. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] Figure 1 Flow chart of a water pollution early warning method according to an embodiment of the present disclosure.

[0043] Figure 2 Schematic diagram of the structure of a water pollution warning device according to an embodiment of the present disclosure.

[0044] Figure 3 Schematic diagram of river water mixing experiment results according to an embodiment of the present disclosure.

[0045] Figure 4 It is a schematic diagram of the Pearson correlation coefficient between two water quality parameters, the original data of the water quality parameters and the historical mean according to an embodiment of the present disclosure.

[0046] Figure 5 It is a schematic diagram of dividing a data sample using a binary tree according to an embodiment of the present disclosure.

[0047] Figure 6a and Figure 6b Schematic diagram of the recognition effect of the river water mixing experiment according to the embodiment of the present disclosure, wherein Figure 6a is the accuracy rate of the three methods, Figure 6b is the false alarm rate of the three methods.

[0048] Figure 7 It is a schematic diagram of the recognition effect at various mixing ratios in the river water mixing experiment according to an embodiment of the present disclosure.

[0049] [Reference Signs]

[0050] 1 monitoring module, 2 data acquisition and transmission module, 3 power module, 4 data display and early warning module, 5 box, 6 water inlet pipe, 7 water outlet pipe, 8 water quality sensor, 9 alarm, 10 wheels. DETAILED DESCRIPTION

[0051] In order to make the objectives, technical solutions and advantages of the present disclosure more clearly understood, the present disclosure is further described in detail below in combination with specific embodiments and with reference to the accompanying drawings.

[0052] Certain embodiments of the present disclosure will be described more fully below with reference to the accompanying drawings, some but not all of which will be shown. In fact, the various embodiments of the present disclosure may be implemented in many different forms and should not be construed as limited to the embodiments set forth herein; rather, these embodiments are provided so that the present disclosure satisfies applicable legal requirements.

[0053] Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the present disclosure. In the following detailed description, for ease of explanation, many specific details are set forth to provide a comprehensive understanding of the embodiments of the present disclosure. However, it is apparent that one or more embodiments may also be implemented without these specific details. In addition, in the following description, descriptions of known structures and technologies are omitted to avoid unnecessary confusion of the concepts of the present disclosure.

[0054] The terms used herein are only for describing specific embodiments and are not intended to limit the present disclosure. The terms "comprise", "include", etc. used herein indicate the existence of the features, steps, operations and / or components, but do not exclude the existence or addition of one or more other features, steps, operations or components.

[0055] All terms (including technical and scientific terms) used herein have the meanings commonly understood by those skilled in the art, unless otherwise defined. It should be noted that the terms used herein should be interpreted as having a meaning consistent with the context of this specification, and should not be interpreted in an idealized or overly rigid manner.

[0056] In an exemplary embodiment of the present disclosure, a water pollution early warning method is provided, such as Figure 1 As shown, Figure 1 The flowchart of the water pollution early warning method according to the embodiment of the present disclosure includes the following steps:

[0057] Step S1: Collect historical data of water quality parameters and build a water pollution warning feature library;

[0058] Step S2: Collect water quality parameter data at the time to be detected, construct a water quality feature vector at the time to be detected, and use the water quality feature vector at the time to be detected and the water pollution warning feature library to form a sample set to be detected;

[0059] Step S3: Use the isolation forest algorithm to identify abnormalities and issue early warnings for the water quality parameter data in the sample set to be tested.

[0060] In the embodiment of the present disclosure, the step S1 of collecting historical data of water quality parameters and constructing a water pollution early warning feature library includes:

[0061] Step A1: Calculate the correlation coefficient between the n water quality parameter data at time t, the mean of the n water quality parameter historical data from time tk to time t, a total of k+1 data, and construct the water quality feature vector at time t, recorded as Realize the extraction of data features and the construction of feature vectors.

[0062] In step A1, the correlation coefficient is any one of the Pearson correlation coefficient, the Spearman correlation coefficient, the Kendall correlation coefficient or the covariance; when the correlation coefficient is the Pearson correlation coefficient, the Pearson correlation coefficient r is calculated using the following formula:

[0063]

[0064] In the formula, x i and i They represent data at the same time on different days. and They represent the mean of the data in the same time period on different days, and n is the number of data in a certain time period; the value range of r is [-1, 1]. r is greater than or less than zero, which indicates that the two water quality parameters have a certain synergistic feedback phenomenon, and the larger the absolute value of r, the more obvious the synergistic feedback phenomenon.

[0065] Step A2: According to step A1, the historical data of water quality parameters at m moments are constructed into a water quality pollution early warning feature library containing mk water quality feature vectors.

[0066] In an embodiment of the present disclosure, in the step of collecting water quality parameter data at the time to be detected, constructing a water quality feature vector at the time to be detected, and forming a sample set to be detected together with the water quality pollution warning feature library, the water quality feature vector at the time to be detected is constructed according to step A1, and the water quality feature vector at the time to be detected is the sample to be detected, and the sample to be detected and the water quality pollution warning feature library together constitute the sample set to be detected.

[0067] In an embodiment of the present disclosure, the use of the isolation forest algorithm in step S3 to perform abnormal identification and early warning on the water quality parameter data in the sample set to be detected includes:

[0068] Step 1: Replace with replacement from n s From the detection sample set, ψ samples are extracted to construct a data subset, where n s =m-k+1;

[0069] Step 2: Randomly select an attribute in the data subset, which is any column in the test sample set;

[0070] Step 3: Randomly select a value Value of the attribute;

[0071] Step 4: Use iTree with a binary tree structure to split each data sample according to the selected attribute. If the data sample x is less than Value, put it into the left subtree, otherwise put it into the right subtree;

[0072] Step 5: Repeat steps 3 and 4 to recursively construct the left subtree and the right subtree until all leaf nodes have only one data sample, that is, the data sample cannot be split any more, and iTree stops growing;

[0073] Step 6: Repeat steps 1 to 5 to build n t iTree, forming an iForest;

[0074] Step 7: Calculate the value of each data sample in n t The average path length in an iTree and the p-quantile of the average path length. If the average path length of the sample to be tested is greater than the p-quantile of the average path length, the water quality is abnormal, otherwise the water quality is normal.

[0075] The p quantile of the average path length described in step 7 is related to the average path length and the sampling size. Assume that the path length of the data sample x on an iTree is h(x). t The average path length on an iTree is E(h(x)), then the p-quantile s(x, ψ) of the data sample x is:

[0076]

[0077]

[0078] H(ψ-1) in formula (3) is the harmonic number, H(ψ-1)=ln(ψ-1)+0.5772156649. The closer E(h(x)) is to 0, the closer s(x, ψ) is to 1, and the easier it is for a data sample to be judged as abnormal.

[0079] In an embodiment of the present disclosure, the isolation forest algorithm described in step S3 includes two stages, wherein: steps 1 to 6 are a training stage, in which iForest is established based on a training data set; step 7 is an evaluation stage, in which the iForest established based on v realizes the detection of abnormal data in the training data set, and can detect abnormal data in new data.

[0080] based on Figure 1 The present disclosure also provides a water pollution early warning device, specifically as follows Figure 2 As shown, Figure 2The structure diagram of the water pollution early warning device according to the embodiment of the present disclosure is shown in FIG. The water pollution early warning device at least comprises a monitoring module 1, a data acquisition and transmission module 2, a power module 3 and a data display and early warning module 4, wherein:

[0081] The monitoring module 1 includes a water quality sensor 8, which monitors the water quality of water entering the monitoring module 1 in real time and obtains water quality data;

[0082] The data acquisition and transmission module 2 is used to transmit the water quality data monitored by the water quality sensor 8 to the data display and early warning module 4, and can also wirelessly transmit the water quality data monitored by the water quality sensor 8 to the cloud server;

[0083] The power supply module 3 is equipped with a DC power supply and an AC power supply, and is used to supply power to the monitoring module 1, the data acquisition and transmission module 2, and the data display and early warning module 4;

[0084] The data display and warning module 4 is used to store and display in real time the water quality data input by the data acquisition and transmission module 2, and to judge the water quality based on the water quality data, and to issue a warning when the water quality is abnormal.

[0085] In the embodiments of the present disclosure, Figure 2 As shown, the monitoring module 1 further includes a water inlet pipe 6 and a water outlet pipe 7. Water enters the monitoring module 1 from the water inlet pipe 6, and the monitored water is discharged from the water outlet pipe 7. The water quality sensor 8 monitors the water quality of the water entering the monitoring module 1 in real time, and the obtained water quality data includes at least two of pH value, temperature, conductivity, ORP, residual chlorine, turbidity, and COD.

[0086] In the embodiments of the present disclosure, Figure 2 As shown, the data display and warning module 4 issues a warning when the water quality is abnormal, including: the data display and warning module 4 triggers the alarm 9 to flash red when the water quality is abnormal, and sends the alarm information to the cloud server or pushes it to the mobile device.

[0087] In the embodiments of the present disclosure, Figure 2 As shown, the water pollution warning device also includes: a box 5 for accommodating and protecting the monitoring module 1, the data acquisition and transmission module 2, the power module 3 and the data display and warning module 4.

[0088] Furthermore, in order to facilitate movement, the box 5 includes at least four wheels 10, which are respectively installed at four corners of the bottom of the box 5.

[0089] Example

[0090] like Figure 2 As shown, Figure 2This is a schematic diagram of the structure of a water pollution warning device according to an embodiment of the present disclosure. Figure 2 The water pollution warning device shown in the figure is used to conduct a water pollution simulation experiment. The turbidity of the water from the second water supply tank is 0.04NTU, the residual chlorine concentration is 0.5mg / L, and the pollutant is natural river water, the turbidity of natural river water is 1.61NTU, and the residual chlorine concentration is 0mg / L. The experimental steps are:

[0091] 1) The water pump pumps water from the second water supply tank to the disclosed device at a flow rate of 0.5L / min for more than 6 hours;

[0092] 2) Two water pumps pump water from the second water supply tank and the pollutant water tank to the disclosed device respectively. The sum of the flow rates of the two water pumps is 0.5 L / min. The pollutant mixing ratios are 1%, 3%, 5%, 10%, and 15%, respectively. The injection of each pollutant mixing ratio lasts for about 30-40 minutes, and then the addition of pollutants is stopped. The system is flushed with water from the two water supply tanks at a flow rate of 0.5 L / min for 1 hour, and then the next mixing experiment is carried out.

[0093] The pollution simulation experiment obtained 24 hours of monitoring data with a data collection interval of 150 seconds, of which the baseline data was as long as 16 hours and the pollution simulation process lasted 8 hours. Figure 3 A schematic diagram showing the results of a river water mixing experiment according to an embodiment of the present disclosure is shown.

[0094] The following is a detailed description of the method flow for implementing water pollution warning using a water pollution warning device according to an embodiment of the present disclosure:

[0095] (1) Data feature extraction

[0096] This embodiment uses the Pearson correlation coefficient r to characterize the synergistic feedback phenomenon between two parameters. The larger the absolute value of r, the greater the possibility of contamination. The calculation formula is as follows:

[0097]

[0098] In the formula, x i and i They represent data at the same time on different days. and They represent the mean of the data in the same time period on different days, and n is the number of data in a certain time period; the value range of r is [-1, 1]. r is greater than or less than zero, which indicates that the two water quality parameters have a certain synergistic feedback phenomenon, and the larger the absolute value of r, the more obvious the synergistic feedback phenomenon.

[0099] This embodiment uses all data from the current moment and the previous 22.5 minutes to calculate the Pearson correlation coefficient, that is, n in formula (1) is 10, the data collection interval is 150 seconds, the previous 22.5 minutes contains data from 9 moments, plus the current moment, a total of 10 data.

[0100] The water quality monitoring data at each moment can be used to calculate the Pearson correlation coefficient between two water quality parameters by formula (1). This embodiment uses four water quality parameters (residual chlorine, turbidity, conductivity, ORP), so six correlation coefficients can be calculated at each moment. Figure 4 As shown, Figure 4 The figure is a schematic diagram of the Pearson correlation coefficient between two water quality parameters, the original data of the water quality parameters and the historical mean according to the embodiment of the present disclosure. In this embodiment, the original data of the water quality parameters at each moment, the historical mean data, and the Pearson correlation coefficient reflecting the collaborative feedback phenomenon are combined to form a 14-dimensional feature vector for the identification and early warning of water pollution events.

[0101] In the absence of a pollution incident, the value of the Pearson correlation coefficient in the water quality feature vector corresponding to each moment should be relatively small, the raw data of the water quality parameters fluctuate within a certain range, and the historical mean data of the water quality parameters change little. After a pollution incident occurs, the absolute values ​​of some Pearson correlation coefficients in the water quality feature vectors corresponding to each moment increase, the raw data of some water quality parameters also fluctuate suddenly, and the historical mean data of some water quality parameters also fluctuate suddenly. The extraction of water quality feature vectors can make full use of the collaborative feedback phenomenon of multiple water quality parameters on pollution incidents, while retaining the original information of the monitoring data.

[0102] (2) Isolation Forest Algorithm

[0103] The Isolation Forest algorithm uses a binary tree to segment data samples. When each data sample is isolated (i.e., each leaf node of the binary tree has only one data sample), the binary tree stops growing. Under this random segmentation strategy, abnormal data that is easy to be isolated usually has a shorter path length. The path length refers to the number of edges that a data sample passes through from the root node of the tree to the time it is isolated to a leaf node. The length of the path reflects the difficulty of isolating the data sample. Figure 5 The figure shows the process of splitting five data samples a, b, c, d and e by a binary tree. The path lengths of b and e are 1 and 2 respectively, and the path lengths of other data are not less than 3. b and e are easier to be isolated and are more likely to be abnormal data.

[0104] In the Isolation Forest Algorithm, the binary tree with randomly segmented data samples is named iTree. In order to ensure the accuracy and stability of the segmentation results, the Isolation Forest Algorithm needs to construct n tiTree, this t The number of iTrees constitutes an isolation forest iForest. iForest can randomly divide the data n t By analyzing each data sample in n t The average path length in the segmentation can be used to determine whether the data is abnormal.

[0105] The steps to implement water quality anomaly detection using the isolation forest algorithm are as follows:

[0106] 1) With replacement from n s Extract ψ samples from the data samples to construct a data subset;

[0107] 2) Randomly select an attribute from a subset of data;

[0108] 3) Randomly select a value Value of the attribute;

[0109] 4) Split each data sample according to the selected attribute. If the sample x is less than Value, put it into the left subtree, otherwise put it into the right subtree;

[0110] 5) Repeat steps 3 and 4 to recursively construct the left subtree and the right subtree until all leaf nodes have only one sample (that is, the data cannot be split any further), and iTree stops growing;

[0111] 6) Repeat steps 1 to 5 to construct n t iTree, forming an iForest;

[0112] 7) Calculate the value of each data sample in n t The average path length and anomaly score in each iTree are used to determine whether the data is abnormal.

[0113] When ψ and n t When the values ​​of are 256 and 100 respectively, the Isolation Forest Algorithm can achieve better anomaly identification results. In practical applications, if the total number of data samples is less than 256, all samples are used to construct the iTree. The anomaly score described in step 7 is related to both the average path length and the sampling size. The path length of the data sample x on an iTree is h(x). t The average path length on an iTree is E(h(x)), and the anomaly score s(x, ψ) of data sample x is:

[0114]

[0115]

[0116] H(ψ-1) in formula (3) is the harmonic number, H(ψ-1) = ln(ψ-1) + 0.5772156649; the closer E(h(x)) is to 0, the closer s(x, ψ) is to 1, and the easier it is for a data sample to be judged as abnormal. The isolation forest algorithm is a two-stage method. Steps 1 to 6 are called the training stage, which can establish an iForest based on a training data set; step 7 is called the evaluation stage, which can not only detect abnormal data in the training data set based on the existing iForest, but also detect abnormal data in new data.

[0117] For the pollution simulation experiment data, this embodiment uses the water quality feature vector generated by part of the baseline data (about 12 hours) as training data to establish iForest, and then identifies and warns the remaining baseline data and pollution data. For normal monitoring data (i.e., all baseline data), this embodiment uses about 12 hours of monitoring data to establish iForest, and then identifies and warns the remaining data.

[0118] (3) Comparison of water pollution warning performance

[0119] This embodiment compares the early warning performance of the present disclosure and two other methods - multi-parameter and single-parameter water pollution early warning methods. The two comparison methods also use the isolation forest algorithm to identify and warn pollution events. The difference is that the water quality feature vector of the multi-parameter method only contains the original monitoring data of the water quality parameters, and the water quality feature vector of the single-parameter method only contains one water quality parameter (such as residual chlorine). The disclosed method is recorded as "corr+raw", the multi-parameter method is recorded as "raw", and the single-parameter method is recorded as "Cl".

[0120] This embodiment uses the True Positive Rate (TPR) and the False Positive Rate (FPR) to evaluate the early warning performance. The higher the TPR, the higher the probability that the pollution event is detected, and the higher the FPR, the higher the probability that the baseline is misjudged as a pollution event.

[0121]

[0122]

[0123] in,

[0124] TP, it is judged that a pollution incident has occurred, and a pollution incident actually occurred;

[0125] FP, it is judged that a pollution incident has occurred, but in fact no pollution incident has occurred;

[0126] TN, judged as the baseline condition, with no actual pollution incidents;

[0127] FN, judged as baseline conditions, but a pollution incident actually occurred.

[0128] Figure 6a and Figure 6b Schematic diagram of the recognition effect of the river water mixing experiment according to the embodiment of the present disclosure, wherein Figure 6a is the accuracy rate of the three methods, Figure 6b The false alarm rates of the three methods are as follows. Compared with the multi-parameter method, the present disclosure increases the accurate alarm rate by 18.1% and reduces the false alarm rate by 80.8%; compared with the single-parameter (residual chlorine) method, the present disclosure increases the accurate alarm rate by 75.6% and reduces the false alarm rate by 8.1%.

[0129] Figure 7 The accuracy of the three methods at each mixing ratio is further shown. It can be found that the water pollution early warning method provided by the present disclosure shows the strongest recognition ability at each mixing ratio. At a low mixing ratio, the dilution capacity of river water to the secondary supply water is limited, the water quality parameters change little, and the synergistic feedback phenomenon is not very obvious, so the recognition ability is also poor.

[0130] The water pollution early warning method and device provided by the present disclosure can fully utilize the collaborative feedback phenomenon of multiple water quality parameters on pollution events by extracting water quality feature vectors, while retaining the original information of monitoring data. The isolation forest algorithm is a purely unsupervised method that does not require a large amount of data accumulation, especially does not require data of various pollution categories, and has no requirements for data distribution. In fact, it is more suitable for the scenario of detecting unknown pollution events.

[0131] So far, the present disclosure has been described in detail in conjunction with the accompanying drawings. Based on the above description, those skilled in the art should have a clear understanding of the present disclosure.

[0132] It should be noted that the implementation methods not shown or described in the drawings or the text of the specification are all forms known to ordinary technicians in the relevant technical field and are not described in detail. In addition, the above definitions of each element are not limited to the various specific structures, shapes or methods mentioned in the embodiments, and ordinary technicians in the field can simply change or replace them.

[0133] Of course, according to actual needs, the present disclosure may also include other parts, which are irrelevant to the innovation of the present disclosure and will not be described here.

[0134] Moreover, the shapes and sizes of the components in the figures do not reflect the real size and proportion, but only illustrate the contents of the embodiments of the present disclosure. In addition, in the claims, any reference symbols between brackets shall not be constructed as limiting the claims.

[0135] Unless otherwise indicated, the numerical parameters in this specification and the appended claims are approximate values ​​and can vary according to the desired properties obtained through the content of the present disclosure. Specifically, all numbers used in the specification and claims to express the content of the composition, reaction conditions, etc., should be understood to be modified by the term "about" in all cases. In general, the meaning of the expression is to include a variation of ±10% in some embodiments, ±5% in some embodiments, ±1% in some embodiments, and ±0.5% in some embodiments by a specific number.

[0136] Furthermore, the word "comprising" does not exclude the presence of elements or steps not listed in a claim. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements.

[0137] In addition, unless the steps are specifically described or must occur in sequence, the order of the above steps is not limited to the above list, and can be changed or rearranged according to the required design. And the above embodiments can be mixed and matched with each other or with other embodiments based on design and reliability considerations, that is, the technical features in different embodiments can be freely combined to form more embodiments.

[0138] Similarly, it should be understood that in order to streamline the present disclosure and aid in understanding one or more of the various disclosed aspects, in the above description of the exemplary embodiments of the present disclosure, the various features of the present disclosure are sometimes grouped together into a single embodiment, figure, or description thereof. However, this disclosed method should not be interpreted as reflecting the following intention: the claimed disclosure requires more features than the features explicitly recited in each claim. More specifically, as reflected in the claims below, the disclosed aspects are less than all the features of the single embodiment disclosed above. Therefore, the claims that follow the specific embodiment are hereby expressly incorporated into the specific embodiment, with each claim itself serving as a separate embodiment of the present disclosure.

[0139] In addition, in the drawings or descriptions, similar or identical parts use the same figure numbers. The technical features in the various embodiments exemplified in the specification can be freely combined to form new solutions without conflict. In addition, each claim can be used as an embodiment alone or the technical features in each claim can be combined as a new embodiment, and in the drawings, the shape or thickness of the embodiment can be expanded and simplified or conveniently indicated. Furthermore, the elements or implementations not shown or described in the drawings are in a form known to a person of ordinary skill in the art. In addition, although demonstrations of parameters containing specific values ​​may be provided herein, it should be understood that the parameters do not need to be exactly equal to the corresponding values, but can be approximated to the corresponding values ​​within an acceptable error tolerance or design constraint.

[0140] Unless there are technical obstacles or contradictions, the above-mentioned various embodiments of the present disclosure can be freely combined to form additional embodiments, and these additional embodiments are all within the protection scope of the present disclosure.

[0141] Although the present disclosure is described in conjunction with the accompanying drawings, the embodiments disclosed in the accompanying drawings are intended to exemplify the preferred embodiments of the present disclosure and should not be construed as limiting the present disclosure. The dimensional ratios in the accompanying drawings are merely illustrative and should not be construed as limiting the present disclosure.

[0142] Although some embodiments of the present general inventive concept have been shown and described, it will be appreciated by those skilled in the art that changes may be made to these embodiments without departing from the principles and spirit of the present general inventive concept, the scope of which is defined by the claims and their equivalents.

[0143] The specific embodiments described above further illustrate the purpose, technical solutions and beneficial effects of the present disclosure. It should be understood that the above description is only a specific embodiment of the present disclosure and is not intended to limit the present disclosure. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present disclosure should be included in the protection scope of the present disclosure.

Claims

1. A water pollution early warning method, characterized in that: include: Collect historical data on water quality parameters and build a water pollution early warning feature database; Collect water quality parameter data at the time to be detected, construct a water quality feature vector at the time to be detected, and use the water quality feature vector at the time to be detected and the water pollution warning feature library to form a sample set to be detected; The isolation forest algorithm is used to identify abnormalities and provide early warning for the water quality parameter data in the sample set to be tested. The method of collecting historical data of water quality parameters and constructing a water pollution early warning feature library includes: Step A1: Collecting all historical data of water quality parameters at time t and the previous k times, calculating the correlation coefficient between n water quality parameter data at time t, and the mean of k+1 data of n historical data of water quality parameters from time tk to time t, and constructing a water quality feature vector at time t, recorded as Realize the extraction of data features and the construction of feature vectors; Step A2: According to Step A1, the historical data of water quality parameters at m moments are constructed into a water quality pollution warning feature library containing mk water quality feature vectors; In the step of collecting water quality parameter data at the time to be detected, constructing a water quality feature vector at the time to be detected, and forming a sample set to be detected by combining the water quality feature vector at the time to be detected with the water quality pollution warning feature library, the water quality feature vector at the time to be detected is constructed according to step A1, the water quality feature vector at the time to be detected is the sample to be detected, and the sample to be detected and the water quality pollution warning feature library together form a sample set to be detected; The isolation forest algorithm is used to identify and warn abnormalities in the water quality parameter data of the sample to be tested, including: Step 1: Replace with replacement from n s From the detection sample set, ψ samples are extracted to construct a data subset, where n s =m-k+1; Step 2: Randomly select an attribute in the data subset, which is any column in the test sample set; Step 3: Randomly select a value Value of the attribute; Step 4: Use iTree with a binary tree structure to split each data sample according to the selected attribute. If the data sample x is less than Value, put it into the left subtree, otherwise put it into the right subtree; Step 5: Repeat steps 3 and 4 to recursively construct the left subtree and the right subtree until all leaf nodes have only one data sample, that is, the data sample cannot be split any more, and iTree stops growing; Step 6: Repeat steps 1 to 5 to build n t iTree, forming an iForest; Step 7: Calculate the value of each data sample in n t The average path length in an iTree and the p-quantile of the average path length. If the average path length of the sample to be tested is greater than the p-quantile of the average path length, the water quality is abnormal, otherwise the water quality is normal.

2. The water pollution early warning method according to claim 1, characterized in that: The correlation coefficient in step A1 is any one of Pearson correlation coefficient, Spearman correlation coefficient, Kendall correlation coefficient or covariance.

3. The water pollution early warning method according to claim 2, characterized in that: The correlation coefficient is the Pearson correlation coefficient, and the Pearson correlation coefficient r is calculated using the following formula: In the formula, x i and i They represent data at the same time on different days. and They represent the mean of the data in the same time period on different days, and n is the number of data in a certain time period; the value range of r is [-1,1]. r is greater than or less than zero, which indicates that the two water quality parameters have a certain synergistic feedback phenomenon, and the larger the absolute value of r, the more obvious the synergistic feedback phenomenon.

4. The water pollution early warning method according to claim 1, characterized in that: The p quantile of the average path length described in step 7 is related to the average path length and the sampling size. Assume that the path length of the data sample x on an iTree is h(x). t The average path length on an iTree is E(h(x)), then the p-quantile s(x,ψ) of the data sample x is: H(ψ-1) in formula (3) is the harmonic number, H(ψ-1)=ln(ψ-1)+0.5772156649. The closer E(h(x)) is to 0, the closer s(x,ψ) is to 1, and the data sample is more likely to be judged as abnormal.

5. The water pollution early warning method according to claim 1, characterized in that: The isolation forest algorithm includes two stages, where: Steps 1 to 6 are the training phase, which is to build iForest based on a training data set; Step 7 is the evaluation phase, which is to detect abnormal data in the training data set based on the established iForest, and can detect abnormal data in new data.

6. A water pollution early warning device, used to implement the water pollution early warning method according to any one of claims 1 to 5, characterized in that: include: The monitoring module (1) comprises a water quality sensor (8), wherein the water quality sensor (8) monitors the quality of water entering the monitoring module (1) in real time to obtain water quality data; A data collection and transmission module (2) is used to transmit the water quality data monitored by the water quality sensor (8) to the data display and early warning module (4); A data display and warning module (4) is used to store and display in real time the water quality data input by the data acquisition and transmission module (2), and to judge the water quality based on the water quality data, and to issue a warning when the water quality is abnormal; as well as The power module (3) is equipped with a direct current power supply and an alternating current power supply and is used to supply power to the monitoring module (1), the data acquisition and transmission module (2) and the data display and early warning module (4).

7. The water pollution early warning device according to claim 6, characterized in that: The monitoring module (1) further comprises a water inlet pipe (6) and a water outlet pipe (7), water enters the monitoring module (1) from the water inlet pipe (6), and the monitored water is discharged from the water outlet pipe (7).

8. The water pollution early warning device according to claim 6, characterized in that: The water quality data includes at least two of pH value, temperature, conductivity, ORP, residual chlorine, turbidity, and COD.

9. The water pollution early warning device according to claim 6, characterized in that: The data collection and transmission module (2) also wirelessly transmits the water quality data monitored by the water quality sensor (8) to the cloud server.

10. The water pollution early warning device according to claim 6, characterized in that: The data display and warning module (4) issues a warning when the water quality is abnormal, including: When the water quality is abnormal, the data display and warning module (4) triggers the alarm (9) to flash a red light, and sends the alarm information to a cloud server or pushes it to a mobile device.

11. The water pollution early warning device according to claim 6, characterized in that: The water pollution early warning device also includes: The box (5) is used to accommodate and protect the monitoring module (1), the data acquisition and transmission module (2), the power supply module (3) and the data display and early warning module (4).

12. The water pollution early warning device according to claim 11, characterized in that: The box (5) comprises at least four wheels (10) to facilitate movement.