Coagulant putting prediction method, device, equipment and medium
Through the coagulant delivery prediction method based on machine learning, the stacking integrated model is used to predict the amount of coagulant added in the water treatment process, which solves the problem of poor water quality stability under manual control and achieves precise coagulant delivery and water quality control. Improved stability.
Patent Information
- Application Number
- CN202410681618.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-29
- Publication Date
- 2024-09-06
AI Technical Summary
The coagulant delivery control in the existing water treatment process relies on manual experience, resulting in poor water quality stability, weak control timeliness and continuity, and the inability to respond to real-time changes in raw water parameters. It is also difficult to accurately dose the coagulant, resulting in increased chemical consumption. .
A coagulant dosing prediction method based on a machine learning model is used to obtain water quality data, determine the difference between the monitored water turbidity and the preset water turbidity, and use the trained stacking integrated model to predict the coagulant addition amount, including the first The machine learning model, the second machine learning model and the linear regression model are trained based on historical data, and the weight parameters are adjusted to achieve precise delivery of coagulant.
It improves the accuracy and adaptability of coagulant delivery, reduces the amount of chemicals used, enhances the stability of water quality and the timeliness of control, adapts to seasonal and climate changes, and reduces chemical consumption.
Smart Images

Figure CN118607706A
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of sewage treatment informatization, and in particular to a method, device, equipment and medium for predicting the placement of a coagulant. Background Art
[0002] The water treatment process of a water plant usually includes steps such as coagulation, sedimentation, filtration, ozone addition, and chlorination. Among them, coagulation and sedimentation is one of the core links of the water purification process. In particular, the precise control of coagulation dosing is closely related to the water quality and drug consumption at the factory, and has always been valued by water plants. The principle of coagulation dosing is to effectively mix the pollutants in the raw water by adding coagulants such as polyaluminium chloride (PAC) to the raw water, and use gravity to settle the coagulated sediment into the pre-sedimentation tank, thereby effectively removing floating objects and solid pollutants in the water.
[0003] The relevant technology is usually fixed-value proportion dosing, and experienced technicians decide to add a certain amount of coagulant according to the flow rate and turbidity of the raw water according to the rules. The proportion and dosage of the coagulant depend on manual experience, so the stability of the water quality is poor; secondly, manual dosing is prone to poor control timeliness and continuity, and cannot respond to the real-time continuous changes in raw water parameters in time; thirdly, due to the low accuracy of manual operation and the difficulty of accurate dosing, technicians may increase the dosage of a certain proportion based on experience to ensure water quality safety, but at the same time it will also increase the consumption of coagulants.
[0004] Therefore, how to achieve accurate delivery of coagulants is an urgent problem that needs to be solved. Summary of the invention
[0005] In order to solve the above technical problems, the present disclosure provides a coagulant dosage prediction method, device, equipment, and medium.
[0006] In a first aspect, the present disclosure provides a method for predicting the dosage of a coagulant, comprising:
[0007] Obtain water quality data;
[0008] When the water quality data is normal, determining whether the absolute value of the difference between the monitored water turbidity and the preset water turbidity is less than a preset value;
[0009] When the absolute value of the difference between the monitored water turbidity and the preset water turbidity is greater than or equal to the preset value, the water quality data is input into the target coagulant delivery prediction model, and the predicted coagulant addition amount is output; the target coagulant delivery prediction model is obtained by training the preset stacking integrated model based on the training sample set; the preset stacking integrated model includes: a first machine learning model, a second machine learning model and a linear regression model; the training sample set includes: a plurality of historical coagulation and sedimentation data and the actual coagulant addition amount corresponding to each historical coagulation and sedimentation data;
[0010] The coagulant is added according to the predicted coagulant addition amount.
[0011] As an optional implementation of the embodiment of the present disclosure, the determining whether the absolute value of the difference between the monitored water turbidity and the preset water turbidity is less than a preset value further includes:
[0012] When the absolute value of the difference between the monitored water turbidity and the preset water turbidity is less than the preset value, the original amount of coagulant added is maintained.
[0013] As an optional implementation of the embodiment of the present disclosure, the target coagulant delivery prediction model is obtained by training the stacking integrated model based on the training sample set, and includes:
[0014] Get the first training set and the second training set;
[0015] Input the first training set into a plurality of machine learning models to be screened for training, and screen and obtain a first machine learning model and a second machine learning model; the weight of the first machine learning model is a first weight value, the weight of the second machine learning model is a second weight value, and the sum of the first weight value and the second weight value is 1;
[0016] Dividing the secondary training set according to a first preset ratio to obtain a first training set and a first test set;
[0017] Inputting the first training set into the first machine learning model and the second machine learning model respectively, and using a 5-fold cross validation algorithm to train the first machine learning model and the second machine learning model respectively, to obtain the predicted coagulant addition amount of the first machine learning model and the predicted coagulant addition amount of the second machine learning model;
[0018] Constructing a target training set based on the predicted coagulant addition amount of the first machine learning model, the first weight value, the predicted coagulant addition amount of the second machine learning model, and the second weight value;
[0019] The target training set is input into the linear regression model for training, and the predicted coagulant addition amount corresponding to each historical coagulation sedimentation data in the target training set is obtained;
[0020] According to the actual amount of coagulant added corresponding to each piece of historical coagulation and sedimentation data in the first test set and the predicted amount of coagulant added corresponding to each piece of historical coagulation and sedimentation data in the target training set, a loss function is determined, and the weight parameters of the preset stacking integrated model are adjusted according to the loss function to obtain a target coagulant dosage prediction model.
[0021] As an optional implementation of the embodiment of the present disclosure, the predicted coagulant addition amount based on the first machine learning model, the first weight value, the predicted coagulant addition amount based on the second machine learning model, and the second weight value, constructing a target training set includes:
[0022] Constructing a first sub-training set according to the actual amount of coagulant added corresponding to each piece of historical coagulation and sedimentation data in the first training set and the predicted amount of coagulant added output by the first machine learning model;
[0023] Constructing a second sub-training set according to the actual amount of coagulant added corresponding to each piece of historical coagulation and sedimentation data in the first training set and the predicted amount of coagulant added output by the second machine learning model;
[0024] A target training set is constructed according to the first sub-training set and the first weight value, the second sub-training set and the second weight value.
[0025] As an optional implementation of the embodiment of the present disclosure, the first training set is input into a plurality of machine learning models to be screened for training, and the first machine learning model and the second machine learning model are screened and obtained, including:
[0026] Inputting the first training set into a plurality of machine learning models to be screened for training respectively, and obtaining prediction results of each machine learning model to be screened;
[0027] According to the prediction results of each of the machine learning models to be screened, the multiple machine learning models to be screened are sorted to obtain the prediction accuracy sorting results of the multiple machine learning models to be screened;
[0028] According to the prediction accuracy ranking results of the multiple machine learning models to be screened, a first machine learning model and a second machine learning model are determined, and weights are assigned to the first machine learning model and the second machine learning model.
[0029] As an optional implementation of the embodiment of the present disclosure, the obtaining of the first training set and the second training set includes:
[0030] Acquire a historical coagulation and sedimentation data set; the historical coagulation and sedimentation data set includes: a plurality of historical coagulation and sedimentation data within a preset time;
[0031] The historical coagulation and sedimentation data set is divided according to a second preset ratio to obtain a first training set and a second training set.
[0032] As an optional implementation of the embodiment of the present disclosure, when the absolute value of the difference between the monitored water turbidity and the preset water turbidity is greater than or equal to the preset value, the water quality data is input into the target coagulant dosage prediction model, and before the predicted coagulant addition amount is output, it also includes:
[0033] The water quality data is processed for missing values and outliers to obtain a feature vector corresponding to the water quality data.
[0034] In a second aspect, the present disclosure provides a coagulant delivery prediction device, comprising:
[0035] An acquisition module, used to obtain water quality data;
[0036] A judgment module, used for judging whether the absolute value of the difference between the monitored water turbidity and the preset water turbidity is less than a preset value when the water quality data is normal;
[0037] An output module is used to input the water quality data into a target coagulant delivery prediction model and output a predicted coagulant addition amount when the absolute value of the difference between the monitored water turbidity and the preset water turbidity is greater than or equal to the preset value; the target coagulant delivery prediction model is obtained by training a preset stacking integrated model based on a training sample set; the preset stacking integrated model includes: a first machine learning model, a second machine learning model and a linear regression model; the training sample set includes: a plurality of historical coagulation and sedimentation data and an actual coagulant addition amount corresponding to each historical coagulation and sedimentation data;
[0038] The delivery module is used to deliver the coagulant according to the predicted coagulant addition amount.
[0039] As an optional implementation of the embodiment of the present disclosure, the judgment module is further used to:
[0040] When the absolute value of the difference between the monitored water turbidity and the preset water turbidity is less than the preset value, the original amount of coagulant added is maintained.
[0041] As an optional implementation of the embodiment of the present disclosure, the device further includes: a training module, the training module including:
[0042] An acquisition unit, used to acquire a first training set and a second training set;
[0043] A screening unit, used for inputting the first training set into a plurality of machine learning models to be screened for training, and screening to obtain a first machine learning model and a second machine learning model; the weight of the first machine learning model is a first weight value, the weight of the second machine learning model is a second weight value, and the sum of the first weight value and the second weight value is 1;
[0044] A division unit, used for dividing the secondary training set according to a first preset ratio to obtain a first training set and a first test set;
[0045] A first training unit is used to input the first training set into the first machine learning model and the second machine learning model respectively, and use a 5-fold cross validation algorithm to train the first machine learning model and the second machine learning model respectively to obtain the predicted coagulant addition amount of the first machine learning model and the predicted coagulant addition amount of the second machine learning model;
[0046] A construction unit, configured to construct a target training set based on the predicted coagulant addition amount of the first machine learning model, the first weight value, the predicted coagulant addition amount of the second machine learning model, and the second weight value;
[0047] A second training unit is used to input the target training set into the linear regression model for training, and obtain the predicted coagulant addition amount corresponding to each historical coagulation and sedimentation data in the target training set;
[0048] A generating unit is used to determine a loss function according to the actual amount of coagulant added corresponding to each piece of historical coagulation and sedimentation data in the first test set and the predicted amount of coagulant added corresponding to each piece of historical coagulation and sedimentation data in the target training set, and adjust the weight parameters of the preset stacking integrated model according to the loss function to obtain a target coagulant delivery prediction model.
[0049] As an optional implementation of the embodiment of the present disclosure, the construction unit is specifically used for:
[0050] Constructing a first sub-training set according to the actual amount of coagulant added corresponding to each piece of historical coagulation and sedimentation data in the first training set and the predicted amount of coagulant added output by the first machine learning model;
[0051] Constructing a second sub-training set according to the actual amount of coagulant added corresponding to each piece of historical coagulation and sedimentation data in the first training set and the predicted amount of coagulant added output by the second machine learning model;
[0052] A target training set is constructed according to the first sub-training set and the first weight value, the second sub-training set and the second weight value.
[0053] As an optional implementation of the embodiment of the present disclosure, the screening unit is specifically used for:
[0054] Inputting the first training set into a plurality of machine learning models to be screened for training respectively, and obtaining prediction results of each machine learning model to be screened;
[0055] According to the prediction results of each of the machine learning models to be screened, the multiple machine learning models to be screened are sorted to obtain the prediction accuracy sorting results of the multiple machine learning models to be screened;
[0056] According to the prediction accuracy ranking results of the multiple machine learning models to be screened, a first machine learning model and a second machine learning model are determined, and weights are assigned to the first machine learning model and the second machine learning model.
[0057] As an optional implementation of the embodiment of the present disclosure, the acquisition unit is specifically used to:
[0058] Acquire a historical coagulation and sedimentation data set; the historical coagulation and sedimentation data set includes: a plurality of historical coagulation and sedimentation data within a preset time;
[0059] The historical coagulation and sedimentation data set is divided according to a second preset ratio to obtain a first training set and a second training set.
[0060] As an optional implementation of the embodiment of the present disclosure, the device further includes:
[0061] The preprocessing module is used to perform missing value processing and outlier processing on the water quality data to obtain a feature vector corresponding to the water quality data.
[0062] In a third aspect, an embodiment of the present disclosure provides an electronic device, comprising: a memory and a processor; the memory stores a computer program, and when the processor executes the computer program, it implements the coagulant dosage prediction method described in the first aspect or any embodiment of the first aspect.
[0063] In a fourth aspect, an embodiment of the present disclosure provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method for predicting the dosage of a coagulant as described in any one of the embodiments of the first aspect.
[0064] The technical solution provided by the embodiments of the present disclosure has the following advantages over the prior art: obtaining water quality data; when the water quality data is normal, determining whether the absolute value of the difference between the monitored water turbidity and the preset water turbidity is less than a preset value; when the absolute value of the difference between the monitored water turbidity and the preset water turbidity is greater than or equal to the preset value, inputting the water quality data into a target coagulant dosage prediction model, and outputting a predicted coagulant addition amount; the target coagulant dosage prediction model is obtained by training a preset stacking integrated model based on a training sample set; and the coagulant is administered according to the predicted coagulant addition amount. Since the preset stacking integrated model includes: a first machine learning model, a second machine learning model, a linear regression model and other basic models, by complementing the advantages of multiple basic models, better generalization performance or robustness than a single learner can be obtained, and the training sample set includes: multiple historical coagulation and sedimentation data and the actual coagulant addition amount corresponding to each historical coagulation and sedimentation data. The preset stacking integrated model is trained with the training sample set to obtain a target coagulant delivery prediction model. When the absolute value of the difference between the monitored water turbidity and the preset water turbidity is greater than or equal to the preset value, the water quality data is input into the target coagulant delivery prediction model, and the predicted coagulant addition amount is output. This can better adapt to business scenarios and avoid the situation where the applicability of the model is reduced due to changes in water plant data due to seasons, climate and other factors, thereby achieving accurate delivery of coagulants. BRIEF DESCRIPTION OF THE DRAWINGS
[0065] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0066] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0067] Figure 1 It is the water treatment process flow chart of the water plant;
[0068] Figure 2 It is a structural schematic diagram of a coagulant delivery prediction system provided by an embodiment of the present disclosure;
[0069] Figure 3 It is a flow chart of a method for predicting the amount of coagulant provided by an embodiment of the present disclosure;
[0070] Figure 4 A schematic diagram of a training process of a target coagulant delivery prediction model provided in an embodiment of the present disclosure;
[0071] Figure 5 It is a structural schematic diagram of a coagulant delivery prediction device provided by an embodiment of the present disclosure;
[0072] Figure 6 It is a structural schematic diagram of an electronic device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION
[0073] In order to more clearly understand the above-mentioned objectives, features and advantages of the present disclosure, the scheme of the present disclosure will be further described below. It should be noted that the embodiments of the present disclosure and the features in the embodiments can be combined with each other without conflict.
[0074] In the following description, many specific details are set forth to facilitate a full understanding of the present disclosure, but the present disclosure may also be implemented in other ways different from those described herein; it is obvious that the embodiments in the specification are only part of the embodiments of the present disclosure, rather than all of the embodiments.
[0075] Relational terms such as “first” and “second” in the description and claims of the present disclosure are merely used to distinguish one entity or operation from another entity or operation, but do not necessarily require or imply any such actual relationship or order between these entities or operations.
[0076] In the embodiments of the present disclosure, words such as "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of the present disclosure should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a concrete way. In addition, in the description of the embodiments of the present disclosure, unless otherwise specified, the meaning of "multiple" refers to two or more.
[0077] The water treatment process of a water plant usually includes steps such as coagulation, sedimentation, filtration, ozone addition, and chlorination. Figure 1 As shown, Figure 1 This is the water treatment process flow chart of the water plant.
[0078] The coagulant dosage prediction method provided by the present disclosure can be applied to Figure 2In the application environment shown, the coagulant delivery prediction method is applied to the coagulant delivery prediction system. The coagulant delivery prediction system includes: a physical device layer 201, a business platform layer 202, and a data visualization layer 203. The physical device layer is the basis of the water quality detection system, and mainly includes various sensors, such as temperature and humidity sensors, water pressure sensors, turbidity meters, etc., for collecting water quality information. The collected data is packaged in JSON format and uploaded to the Internet of Things server layer through the network for processing and analysis. The Internet of Things server layer uses the EMQX message server to transmit data through the MQTT protocol. Receive the data information reported by the sensor node and forward the data information to the database of the business platform layer for storage. The interaction between the client (sensor node) and the server is realized by publishing and subscribing to messages. The business platform layer is an important part of the data management of the water plant, mainly focusing on business management, including authority management, equipment management, coagulant prediction module, data statistics, etc. The visualization layer is the interactive interface between the system and the user, mainly including large-screen visualization, dosing page, and background management.
[0079] In some embodiments, Figure 1 As shown, a method for predicting the amount of coagulant is provided, comprising the following steps S31-S33:
[0080] S31. Obtain water quality data.
[0081] Water quality data include: temperature, humidity, rainfall, conductivity, dissolved oxygen, pH, inlet turbidity, outlet turbidity actual value, outlet turbidity set value, water flow, dosage, etc.
[0082] Specifically, the acquisition of water quality data relies on various sensors included in the physical device layer, such as temperature and humidity sensors, water pressure sensors, turbidity meters, etc., which are used to collect water quality information.
[0083] S32: When the water quality data is normal, determine whether the absolute value of the difference between the monitored water turbidity and the preset water turbidity is less than a preset value.
[0084] Among them, the preset water turbidity value and the preset numerical value can be set according to the actual situation, and no specific restrictions are imposed here. Water turbidity is generally related to the content of suspended matter in water. When the water plant adopts conventional treatment process, the turbidity of the effluent from the sedimentation tank should be controlled at 3NTU (scattered turbidity unit, indicating that the instrument measures the scattered light intensity in the direction at a 90° angle to the incident light).
[0085] Specifically, in addition to data collection and storage, the coagulant dosage prediction system also supports the operator to set the effluent turbidity. According to the absolute value of the difference between the monitored water turbidity and the preset water turbidity and the size relationship of the preset value, it is determined whether the dosage needs to be re-predicted.
[0086] In some embodiments, the above step S32 (determining whether the absolute value of the difference between the monitored water turbidity and the preset water turbidity is less than a preset value) can also be implemented in the following manner:
[0087] When the absolute value of the difference between the monitored water turbidity and the preset water turbidity is less than the preset value, the original amount of coagulant added is maintained.
[0088] For example, assuming that the preset value is 0.2, if the absolute value of the difference between the detected outlet water turbidity and the set outlet water turbidity is less than 0.2, it means that the current outlet water turbidity is within a reasonable range, and the system will maintain the original dosage.
[0089] In some embodiments, missing value processing and outlier processing are performed on the water quality data to obtain a feature vector corresponding to the water quality data.
[0090] Specifically, in actual operation, the sensor will collect important data such as water quality, water flow, and drug flow in real time. These data will be stored in the database at a certain frequency for persistence and subsequent analysis. During the data storage process, the coagulant delivery prediction system will perform quality checks on the data to ensure the integrity and accuracy of the data. If data is found to be missing or abnormal, the system will trigger the alarm function to remind the staff to check and deal with it in time. The staff calibrates the sensor to see if the data can be collected and processed normally. In addition, the front end will use websocket to obtain information from the message server in real time and display it on the page.
[0091] For example, the missing values are filled using the nearest neighbor KNN algorithm to fill the data. The purpose of this is to ensure data continuity and avoid the loss of time series information. The outlier detection uses a box plot to draw a box plot of each attribute. When a sample point is not within the preset range, it is considered to be an outlier and is directly deleted.
[0092] S33. When the absolute value of the difference between the monitored water turbidity and the preset water turbidity is greater than or equal to the preset value, the water quality data is input into a target coagulant dosage prediction model, and a predicted coagulant addition amount is output.
[0093] Among them, the target coagulant dosage prediction model is obtained by training a preset stacking integrated model based on a training sample set; the preset stacking integrated model includes: a first machine learning model, a second machine learning model and a linear regression model; the training sample set includes: multiple historical coagulation and sedimentation data and the actual coagulant addition amount corresponding to each historical coagulation and sedimentation data.
[0094] Specifically, when the absolute value of the difference between the monitored water turbidity and the preset water turbidity is greater than or equal to the preset value, the system will re-predict the dosage according to the target coagulant dosage prediction model to guide the staff to adjust the dosage in time to ensure the stability and qualification of the effluent turbidity. In this way, the system can maximize the savings in the amount of reagents used while ensuring water quality, and improve the economy and environmental protection of dosing.
[0095] Exemplarily, the preset Stacking integrated model consists of two layers, namely the first layer basic model and the second layer meta-model. In the embodiment of the present disclosure, the first layer basic model includes the first machine learning model CatBoost and the second machine learning model KRR. The second layer meta-model is a linear regression model.
[0096] In some embodiments, the target coagulant delivery prediction model is obtained by training the stacking integrated model based on the training sample set, which can be implemented in the following way:
[0097] A. Obtain the first training set and the second training set.
[0098] Optionally, the above step A (obtaining the first training set and the second training set) can be implemented in the following way:
[0099] a. Obtain historical coagulation and sedimentation data sets.
[0100] The historical sedimentation data set includes: multiple historical coagulation sedimentation data within a preset time. Each historical coagulation sedimentation data includes: temperature, humidity, rainfall, conductivity, dissolved oxygen, pH, inlet turbidity, outlet turbidity actual value, outlet turbidity set value, water flow, dosage, etc.
[0101] For example, a total of 25,000 production data of two sedimentation tanks from January 2023 to June 2023 are obtained from the water plant. Each piece of data includes temperature, humidity, rainfall, conductivity, dissolved oxygen, pH, inlet turbidity, actual value of outlet turbidity, set value of outlet turbidity, water flow, dosage, etc.
[0102] b. Dividing the historical coagulation and sedimentation data set according to a second preset ratio to obtain a first training set and a second training set.
[0103] Among them, the second preset ratio can be set according to actual needs. For example, the second preset ratio can be 1:1, or it can be other reasonable values. The second preset ratio is not specifically limited here.
[0104] Exemplarily, the historical coagulation and sedimentation data set of the water plant is divided into a first training set and a second training set in a 1:1 ratio.
[0105] B. Input the first training set into multiple machine learning models to be screened for training, and screen and obtain the first machine learning model and the second machine learning model.
[0106] Among them, the weight of the first machine learning model is a first weight value, the weight of the second machine learning model is a second weight value, and the sum of the first weight value and the second weight value is 1.
[0107] Optionally, the above step B (inputting the first training set into multiple machine learning models to be screened for training, and screening to obtain the first machine learning model and the second machine learning model) can be implemented as follows:
[0108] 1) Input the first training set into multiple machine learning models to be screened for training, and obtain the prediction results of each machine learning model to be screened.
[0109] Among them, the multiple machine learning models to be screened can be ridge regression, Lasso regression, SVR, KRR, XGBoost, CatBoost, etc., or they can be user-defined algorithms (such as custom algorithms improved from basic algorithms). There is no specific restriction on the machine learning models to be screened.
[0110] In the disclosed example, the introduction of different algorithms can improve the accuracy of the overall prediction results, while meeting the customized needs of water plant users and subsequent transformation and upgrading needs.
[0111] 2) According to the prediction results of each of the machine learning models to be screened, the multiple machine learning models to be screened are sorted to obtain the prediction accuracy sorting results of the multiple machine learning models to be screened.
[0112] 3) Determine a first machine learning model and a second machine learning model according to the prediction accuracy ranking results of the multiple machine learning models to be screened, and assign weights to the first machine learning model and the second machine learning model.
[0113] Specifically, the training data sets are used to train the above-mentioned multiple machine learning models to be screened and obtain prediction results. The performance of each machine learning model to be screened is evaluated based on the obtained results, and a weight is assigned to each algorithm. Based on the assigned weights, the two machine learning models to be screened with the best performance are screened. Assume that the weights of the A algorithm and the B algorithm are a and b respectively (satisfying a+b=1).
[0114] In addition, it should be noted that based on the assigned weights, more than two machine learning models with the best performance can be screened out. For example, there can be three machine learning models to be screened. At this time, it is assumed that the weights of algorithm A, algorithm B, and algorithm C are a, b, and c (satisfying a+b+c=1), respectively, and so on, and can be expanded.
[0115] The method provided in the embodiment of the present disclosure can screen out an algorithm model suitable for prediction based on business data through a competitive manner, and at the same time, perform multi-model fusion according to the weights of different algorithm models, so as to achieve more accurate prediction.
[0116] C. Divide the secondary training set according to a first preset ratio to obtain a first training set and a first test set.
[0117] Among them, the first preset ratio can be set according to actual needs. For example, the first preset ratio can be 7:3, or other reasonable values. The first preset ratio is not specifically limited here.
[0118] D. Input the first training set into the first machine learning model and the second machine learning model respectively, and use a 5-fold cross validation algorithm to train the first machine learning model and the second machine learning model respectively to obtain the predicted coagulant addition amount of the first machine learning model and the predicted coagulant addition amount of the second machine learning model.
[0119] Among them, 5-fold cross validation is a commonly used model evaluation method, which is used to evaluate the performance of machine learning models and tune them. The basic idea is to divide the data set into 5 subsets of equal size and then conduct 5 rounds of experiments. In each round of experiments, one of the subsets is used as the validation set, and the remaining 4 subsets are used as the training set. The model is then trained with the training set and evaluated on the validation set. Finally, the evaluation results obtained from the 5 rounds of experiments are averaged as the final performance indicator of the model.
[0120] Specifically, (3) based on the obtained two algorithms A and B, they are used as the base learners of the first layer of the stacking ensemble learning model, and the secondary training set is divided into the first training set and the first test set in the ratio of 7:3 (the first preset ratio). For this part of the training set, 5-fold cross validation is used for model training.
[0121] E. Construct a target training set based on the predicted coagulant addition amount of the first machine learning model, the first weight value, the predicted coagulant addition amount of the second machine learning model, and the second weight value.
[0122] In some embodiments, the above step E (constructing a target training set based on the predicted coagulant addition amount of the first machine learning model, the first weight value, the predicted coagulant addition amount of the second machine learning model, and the second weight value) can be implemented as follows:
[0123] (1) Constructing a first sub-training set according to the actual amount of coagulant added corresponding to each piece of historical coagulation and sedimentation data in the first training set and the predicted amount of coagulant added output by the first machine learning model.
[0124] (2) Construct a second sub-training set according to the actual amount of coagulant added corresponding to each piece of historical coagulation and sedimentation data in the first training set and the predicted amount of coagulant added output by the second machine learning model.
[0125] (3) Construct a target training set based on the first sub-training set and the first weight value, the second sub-training set and the second weight value.
[0126] For example, the process of constructing the target training set can refer to Figure 4 As shown, Figure 4 A schematic diagram of a target training set construction process provided for an embodiment of the present disclosure. The first training set is divided into 5 equal parts, 4 of which are used to train the model, and the remaining 1 is used for prediction of the base learner. At this time, a total of 5 prediction results of each of the two algorithms will be obtained. The obtained prediction results and the actual results are combined into a new training set by stacking, and the weights of algorithm A and algorithm B are considered to be a and b respectively, which are used for training the second-layer meta-model.
[0127] F. Input the target training set into the linear regression model for training, and obtain the predicted coagulant addition amount corresponding to each historical coagulation and sedimentation data in the target training set.
[0128] G. Determine a loss function based on the actual amount of coagulant added corresponding to each piece of historical coagulation and sedimentation data in the first test set and the predicted amount of coagulant added corresponding to each piece of historical coagulation and sedimentation data in the target training set, and adjust the weight parameters of the preset stacking integrated model according to the loss function to obtain a target coagulant dosage prediction model.
[0129] Specifically, the linear regression model is used in the second-layer meta-model of the Stacking ensemble model for training again, and linear regression training is performed to improve its prediction accuracy. By fusing in this way, the Stacking ensemble model is finally obtained.
[0130] S34, adding coagulant according to the predicted coagulant addition amount.
[0131] Specifically, when the absolute value of the difference between the monitored water turbidity and the preset water turbidity is greater than or equal to the preset value, the system will re-predict the dosage according to the target coagulant dosage prediction model, and then the dosage will be made according to the re-predicted coagulant dosage.
[0132] The present invention provides a method for predicting the dosage of a coagulant, which obtains water quality data; when the water quality data is normal, determines whether the absolute value of the difference between the monitored water turbidity and the preset water turbidity is less than a preset value; when the absolute value of the difference between the monitored water turbidity and the preset water turbidity is greater than or equal to the preset value, inputs the water quality data into a target coagulant dosage prediction model, and outputs a predicted amount of coagulant added; the target coagulant dosage prediction model is obtained by training a preset stacking integrated model based on a training sample set; and the coagulant is dosed according to the predicted amount of coagulant added. Since the preset stacking integrated model includes: a first machine learning model, a second machine learning model, a linear regression model and other basic models, by complementing the advantages of multiple basic models, better generalization performance or robustness than a single learner can be obtained, and the training sample set includes: multiple historical coagulation and sedimentation data and the actual coagulant addition amount corresponding to each historical coagulation and sedimentation data. The preset stacking integrated model is trained with the training sample set to obtain a target coagulant delivery prediction model. When the absolute value of the difference between the monitored water turbidity and the preset water turbidity is greater than or equal to the preset value, the water quality data is input into the target coagulant delivery prediction model, and the predicted coagulant addition amount is output. This can better adapt to business scenarios and avoid the situation where the applicability of the model is reduced due to changes in water plant data due to seasons, climate and other factors, thereby achieving accurate delivery of coagulants.
[0133] In some embodiments, reference Figure 5 As shown, a coagulant delivery prediction device 500 is provided, comprising:
[0134] An acquisition module 510 is used to acquire water quality data;
[0135] The judgment module 520 is used to judge whether the absolute value of the difference between the monitored water turbidity and the preset water turbidity is less than a preset value when the water quality data is normal;
[0136] The output module 530 is used to input the water quality data into the target coagulant delivery prediction model and output the predicted coagulant addition amount when the absolute value of the difference between the monitored water turbidity and the preset water turbidity is greater than or equal to the preset value; the target coagulant delivery prediction model is obtained by training the preset stacking integrated model based on the training sample set; the preset stacking integrated model includes: a first machine learning model, a second machine learning model and a linear regression model; the training sample set includes: a plurality of historical coagulation and sedimentation data and the actual coagulant addition amount corresponding to each historical coagulation and sedimentation data;
[0137] The delivery module 540 is used to deliver the coagulant according to the predicted coagulant addition amount.
[0138] As an optional implementation of the embodiment of the present disclosure, the judgment module is further used to:
[0139] When the absolute value of the difference between the monitored water turbidity and the preset water turbidity is less than the preset value, the original amount of coagulant added is maintained.
[0140] As an optional implementation of the embodiment of the present disclosure, the device further includes: a training module, the training module including:
[0141] An acquisition unit, used to acquire a first training set and a second training set;
[0142] A screening unit, used for inputting the first training set into a plurality of machine learning models to be screened for training, and screening to obtain a first machine learning model and a second machine learning model; the weight of the first machine learning model is a first weight value, the weight of the second machine learning model is a second weight value, and the sum of the first weight value and the second weight value is 1;
[0143] A division unit, used for dividing the secondary training set according to a first preset ratio to obtain a first training set and a first test set;
[0144] A first training unit is used to input the first training set into the first machine learning model and the second machine learning model respectively, and use a 5-fold cross validation algorithm to train the first machine learning model and the second machine learning model respectively to obtain the predicted coagulant addition amount of the first machine learning model and the predicted coagulant addition amount of the second machine learning model;
[0145] A construction unit, configured to construct a target training set based on the predicted coagulant addition amount of the first machine learning model, the first weight value, the predicted coagulant addition amount of the second machine learning model, and the second weight value;
[0146] A second training unit is used to input the target training set into the linear regression model for training, and obtain the predicted coagulant addition amount corresponding to each historical coagulation and sedimentation data in the target training set;
[0147] A generating unit is used to determine a loss function according to the actual amount of coagulant added corresponding to each piece of historical coagulation and sedimentation data in the first test set and the predicted amount of coagulant added corresponding to each piece of historical coagulation and sedimentation data in the target training set, and adjust the weight parameters of the preset stacking integrated model according to the loss function to obtain a target coagulant delivery prediction model.
[0148] As an optional implementation of the embodiment of the present disclosure, the construction unit is specifically used for:
[0149] Constructing a first sub-training set according to the actual amount of coagulant added corresponding to each piece of historical coagulation and sedimentation data in the first training set and the predicted amount of coagulant added output by the first machine learning model;
[0150] Constructing a second sub-training set according to the actual amount of coagulant added corresponding to each piece of historical coagulation and sedimentation data in the first training set and the predicted amount of coagulant added output by the second machine learning model;
[0151] A target training set is constructed according to the first sub-training set and the first weight value, the second sub-training set and the second weight value.
[0152] As an optional implementation of the embodiment of the present disclosure, the screening unit is specifically used for:
[0153] Inputting the first training set into a plurality of machine learning models to be screened for training respectively, and obtaining prediction results of each machine learning model to be screened;
[0154] According to the prediction results of each of the machine learning models to be screened, the multiple machine learning models to be screened are sorted to obtain the prediction accuracy sorting results of the multiple machine learning models to be screened;
[0155] According to the prediction accuracy ranking results of the multiple machine learning models to be screened, a first machine learning model and a second machine learning model are determined, and weights are assigned to the first machine learning model and the second machine learning model.
[0156] As an optional implementation of the embodiment of the present disclosure, the acquisition unit is specifically used to:
[0157] Acquire a historical coagulation and sedimentation data set; the historical coagulation and sedimentation data set includes: a plurality of historical coagulation and sedimentation data within a preset time;
[0158] The historical coagulation and sedimentation data set is divided according to a second preset ratio to obtain a first training set and a second training set.
[0159] As an optional implementation of the embodiment of the present disclosure, the device further includes:
[0160] The preprocessing module is used to perform missing value processing and outlier processing on the water quality data to obtain a feature vector corresponding to the water quality data.
[0161] The coagulant dosage prediction device provided by the present invention obtains water quality data; when the water quality data is normal, it is determined whether the absolute value of the difference between the monitored water turbidity and the preset water turbidity is less than the preset value; when the absolute value of the difference between the monitored water turbidity and the preset water turbidity is greater than or equal to the preset value, the water quality data is input into a target coagulant dosage prediction model, and the predicted coagulant addition amount is output; the target coagulant dosage prediction model is obtained by training a preset stacking integrated model based on a training sample set; and the coagulant is dosed according to the predicted coagulant addition amount. Since the preset stacking integrated model includes: a first machine learning model, a second machine learning model, a linear regression model and other basic models, by complementing the advantages of multiple basic models, better generalization performance or robustness than a single learner can be obtained, and the training sample set includes: multiple historical coagulation and sedimentation data and the actual coagulant addition amount corresponding to each historical coagulation and sedimentation data. The preset stacking integrated model is trained with the training sample set to obtain a target coagulant delivery prediction model. When the absolute value of the difference between the monitored water turbidity and the preset water turbidity is greater than or equal to the preset value, the water quality data is input into the target coagulant delivery prediction model, and the predicted coagulant addition amount is output. This can better adapt to business scenarios and avoid the situation where the applicability of the model is reduced due to changes in water plant data due to seasons, climate and other factors, thereby achieving accurate delivery of coagulants.
[0162] The specific limitations of the coagulant delivery prediction device can be found in the limitations of the coagulant delivery prediction method above, which will not be repeated here. Each module in the above coagulant delivery prediction device can be implemented in whole or in part by software, hardware and a combination thereof. The above modules can be embedded in or independent of the processor of the electronic device in the form of hardware, or can be stored in the processor of the electronic device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0163] The present disclosure also provides an electronic device, Figure 6 This is a schematic diagram of the structure of an electronic device provided by an embodiment of the present disclosure. Figure 6As shown, the electronic device provided in this embodiment includes: a memory 61 and a processor 62, the memory 61 is used to store a computer program; the processor 62 is used to execute the steps executed in any embodiment of the fault identification method of the image acquisition device provided by the above method embodiment when calling the computer program. The electronic device includes a processor, a memory, a communication interface, a display screen and an input device connected through a system bus. Among them, the processor of the electronic device is used to provide computing and control capabilities. The memory of the electronic device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. When the computer program is executed by the processor, a method for identifying a fault of an image acquisition device is implemented. The display screen of the electronic device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the electronic device can be a touch layer covered on the display screen, or a key, trackball or touchpad set on the housing of the computer device, or an external keyboard, touchpad or mouse.
[0164] Those skilled in the art will understand that Figure 6 The structure shown in the figure is only a block diagram of a part of the structure related to the scheme of the present disclosure, and does not constitute a limitation on the computer device to which the scheme of the present disclosure is applied. The specific electronic device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0165] In some embodiments, the coagulant dosage prediction device provided by the present disclosure can be implemented in the form of a computer program. Figure 6 The computer program composed of various program modules enables the processor to execute the steps of the fault identification method of the image acquisition device of the electronic device of each embodiment of the present disclosure described in this specification.
[0166] The embodiment of the present disclosure further provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the fault identification method for the image acquisition device provided by the above method embodiment is implemented.
[0167] Those skilled in the art will appreciate that the embodiments of the present disclosure may be provided as methods, systems, or computer program products. Therefore, the present disclosure may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Furthermore, the present disclosure may take the form of a computer program product implemented on one or more computer-usable storage media containing computer-usable program code.
[0168] The processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.
[0169] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0170] Computer readable media include permanent and non-permanent, removable and non-removable storage media. Storage media can be implemented by any method or technology to store information, and the information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0171] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0172] The above description is only a specific embodiment of the present disclosure, so that those skilled in the art can understand or implement the present disclosure. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present disclosure. Therefore, the present disclosure will not be limited to the embodiments described herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for predicting the dosage of a coagulant, characterized in that: The method comprises: Obtain water quality data; When the water quality data is normal, determining whether the absolute value of the difference between the monitored water turbidity and the preset water turbidity is less than a preset value; When the absolute value of the difference between the monitored water turbidity and the preset water turbidity is greater than or equal to the preset value, the water quality data is input into the target coagulant delivery prediction model, and the predicted coagulant addition amount is output; the target coagulant delivery prediction model is obtained by training the preset stacking integrated model based on the training sample set; the preset stacking integrated model includes: a first machine learning model, a second machine learning model and a linear regression model; the training sample set includes: a plurality of historical coagulation and sedimentation data and the actual coagulant addition amount corresponding to each historical coagulation and sedimentation data; The coagulant is added according to the predicted coagulant addition amount.
2. The method according to claim 1, characterized in that The step of determining whether the absolute value of the difference between the monitored water turbidity and the preset water turbidity is less than a preset value further includes: When the absolute value of the difference between the monitored water turbidity and the preset water turbidity is less than the preset value, the original amount of coagulant added is maintained.
3. The method according to claim 1, characterized in that The target coagulant delivery prediction model is obtained by training the stacking integrated model based on the training sample set, and includes: Get the first training set and the second training set; Input the first training set into a plurality of machine learning models to be screened for training, and screen and obtain a first machine learning model and a second machine learning model; the weight of the first machine learning model is a first weight value, the weight of the second machine learning model is a second weight value, and the sum of the first weight value and the second weight value is 1; Dividing the secondary training set according to a first preset ratio to obtain a first training set and a first test set; Inputting the first training set into the first machine learning model and the second machine learning model respectively, and using a 5-fold cross validation algorithm to train the first machine learning model and the second machine learning model respectively, to obtain the predicted coagulant addition amount of the first machine learning model and the predicted coagulant addition amount of the second machine learning model; Constructing a target training set based on the predicted coagulant addition amount of the first machine learning model, the first weight value, the predicted coagulant addition amount of the second machine learning model, and the second weight value; The target training set is input into the linear regression model for training, and the predicted coagulant addition amount corresponding to each historical coagulation sedimentation data in the target training set is obtained; According to the actual amount of coagulant added corresponding to each piece of historical coagulation and sedimentation data in the first test set and the predicted amount of coagulant added corresponding to each piece of historical coagulation and sedimentation data in the target training set, a loss function is determined, and the weight parameters of the preset stacking integrated model are adjusted according to the loss function to obtain a target coagulant dosage prediction model.
4. The method according to claim 3, characterized in that The step of constructing a target training set based on the predicted coagulant addition amount of the first machine learning model, the first weight value, the predicted coagulant addition amount of the second machine learning model, and the second weight value comprises: Constructing a first sub-training set according to the actual amount of coagulant added corresponding to each piece of historical coagulation and sedimentation data in the first training set and the predicted amount of coagulant added output by the first machine learning model; Constructing a second sub-training set according to the actual amount of coagulant added corresponding to each piece of historical coagulation and sedimentation data in the first training set and the predicted amount of coagulant added output by the second machine learning model; A target training set is constructed according to the first sub-training set and the first weight value, the second sub-training set and the second weight value.
5. The method according to claim 3, characterized in that: The first training set is input into a plurality of machine learning models to be screened for training, and the first machine learning model and the second machine learning model are screened and obtained, including: Inputting the first training set into a plurality of machine learning models to be screened for training respectively, and obtaining prediction results of each machine learning model to be screened; According to the prediction results of each of the machine learning models to be screened, the multiple machine learning models to be screened are sorted to obtain the prediction accuracy sorting results of the multiple machine learning models to be screened; According to the prediction accuracy ranking results of the multiple machine learning models to be screened, a first machine learning model and a second machine learning model are determined, and weights are assigned to the first machine learning model and the second machine learning model.
6. The method according to claim 3, characterized in that The obtaining of the first training set and the second training set comprises: Acquire a historical coagulation and sedimentation data set; the historical coagulation and sedimentation data set includes: a plurality of historical coagulation and sedimentation data within a preset time; The historical coagulation and sedimentation data set is divided according to a second preset ratio to obtain a first training set and a second training set.
7. The method according to claim 1, characterized in that When the absolute value of the difference between the monitored water turbidity and the preset water turbidity is greater than or equal to the preset value, the water quality data is input into the target coagulant dosage prediction model, and before the predicted coagulant addition amount is output, the method further includes: The water quality data is processed for missing values and outliers to obtain a feature vector corresponding to the water quality data.
8. A coagulant dosage prediction device, characterized in that: The coagulant delivery prediction device comprises: An acquisition module, used to obtain water quality data; A judgment module, used for judging whether the absolute value of the difference between the monitored water turbidity and the preset water turbidity is less than a preset value when the water quality data is normal; An output module is used to input the water quality data into a target coagulant delivery prediction model and output a predicted coagulant addition amount when the absolute value of the difference between the monitored water turbidity and the preset water turbidity is greater than or equal to the preset value; the target coagulant delivery prediction model is obtained by training a preset stacking integrated model based on a training sample set; the preset stacking integrated model includes: a first machine learning model, a second machine learning model and a linear regression model; the training sample set includes: a plurality of historical coagulation and sedimentation data and an actual coagulant addition amount corresponding to each historical coagulation and sedimentation data; The delivery module is used to deliver the coagulant according to the predicted coagulant addition amount.
9. An electronic device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the coagulant dosage prediction method according to any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium, characterized in that: A computer program is stored thereon, and when the computer program is executed by a processor, the method for predicting the dosage of a coagulant according to any one of claims 1 to 7 is implemented.
Citation Information
Cited By
Flocculation dosing control method and device, electronic equipment and storage medium
CN121894773A
A method, apparatus, electronic device and storage medium for controlling flocculation dosing
CN121894773B
