River water quality prediction method and system based on machine learning
Through the depth-time convolution random forest model and the improved killer whale hunting algorithm, the limitations of time dependence and non-linear relationships in river water quality prediction are solved, the accuracy and robustness of the prediction are improved, and it is suitable for rapid response. Application scenarios.
Patent Information
- Application Number
- CN202411200152.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-29
- Publication Date
- 2024-09-24
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing river water quality prediction models have limitations in capturing complex time dependencies and nonlinear relationships, resulting in inaccurate prediction results. In addition, the candidate solutions of the traditional killer whale hunting algorithm in the search space tend to be concentrated, affecting the model prediction effect. and real-time.
A deep-temporal convolutional random forest model is used to build a river water quality prediction model. The time dependence and nonlinear relationship are captured through dilated convolution layers, and Gaussian mutation is introduced into the killer whale hunting algorithm to increase the diversity of candidate solutions and global search capabilities. .
It improves the accuracy and robustness of river water quality prediction, enhances the reliability and practicality of the model, and meets the application requirements of real-time and rapid response.
Smart Images

Figure CN118690670A
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of river intelligent management, and specifically refers to a river water quality prediction method and system based on machine learning. Background Art
[0002] River water quality prediction uses machine learning technology to analyze water quality data and related factors to predict the future water quality of the river. It aims to timely detect potential pollution problems in the river and help relevant departments take preventive measures quickly, thereby improving river management efficiency and better protecting the health of the river ecosystem.
[0003] However, in the existing river water quality prediction process, there is a technical problem that the river water quality changes have obvious time dependence, and the traditional model has limitations in capturing complex time dependence and nonlinear relationships, resulting in inaccurate prediction results, affecting the effectiveness of subsequent river water quality management; there is a technical problem that the prediction effect of the river water quality prediction model depends on the selection of model parameters, and the candidate solutions of the traditional killer whale hunting algorithm in the search space tend to be concentrated, which leads to insufficient diversity of candidate solutions, affecting the model prediction effect, and the convergence speed is unstable, making it difficult to meet the actual needs of real-time and accuracy requirements of river water quality prediction. Summary of the invention
[0004] In view of the above situation, in order to overcome the defects of the prior art, the present invention provides a river water quality prediction method and system based on machine learning. In view of the technical problem that in the existing river water quality prediction process, the river water quality changes have obvious time dependence, and the traditional model has limitations in capturing complex time dependence and nonlinear relationships, resulting in inaccurate prediction results and affecting the effectiveness of subsequent river water quality management, this solution creatively adopts a deep time convolution random forest model to construct a river water quality prediction model, and more effectively captures time dependence through the expansion convolution layer, enhances the modeling ability of nonlinear relationships, and multi-layer expansion convolution can better extract features of different time scales, and improves the prediction accuracy and robustness of the model through the random forest subnet, thereby enhancing the river water quality. Reliability of prediction; In view of the technical problem that in the existing river water quality prediction process, the prediction effect of the river water quality prediction model depends on the selection of model parameters, and the candidate solutions of the traditional killer whale hunting algorithm in the search space tend to be concentrated, which leads to insufficient diversity of candidate solutions, affecting the model prediction effect, and the convergence speed is unstable, which is difficult to meet the actual needs of real-time and accuracy requirements of river water quality prediction. This solution creatively adopts an improved killer whale hunting algorithm to optimize the model parameters. By introducing Gaussian variation into the killer whale hunting algorithm, the diversity of candidate solutions is increased, the global search capability of the algorithm is enhanced, and the convergence speed is accelerated, thereby improving the efficiency and effect of model optimization. It is suitable for actual application scenarios that require rapid response and helps to enhance the practicality of river water quality prediction.
[0005] The technical solution adopted by the present invention is as follows: The river water quality prediction method based on machine learning provided by the present invention comprises the following steps:
[0006] Step S1: data preparation;
[0007] Step S2: data preprocessing;
[0008] Step S3: constructing a river water quality prediction model;
[0009] Step S4: optimal river water quality prediction design;
[0010] Step S5: River water quality prediction.
[0011] Furthermore, in step S1, the data preparation is used to collect raw data required for river water quality prediction, specifically, to obtain river water quality data by collecting daily water quality data, precipitation data and runoff data.
[0012] Furthermore, in step S2, the data preprocessing is used to optimize data quality, specifically by performing data preprocessing on the river water quality data through outlier removal, missing value filling and data normalization to obtain river water quality optimized data.
[0013] Furthermore, in step S3, the river water quality prediction model is constructed by using a deep temporal convolution random forest model to construct a river water quality prediction model;
[0014] The deep temporal convolutional random forest model comprises an input layer, a deep temporal convolutional subnet, a random forest subnet and an output layer;
[0015] The deep temporal convolutional subnetwork is used to extract important time-dependent features from the data;
[0016] The random forest subnet is used to process high-dimensional features and capture complex nonlinear relationships;
[0017] The river water quality prediction model is constructed, comprising the following steps:
[0018] Step S31: constructing an input layer for receiving input data, specifically receiving river water quality optimization data as input of the model through the input layer to obtain input data;
[0019] Step S32: construct a deep temporal convolutional subnet, specifically, setting an extended convolutional layer, a residual connection and a dense layer in the deep temporal convolutional subnet, calculating the input data through the deep temporal convolutional subnet to obtain temporal convolutional features, including the following steps:
[0020] Step S321: construct a dilated convolution layer, and perform a dilated convolution operation on the input data through the dilated convolution layer to obtain time series features. The calculation formula of the dilated convolution operation is:
[0021] ;
[0022] In the formula, y t is the time series feature at the tth time step, specifically the result of the dilated convolution operation at the tth time step, t is the time step index, k is the convolution kernel size, j is the convolution kernel index, r is the dilation rate, and w j is the jth convolution and weight, x t+r(j-1) is the value of the input data at the t+r(j-1)th time step;
[0023] Step S322: stack K layers of dilated convolutional layers to increase the model depth and feature representation capability, and set residual connections between each layer of dilated convolutional layers;
[0024] The calculation formula of the residual connection is:
[0025] ;
[0026] In the formula, z t is the residual connection result at the tth time step, x t is the value of the input data at time step t;
[0027] Step S323: construct a dense layer for further processing the output of the dilated convolutional layer, and obtain the temporal convolution features through the dense layer calculation;
[0028] Step S33: constructing a random forest subnet, specifically setting B decision trees in the random forest subnet, calculating the time series convolution features through the random forest subnet, and obtaining the random forest prediction results, including the following steps:
[0029] Step S331: construct B decision trees;
[0030] Step S332: Integrate the prediction results of each decision tree, and the calculation formula is:
[0031] ;
[0032] In the formula, y tree is the random forest prediction result, B is the number of decision trees, b is the decision tree index, and h b (·) is the prediction function of the bth decision tree, X is the input of the decision tree, specifically the temporal convolution feature;
[0033] Step S34: construct an output layer for outputting the final prediction result of the model, specifically, setting a Softmax activation function in the output layer, mapping the random forest prediction result through the output layer, and obtaining the final prediction result of the model;
[0034] Step S35: constructing a deep temporal convolutional random forest model, specifically by constructing an input layer, constructing a deep temporal convolutional subnet, constructing a random forest subnet and constructing an output layer, to obtain a deep temporal convolutional random forest model;
[0035] Step S36: initial model training, specifically, performing initial model training on the deep temporal convolutional random forest model to obtain a river water quality prediction model.
[0036] Further, in step S4, the optimal river water quality prediction design is used to optimize the river water quality prediction model, specifically using an improved killer whale hunting algorithm to optimize model parameters to obtain the optimal river water quality prediction model, including the following steps:
[0037] Step S41: improving the killer whale hunting algorithm, specifically introducing Gaussian variation into the killer whale hunting algorithm to avoid falling into the local optimum, improve the global search effect, and obtain an improved killer whale hunting algorithm;
[0038] Step S42: constructing an improved killer whale hunting algorithm, including the following steps:
[0039] Step S421: initializing the killer whale position, specifically randomly generating the killer whale position in the candidate solution space, wherein the killer whale position is used to represent the candidate solution;
[0040] Step S422: constructing a fitness function, specifically using the model loss function as the fitness function;
[0041] Step S423: generating the optimal position of the killer whale, specifically using the fitness function to evaluate each killer whale position, and selecting a killer whale with the best fitness value as the optimal position of the killer whale;
[0042] Step S424: constructing a killer whale position update strategy, specifically, updating the killer whale position through a prey encirclement strategy and a prey attack strategy, including the following steps:
[0043] Step S4241: construct a strategy to surround the prey, specifically by randomly selecting three killer whale positions and updating the killer whale positions dimension by dimension. The calculation formula is:
[0044] ;
[0045] In the formula, is a scaling factor used to adjust the amplitude of the killer whale position update, R is a random number in the range [0,1], and K max is the maximum number of iterations, k is the iteration index, i is the killer whale index, and d is the dimension index, specifically the dimension index of the candidate solution space. is the updated killer whale position in the dth dimension, specifically the position of the i-th killer whale in the dth dimension in the k-th iteration, is the position of the first randomly selected killer whale in the kth iteration in the dth dimension, is the position of the second randomly selected killer whale in the kth iteration in the dth dimension, is the position of the third randomly selected killer whale in the kth iteration in the dth dimension;
[0046] Step S4242: Construct a strategy for attacking prey, specifically, select four killer whales with the best fitness values, and randomly select three killer whale positions. By calculating the killer whale speed, the killer whale position is updated. The calculation formula is:
[0047] ;
[0048] In the formula, is the speed of the ith killer whale when attacking its prey, is the first optimal killer whale position, specifically the killer whale position with the best fitness value in the kth iteration, It is the second best killer whale location. It is the third best killer whale location. It is the fourth best killer whale location. is the speed of the ith killer whale in the hunting area, which specifically refers to an area formed by all killer whales during the hunting process, is the first random killer whale position, specifically the first randomly selected killer whale position in the kth iteration, is the second random killer whale position, is the third random killer whale position, is the updated killer whale position, specifically the position of the i-th killer whale in the k-th iteration, is the position of the killer whale before the update, specifically the position of the i-th killer whale in the k-1th iteration, is the first weight of speed, It is the second weight of speed;
[0049] Step S4243: Select the killer whale position update strategy, specifically, randomly generate a strategy selection factor in the range of [0,1]. When the strategy selection factor is greater than 0.5, use the surround prey strategy to update the killer whale position, otherwise use the attack prey strategy to update the killer whale position;
[0050] Step S425: Apply Gaussian mutation to generate a new killer whale position, and the calculation formula is:
[0051] ;
[0052] In the formula, is the mean of the Gaussian variation, is the optimal position of the killer whale in the kth iteration, is the current position of the killer whale in the kth iteration, is the Gaussian variation variance, It is the new killer whale position. is from the mean , the variance is Generate random numbers from a Gaussian distribution;
[0053] Step S426: iteratively updating the position of the killer whale, specifically, iteratively updating the position of the killer whale by repeatedly executing steps S423 to S425 until a maximum number of iterations is reached;
[0054] Step S43: Parameter tuning, specifically, tuning the parameters of the river water quality prediction model through the improved killer whale hunting algorithm to obtain the optimal river water quality prediction model.
[0055] Furthermore, in step S5, the river water quality prediction is used to predict river water quality, specifically to predict river water quality through an optimal river water quality prediction model, obtain river water quality prediction results, and provide river management suggestions. When there is an abnormality in river water quality, an early warning reminder is issued.
[0056] The river water quality prediction system based on machine learning provided by the present invention comprises: a data preparation module, a data preprocessing module, a river water quality prediction model construction module, an optimal river water quality prediction design module and a river water quality prediction module;
[0057] The data preparation module is used for data preparation, obtains river water quality data through data preparation, and sends the river water quality data to the data preprocessing module;
[0058] The data preprocessing module is used for data preprocessing, and obtains river water quality optimization data through data preprocessing, and sends the river water quality optimization data to the river water quality prediction model building module;
[0059] The river water quality prediction model construction module is used for river water quality prediction model construction, obtains the river water quality prediction model through river water quality prediction model construction, and sends the river water quality prediction model to the optimal river water quality prediction design module;
[0060] The optimal river water quality prediction design module is used for optimal river water quality prediction design, and obtains an optimal river water quality prediction model through the optimal river water quality prediction design, and sends the optimal river water quality prediction model to the river water quality prediction module;
[0061] The river water quality prediction module predicts river water quality through the optimal river water quality prediction model, obtains river water quality prediction results, and provides river management suggestions. When there is an abnormality in river water quality, an early warning reminder is issued.
[0062] The beneficial effects achieved by the present invention using the above scheme are as follows:
[0063] (1) In view of the fact that the changes in river water quality have obvious time dependence in the existing river water quality prediction process, the traditional model has limitations in capturing complex time dependence and nonlinear relationships, resulting in inaccurate prediction results and affecting the effectiveness of subsequent river water quality management. This solution creatively uses the deep time convolution random forest model to construct a river water quality prediction model. The dilated convolution layer can more effectively capture the time dependence and enhance the modeling ability of nonlinear relationships. The multi-layer dilated convolution can better extract features of different time scales, and the random forest subnet can improve the prediction accuracy and robustness of the model, thereby enhancing the reliability of river water quality prediction.
[0064] (2) In view of the technical problem that in the existing river water quality prediction process, the prediction effect of the river water quality prediction model depends on the selection of model parameters, and the candidate solutions of the traditional killer whale hunting algorithm in the search space tend to be concentrated, which leads to insufficient diversity of candidate solutions, affecting the model prediction effect, and the convergence speed is unstable, which is difficult to meet the actual needs of real-time and accuracy requirements of river water quality prediction. This scheme creatively adopts an improved killer whale hunting algorithm to optimize the model parameters. By introducing Gaussian variation into the killer whale hunting algorithm, the diversity of candidate solutions is increased, the global search capability of the algorithm is enhanced, and the convergence speed is accelerated, thereby improving the efficiency and effect of model optimization. It is suitable for actual application scenarios that require rapid response and helps to enhance the practicality of river water quality prediction. BRIEF DESCRIPTION OF THE DRAWINGS
[0065] Figure 1 A schematic diagram of the flow chart of the river water quality prediction method based on machine learning provided by the present invention;
[0066] Figure 2 A schematic diagram of a river water quality prediction system based on machine learning provided by the present invention;
[0067] Figure 3 is a schematic diagram of the process of step S3;
[0068] Figure 4 It is a schematic diagram of the process of step S4.
[0069] The accompanying drawings are used to provide further understanding of the present invention and constitute a part of the specification. They are used to explain the present invention together with the embodiments of the present invention and do not constitute a limitation of the present invention. DETAILED DESCRIPTION
[0070] The technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments; based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0071] In the description of the present invention, it should be understood that terms such as “upper”, “lower”, “front”, “back”, “left”, “right”, “top”, “bottom”, “inside” and “outside” indicating directions or positional relationships are based on the directions or positional relationships shown in the accompanying drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific direction, be constructed and operated in a specific direction, and therefore should not be understood as limiting the present invention.
[0072] Example 1, see Figure 1 The present invention provides a method for predicting river water quality based on machine learning, the method comprising the following steps:
[0073] Step S1: data preparation;
[0074] Step S2: data preprocessing;
[0075] Step S3: constructing a river water quality prediction model;
[0076] Step S4: optimal river water quality prediction design;
[0077] Step S5: River water quality prediction.
[0078] Example 2, see Figure 1 This embodiment is based on the above embodiment. In step S1, the data preparation is used to collect the original data required for river water quality prediction, specifically, by collecting daily water quality data, precipitation data and runoff data to obtain river water quality data.
[0079] Example 3, see Figure 1 This embodiment is based on the above embodiment. In step S2, the data preprocessing is used to optimize the data quality, specifically by removing outliers, filling missing values and normalizing data to preprocess the river water quality data to obtain river water quality optimization data.
[0080] Example 4, see Figure 1 and Figure 3 , this embodiment is based on the above embodiment, in step S3, the river water quality prediction model is constructed, specifically by using a deep time convolution random forest model to construct the river water quality prediction model;
[0081] The deep temporal convolutional random forest model comprises an input layer, a deep temporal convolutional subnet, a random forest subnet and an output layer;
[0082] The deep temporal convolutional subnetwork is used to extract important time-dependent features from the data;
[0083] The random forest subnet is used to process high-dimensional features and capture complex nonlinear relationships;
[0084] The river water quality prediction model is constructed, comprising the following steps:
[0085] Step S31: constructing an input layer for receiving input data, specifically receiving river water quality optimization data as input of the model through the input layer to obtain input data;
[0086] Step S32: construct a deep temporal convolutional subnet, specifically, setting an extended convolutional layer, a residual connection and a dense layer in the deep temporal convolutional subnet, calculating the input data through the deep temporal convolutional subnet to obtain temporal convolutional features, including the following steps:
[0087] Step S321: construct a dilated convolution layer, and perform a dilated convolution operation on the input data through the dilated convolution layer to obtain time series features. The calculation formula of the dilated convolution operation is:
[0088] ;
[0089] In the formula, y t is the time series feature at the tth time step, specifically the result of the dilated convolution operation at the tth time step, t is the time step index, k is the convolution kernel size, j is the convolution kernel index, r is the dilation rate, and w j is the jth convolution and weight, x t+r(j-1) is the value of the input data at the t+r(j-1)th time step;
[0090] Step S322: stack K layers of dilated convolutional layers to increase the model depth and feature representation capability, and set residual connections between each layer of dilated convolutional layers;
[0091] The calculation formula of the residual connection is:
[0092] ;
[0093] In the formula, z tis the residual connection result at the tth time step, x t is the value of the input data at time step t;
[0094] Step S323: construct a dense layer for further processing the output of the dilated convolutional layer, and obtain the temporal convolution features through the dense layer calculation;
[0095] Step S33: constructing a random forest subnet, specifically setting B decision trees in the random forest subnet, calculating the time series convolution features through the random forest subnet, and obtaining the random forest prediction results, including the following steps:
[0096] Step S331: construct B decision trees;
[0097] Step S332: Integrate the prediction results of each decision tree, and the calculation formula is:
[0098] ;
[0099] In the formula, y tree is the random forest prediction result, B is the number of decision trees, b is the decision tree index, and h b (·) is the prediction function of the bth decision tree, X is the input of the decision tree, specifically the temporal convolution feature;
[0100] Step S34: construct an output layer for outputting the final prediction result of the model, specifically, setting a Softmax activation function in the output layer, mapping the random forest prediction result through the output layer, and obtaining the final prediction result of the model;
[0101] Step S35: constructing a deep temporal convolutional random forest model, specifically by constructing an input layer, constructing a deep temporal convolutional subnet, constructing a random forest subnet and constructing an output layer, to obtain a deep temporal convolutional random forest model;
[0102] Step S36: initial model training, specifically, performing initial model training on the deep temporal convolutional random forest model to obtain a river water quality prediction model;
[0103] By performing the above operations, in view of the technical problem that in the existing river water quality prediction process, the river water quality changes have obvious time dependence, and the traditional model has limitations in capturing complex time dependence and nonlinear relationships, resulting in inaccurate prediction results and affecting the effectiveness of subsequent river water quality management, this solution creatively uses the deep time convolution random forest model to construct a river water quality prediction model. The dilated convolution layer can more effectively capture the time dependence and enhance the modeling ability of nonlinear relationships. The multi-layer dilated convolution can better extract features of different time scales, and the random forest subnet can improve the model prediction accuracy and robustness, thereby enhancing the reliability of river water quality prediction.
[0104] Example 5, see Figure 1 and Figure 4 This embodiment is based on the above embodiment. In step S4, the optimal river water quality prediction design is used to optimize the river water quality prediction model. Specifically, the improved killer whale hunting algorithm is used to optimize the model parameters to obtain the optimal river water quality prediction model, including the following steps:
[0105] Step S41: improving the killer whale hunting algorithm, specifically introducing Gaussian variation into the killer whale hunting algorithm to avoid falling into the local optimum, improve the global search effect, and obtain an improved killer whale hunting algorithm;
[0106] Step S42: constructing an improved killer whale hunting algorithm, including the following steps:
[0107] Step S421: initializing the killer whale position, specifically randomly generating the killer whale position in the candidate solution space, wherein the killer whale position is used to represent the candidate solution;
[0108] Step S422: constructing a fitness function, specifically using the model loss function as the fitness function;
[0109] Step S423: generating the optimal position of the killer whale, specifically using the fitness function to evaluate each killer whale position, and selecting a killer whale with the best fitness value as the optimal position of the killer whale;
[0110] Step S424: constructing a killer whale position update strategy, specifically, updating the killer whale position through a prey encirclement strategy and a prey attack strategy, including the following steps:
[0111] Step S4241: construct a strategy to surround the prey, specifically by randomly selecting three killer whale positions and updating the killer whale positions dimension by dimension. The calculation formula is:
[0112] ;
[0113] In the formula, is a scaling factor used to adjust the amplitude of the killer whale position update, R is a random number in the range [0,1], and K max is the maximum number of iterations, k is the iteration index, i is the killer whale index, and d is the dimension index, specifically the dimension index of the candidate solution space. is the updated killer whale position in the dth dimension, specifically the position of the i-th killer whale in the dth dimension in the k-th iteration, is the position of the first randomly selected killer whale in the kth iteration in the dth dimension, is the position of the second randomly selected killer whale in the kth iteration in the dth dimension, is the position of the third randomly selected killer whale in the kth iteration in the dth dimension;
[0114] Step S4242: Construct a strategy for attacking prey, specifically, select four killer whales with the best fitness values, and randomly select three killer whale positions. By calculating the killer whale speed, the killer whale position is updated. The calculation formula is:
[0115] ;
[0116] In the formula, is the speed of the ith killer whale when attacking its prey, is the first optimal killer whale position, specifically the killer whale position with the best fitness value in the kth iteration, It is the second best killer whale location. It is the third best killer whale location. It is the fourth best killer whale location. is the speed of the ith killer whale in the hunting area, which specifically refers to an area formed by all killer whales during the hunting process, is the first random killer whale position, specifically the first randomly selected killer whale position in the kth iteration, is the second random killer whale position, is the third random killer whale position, is the updated killer whale position, specifically the position of the i-th killer whale in the k-th iteration, is the position of the killer whale before the update, specifically the position of the i-th killer whale in the k-1th iteration, is the first weight of speed, It is the second weight of speed;
[0117] Step S4243: Select the killer whale position update strategy, specifically, randomly generate a strategy selection factor in the range of [0,1]. When the strategy selection factor is greater than 0.5, use the surround prey strategy to update the killer whale position, otherwise use the attack prey strategy to update the killer whale position;
[0118] Step S425: Apply Gaussian mutation to generate a new killer whale position, and the calculation formula is:
[0119] ;
[0120] In the formula, is the mean of the Gaussian variation, is the optimal position of the killer whale in the kth iteration, is the current position of the killer whale in the kth iteration, is the Gaussian variation variance, It is the new killer whale position. is from the mean , the variance is Generate random numbers from a Gaussian distribution;
[0121] Step S426: iteratively updating the position of the killer whale, specifically, iteratively updating the position of the killer whale by repeatedly executing steps S423 to S425 until a maximum number of iterations is reached;
[0122] Step S43: parameter tuning, specifically, tuning the parameters of the river water quality prediction model through the improved killer whale hunting algorithm to obtain the optimal river water quality prediction model;
[0123] Table 1 is a comparison of model parameters before and after parameter tuning in Example 5 of the present invention. As shown in the table, kernel_size is used to indicate the size of the convolution kernel, dilation_rate is used to indicate the dilation rate, num_estimators is used to indicate the number of decision trees, max_depth is used to indicate the maximum depth of the decision tree, learning_rate is used to indicate the learning rate, and dropout_rate is used to indicate the dropout rate;
[0124] Table 1 Comparison of model parameters before and after parameter tuning
[0125]
[0126] Table 2 is a comparison of model performance before and after parameter tuning in Example 5 of the present invention. As shown in the table, the RMSE is used to represent the root mean square error. The smaller the root mean square error, the higher the model prediction accuracy;
[0127] Table 2 Comparison of model performance before and after parameter tuning
[0128]
[0129] By performing the above operations, in order to solve the technical problem that in the existing river water quality prediction process, the prediction effect of the river water quality prediction model depends on the selection of model parameters, and the candidate solutions of the traditional killer whale hunting algorithm in the search space tend to be concentrated, which leads to insufficient diversity of candidate solutions, affects the model prediction effect, and the convergence speed is unstable, and it is difficult to meet the actual needs of real-time and accuracy requirements of river water quality prediction, this scheme creatively adopts an improved killer whale hunting algorithm to optimize the model parameters, and introduces Gaussian variation into the killer whale hunting algorithm to increase the diversity of candidate solutions, enhance the global search capability of the algorithm, accelerate the convergence speed, improve the efficiency and effect of model optimization, and is suitable for actual application scenarios that require rapid response, which helps to enhance the practicality of river water quality prediction.
[0130] Example 6, see Figure 1 This embodiment is based on the above embodiment. In step S5, the river water quality prediction is used to predict the river water quality, specifically to predict the river water quality through the optimal river water quality prediction model, obtain the river water quality prediction result, and provide river management suggestions. When the river water quality is abnormal, an early warning reminder is issued.
[0131] Embodiment 7, see Figure 2 , this embodiment is based on the above embodiment, and the river water quality prediction system based on machine learning provided by the present invention includes: a data preparation module, a data preprocessing module, a river water quality prediction model construction module, an optimal river water quality prediction design module and a river water quality prediction module;
[0132] The data preparation module is used for data preparation, obtains river water quality data through data preparation, and sends the river water quality data to the data preprocessing module;
[0133] The data preprocessing module is used for data preprocessing, and obtains river water quality optimization data through data preprocessing, and sends the river water quality optimization data to the river water quality prediction model building module;
[0134] The river water quality prediction model construction module is used for river water quality prediction model construction, obtains the river water quality prediction model through river water quality prediction model construction, and sends the river water quality prediction model to the optimal river water quality prediction design module;
[0135] The optimal river water quality prediction design module is used for optimal river water quality prediction design, and obtains an optimal river water quality prediction model through the optimal river water quality prediction design, and sends the optimal river water quality prediction model to the river water quality prediction module;
[0136] The river water quality prediction module predicts river water quality through the optimal river water quality prediction model, obtains river water quality prediction results, and provides river management suggestions. When there is an abnormality in river water quality, an early warning reminder is issued.
[0137] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants 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.
[0138] While the embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that many changes, modifications, substitutions and variations can be made to the embodiments without departing from the principles and spirit of the invention.
[0139] The present invention and its embodiments are described above, which is not restrictive. The drawings show only one embodiment of the present invention, and the actual structure is not limited thereto. In short, if ordinary technicians in the field are inspired by it and design structural methods and embodiments similar to the technical solution without creativity without departing from the purpose of the invention, they should all fall within the protection scope of the present invention.
Claims
1. A river water quality prediction method based on machine learning, characterized by: The method comprises the following steps: Step S1: data preparation; Step S2: data preprocessing; Step S3: constructing a river water quality prediction model, specifically using a deep temporal convolutional random forest model to construct a river water quality prediction model; The deep temporal convolutional random forest model comprises an input layer, a deep temporal convolutional subnet, a random forest subnet and an output layer; The deep temporal convolutional subnetwork is used to extract important time-dependent features from the data; The random forest subnet is used to process high-dimensional features and capture complex nonlinear relationships; Step S4: optimal river water quality prediction design is used to optimize the river water quality prediction model, specifically using the improved killer whale hunting algorithm to optimize the model parameters to obtain the optimal river water quality prediction model, including the following steps: Step S41: improving the killer whale hunting algorithm, specifically introducing Gaussian variation into the killer whale hunting algorithm to obtain an improved killer whale hunting algorithm; Step S42: constructing an improved killer whale hunting algorithm; Step S43: parameter tuning, specifically, tuning the parameters of the river water quality prediction model through the improved killer whale hunting algorithm to obtain the optimal river water quality prediction model; Step S5: River water quality prediction.
2. The method for predicting river water quality based on machine learning according to claim 1, characterized in that: In step S3, the river water quality prediction model is constructed, including the following steps: Step S31: constructing an input layer for receiving input data, specifically receiving river water quality optimization data as input of the model through the input layer to obtain input data; Step S32: construct a deep temporal convolutional subnet, specifically, setting an extended convolutional layer, a residual connection and a dense layer in the deep temporal convolutional subnet, calculating the input data through the deep temporal convolutional subnet to obtain temporal convolutional features, including the following steps: Step S321: construct a dilated convolution layer, and perform a dilated convolution operation on the input data through the dilated convolution layer to obtain time series features. The calculation formula of the dilated convolution operation is: ; In the formula, y t is the time series feature at the tth time step, specifically the result of the dilated convolution operation at the tth time step, t is the time step index, k is the convolution kernel size, j is the convolution kernel index, r is the dilation rate, and w j is the jth convolution and weight, x t+r(j-1) is the value of the input data at the t+r(j-1)th time step; Step S322: stack K layers of dilated convolutional layers to increase the model depth, and set residual connections between each layer of dilated convolutional layers; The calculation formula of the residual connection is: ; In the formula, z t is the residual connection result at the tth time step, x t is the value of the input data at time step t; Step S323: construct a dense layer for further processing the output of the dilated convolutional layer, and obtain the temporal convolution features through the dense layer calculation; Step S33: constructing a random forest subnet, specifically setting B decision trees in the random forest subnet, calculating the time series convolution features through the random forest subnet, and obtaining the random forest prediction results, including the following steps: Step S331: construct B decision trees; Step S332: Integrate the prediction results of each decision tree, and the calculation formula is: ; In the formula, y tree is the random forest prediction result, B is the number of decision trees, b is the decision tree index, and h b (·) is the prediction function of the bth decision tree, X is the input of the decision tree, specifically the temporal convolution feature; Step S34: construct an output layer for outputting the final prediction result of the model, specifically, setting a Softmax activation function in the output layer, mapping the random forest prediction result through the output layer, and obtaining the final prediction result of the model; Step S35: constructing a deep temporal convolutional random forest model, specifically by constructing an input layer, constructing a deep temporal convolutional subnet, constructing a random forest subnet and constructing an output layer, to obtain a deep temporal convolutional random forest model; Step S36: initial model training, specifically, performing initial model training on the deep temporal convolutional random forest model to obtain a river water quality prediction model.
3. The method for predicting river water quality based on machine learning according to claim 2, characterized in that: In step S42, the construction of an improved killer whale hunting algorithm includes the following steps: Step S421: initializing the killer whale position, specifically randomly generating the killer whale position in the candidate solution space, wherein the killer whale position is used to represent the candidate solution; Step S422: constructing a fitness function, specifically using the model loss function as the fitness function; Step S423: generating the optimal position of the killer whale, specifically using the fitness function to evaluate each killer whale position, and selecting a killer whale with the best fitness value as the optimal position of the killer whale; Step S424: constructing a killer whale position update strategy, specifically, updating the killer whale position through a prey encirclement strategy and a prey attack strategy; Step S425: Apply Gaussian mutation to generate a new killer whale position, and the calculation formula is: ; In the formula, is the mean of the Gaussian variation, is the optimal position of the killer whale in the kth iteration, is the current position of the killer whale in the kth iteration, is the Gaussian variation variance, It is the new killer whale position. is from the mean , the variance is Generate random numbers from a Gaussian distribution; Step S426: iteratively updating the position of the killer whale, specifically, iteratively updating the position of the killer whale by repeatedly executing steps S423 to S425 until the maximum number of iterations is reached.
4. The method for predicting river water quality based on machine learning according to claim 3, characterized in that: In step S424, the killer whale position update strategy is constructed, specifically updating the killer whale position through the prey encirclement strategy and the prey attack strategy, including the following steps: Step S4241: construct a strategy to surround the prey, specifically by randomly selecting three killer whale positions and updating the killer whale positions dimension by dimension. The calculation formula is: ; In the formula, is a scaling factor used to adjust the amplitude of the killer whale position update, R is a random number in the range [0,1], and K max is the maximum number of iterations, k is the iteration index, i is the killer whale index, and d is the dimension index, specifically the dimension index of the candidate solution space. is the updated killer whale position in the dth dimension, specifically the position of the i-th killer whale in the dth dimension in the k-th iteration, is the position of the first randomly selected killer whale in the kth iteration in the dth dimension, is the position of the second randomly selected killer whale in the kth iteration in the dth dimension, is the position of the third randomly selected killer whale in the kth iteration in the dth dimension; Step S4242: Construct a strategy for attacking prey, specifically, select four killer whales with the best fitness values, and randomly select three killer whale positions. By calculating the killer whale speed, the killer whale position is updated. The calculation formula is: ; In the formula, is the speed of the ith killer whale when attacking its prey, is the first optimal killer whale position, specifically the killer whale position with the best fitness value in the kth iteration, It is the second best killer whale location. It is the third best killer whale location. It is the fourth best killer whale location. is the speed of the ith killer whale in the hunting area, which specifically refers to an area formed by all killer whales during the hunting process, is the first random killer whale position, specifically the first randomly selected killer whale position in the kth iteration, is the second random killer whale position, is the third random killer whale position, is the updated killer whale position, specifically the position of the i-th killer whale in the k-th iteration, is the position of the killer whale before the update, specifically the position of the i-th killer whale in the k-1th iteration, is the first weight of speed, It is the second weight of speed; Step S4243: Select the killer whale position update strategy, specifically, randomly generate a strategy selection factor in the range of [0,1]. When the strategy selection factor is greater than 0.5, use the surround prey strategy to update the killer whale position, otherwise use the attack prey strategy to update the killer whale position.
5. The method for predicting river water quality based on machine learning according to claim 4, characterized in that: In step S5, the river water quality prediction is used to predict the river water quality, specifically to predict the river water quality through the optimal river water quality prediction model, obtain the river water quality prediction result, and provide river management suggestions. When the river water quality is abnormal, an early warning reminder is issued.
6. The method for predicting river water quality based on machine learning according to claim 5, characterized in that: In step S1, the data preparation is used to collect the original data required for river water quality prediction, specifically, to obtain river water quality data by collecting daily water quality data, precipitation data and runoff data.
7. The method for predicting river water quality based on machine learning according to claim 6, characterized in that: In step S2, the data preprocessing is used to optimize the data quality, specifically by performing data preprocessing on the river water quality data through outlier removal, missing value filling and data normalization to obtain river water quality optimized data.
8. A river water quality prediction system based on machine learning, used to implement the river water quality prediction method based on machine learning as described in any one of claims 1 to 7, characterized in that: It includes a data preparation module, a data preprocessing module, a river water quality prediction model building module, an optimal river water quality prediction design module and a river water quality prediction module.
9. The river water quality prediction system based on machine learning according to claim 8, characterized in that: The data preparation module is used for data preparation, obtains river water quality data through data preparation, and sends the river water quality data to the data preprocessing module; The data preprocessing module is used for data preprocessing, and obtains river water quality optimization data through data preprocessing, and sends the river water quality optimization data to the river water quality prediction model building module; The river water quality prediction model construction module is used for river water quality prediction model construction, obtains the river water quality prediction model through river water quality prediction model construction, and sends the river water quality prediction model to the optimal river water quality prediction design module; The optimal river water quality prediction design module is used for optimal river water quality prediction design, and obtains an optimal river water quality prediction model through the optimal river water quality prediction design, and sends the optimal river water quality prediction model to the river water quality prediction module; The river water quality prediction module predicts river water quality through the optimal river water quality prediction model, obtains river water quality prediction results, and provides river management suggestions. When there is an abnormality in river water quality, an early warning reminder is issued.
Citation Information
Patent Citations
Water quality prediction method for optimizing SVR model based on improved SSA algorithm
CN116956696A
Winter abnormal snowfall prediction method based on meteorological data and statistical model
CN118332496A
River integrated management system based on big data analysis
CN118469157A
Method and system for calculating pollution intensity in flood season of agricultural area based on rainfall and water quality monitoring
CN118521227A
Wind power prediction method and system for optimizing deep transformer network
US20220197233A1
Cited By
Vital sign prediction system for pediatric clinical assistance
CN119132614A
