Underground water level prediction method based on machine learning
By combining historical groundwater level and meteorological data with machine learning methods, a Bayesian k-fold cross-validation model was constructed, which solved the shortcomings of traditional methods in obtaining hydrological parameters and handling nonlinear relationships, and achieved groundwater level prediction with higher accuracy and efficiency.
Patent Information
- Application Number
- CN202511768339.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-28
- Publication Date
- 2026-02-03
AI Technical Summary
Traditional numerical models and time series methods struggle to obtain accurate hydrological parameters and handle nonlinear relationships, making it difficult to capture complex patterns of groundwater level changes, resulting in insufficient prediction accuracy and efficiency.
Using machine learning methods and combining historical groundwater level and meteorological data, a machine learning model is constructed for groundwater level prediction through Bayesian k-fold cross-validation and feature selection, including data preprocessing, feature selection and model training.
It improves the accuracy and reliability of groundwater level prediction, better captures the patterns and complex relationships of groundwater level changes, shortens prediction response time, and enhances prediction accuracy and efficiency.
Smart Images

Figure CN121456629A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application relates to the technical field of underground water level prediction, in particular to a machine learning-based underground water level prediction method. BACKGROUND
[0002] Underground water level prediction is one of the core technologies of modern water resource management, and its significance not only relates to resource optimization, but also relates to ecological safety and disaster prevention and control. For example, underground water level change directly affects agricultural irrigation (accounting for 40% of global water consumption) and urban water supply stability, and accurate prediction can optimize mining plans and avoid overexploitation-induced land subsidence or water source depletion. In the research on underground water level prediction, traditional numerical models require accurate hydrological parameters (permeability coefficient, specific yield), and actual data is difficult to obtain, time series method is difficult to handle nonlinear relationship, and it is difficult to capture complex pattern changes. SUMMARY
[0003] Therefore, it is necessary to provide a machine learning-based underground water level prediction method capable of improving underground water level prediction accuracy.
[0004] A machine learning-based underground water level prediction method, the method comprising the following steps: S1. Obtain historical related data of the underground water to be measured, and pretreat the historical related data; the historical related data at least includes historical underground water level data and historical meteorological data; the historical meteorological data at least includes historical precipitation data, historical evapotranspiration data, historical temperature data, historical humidity data, historical daily net radiation data and historical wind speed data; S2. Construct a machine learning model, train the machine learning model based on the pretreated historical related data and the Bayesian-k fold cross-validation method, and obtain a target underground water level prediction model; S3. Predict the underground water level by the target underground water level prediction model.
[0005] The machine learning-based underground water level prediction method provided by the application comprehensively considers multiple influencing factors of underground water level change by including historical underground water level data and historical meteorological data in the historical related data used for modeling, so that the law of underground water level change can be more comprehensively captured, and the prediction accuracy and reliability of the underground water level prediction model are improved. Secondly, the machine learning model is trained based on the pretreated historical related data and the Bayesian-k fold cross-validation method to obtain a target underground water level prediction model, so that features can be further extracted and nonlinear modeling can be performed, so that the complex relationship in underground water level change can be better captured, and the prediction accuracy of the underground water level prediction model is further improved. BRIEF DESCRIPTION OF DRAWINGS
[0006] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the embodiments will be briefly introduced as follows. Obviously, the drawings in the following description are only some embodiments of the present application, and all other drawings obtained by those of ordinary skill in the art without creative effort based on the drawings are within the scope of protection of the present application.
[0007] Figure 1 A flow chart of a groundwater level prediction method in an embodiment; Figure 2 A result graph of groundwater level autocorrelation and partial autocorrelation analysis in an embodiment; FIG. 3(a) is a schematic diagram of a groundwater level prediction framework in an embodiment; FIG. 3(b) is a schematic diagram of a groundwater level prediction framework in another embodiment; Figure 4 A comparison graph of groundwater level training set prediction results and measured results in an embodiment; Figure 5 A comparison graph of groundwater level test set prediction results and measured results in an embodiment; Figure 6 A SHAP value distribution graph of groundwater level feature variables without feature screening in an embodiment; Figure 7 A SHAP value distribution graph of screened groundwater level feature variables in an embodiment. DETAILED DESCRIPTION
[0008] The technical solutions in the embodiments of the present application will be described clearly and completely in combination with the drawings in the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, not all. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of the present application.
[0009] It should be noted that all directional indications (such as up, down, left, right, front, back, etc.) in the embodiments of the present application are only used to explain the relative positional relationship, movement condition, etc. between components in a certain posture (as shown in the drawings), and if the certain posture changes, the directional indications will also change accordingly.
[0010] In addition, the description involving "first", "second" and the like in the present application is only for the purpose of description, and cannot be understood as indicating or implying the relative importance of the indicated technical features or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first", "second" can be explicitly or implicitly included at least one of the features. In addition, "and / or" throughout the text includes three schemes, taking A and / or B as an example, including A technical solution, B technical solution, and A and B simultaneously meet the technical solution; in addition, the technical solutions of each embodiment can be combined with each other, but it must be based on the realization of the technical personnel in the art, when the combination of technical solutions appears contradictory or cannot be realized, it should be considered that the combination of technical solutions does not exist, nor in the protection scope required by the present application.
[0011] In the research of groundwater level prediction, the traditional numerical model needs accurate hydrological parameters (permeability coefficient, specific yield), and it is difficult to obtain actual data. The time series method is difficult to handle nonlinear relationship and difficult to capture complex pattern changes. The deep learning model automatically learns the nonlinear relationship between water level and meteorology / human activity without manual definition of equation.
[0012] The traditional numerical model such as MODFLOW requires extremely high computing power to calculate long-period dynamics, and the error accumulates with the step length. The deep learning method (such as recurrent neural network LSTM) naturally remembers the historical state, and BTimesNet further captures the inter-period dependence (such as 12-month period) through two-dimensional time reconstruction, and the prediction step length is extended to 4-12 months. The traditional method (Kriging method) relies on spatial interpolation, and the accuracy is low under sparse data. The deep learning method can integrate meteorological (precipitation P, evapotranspiration ET), exploitation amount, remote sensing image and other multi-dimensional features to improve the prediction robustness.
[0013] The traditional numerical simulation (such as MODFLOW) transient simulation needs several hours to several days, while the artificial intelligence method based on machine learning shortens the prediction response time to minutes after accelerated training by GPU.
[0014] As shown in Figure 1 Based on this, the present application provides a groundwater level prediction method based on machine learning, which comprises the following steps: S1. Obtain the historical related data of the measured groundwater, and pretreat the historical related data; the historical related data at least includes historical groundwater level data and historical meteorological data; the historical meteorological data at least includes historical precipitation data, historical evapotranspiration data, historical temperature data, historical humidity data, historical daily net radiation data and historical wind speed data; S2. Construct a machine learning model, train the machine learning model based on the pretreated historical related data and the Bayesian-k-fold cross-validation method, and obtain a target groundwater level prediction model; S3. predicting the groundwater level by the target groundwater level prediction model.
[0015] The groundwater level prediction method based on machine learning provided by the application comprehensively considers multiple influencing factors of groundwater level change, so that the law of groundwater level change can be more comprehensively captured, and the prediction accuracy and reliability of the groundwater level prediction model are improved. Secondly, the machine learning model is trained based on the preprocessed historical related data and the Bayesian-k fold cross-validation method to obtain the target groundwater level prediction model, so that the features can be further extracted and nonlinear modeling can be performed, so that the complex relationship in the groundwater level change can be better captured, and the prediction accuracy of the groundwater level prediction model is further improved.
[0016] In an embodiment, step S1 comprises: S11. The missing values in the historical related data are filled by using the mean filling method, the interpolation method or the trend method, and the noise in the filled historical related data is identified and removed by using the clustering algorithm. Specifically, the missing values in the historical related data are filled by using the mean filling method, the interpolation method or the trend method, so that the filled data has randomness and uncertainty, and can better reflect the true distribution of the unknown data. The noise in the filled historical related data is identified and removed by using the clustering algorithm, so as to identify the defects in the data filling process, improve the data quality and consistency, and enhance the reliability of subsequent data analysis and modeling.
[0017] Specifically, the mean filling method refers to replacing the missing values with the mean value of the characteristics, which is suitable for numerical data, small missing proportion and data approximately obeying normal distribution. The specific steps of filling the missing values by using the mean filling method include: calculating the average value of the non-missing values in the characteristic column in advance, and then replacing all the missing values with the average value.
[0018] The specific formula involved in the mean filling method is as follows: ; Wherein, represents the average value of the characteristic sequence; represents the characteristic value in the characteristic sequence; and N represents the length of the characteristic sequence.
[0019] The interpolation method refers to using the adjacent point relationship of the existing data to calculate the missing values by using a mathematical model (such as linear, polynomial), and the commonly used methods include linear interpolation, piecewise spline and polynomial interpolation. The linear interpolation method is selected for the part of the missing data in the application, which is simple and fast, and can also preserve the local data characteristics.
[0020] The specific formula involved in the interpolation method is as follows: ; wherein, represents the feature sequence value inserted at time t; represents the feature sequence value relative to the previous time of t; represents the feature sequence value relative to the next time of t.
[0021] It should be noted that for large missing data, the trend method can be used to fill in the missing values. The specific steps of filling in the missing values by the trend method include: 1) fitting the trend model of the existing values; 2) estimating the value of the missing position by the trend model; and 3) filling in the missing data with the predicted value.
[0022] Clustering algorithm: the objective of the K-means clustering algorithm is to minimize the Within-Cluster Sum of Squares (WCSS), and the specific formula is as follows: ; wherein, represents the jth family, = represents the family center, J represents the sum of squares of distances of all sample points to the cluster center to which they belong, X i represents the ith data point, K represents the number of clusters preset, represents the distance between the data point X i and the cluster center μ j .
[0023] Noise elimination method: if the distance of a point to the nearest cluster center is much larger than the average distance, or it belongs to a particularly small cluster, it can be determined as noise.
[0024] The formula involved in the noise condition judgment is: ; wherein τ is a threshold value.
[0025] S12. Normalize the historical related data after noise elimination to obtain the preprocessed historical related data. Normalization is to scale the data of different indicators to the same scale range, so as to eliminate the influence of the dimension of data characteristics, avoid that some indicators have too great influence on the prediction result, and better perform data processing and model training.
[0026] The specific formula involved in the normalization processing is as follows: ; wherein represents the normalized value, represents the original value, represents the minimum value of the feature sequence, represents the maximum value of the feature sequence.
[0027] In an embodiment, step S2 comprises: S21. applying at least one of autocorrelation analysis, partial autocorrelation analysis, maximum correlation-minimum redundancy algorithm and extreme random tree algorithm to the preprocessed historical correlation data for feature screening, and taking the screened feature data set as the input feature of the machine learning model to improve the simulation accuracy and operation efficiency of the groundwater level prediction model.
[0028] Specifically, in the machine learning modeling of time series, identifying the lag period of groundwater level is a basic task to determine the influencing factors of groundwater level, and the data with strong correlation is taken as the input feature, and the weak or redundant features are removed. Lag refers to the time interval between the current time and the value at a certain time in time series data, which is widely used in time series prediction, signal processing, causal analysis and other fields.
[0029] The effective lag period of groundwater level can be calculated using autocorrelation function (ACF) and partial autocorrelation function (PACF). Autocorrelation function measures the linear correlation between the sequence itself and its lag version, and partial autocorrelation function measures the correlation between the current value and its lag k (lag k represents the sequence data with lag k days), excluding the influence of intermediate lags. The formula of autocorrelation function is as follows: Autocorrelation coefficient of lag k: ; Where: ; ACF represents autocorrelation coefficient, Cov(k) is the covariance of lag k, Var(X) represents the variance of sequence data.
[0030] The partial autocorrelation function measures the direct correlation between the sequence data and its lag k after excluding the influence of intermediate lags, and the partial autocorrelation coefficient is usually denoted as , The formula of partial autocorrelation function is as follows: ; Under the given condition , ,… , , The estimation of the partial autocorrelation coefficient can be achieved by the sample partial autocorrelation coefficient, which is achieved by replacing the value of p in the Yule-Walker equation with r, and then calculating for k = 1, 2, …, the Yule-Walker equation involved in the calculation of the partial autocorrelation coefficient is as follows: ; Finally, the value of is obtained by using Cramer's rule.
[0031] When > 0, it indicates that the parameter is positively correlated with the groundwater level; when < 0, it indicates that the parameter is negatively correlated with the groundwater level. The parameters with <-0.2 are considered to have relevance.
[0032] As shown in Figure 2 , in an embodiment, autocorrelation and partial autocorrelation analysis of the groundwater level is performed using the autocorrelation function (ACF) and the partial autocorrelation function (PACF), specifically, the autocorrelation function (ACF) is used to measure the correlation between the groundwater level sequence and its lag version, if the autocorrelation function (ACF) cannot directly reflect the difference between different lag periods of the groundwater level (for example, the autocorrelation coefficients are far beyond the confidence interval), then further analysis using the partial autocorrelation function (PACF) is required, after analysis using the partial autocorrelation function (PACF), the important lag periods of 1 to 3 days are obtained.
[0033] Specifically, Figure 2 the upper left subgraph of the figure represents the autocorrelation analysis diagram of the water level sequence in an embodiment, from the autocorrelation coefficient result, it can be found that after setting the lag period to 30 days, the groundwater level of each lag period exceeds the confidence interval, such a result does not represent that the autocorrelation of the water level of each lag period is extremely strong. Therefore, further analysis using the partial autocorrelation is required, Figure 2 the upper right subgraph of the figure represents the autocorrelation analysis diagram of the water level sequence in an embodiment, the result shows that the correlation of the lag periods of 1 day, 2 days and 3 days significantly exceeds the lag interval, thus the lag groundwater level that significantly exceeds the confidence interval can be included in the input parameter. Figure 2 The lower subgraph of the figure represents the daily groundwater level diagram in an embodiment, the daily groundwater level is the target variable to be predicted in the model training.
[0034] The mRMR method (Minimum Redundancy Maximum Relevance) is a feature selection method that considers both the correlation between features and output variables and the redundancy between features. The core idea contains two parts: maximum relevance and minimum redundancy. Maximum relevance means that the selected features should have as much relevance as possible to the target variable (i.e., the fitted value) c. The mutual information method is commonly used to measure it, and the specific formula is as follows: ; wherein, represents the average value of all mutual information values between the feature and the fitted value c; is the i-th parameter feature; S is the current selected feature subset; represents the mutual information between the feature and the fitted value c.
[0035] Minimum redundancy means that the redundancy between the selected features should be as small as possible to avoid selecting highly correlated duplicate features.
[0036] ; wherein, is the average value of all mutual information values between the feature and the feature ; is the i-th parameter feature; is the j-th parameter feature.
[0037] The mRMR method combines maximum relevance and minimum redundancy to pursue both "high relevance" and "low redundancy".
[0038] ; In this embodiment, the mRMR method is used to perform maximum relevance-minimum redundancy analysis on the groundwater level and each meteorological feature variable (including lag period) to select the top-ranked feature variables, and the determined lagged groundwater level is used to form a new input feature dataset.
[0039] Extra Trees (Extremely Randomized Trees) is an ensemble learning algorithm based on decision trees. It further reduces model variance and improves generalization ability by increasing randomness, especially in high-dimensional data and noisy scenarios. In specific implementation, the importance score of each feature variable can be calculated by the Extra Trees algorithm, then the feature importance can be sorted according to the importance score of each feature variable, and the target feature variable can be selected based on the sorting result.
[0040] The Extra Trees algorithm includes the following steps: Initialization parameters: Set the number of trees K, the number of features randomly selected for each node m (m= (where d is the total characteristic number). Construct K decision trees: Use all training data for each decision tree; Randomly select m features as candidate splitting features. For each candidate feature, randomly generate a splitting point s within its value range [min(f), max(f)]. Divide the current node sample into a left child node (xf ≤ s) and a right child node (xf > s) according to the splitting point. Repeat the splitting process until the number of node samples is less than the threshold or the maximum depth is reached. The final feature importance score is the average of all trees.
[0041] ; Among them, T k (x) represents the feature importance score.
[0042] In some embodiments, step S2 further includes: S22. Use the Bayesian k-fold cross-validation method to optimize the hyperparameters of the machine learning model and select the optimal model parameters; S23. Divide the selected feature dataset into training and test sets according to a certain ratio. Input the training set into the machine learning model with selected parameters for training to obtain the target groundwater level prediction model. Use the test set to evaluate the accuracy of the target groundwater level prediction model.
[0043] Specifically, the machine learning models include Support Vector Machine (SVM) and GBDT models. The SVM model can be constructed using a Radial Basis Function (RBF) kernel, and the hyperparameters of the machine learning model can be optimized using the Bayesian k-fold cross-validation method to select the optimal model parameters. The selected feature variable set and groundwater level can be divided into training and test sets in an 8:2 ratio. The divided training set is fed into the machine learning model for inner loop training, and the trained model is saved. This model is the target groundwater level prediction model, and the test set is used to evaluate the model accuracy.
[0044] Referring to Figures 3(a) and 3(b), Figure 3(a) is a schematic diagram of the groundwater level prediction framework in one embodiment; Figure 3(b) is a schematic diagram of the groundwater level prediction framework in another embodiment. The feature variables precipitation (P), temperature (T), net daily radiation (Rn), humidity (HD), evapotranspiration (ET), wind speed (WIN), and historical groundwater level (LT) are selected by combining autocorrelation analysis (ACF), partial correlation analysis (PACF), and maximum correlation-minimum redundancy (RMR). The selected features and target sequences are used as input data and fed into the support vector machine (SVM) model and the GBDT model for training, respectively. At the same time, the Bayesian k-fold cross-validation optimization method is used to optimize the model hyperparameters to obtain the optimal hyperparameter set. Based on the optimized hyperparameter set, the corresponding machine learning model is trained to obtain the target groundwater level prediction model. Finally, the contribution of each feature predicted by the target groundwater level prediction model is evaluated by the SHAP analysis method described later.
[0045] It should be noted that the difference between the Support Vector Machine (SVM) model and the GBDT model is that the SVM model is essentially a linear model, which can use the kernel trick to handle nonlinear problems and is suitable for small to medium-sized data. On the other hand, the GBDT model is essentially a nonlinear model, which can naturally handle complex nonlinear relationships and is suitable for large-scale data.
[0046] For details, please refer to Figure 4 and Figure 5 , Figure 4 This is a comparison chart of the predicted and measured results of groundwater level training set in one embodiment. The comparison shows that the model exhibits excellent performance on the test set, while the model is on the training set. Figure 5 This is a comparison chart of the predicted and measured results of the groundwater level test set in one embodiment. The comparison results show that the predicted value deviates slightly from the actual value (measured value), but the overall trend is basically the same, and the model shows good performance on the training set.
[0047] The Bayesian-k-fold cross-validation method is a coupled method of Bayesian optimization and K-fold cross-validation. The coupling steps are as follows: First, the training data is divided into k folds. Then, k-1 folds are used as the training set and input into the machine learning model. The remaining 1 fold is used as the validation set for validation. This process is repeated k times (details are explained below). Finally, the mean result of the k validations is used as the objective function. The Bayesian optimization method is used to optimize the hyperparameters of the objective function to obtain the optimal hyperparameter combination.
[0048] In summary, step S22 includes: Step S221. Perform K-fold cross-validation on the training data using the K-fold cross-training and validation method, and use the validation result as the objective function. Then, optimize the hyperparameters of the objective function using the Bayesian optimization method to obtain the optimal hyperparameter combination. The specific process is illustrated in Figures 3(a) and 3(b). Therefore, this invention optimizes the model's hyperparameters by coupling the Bayesian optimization method with the k-fold cross-training method, which ensures the robustness and efficiency of the hyperparameter optimization process.
[0049] Bayesian optimization is a global optimization algorithm used to optimize computationally expensive, non-differentiable, or black-box functions (such as machine learning model performance). It is particularly suitable for hyperparameter tuning, such as the optimization of hyperparameters in models like SVM, XGBoost, and LSTM. Its core structure consists of three parts: 1. The black-box function to be optimized has the following form: f(x): Rd→R; Rd represents a d-dimensional real vector space, and R indicates that the output is a real number; 2. Surrogate Model; The surrogate model typically uses Gaussian process regression, as shown in the following formula: ; Where m(x)=E[f(x)], which represents the mean function, k(x,x')=E[(f(x)-m(x))(f(x')-m(x')), which represents the covariance function, x represents the point to be predicted, and x' represents the point in the historical observation data.
[0050] A surrogate model is used to approximate the objective function f(x) to reduce computational cost. This invention uses the most commonly used Gaussian process (GP). 3. Acquisition Function, the specific formulas involved are as follows: EI(x,Q)=E Q [max(0,μ Q (x best )-f(x))]; Where, x best μ represents the position where the posterior mean is minimum. Q (x best ) represents the minimum posterior mean; EI(x,Q) represents the expected improvement.
[0051] The specific algorithm flow of the Bayesian optimization method is as follows: (1) Initially sample several points (random or latin hypercube); (2) The above-mentioned collected points are used to train the surrogate model (Gaussian process); (3) Optimize the acquisition function to find the optimal point x. n ; Specifically, the search is based on the expected value EI of the improvement amount. A point with a large EI indicates that the prediction uncertainty at this location is large (i.e., there is a chance to find the maximum value). (4) In f(x) n Real-world evaluation (trained model + computational performance); Specifically, at the optimal point x n Above, the objective function f(x) is actually run once, that is, using the point x. n The corresponding hyperparameters are used to train the model, and then performance metrics are calculated on the validation set. It should be noted that hyperparameters are configuration parameters that need to be manually set before starting to learn the model, and the model refers to the machine learning model to be optimized by hyperparameters.
[0052] (5) Add training data and update the agent model; (6) Repeat steps (2) to (5) until the maximum number of iterations is reached or the objective function converges; Loss function: The loss function is the objective function f(x) optimized by the Bayesian k-fold cross-validation method. The loss function can be the mean squared error (MSE). MSE is a commonly used metric to measure the difference between predicted and true values, widely applied in regression analysis, machine learning, and signal processing. Its core idea is to quantify the overall magnitude of the prediction error; the smaller the value, the more accurate the prediction. When MSE = 0, the prediction is completely accurate. Due to the squared calculation, it is highly sensitive to outliers and suitable for monitoring extreme outliers in predicted water levels.
[0053] Optimizer selection: The optimizer chosen is the Adam algorithm. The Adam algorithm is a deep learning optimization algorithm used in each inner loop during Bayesian k-fold cross-validation. Adam (Adaptive Moment Estimation) is a widely used deep learning optimization algorithm that combines the advantages of momentum and root mean square propagation (RMSProp). It can adaptively adjust the learning rate of each parameter and is suitable for large-scale data and parameter optimization problems.
[0054] K-Fold Cross Validation is a commonly used model evaluation method in machine learning training. Its main purpose is to reduce bias in model evaluation and improve the reliability of model generalization. It avoids the randomness caused by a single partition, and each data point can participate in both training and validation. The specific steps are as follows: Step 1: Subsample Splitting. The training set is further divided into k subsets. Among these subsets, k-1 subsets are merged for model training purposes, while the remaining 1 subset serves as the validation set, specifically for model evaluation.
[0055] Step 2: Cross-validation. Perform one iteration of cross-validation, iteratively using each subset of the k-1 subsets as the training set for model training. Repeat this process k times, where each subset is designated as the validation set in turn. The above iterative process will produce k different models.
[0056] Step 3: Model Evaluation. Evaluate the predictive performance of k models on their respective validation sets, calculate the evaluation metric for each model, and then average these evaluation metrics to obtain the final performance evaluation metric for cross-validation. In the hyperparameter optimization process, this invention uses MSE as the evaluation metric. The MSE of the k-th model is... k And the overall evaluation metric MSE for the entire cross-validation cross The calculation is as follows: ; ; in, This represents the model's predicted value for the groundwater level; This represents the observed groundwater level; n represents the number of samples in the test set.
[0057] Referring to Figures 3(a) and 3(b), the specific principle of the K-fold cross-validation method will be illustrated with an example using K=5: Assume the dataset contains 1000 samples; Division: After random shuffling, the samples were divided into 5 folds, with 200 samples in each fold; Round 1: Fold 1 is used as the validation set, and folds 2-5 are used as the training set → train the model, test it on fold 1, and obtain the evaluation metric MSE1; Round 2: Fold 2 is used as the validation set, and folds 1, 3-5 are used as the training set → train the model, test it on fold 2, and obtain the evaluation metric MSE2; Round 3: Fold 3 is used as the validation set, and folds 1-2 and 4-5 are used as the training set → train the model, test it on fold 3, and obtain the evaluation metric MSE3; Round 4: Fold 4 is used as the validation set, and folds 1-3 and 5 are used as the training set → train the model, test it on fold 4, and obtain the evaluation metric MSE4; Round 5: Fold 5 is used as the validation set, and folds 1-4 are used as the training set → train the model, test it on fold 5, and obtain the evaluation metric MSE5; Summary: Overall evaluation indicators = ; In one embodiment, the machine learning model includes a Support Vector Machine (SVM) model. The SVM model is used for water level prediction. Support Vector Machines are a popular machine learning tool widely used in classification and regression. SVM regression is considered a non-parametric technique because its core relies on a kernel function. In the step of constructing the SVM model, this invention uses the RBF (Gaussian kernel) kernel function as the kernel function. It is the most commonly used kernel function for non-linear data, and its formula is as follows: ; Where, x j , x k Representing two sample vectors, x represents j , x k The Euclidean distance between them is given, and γ represents the kernel parameter. The kernel parameter γ and the penalty parameter C are adjusted using a Bayesian k-fold cross-validation optimization algorithm to achieve optimal parameter selection. The specific process is as follows: (1) Prepare the corresponding dataset: Divide the groundwater level data into training set and test set; (2) Define the parameter space: Define the range of values for the penalty parameter C and the kernel parameter γ (usually search in the logarithmic space, for example, C from 10). -3 Up to 10 3 γ from 10 -3 Up to 10 3 ); (3) Initialize Bayesian optimization: Select several initial points (e.g., randomly select) and calculate their objective function values (i.e., the average MSE of K-fold cross-validation, also known as MSE). cross ); (4) Iterate through the following process: (41) Fit a Gaussian process (surrogate model) using all currently observed parameters and the corresponding objective function values; (42) Select the next evaluation point, which is determined by maximizing the acquisition function (e.g., the desired improvement in EI); (43). Run K-fold cross-validation on the selected parameters (C, γ) to calculate the objective function value (i.e., the average MSE). (44) Add the new parameters and the corresponding MSE to the observation set; (5) Iterate until the predetermined number of evaluations is reached or convergence is achieved; (6) Select the optimal parameters: Select the parameters (C, γ) with the smallest average MSE from the observation set; (7) Train the SVM model on the entire training set using the optimal parameters and evaluate it on the test set.
[0058] In one embodiment, mean square error (MAE), root mean square error (RMSE), and coefficient of determination (R²) are used. 2 Three evaluation indicators are used to assess the accuracy of the target groundwater level prediction model.
[0059] Specifically, mean square error (MAE), root mean square error (RMSE), and coefficient of determination (R²) 2 The calculation formulas are as follows: ; ; ; in, This represents the observed groundwater level. This represents the mean of groundwater level observations; This represents the model's predicted value for groundwater level; n represents the number of test set samples.
[0060] In this embodiment, referring to Table 1, by comparing the model evaluation indicators with and without selected feature variables (including lag periods), it can be found that the performance of each indicator parameter of the SVM model is significantly improved after feature variable selection.
[0061] Table 1: Groundwater level prediction results with and without feature variables selected:
[0062] In one embodiment, step S2 further includes: S24. The SHAP algorithm is used to quantify the contribution of input features to the output of the target groundwater level prediction model.
[0063] Specifically, the SHAP algorithm is an interpretable machine learning model algorithm. Its core objective is to quantify the contribution of input features to the model's output, transforming the decision-making process of a "black box model" into a "quantifiable feature contribution," thus providing crucial support for the model's credibility, security, and optimization. The SHAP value represents the "contribution" of a single feature to the model's final prediction result. SHAP values can be positive or negative. By analyzing SHAP values, the contribution of feature variables to the model's prediction can be determined, allowing us to understand how each feature influences the prediction of the target groundwater level prediction model.
[0064] In this embodiment, the SHAP value is specifically used to reveal the nonlinear relationship between climate characteristics and groundwater level. For example... Figure 6 and Figure 7 As shown, in machine learning prediction scenarios, for a given query point, the SHAP value of a feature can explain the degree to which that feature contributes to the current prediction result (response value in a regression task or class scores in a classification task). The SHAP value reflects the degree to which the predicted value of the query point deviates from the average predicted value due to the presence of that feature. For any query point, the sum of the SHAP values of all features equals the total deviation between that predicted value and the average predicted value. Query point The SHAP value of the i-th feature is defined by the value function v as: ; in, Indicates the features in the SHAP value Average contribution to the overall results; Indicates that only features are included. A single feature set; Represents the total number of all features; A set representing all features; Represents a set The cardinality; It is a query point Corresponding feature set The value function of the set. The value of this function reflects the set's value. Features in the query point Expected contribution of the prediction results.
[0065] Specifically Figure 6 The diagram illustrates the SHAP value distribution of historical groundwater level (t-1) and six meteorological data points (solar radiation, average temperature, reference evapotranspiration, wind speed, humidity, and precipitation) without feature filtering. The results show that historical groundwater level (t-1) has the widest SHAP value distribution, indicating its greatest contribution to model prediction. Specifically, lower historical groundwater level (t-1) significantly reduces predicted values (negative contribution), while higher historical groundwater level (t-1) significantly increases predicted values (positive contribution). This demonstrates strong autocorrelation of groundwater level, making it the core predictive factor of the model. The other six climate factors, without feature filtering, have SHAP values close to zero.
[0066] Figure 7The diagram illustrates the SHAP value distribution of historical groundwater levels (t-1), (t-2), and (t-3) and four meteorological data points (humidity (t-22), solar radiation (t-14), average temperature, and precipitation) after feature filtering. The results show that historical groundwater levels (t-1), (t-2), and (t-3) all make significant contributions to the model's predictions, serving as core predictive factors, with their ranking decreasing sequentially. Furthermore, humidity (t-22) and solar radiation (t-14) rank 3rd and 4th respectively; although their contributions are lower than those of historical groundwater levels, they are not negligible. Humidity (t-22) shows a positive correlation with the contribution, while solar radiation (t-14) shows a negative correlation. This indicates a positive correlation between humidity (t-22) and groundwater level, and a negative correlation between solar radiation (t-14) and groundwater level.
[0067] In summary, groundwater level prediction is a core link in coordinating the "water-ecology-city" system. Machine learning, with its nonlinear modeling, long-term time-series dependence, and multi-source fusion capabilities, has overcome the bottlenecks of traditional methods in terms of accuracy, efficiency, and adaptability. With the development of interpretability enhancement (such as SHAP) and probabilistic prediction (such as the hyperparameter optimization framework of Bayesian-k-fold cross-validation), machine learning is driving water resource management from "passive response" to "active regulation," providing key technical support for addressing water security challenges under global climate change.
[0068] The above are merely preferred embodiments of the present invention and do not limit the scope of the patent. Any equivalent structural transformations made using the contents of the specification and drawings of the present invention under the inventive concept of the present invention, or direct / indirect applications in other related technical fields, are included within the scope of patent protection of the present invention.
Claims
1. A groundwater level prediction method based on machine learning, characterized in that, Includes the following steps: S1. Obtain historical relevant data of the groundwater to be measured, and preprocess the historical relevant data; the historical relevant data includes at least historical groundwater level data and historical meteorological data; the historical meteorological data includes at least historical precipitation data, historical evapotranspiration data, historical temperature data, historical humidity data, historical net daily radiation data, and historical wind speed data; S2. Construct a machine learning model, train the machine learning model based on preprocessed historical relevant data and Bayesian k-fold cross-validation method, and obtain the target groundwater level prediction model; S3. Predict the groundwater level using the target groundwater level prediction model.
2. The groundwater level prediction method according to claim 1, characterized in that, Step S1 includes: S11. Use the mean imputation method, interpolation method or trend method to fill in the missing values in the historical related data, and use a clustering algorithm to identify and remove noise in the completed historical related data; S12. Normalize the historical correlation data after noise removal to obtain the preprocessed historical correlation data.
3. The groundwater level prediction method according to claim 1, characterized in that, Step S2 includes: S21. Apply at least one of autocorrelation analysis, partial autocorrelation analysis, maximum correlation-minimum redundancy algorithm and extreme random tree algorithm to perform feature filtering on the preprocessed historical correlation data, and use the filtered feature dataset as the input features of the machine learning model.
4. The groundwater level prediction method according to claim 1, characterized in that, In step S21, autocorrelation and partial autocorrelation functions are used to perform autocorrelation and partial autocorrelation analysis on the groundwater level. The formulas involved in the autocorrelation function are as follows: The autocorrelation coefficient of lag k: ; in: ; Represents the autocorrelation coefficient. It is the covariance of lag k. Represents the variance of sequence data; The formulas involved in the partial autocorrelation function are as follows: ; Indicates under given conditions , ,… Below, two random variables , The correlation coefficient.
5. The groundwater level prediction method according to claim 3, characterized in that, Step S2 further includes: S22. The machine learning model is optimized using the Bayesian-k-fold cross-validation method to select the optimal model parameters; S23. Divide the selected feature dataset into training and test sets according to a certain ratio. Input the training set into the machine learning model with selected parameters for training to obtain the target groundwater level prediction model. Use the test set to evaluate the accuracy of the target groundwater level prediction model.
6. The groundwater level prediction method according to claim 5, characterized in that, Step S22 includes: S221. Perform K-fold cross-validation on the training data using the K-fold cross-validation method and use the validation result as the objective function. Then, optimize the hyperparameters of the objective function using the Bayesian optimization method to obtain the optimal hyperparameter combination.
7. The groundwater level prediction method according to claim 5, characterized in that, Step S2 further includes: S24. The SHAP algorithm is used to quantify the contribution of input features to the output of the target groundwater level prediction model.
8. The groundwater level prediction method according to claim 1, characterized in that, The machine learning model includes a Support Vector Machine (SVM) model. In the step of constructing the SVM model, the RBF kernel function is used as the kernel function, and the formula is as follows: ; in, , Representing two sample vectors, express , The Euclidean distance between them is given, and γ represents the kernel parameter. The kernel parameter γ and the penalty parameter C are adjusted using the Bayesian-k-fold cross-validation optimization algorithm to achieve the optimal parameter selection.
9. The groundwater level prediction method according to claim 8, characterized in that, The steps for adjusting the kernel parameter γ and penalty parameter C using the Bayesian-k-fold cross-validation optimization algorithm to achieve optimal parameter selection include: (1) Prepare the corresponding dataset: Divide the groundwater level data into training set and test set; (2) Define the parameter space: Define the range of values for the penalty parameter C and the kernel parameter γ; (3) Initialize Bayesian optimization: Select several initial points and calculate their objective function values, where the objective function value is the average MSE obtained by the K-fold cross-validation method; (4) Iterate through the following process: (41) Fit a Gaussian process using all currently observed parameters and their corresponding objective function values; (42) Select the next evaluation point, which is determined by maximizing the acquisition function; (43) Run K-fold cross-validation on the selected parameters C and γ, and calculate the average MSE; (44) Add the new parameters and the corresponding MSE to the observation set; (5) Iterate until the predetermined number of evaluations is reached or convergence is achieved; (6) Select the optimal parameters: Select the parameters C and γ that have the smallest average MSE from the observation set; (7) Train the SVM model on the entire training set using the optimal parameters and evaluate it on the test set.
10. The groundwater level prediction method according to claim 1, characterized in that, The mean square error (MAE), root mean square error (RMSE), and coefficient of determination (R²) were used. 2 Three evaluation indicators are used to assess the accuracy of the target groundwater level prediction model; Among them, mean square error (MAE), root mean square error (RMSE), and coefficient of determination (R²) 2 The calculation formulas are as follows: ; ; ; in, This represents the observed groundwater level. This represents the mean of groundwater level observations; This represents the model's predicted value for groundwater level; n represents the number of test set samples.
Citation Information
Patent Citations
Water chilling unit fault diagnosis method and system based on Bayesian optimization LightGBM, and medium
CN113792762A
Loess landslide slip prediction method and system based on meta-learning and Bayesian optimization
CN117349751A
Underground water level prediction method, equipment and medium
CN118014391A