Water quality evaluation machine learning Bayesian model based on suspended particulate matter density
By using the entropy-weighted Bayesian model and weighted distance formula in water quality assessment, combined with the density of suspended particulate matter and multiple water quality indicators, the problem of inaccurate posterior probability calculation in traditional water quality assessment is solved, and a more accurate and rapid Water quality class assessment.
Patent Information
- Application Number
- CN202410719146.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-04
- Publication Date
- 2024-08-30
- Estimated Expiration
- 2044-06-04
AI Technical Summary
Traditional water quality assessment methods have the problem of inaccurate distance formulas when calculating posterior probabilities, resulting in inaccurate water quality grade assessment.
The machine learning Bayesian model of water quality assessment based on the density of suspended particulate matter is used. The posterior probability is calculated through the entropy weighted Bayesian model and the weighted distance formula. The density of suspended particulate matter and multiple water quality indicators are combined to divide the detailed water quality grade range, and Use MATLAB to generate a Bayesian classifier for evaluation.
The accuracy of water quality assessment is improved, the rapid assessment of water quality levels based on the density of suspended particulate matter is realized, and the rapid assessment method is simplified.
Smart Images

Figure CN118568595A
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of water quality assessment, and specifically is a machine learning Bayesian model for water quality assessment based on suspended particle density. Background Art
[0002] Traditional water quality assessment methods include single factor evaluation method, comprehensive index evaluation method, etc. Bayesian model can quantitatively reflect the influence degree and confidence of other factors on water quality, so it has many applications in water quality assessment methods, such as prior art 1: Tang Jinping et al. Groundwater quality assessment model and application based on Bayesian theory [J], Water-saving irrigation, 2018, No. 4, 88-91. In the calculation step (2), the distance value method based on geometric probability is used to calculate the inverse of the absolute value of the distance between the water quality index detection value and the standard value. Prior art 1 regards any water quality level as only a value. If it is higher or lower than this value, it is considered to be a certain distance away from this level. In fact, any water quality level is a range, and the probability of belonging to this level within this range is 100%. Summary of the invention
[0003] The purpose of the present invention is to improve the traditional posterior probability calculation distance formula to make the calculation result more accurate.
[0004] In order to achieve the above object, the present invention adopts the following technical solution:
[0005] A machine learning Bayesian model for water quality assessment based on suspended particle density includes the following steps:
[0006] S1. Collect and test several water quality samples, use indoor testing to measure the suspended particle density index, and use outdoor testing to obtain multiple water quality indicators for each sample;
[0007] S2. Establish an entropy-weighted Bayesian model for water quality assessment;
[0008] S3. Based on the five indicator data obtained from the above water quality test, the entropy weight is calculated according to the degree of chaos of the data system;
[0009] S4. Calculate the posterior probability P of the sample being in Class I to V water using the weighted distance formula;
[0010] S5. Divide the adjacent water quality levels from Class I to Class V into ten equal parts, and calculate the highest probability value P in the above posterior probability P. ik and the second highest probability value P (i±1)k The difference C is used to determine the water quality level L:
[0011]
[0012] Among them, d has no specific meaning and is only used to define the range of C, d = 1, 2, 3, 4, 5; i is the water quality grade;
[0013] S6. Based on the water quality grade of each sample calculated in S5, the water quality grade of each sample is matched with the suspended particle density of the sample, a large number of samples are selected as training sets, and the fitcnb function in the computer software MATLAB R2022a is used to generate a Bayesian classifier for water quality assessment based on suspended particles;
[0014] S7. Select the suspended particle density of the test set samples and predict the water quality level of the sample points based on the Bayesian classifier predict function.
[0015] Specifically, the suspended particle density index in step S1 includes the density of debris-like suspended particles and the density of fibrous suspended particles.
[0016] Specifically, the method for obtaining the suspended particle density index in step S1 includes: using a 25# biological net to filter to obtain a suspended particle sample, connecting a ZooSCAN image automatic scanning and analysis system instrument, diluting the collected suspended particle sample by a certain amount, and using the instrument to preview at a resolution of 300dp and scan at a resolution of 2400dp to collect the image and morphological data of the suspended particles; using filezilla software to upload the suspended particle image and morphological data to a database, performing classification training, manual verification and data export on the www.ecotaxa.cn website, and obtaining the density of debris-like suspended particles and the density of fibrous suspended particles.
[0017] Specifically, calculating the entropy weight in step S3 specifically includes:
[0018] S31. Data preprocessing: organize the raw data into the original matrix X and standardize it
[0019]
[0020] Where k is the site, j is the indicator, X is the matrix of original data, x is an item in the original matrix, Z is the standardized matrix, z is an item in the standardized matrix, and n is the total number of sites;
[0021] S32. Calculate the probability matrix P
[0022]
[0023] Where P is the probability matrix, and p is an item in the probability matrix;
[0024] S33. Calculate the entropy weight W
[0025]
[0026] Among them, e j is an intermediate variable, W j is the weight of the j indicator, and m is the total number of indicators.
[0027] Specifically, calculating the posterior probability P in step S4 specifically includes:
[0028] S41. The absolute distance D between the item detection value and the item standard value of the extremely large indicator data site can be calculated using the following formula:
[0029] ① When i=1:
[0030]
[0031] ② When i≠1:
[0032]
[0033] The absolute distance D between the project detection value and the project standard value of the extremely small indicator data station can be calculated using the following formula:
[0034] ① When i=1:
[0035]
[0036] ② When i≠1:
[0037]
[0038] S42. Calculate relative distance
[0039]
[0040] Among them, D(x jk |y ji ) is the relative distance. The smaller the value, the smaller the possibility that the water quality level of the indicator of station k belongs to i; otherwise, the larger the value;
[0041] S43. For sample point k, for index j, D(x jk |y ji ) to perform vertical normalization
[0042]
[0043] Where P ijk represents the probability that the jth indicator at the kth detection point belongs to the ith water quality level, P ik It represents the probability that the kth detection point belongs to the i-th water quality level.
[0044] Specifically, in step S1, outdoor detection is used to obtain five water quality indicators of each sample, including dissolved oxygen DO, permanganate index COD_Mn, total nitrogen TN, total phosphorus TP and ammonia nitrogen NH3-N values.
[0045] Beneficial effects of the present invention:
[0046] The present invention simplifies the existing rapid water quality assessment method, improves the accuracy of the assessment by improving the calculation formula in the prior art, and realizes the rapid assessment of the water quality grade based on the density of suspended particles. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] Figure 1 is a flow chart of the method of the present invention. DETAILED DESCRIPTION
[0048] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0049] Example 1
[0050] like Figure 1 As shown, the method of the present invention comprises the following steps:
[0051] S1. Obtain water quality samples from the test area of the drinking water source, use indoor testing to measure the suspended particle density index, and use outdoor testing to obtain 5 water quality indicators of each sample, including dissolved oxygen DO, permanganate index COD_Mn, total nitrogen TN, total phosphorus TP and ammonia nitrogen NH3-N values;
[0052] The suspended particle density index measured by indoor detection is the density of debris-like suspended particles D_De and the density of fibrous suspended particles D_Fi; the specific method is: use 25# biological net filtration to obtain suspended particle samples, connect the ZooSCAN image automatic scanning and analysis system (France, HYDROPTIC) instrument, dilute the collected suspended particle samples by a certain amount, and use the instrument to preview at 300dp resolution and scan at 2400dp resolution to collect the image and morphological data of suspended particles. Use filezilla software to upload the suspended particle images and morphological data to the database, perform classification training, manual verification and data export on the www.ecotaxa.cn website, and obtain the density of debris-like suspended particles D_De and the density of fibrous suspended particles D_Fi;
[0053] Multiple water quality indicators can be obtained by outdoor detection. In this embodiment, for the sake of convenience, only five items, namely, dissolved oxygen DO, permanganate index COD_Mn, total nitrogen TN, total phosphorus TP, and ammonia nitrogen NH3-N, are used. In actual application, indicators can be selected according to the type of water source sampled. The method of obtaining five water quality indicators by outdoor detection is a prior art and will not be repeated here.
[0054] S2. Based on the five indicators of dissolved oxygen DO, permanganate index COD_Mn, total nitrogen TN, total phosphorus TP and ammonia nitrogen NH3-N obtained from the above water quality test, an entropy weighted Bayesian model for water quality evaluation is established, and the formula is:
[0055]
[0056] In the formula, P(y ji |x jk ) is in x jk In the event of ji The probability of occurrence. ji represents the standard value of index j for water quality level i, x jk It represents the measured value of the j index at the station k, i is the water quality grade, and j is the index.
[0057] In the absence of any known data, the probability that the water quality at a certain point belongs to any level is the same, so the prior probability is:
[0058] P(y j1 )=P(y j2 )=P(y j3 )=P(y j4 )=P(y j5 )=1 / 5
[0059] In the formula, P(y j1 ) is the probability that the j index is Class I water, P(y j2 )、P(y j3 )、P(y j4 )、P(y j5 ) represent the probability of the j index being Class II water, Class III water, Class IV water, and Class V water respectively.
[0060] S3. Based on the five indicators obtained from the above water quality test, the entropy value W is calculated according to the degree of confusion of the data system, including:
[0061] S31. Data preprocessing: organize the raw data into the original matrix X and standardize it
[0062]
[0063] In the formula, k and j are the same as above, X is the matrix of original data, x is an item in the original matrix, and xkj The value of is the multiple water quality indicators of each sample detected in step S1, Z is the standardized matrix, z is an item in the standardized matrix, and n is the total number of sites.
[0064] S32. Calculate the probability matrix P
[0065]
[0066] Among them, P is the probability matrix, and p is an item in the probability matrix.
[0067] S33. Calculate entropy weight W
[0068]
[0069] Among them, e j is an intermediate variable, W j is the weight of the j indicator, m is the total number of indicators, and other parameters are the same as above.
[0070] S4. Based on the five indicators obtained from the above water quality test, the weighted distance formula is used to calculate the posterior probability P of the sample being in Class I to V water, specifically including:
[0071] S41. The absolute distance D between the item detection value and the item standard value of the extremely large indicator data site can be calculated using the following formula:
[0072] ① When i=1:
[0073]
[0074] ② When i≠1:
[0075]
[0076] The absolute distance D between the project detection value and the project standard value of the extremely small indicator data station can be calculated using the following formula:
[0077] ① When i=1:
[0078]
[0079] ② When i≠1:
[0080]
[0081] The maximum / minor index mainly depends on whether the index value increases or decreases as the water quality level improves in the national standard. The maximum large index means that the larger the index value, the better, such as dissolved oxygen, the larger the better. The minimum small index means that the smaller the index value, the better, such as N, P, permanganate, etc., the smaller the better.
[0082] S42. Calculate relative distance
[0083]
[0084] Among them, D(x jk |y ji ) is the relative distance. The smaller the value, the smaller the possibility that the water quality level of the indicator of station k belongs to i; otherwise, the larger the value;
[0085] S43. For the k sample point, for the j index, D(x jk |y ji ) to perform vertical normalization
[0086]
[0087] Where P ijk represents the probability that the jth indicator at the kth detection point belongs to the ith water quality level, P ik It represents the probability that the kth detection point belongs to the i-th water quality level.
[0088] S5. Divide the adjacent water quality grades from Ⅰ to Ⅴ into ten equal parts (because the calculated posterior probability difference between different grades is small, it is believed that the probability difference between adjacent grades is not large, and it is too one-sided to directly characterize it as a certain category, so the water quality between Ⅰ and Ⅱ is divided into 1.1, 1.2...1.9, etc.), according to the highest probability value P in the above posterior probability P ik and the second highest probability value P (i±i)k The difference C is used to determine the water quality level L:
[0089]
[0090] Among them, d has no specific meaning and is only used to define the range of C, d = 1, 2, 3, 4, 5; i is the water quality grade.
[0091] S6. Based on the suspended particle density D and water quality grade L, the water quality grade of each sample is matched with the suspended particle density of the sample, a large number of samples are selected as training sets, and the fitcnb function in the computer software MATLAB R2022a is used to generate a Bayesian classifier for water quality assessment based on suspended particles;
[0092] S7. Select the suspended particle density D of the test set samples, and predict the water quality grade of the sample point based on the Bayesian classifier predict function. When testing, you only need to input the D_De and D_Fi values of the sample to be tested, and automatically get the specific value between which two grades the water quality grade is, such as 1.2 between Class I and Class I.
[0093] Example 2
[0094] In this embodiment, 1245 samples were collected and tested, and the test results of five indicators of some samples are shown in Table 1 below:
[0095] Table 1 Test results of five indicators of some samples
[0096] DO COD_Mn TN TP NH3-N 1 6.390 3.260 0.990 0.0115 0.2486 2 7.360 1.370 0.489 0.0097 0.0626 3 8.150 0.860 0.942 0.0083 0.1490 4 7.630 1.940 0.859 0.1030 0.3094 5 7.340 1.980 0.355 0.0880 0.2649 6 6.730 1.020 0.661 0.2212 0.0119 7 7.420 1.530 0.318 0.1612 0.0329 8 5.130 1.620 0.764 0.0692 0.2075 9 3.430 1.130 0.301 0.0484 0.1622 10 4.290 1.370 0.321 0.0121 0.1984
[0097] The weighted distance formula assigned in step S4 is used to calculate the posterior probability P of the sample shown in Table 1 being in Class I to V water. The calculation results are shown in Table 2.
[0098] Table 2 Posterior probability matrix
[0099]
[0100]
[0101] Among the 1245 samples in this embodiment, 1195 samples are used as training sets and 50 samples are used as test sets. The posterior probability P and water quality grade results L of some test set samples are shown in Table 3 below.
[0102] Table 3 Test set water quality grade results and posterior probability
[0103]
[0104] According to the test results, the accuracy rate can reach 70%±5%.
[0105] Based on the above ideal embodiments of the present invention, the relevant staff can make various changes and modifications without departing from the technical concept of the present invention through the above description. The technical scope of the present invention is not limited to the contents of the specification, and its technical scope must be determined according to the scope of the claims.
Claims
1. A machine learning Bayesian model for water quality assessment based on suspended particle density, characterized in that: The following steps are involved: S1. Collect and test several water quality samples, use indoor testing to measure the suspended particle density index, and use outdoor testing to obtain multiple water quality indicators for each sample; S2. Establish an entropy-weighted Bayesian model for water quality assessment; S3. Based on the index data obtained by S1 detection, the entropy weight is calculated according to the degree of chaos of the data system; S4. Calculate the posterior probability P of the sample being in Class I to V water using the weighted distance formula; S5. Divide the adjacent water quality levels from Class I to Class V into ten equal parts, and calculate the highest probability value P in the above posterior probability P. ik and the second highest probability value P (i±1)k The difference C is used to determine the water quality level L: Among them, d has no specific meaning and is only used to define the range of C, d = 1, 2, 3, 4, 5; i is the water quality grade; S6. Based on the water quality grade of each sample calculated in S5, the water quality grade of each sample is matched with the suspended particle density of the sample, a large number of samples are selected as training sets, and the fitcnb function in the computer software MATLAB R2022a is used to generate a Bayesian classifier for water quality assessment based on suspended particles; S7. Select the suspended particle density of the test set samples and predict the water quality level of the sample points based on the Bayesian classifier predict function.
2. The machine learning Bayesian model for water quality assessment based on suspended particle density according to claim 1 is characterized in that: The suspended particle density index in step S1 includes the density of debris-like suspended particles and the density of fibrous suspended particles.
3. The machine learning Bayesian model for water quality assessment based on suspended particle density according to claim 1 is characterized in that: The method for obtaining the suspended particle density index in step S1 includes: using 25# biological net filtration to obtain suspended particle samples, connecting to the ZooSCAN image automatic scanning and analysis system instrument, diluting the collected suspended particle samples by a certain amount, and using the instrument to preview at a resolution of 300dp and scan at a resolution of 2400dp to collect images and morphological data of the suspended particles; using filezilla software to upload the suspended particle images and morphological data to the database, and performing classification training, manual verification and data export on the www.ecotaxa.cn website to obtain the density of debris-like suspended particles and the density of fibrous suspended particles.
4. The machine learning Bayesian model for water quality assessment based on suspended particle density according to claim 1 is characterized in that: Calculating the entropy weight in step S3 specifically includes: S31. Data preprocessing: organize the raw data into the original matrix X and standardize it In the formula, k is the site, j is the indicator, X is the matrix of the original data, x is an item in the original matrix, and x kj The value of is the multiple water quality indicators of each sample detected in step S1, Z is the standardized matrix, z is an item in the standardized matrix, and n is the total number of sites; S32. Calculate the probability matrix P Where P is the probability matrix, and p is an item in the probability matrix; S33. Calculate the entropy weight W Among them, e j is an intermediate variable, W j is the weight of the j indicator, and m is the total number of indicators.
5. The machine learning Bayesian model for water quality assessment based on suspended particle density according to claim 1 is characterized in that: The calculation of the posterior probability P in step S4 specifically includes: S41. The absolute distance D between the item detection value and the item standard value of the extremely large indicator data site can be calculated using the following formula: ① When i=1: ② When i≠1: The absolute distance D between the project detection value and the project standard value of the extremely small indicator data station can be calculated using the following formula: ① When i=1: ② When i≠1: S42. Calculate relative distance Among them, D(x jk |y ji ) is the relative distance. The smaller the value, the smaller the possibility that the water quality level of the indicator of station k belongs to i; otherwise, the larger the value; S43. For sample point k, for index j, D(x jk |y ji ) to perform vertical normalization Where P ijk represents the probability that the jth indicator at the kth detection point belongs to the ith water quality level, P ik It represents the probability that the kth detection point belongs to the i-th water quality level.
6. The machine learning Bayesian model for water quality assessment based on suspended particle density according to claim 1 is characterized in that: In step S1, outdoor testing is used to obtain five water quality indicators of each sample, including dissolved oxygen DO, permanganate index COD_Mn, total nitrogen TN, total phosphorus TP and ammonia nitrogen NH3-N values.
Citation Information
Patent Citations
Quick distinguishing system for water bursting source of mine
CN104597516A
Method and device for weight aggregation optimization by water quality remote sensing and multi-model collaborative inversion
CN107885909A
Bayesian network water quality index evaluation method, water quality grade evaluation method, water quality index prediction method
CN109190865A
Water network system regulation and storage node optimal scheduling and decision-making method considering ecological flow
CN117744501A
Priori probability and probability of error estimation for adaptive bayes pattern recognition
US7979363B1
Cited By
Water quality prediction method and device, computer equipment, storage medium and computer program product
CN118885914A
Water quality prediction method, device, computer equipment, storage medium and computer program product
CN118885914B
