Water quality monitoring method based on holographic three-dimensional model and Kernel-KNN algorithm
Through the water quality monitoring method of holographic three-dimensional model and Kernel-KNN algorithm, groundwater quality data is collected and processed in real time, which solves the problem of slow and inaccurate data collection of traditional water quality detection methods, and achieves efficient and accurate water quality monitoring and prediction.
Patent Information
- Application Number
- CN202311041166.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-18
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2043-08-18
AI Technical Summary
Traditional water quality testing methods suffer from slow and inaccurate data collection, are unable to respond to water quality changes in real time, and suffer from human error and laboratory instrument accuracy issues.
A water quality monitoring method based on the holographic three-dimensional model and the Kernel-KNN algorithm is adopted. By collecting groundwater quality data in real time, online monitoring instruments and cloud data processing are used to train the Kernel-KNN model for water quality prediction, and the results are displayed through three-dimensional images.
Real-time water quality monitoring is realized, detection efficiency and accuracy are improved, human errors are reduced, and the robustness and generalization ability of the model are enhanced.
Smart Images

Figure CN117288905B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the fields of ecology, machine learning and deep learning, and specifically to a water quality monitoring method based on a holographic three-dimensional model and a Kernel-KNN algorithm. Background Art
[0002] Chemical parks may involve the storage and handling of a large number of chemicals and hazardous substances, which may infiltrate groundwater bodies and pose potential pollution risks to groundwater quality and the surrounding environment. Traditional water quality testing usually requires water samples to be collected and returned to the laboratory for processing and testing, which requires a certain amount of time delay. Time delays may result in a lack of agility in real-time response to water quality changes, making it impossible to take necessary measures in a timely manner. In addition, water quality testing methods also require cumbersome sample collection, processing and testing steps, which involve manual operations and the possibility of human errors. Non-standard operations or precision problems of laboratory instruments may lead to inaccurate data. Therefore, there is an urgent need for an operating system that can both collect data in real time and accurately predict water quality. Summary of the invention
[0003] To solve the above problems, the present invention proposes a water quality monitoring method based on a holographic three-dimensional model and a Kernel-KNN algorithm. Through this system, the problems of slow data collection and inaccurate water quality detection can be solved.
[0004] To achieve the above object, the technical solution adopted by the present invention is:
[0005] The water quality monitoring method based on the holographic three-dimensional model and the Kernel-KNN algorithm includes the following steps:
[0006] 1) Collect different groundwater quality data in real time.
[0007] First, establish a real-time online monitoring system for groundwater in the chemical park and real-time data representation. Determine the monitoring index requirements based on the industrial structure and pollution characteristics of the park, and equip online water level monitors, online water level conductivity monitors, multi-index water quality and water level synchronous monitors, meteorological monitors and other professional instrument products at different locations of 100 meters, 200 meters, and 300 meters underground to control water quality changes in real time;
[0008] 2) Real-time data upload.
[0009] Upload the real-time data collected in the above steps to the cloud. For real-time data uploading needs, choose a reliable cloud service provider, such as Amazon Web Services (AWS), Microsoft Azure, Google Cloud, etc. Each provider provides a variety of storage and data processing services. After uploading real-time data to the cloud, you can perform real-time data processing, aggregation, and analysis based on cloud computing and analysis services to extract valuable information and insights;
[0010] 3) Kernel-KNN model training.
[0011] Wherein, the 3) Kernel-KNN model training includes the following sub-steps:
[0012] Data entry;
[0013] Kernel function;
[0014] Distance weight;
[0015] K value selection;
[0016] KD tree finds the nearest neighbor;
[0017] Calculate the loss;
[0018] Parameter optimization;
[0019] Model deployment;
[0020] 4) Kernel-KNN model prediction.
[0021] The data processed in step S2 is used to execute the model trained in step S3. At this point, we can obtain the water quality prediction result of the current area and return the value;
[0022] 5) Three-dimensional image display of water quality.
[0023] After step S4, a value of 1 is returned, indicating that the groundwater is severely polluted, which is displayed in red in the three-dimensional graph; a value of 2 is returned, indicating that the groundwater is heavily polluted, which is displayed in yellow in the three-dimensional graph; and a value of 3 is returned, indicating that the groundwater is lightly polluted, which is displayed in green in the three-dimensional graph;
[0024] As a further improvement of the present invention, the Kernel function formula of step 3) is specifically expressed as:
[0025] f(x)=S(x1+x2+x3...xk) 2 k=1,2,3…n
[0026] Among them, x1, x2, x3…xk represent the sample data features, that is, the data we collected above, and S represents the selection of the squared data. Here we mainly select the data with square terms as the augmented data. The reason for the selection is that if all the data are used as augmented data, overfitting will occur, that is, it is fully fitted during training, but it cannot achieve the desired results during prediction.
[0027] Different from the past, this application proposed for the first time a mechanism for selecting the expanded data, that is, to autonomously select the number and type of expansion according to the data situation. After the processing of this model, on the one hand, the impact of underfitting of the model is solved, and on the other hand, the robustness of the model is improved, making the model generalization effect better.
[0028] As a further improvement of the present invention, the distance weight calculation formula of step 3) is expressed as:
[0029]
[0030] Among them, k represents the weight of the distance, a1b1, a2b2, …anbn represent the characteristics of each sample. The distance between each sample point and other sample points can be obtained by the above calculation formula.
[0031] Different from the past, this application proposes for the first time to perform weighted processing on the distance of sample points. A smaller distance value means that it is close, so we give it a larger weight. A larger distance value means that it is far away, so we give it a smaller weight. Through weighted processing, the model can pay more attention to samples that have a greater impact on the current situation.
[0032] As a further improvement of the present invention, the loss calculation formula in step 3) is specifically expressed as:
[0033]
[0034] Among them, α represents weight information, h s (x (i) ) represents the predicted sample label, y (i) Represents the true sample label.
[0035] Different from the past, this application adds weight processing to the sample loss value, that is, when the loss is large, the weight is reduced, and when the loss is small, the weight is increased. Through this processing method, the model can more easily learn samples with incorrect predictions and focus on their processing operations.
[0036] Compared with the prior art, the present invention has the following beneficial effects:
[0037] 1. The present invention proposes a water quality monitoring system based on a holographic three-dimensional model and a Kernel-KNN algorithm. Through the use of specialized instrument products such as online water level conductivity monitors, multi-index water quality and water level synchronous monitors, and meteorological monitors, and real-time collection of data measured by the instruments, the problem of low efficiency of traditional water quality detection is solved;
[0038] 2. The present invention proposes a water quality monitoring system based on a holographic three-dimensional model and a Kernel-KNN algorithm. The KNN algorithm is integrated into this system. The KNN algorithm is simple and intuitive, suitable for small sample situations, and is insensitive to outliers. Its non-parametric nature makes it highly flexible and has a high improvement effect on data detection;
[0039] 3. The present invention proposes a water quality monitoring system based on a holographic three-dimensional model and a Kernel-KNN algorithm. The Kernel-KNN algorithm is proposed for the first time. By introducing the Kernel function, the original features can be mapped into a high-dimensional feature space, so that the data can be linearly separable in the feature space. This greatly improves the accuracy of water quality detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] Figure 1 It is a flow chart of the water quality monitoring method based on the holographic three-dimensional model and Kernel-KNN algorithm;
[0041] Figure 2 It is a Kernel-KNN model training flow chart of water quality monitoring method based on holographic three-dimensional model and Kernel-KNN algorithm;
[0042] Figure 3 It is a three-dimensional model display diagram of the water quality monitoring method based on the holographic three-dimensional model and Kernel-KNN algorithm. DETAILED DESCRIPTION
[0043] The present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments:
[0044] like Figure 1 Shown is a flow chart of the water quality monitoring method based on the holographic three-dimensional model and Kernel-KNN algorithm.
[0045] Step S1: Collect different groundwater quality data in real time.
[0046] First, a real-time online monitoring system for groundwater in the chemical park and real-time data representation were established. Monitoring index requirements were determined based on the industrial structure and pollution characteristics of the park. Online water level monitors, online water level conductivity monitors, multi-index water quality and water level synchronous monitors, meteorological monitors and other professional instrument products were installed at different locations of 100 meters, 200 meters, and 300 meters underground to control water quality changes in real time.
[0047] Step S2: Real-time data upload.
[0048] According to the real-time data collected in the above steps, upload it to the cloud. For the real-time data uploading needs, choose a reliable cloud service provider, such as Amazon Web Services (AWS), Microsoft Azure, Google Cloud, etc. Each provider provides a variety of storage and data processing services. After uploading the real-time data to the cloud, you can perform real-time data processing, aggregation, and analysis based on the cloud's computing and analysis services to extract valuable information and insights.
[0049] Step S3: Kernel-KNN model training.
[0050] like Figure 2 Shown is the Kernel-KNN model training flow chart of the water quality monitoring method based on the holographic three-dimensional model and the Kernel-KNN algorithm provided in this application.
[0051] Among them, step S3 Kernel-KNN model training includes the following sub-steps:
[0052] Step A1: Data input.
[0053] First, the data uploaded to the cloud is preprocessed, including: first, identifying and processing missing values, outliers, and duplicate values; second, normalizing the data, mainly mapping the value ranges of different features to a unified interval to eliminate the dimensional differences between different features. Data normalization can help improve the comparability of data and the performance of the model; third, the data set is divided into training set, validation set, and test set. The training set is used for model training and parameter optimization, the validation set is used for model selection and debugging, and the test set is used to evaluate the performance and generalization ability of the model; fourth, the data set is constructed.
[0054] Then, the processed data is input into the training model to start training.
[0055] Step A2: Kernel function.
[0056] Since the data features we collected are too few, including only data from specialized instruments such as online water level monitors, online water level conductivity monitors, multi-index water quality and water level synchronous monitors, and meteorological monitors, too few data sets will cause the model to be underfitted, that is, the model cannot converge during training and cannot achieve the expected goals.
[0057] Therefore, this application first proposed to use Kernel function to expand the original data features. The specific formula is as follows:
[0058] f(x)=S(x1+x2+x3...xk) 2 (1) k = 1, 2, 3…n
[0059] Among them, x1, x2, x3…xk represent the sample data features, that is, the data we collected above, and S represents the selection of the squared data. Here we mainly select the data with square terms as the augmented data. The reason for the selection is that if all the data are used as augmented data, overfitting will occur, that is, it is fully fitted during training, but it cannot achieve the desired results during prediction.
[0060] Different from the past, this application proposed for the first time a mechanism for selecting the expanded data, that is, to autonomously select the number and type of expansion according to the data situation. After the processing of this model, on the one hand, the impact of underfitting of the model is solved, and on the other hand, the robustness of the model is improved, making the model generalization effect better.
[0061] Step A3: Distance weight.
[0062] The implementation principle of KNN is to calculate the distance between a given unknown data point and each data point in the training data set. The influence on the current value is determined based on the calculated distance. This application proposes for the first time to weight the distance value, that is, to add a weight to each distance. The smaller the value, the greater the weight, and the larger the value, the smaller the weight. The specific formula is as follows:
[0063]
[0064] Among them, k represents the weight of the distance, a1b1, a2b2, …anbn represent the characteristics of each sample. The distance between each sample point and other sample points can be obtained by the above calculation formula.
[0065] Different from the past, this application proposes for the first time to perform weighted processing on the distance of sample points. A smaller distance value means that it is close, so we give it a larger weight. A larger distance value means that it is far away, so we give it a smaller weight. Through weighted processing, the model can pay more attention to samples that have a greater impact on the current situation.
[0066] Step A4: K value selection.
[0067] The K value is to select K values as the final impact value after sorting the calculated distances in the above steps. The K value is mainly selected in the following ways: First, observe the sample distribution in the data set. If the boundaries between categories are not obvious or the density of the data set is relatively uniform, a smaller K value may be more appropriate. If the boundaries between categories are obvious or there is a lot of noise in the data set, a larger K value may be more appropriate.
[0068] Step A5: KD tree finds the nearest neighbor.
[0069] When the sample data is small, we can use brute force to solve the nearest neighbor, that is, calculate the distance to all samples. However, when the sample size is large, it is a bit labor-intensive to directly calculate the distance of all samples. Therefore, in this case, we can use KD tree to quickly calculate. KD tree uses the n-dimensional features of m samples to calculate the variance of n feature values, and uses the k-th dimension feature nk with the largest variance as the root node. For this feature, the median of the value is selected as the sample division point. Samples less than this value are divided into the left subtree, and samples greater than or equal to this value are divided into the right subtree. The same method is used for the left and right subtrees to find the feature with the largest variance as the root node, and the KD tree can be generated recursively.
[0070] After we generate the KD tree, we can predict the sample target points in the test set. For a target point, we first find the leaf node containing the target point in the KD tree. With the target point as the center and the shortest distance from the target point to the sample instance in the leaf node as the radius, we get a hypersphere, and the nearest neighbor point must be inside this hypersphere. Then return to the parent node of the leaf node and check whether the hyperrectangle contained in another child node intersects with the hypersphere. If it intersects, go to this child node to find out if there is a closer neighbor. If so, update the nearest neighbor. If it does not intersect, it is simple. We directly return to the parent node of the parent node and continue searching for the nearest neighbor in another subtree. When backtracking to the root node, the algorithm ends, and the nearest neighbor node saved at this time is the final nearest neighbor.
[0071] Step A6: Calculate the loss.
[0072] For the prediction results obtained above, the loss is calculated with the actual sample labels. The specific formula is as follows:
[0073]
[0074] Among them, α represents weight information, h s (x (i) ) represents the predicted sample label, y (i) Represents the true sample label.
[0075] Different from the past, this application adds weight processing to the sample loss value, that is, when the loss is large, the weight is reduced, and when the loss is small, the weight is increased. Through this processing method, the model can more easily learn samples with incorrect predictions and focus on their processing operations.
[0076] Step A7: Parameter optimization.
[0077] The purpose of this step is to update the previous parameters. The loss obtained in the previous step is updated by gradient descent, so that the loss continues to decrease. When the loss is reduced to a certain value and no longer changes, the model has reached convergence and we have obtained the ideal model.
[0078] Step A8: Model deployment.
[0079] Deploy the trained model. The deployment options include cloud server deployment or local construction. After the deployment is completed, predictions can be made.
[0080] Step S4: Kernel-KNN model prediction.
[0081] The data processed in step S2 is used to execute the model trained in step S3. At this point, we can obtain the water quality prediction result of the current area and return the value.
[0082] Step S5: Three-dimensional image water quality display.
[0083] After step S4, a return value of 1 indicates that the groundwater is severely polluted, which is displayed in red in the three-dimensional graph. A return value of 2 indicates that the groundwater is heavily polluted, which is displayed in yellow in the three-dimensional graph. A return value of 3 indicates that the groundwater is lightly polluted, which is displayed in green in the three-dimensional graph.
[0084] like Figure 3 Shown is a three-dimensional model display diagram of the water quality monitoring method based on the holographic three-dimensional model and Kernel-KNN algorithm provided by this application.
[0085] The above description is only a preferred embodiment of the present invention and does not constitute any other form of limitation to the present invention. Any modification or equivalent change made based on the technical essence of the present invention still falls within the scope of protection required by the present invention.
Claims
1. Water quality monitoring method based on holographic three-dimensional model and Kernel-KNN algorithm, Features: The steps include: 1) Collect different groundwater quality data in real time; First, a real-time online monitoring system for groundwater in the chemical park and real-time data representation were established. Monitoring index requirements were determined based on the industrial structure and pollution characteristics of the park. Online water level monitors, online water level conductivity monitors, multi-index water quality and water level synchronous monitors, and meteorological monitors were installed at different locations of 100 meters, 200 meters, and 300 meters underground to monitor water quality changes in real time. 2) Real-time data upload; The real-time data collected according to the above steps is uploaded to the cloud. According to the real-time data uploading requirements, a cloud service provider is selected. Each provider provides a variety of storage and data processing services. After uploading the real-time data to the cloud, the real-time data is processed, aggregated and analyzed based on the cloud computing and analysis services to extract valuable information and insights from it. 3) Kernel-KNN model training; Wherein, the 3) Kernel-KNN model training includes the following sub-steps: Data entry; Kernel function; Distance weight; K value selection; KD tree finds the nearest neighbor; Calculate the loss; Parameter optimization; Model deployment; The step 3) Kernel function calculation formula: f(x)=S(x1+x2+x3…xk)2, k=1, 2, 3…n, where x1, x2, x3…xk represent sample data features, and S represents the selection of the data after squared items as augmented data; A selection mechanism is provided for the expanded data, that is, the number and type of expansion are selected autonomously according to the data situation. After being processed by this model, the influence of underfitting of the model is solved, the robustness of the model is improved, and the generalization effect of the model is better; The distance weight calculation formula in step 3) is: Among them, k represents the weight of the distance, a1b1, a2b2, ... anbn represent the characteristics of each sample. The distance between each sample point and other sample points can be obtained through the above calculation formula; The step 3) calculates the loss calculation formula: Among them, α represents weight information, h s (x (i) ) represents the predicted sample label, y (i) Represents the true sample label; 4) Kernel-KNN model prediction; Execute the model trained in step S3 on the data processed in step S2 to obtain the water quality prediction result of the current area and return the value; 5) 3D image display of water quality; After step S4, a return value of 1 indicates that the groundwater is severely polluted, which is displayed in red in the three-dimensional graph. A return value of 2 indicates that the groundwater is heavily polluted, which is displayed in yellow in the three-dimensional graph. A return value of 3 indicates that the groundwater is lightly polluted, which is displayed in green in the three-dimensional graph.
