Machine learning-based tetracycline adsorption capacity prediction method, device, and medium
By employing a multi-model fusion and systematic optimization scheme based on machine learning, the problems of high human and material investment and strong data lag in traditional tetracycline adsorption behavior analysis have been solved. This has enabled high-precision prediction of tetracycline adsorption, supporting wetland pollutant treatment and risk management, and improving the generalization ability and interpretability of the prediction model.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SHANDONG FENGSHI INFORMATION TECH CO LTD
- Filing Date
- 2026-03-30
- Publication Date
- 2026-06-26
AI Technical Summary
In the existing technology, the analysis of tetracycline adsorption behavior relies on on-site sampling tests and batch adsorption experiments, which requires a lot of manpower and resources, has a long experimental cycle, strong data lag, low accuracy of traditional prediction models, and cannot capture the nonlinear coupling effect between multiple factors, resulting in low prediction accuracy, narrow applicability, and information loss due to data processing methods, and weak model generalization ability.
A multi-model fusion and systematic optimization scheme based on machine learning was adopted. By acquiring a dataset of tetracycline adsorbed in the sediment, the data was preprocessed, and the hyperparameters of the machine learning model were optimized using grid search technology. Combined with SHAP feature importance analysis, CatB, RF and XGB models were constructed to achieve accurate prediction of tetracycline in wetland sediment.
It significantly improves the prediction accuracy and stability of tetracycline adsorption capacity in sediment, enabling rapid and accurate identification of high-pollution-risk areas, reducing ecotoxicity and the risk of resistance gene transmission, reducing on-site experimental costs, achieving precise pollutant control, and safeguarding public health and ecological well-being.
Smart Images

Figure CN122290791A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to a method, device, and medium for predicting tetracycline adsorption based on machine learning, belonging to the field of model prediction and pollutant detection and treatment technology. Background Technology
[0002] Tetracycline (TC) is an organic compound that exerts its antibacterial effect by inhibiting bacterial protein synthesis and is effective against a variety of Gram-positive and Gram-negative bacteria, as well as atypical pathogens such as Chlamydia. With the increasing global use of antibiotics, the widespread use of tetracycline (TC) has led to its residues and accumulation in soil, water bodies, and sediments, resulting in ecotoxicity and the spread of antibiotic resistance genes. TC has a long half-life (34-329 h) and is difficult to degrade naturally, thus persisting in the environment for a long time and posing a threat to ecological health. TC is not only detected in surface water but is also widely present in soil and groundwater. Currently, the analysis and determination of tetracycline adsorption are mainly achieved through on-site sampling tests and adsorption kinetics and thermodynamic experiments. Sampling tests require a large investment of manpower and resources, and the data obtained by this method has a lag characteristic; moreover, this method can only analyze the adsorption effect under experimental conditions and cannot predict the adsorption behavior under unexperimented conditions. Wetland sediment is a loose sediment deposited at the bottom or surface of wetland water bodies. It consists of mineral particles, plant and animal remains, microorganisms and their metabolic products, and functions as a source of physical support, nutrient cycling, pollutant adsorption and purification, and providing habitat for wetland organisms. Tetracycline residues in wetland sediment may enter the human body through groundwater infiltration, absorption by agricultural products (such as crops grown around wetlands), and accumulation in aquatic products (such as fish farmed in wetlands), posing a potential threat to public health.
[0003] Traditional tetracycline adsorption behavior analysis relies on on-site sampling and batch adsorption experiments, requiring significant manpower (e.g., field sampling, laboratory operations) and resources (e.g., centrifuge tubes, high-performance liquid chromatography, TC solution reagents). The experiments are also time-consuming (batch adsorption experiments alone require 48 hours for oscillation equilibration), resulting in significant data lag. Traditional prediction models can only incorporate a limited number of influencing factors, failing to capture the nonlinear coupling effects between multiple factors. This leads to low prediction accuracy, narrow applicability, and a tendency for "one-size-fits-all" control measures (e.g., over-investing in low-risk areas or under-managing high-risk areas), making it difficult to meet the needs of different types of wetland pollution assessment. Currently, in tetracycline adsorption behavior prediction technologies, data processing often involves simply deleting missing and outlier values, resulting in data loss. Model construction lacks standardized optimization and validation processes, leading to weak generalization ability. Summary of the Invention
[0004] The purpose of this invention is to overcome the shortcomings of existing technologies and provide a method for predicting tetracycline adsorption capacity based on machine learning. Through multi-model fusion and systematic optimization, the prediction accuracy and stability of tetracycline adsorption capacity in sediment are significantly improved.
[0005] The technical solution adopted in this invention is as follows: The method for predicting tetracycline adsorption based on machine learning includes the following steps: S1. Obtain the dataset of tetracycline adsorption in sediment and distinguish between the input variables and output variables of the dataset. The input variables include the molecular and solid descriptive properties of the sediment, and the output variables include the water-soil partition coefficient of tetracycline in the sediment. S2. Perform data preprocessing on the dataset of tetracycline adsorbed in the sediment to obtain the preprocessed dataset; S3. Using grid search technology, multiple machine learning models are hyperparameter optimized and trained using a preprocessed dataset. The optimal machine learning model is selected by evaluating each model. The machine learning models include CatB model, RF model and XGB model. S4. Based on the optimal machine learning model, perform SHAP feature importance analysis to obtain the importance ranking of input features affecting adsorption capacity prediction, and obtain the feature importance index of the dataset. S5. Using the optimal machine learning model, the water and soil distribution coefficient of tetracycline in wetland sediment is predicted with importance index features as input.
[0006] In the above method, the molecular descriptive properties in step S1 include pH value, OM (%), TN (μg / mg), and TP (μg / mg); the solid descriptive properties include D 50 (μm), Clay (%), Powder (%), Sand (%), and the output variables of the dataset include the soil-water distribution coefficient of sediment to tetracycline.
[0007] In step S3, the evaluation metrics for model selection are the prediction determination coefficient and the mean squared error. The closer the determination coefficient is to 1 and the smaller the mean squared error, the better the model is.
[0008] In step S4, the SHAP feature importance analysis first obtains the average absolute SHAP value of each input feature; then, based on the average absolute SHAP value, the importance value of each input feature is calculated (the average value is the feature importance after taking the absolute value of the feature's SHAP value for all samples, and the average value is sorted from largest to smallest) and sorted to obtain the feature importance index of the dataset.
[0009] In step S4, SHAP stands for Shapley additive interpretation. Organic matter Shapley additive interpretation is a model interpretation method based on the Shapley value principle, which fairly allocates input features in an additive manner, thereby quantifying the contribution of each feature to the model prediction results.
[0010] The tetracycline adsorption prediction device based on machine learning includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, it implements the tetracycline adsorption prediction method based on machine learning as described above.
[0011] A computer-readable storage medium storing a program that, when executed by a processor, implements the steps of the machine learning-based tetracycline adsorption prediction method as described above.
[0012] The beneficial effects of this invention are: This invention simultaneously constructs three machine learning models: a gradient boosting tree model (CatB), a random forest (RF), and a gradient boosting model with automatic category feature processing (XGBoost). It then uses grid search technology to systematically optimize the hyperparameters of each model, and through multi-model comparison and selection, determines the optimal prediction model, significantly improving the prediction accuracy and stability of tetracycline adsorption capacity in sediment. Simultaneously, this invention innovatively introduces SHAP feature importance analysis to quantify the contribution of key physicochemical factors such as pH, organic matter, and particle size to the adsorption effect. This achieves efficient and accurate prediction while ensuring the interpretability of the model mechanism, overcoming the technical bottleneck of "black box prediction" in traditional methods. Compared with single models and conventional parameter settings, the multi-model fusion and systematic optimization scheme adopted in this invention achieves unexpected technical results. The optimal model has a higher prediction determination coefficient (R²), more complete data utilization, and stronger generalization ability, enabling rapid, accurate, and interpretable prediction of tetracycline adsorption in sediment. This provides reliable technical support for wetland tetracycline pollution control and water environment risk management, demonstrating outstanding creativity and practicality.
[0013] This invention integrates multi-source data to construct a machine learning model optimized by grid search, which can accurately predict the tetracycline water-soil distribution coefficient in wetland sediments and quantify the contribution of key factors. Environmentally, it can identify high-pollution-risk areas in advance, reduce ecotoxicity and the spread of resistance genes, avoid persistent pollution, and maintain wetland ecological balance. Economically, it eliminates the need for extensive field experiments, significantly reducing research costs, enabling precise control, avoiding resource waste, and improving governance efficiency. Socially, it establishes a standardized prediction process, improves the environmental protection technology system, and simultaneously reduces the spread of pollutants into the living environment, protecting public health and ecological well-being, and meeting the demand for a beautiful ecological environment. Attached Figure Description
[0014] Figure 1 This is a flowchart of the method of the present invention; Figure 2 To fill in the gaps in the data and identify the differences before and after; Figure 3 These are the evaluation parameters for the three models; Figure 4 Rank the importance of the SHAP input parameters for the three models. Detailed Implementation
[0015] The present invention will be further described below with reference to specific embodiments.
[0016] Example 1: A method for predicting tetracycline adsorption based on machine learning, including the following steps (e.g.) Figure 1 )as follows: S1. Obtain the dataset of tetracycline adsorption in the sediment and distinguish between the input variables and output variables of the dataset: Specifically, the input variables of the dataset include molecular descriptive properties and solid descriptive properties of the sediment. The molecular descriptive properties include pH value, organic matter content (OM) (%), total nitrogen content (TN) (μg / mg), and total phosphorus content (TP) (μg / mg); the solid descriptive properties include particle size D. 50 The dataset includes the following output variables: (μm), clay content (Clay%), silt content (Powder%), and sand content (Sand%). These variables include the sediment-to-tetracycline water-soil distribution coefficient (K). d ).
[0017] In this embodiment, to achieve accurate prediction of adsorption capacity, a raw dataset containing 199 data points was constructed. This dataset is composed of two parts: experimental data from published literature (99 data points) and data obtained by the inventors through adsorption experiments (100 data points). In the experimental data from published literature, the input and output data were directly extracted from the tables in the published literature.
[0018] The water-soil distribution coefficient of adsorbed TC in the sediment and the physicochemical properties of the sediment were obtained through batch adsorption experiments and chemical analysis experiments, specifically: The physicochemical properties of sediment were determined according to national standards. The measured indicators included: TC content (μg / g), pH value, OM (%), TN (μg / mg), TP (μg / mg), and D. 50(μm), Clay (%), Powder (%), and Sand (%). The determination of TC content was to confirm that the TC originally present in the sediment did not affect the adsorption experiment. Batch adsorption experiments were conducted as follows: 50 mL of TC solutions with concentrations of 10, 15, 20, 25, and 30 mg / L were added to glass centrifuge tubes containing 0.1 g of dried sediment, along with 0.01 mol / L NaCl and 100 mg / L NaN3. After light protection, the tubes were placed in a shaking incubator at 25°C and 160 r / min for 48 h (equilibrium time). After the adsorption experiment, the concentration of TC in the solution was determined by high-performance liquid chromatography (HPLC). The experimental data were used to fit a linear isothermal model to obtain the soil-water distribution coefficient (K). d ).
[0019] S2. Preprocess the dataset of tetracycline adsorbed in the sediment to obtain the preprocessed dataset: Specifically, missing values in the dataset are imputed to generate multiple complete datasets; then, statistical analysis is performed on each complete dataset, and the results are merged using Rubin rules to obtain the preprocessed dataset.
[0020] In this embodiment, R language is first used as the programming tool, and the "mice" function in R is used for multiple imputation to handle missing values in the dataset; the imputation is then validated using box plots and the KS test. The box plots of the dataset before and after imputation are shown below. Figure 2 As shown, there was no significant shift in the median or mean. The KS test results indicate that the p-values for the variables “TN”, “TP”, “pH”, “D50”, “OM”, “Clay”, “Powder”, and “Sand” were 0.3197, 0.9999, 0.9889, 1.0000, 1.0000, 1.0000, 1.0000, and 1.0000, respectively, all greater than 0.05, showing no significant difference. This suggests that the data inserted using the multiple imputation method could not reject the null hypothesis, meaning the imputed data did not distort the true distribution of the original numbers.
[0021] Further data preprocessing is performed by using the function "createDataPartition" in the "caret" package to divide 70% of the data into a training set for training the model and 30% as a test set for testing the model's accuracy.
[0022] This invention uses the mean imputation method to handle missing values, ensuring data integrity; by dividing the dataset through stratified sampling and combining it with grid search to optimize model hyperparameters, the stability and reliability of the model are improved, giving it strong practical application value.
[0023] S3. Using grid search technology, multiple machine learning models are hyperparameter optimized and trained on a preprocessed dataset. The optimal machine learning model is then selected through evaluation of each model. Specifically, machine learning models are acquired, including simultaneously constructing a gradient boosting tree model (CatB), a random forest (RF), and an automatically processed category feature gradient boosting model (XGBoost). A grid search method is introduced to systematically tune the key hyperparameters of the CatB model. By evaluating all combinations within a predefined parameter range, the optimal configuration of the model is determined, and the trained CatB model is output. Similarly, a grid search method is introduced to systematically tune the key parameters of the RF model. By evaluating all combinations within a predefined parameter range, the optimal configuration of the model is determined, and the trained RF model is output. The grid search method is also introduced to systematically tune the key hyperparameters of the XGBoost model. By evaluating all combinations within a predefined parameter range, the optimal configuration of the model is determined, and the trained XGBoost model is output. The determination coefficients R0 of the test set for the trained CatB model, the trained RF model, and the trained XGBoost model are obtained respectively. 2 The trained RF model is compared with the root mean square error value and selected as the optimal model. 2 The machine learning model that is closest to 1 and has the smallest root square error.
[0024] In this embodiment, the development and establishment of the machine learning model involves selecting CatB, XGB, and RF from the ML (machine learning) model to predict the adsorption capacity of tetracycline in the sediment. The parameters related to the ML model algorithm are optimized to find the best set of hyperparameters. Specifically, the optimal hyperparameters are obtained through grid search technology, and the evaluation index is specified as negative mean square error.
[0025] The fine-tuned hyperparameters include n_estimators (100, 120, 150), max_depth (3, 5, 7, None), min_samples_split (2, 4, 6), min_samples_leaf (1, 2, 4), and max_features('auto', 'sqrt', 'log2') for the RF model; n_estimators (100, 200, 400, 500), max_depth (3, 5, 10, 15), min_child_weight (1, 3, 5), and learning_rate (0.01, 0.05, 0.1) for the XGB model; and iterations (100, 200, 300), depth (4, 5, 6), learning_rate (0.01, 0.05, 0.1), and l2_leaf_reg for the CATB model. (1, 3, 5). The optimal hyperparameters for the ML model are summarized in Table 1.
[0026] Table 1. Optimal hyperparameter data for the three ML models .
[0027] Furthermore, model evaluation is performed, assessing the R-values of each model on both the training and test sets. 2 And RMSE, where the RF model training set R 2 =0.89, RMSE=0.32, test set R 2 =0.65, RMSE=0.48; XGB model training set R 2 =0.96, RMSE=0.15, test set R 2 =0.59, RMSE=0.73; CATB model training set R 2 =0.89, RMSE=0.55, test set R 2 =0.32, RMSE=0.54. Based on the performance on the test set, the RF model shows the best performance. The scatter plot of the model's predicted values versus actual values is shown below. Figure 3 As shown.
[0028] S4. Based on the optimal machine learning model, perform SHAP feature importance analysis to obtain the ranking of the importance of input features in predicting adsorption capacity, and obtain the feature importance index of the dataset: Specifically, based on the optimal machine learning model, SHAP feature importance analysis is performed to obtain the mean absolute SHAP value for each input feature. The importance value of each input feature is then calculated based on the mean absolute SHAP value and ranked to obtain the feature importance index of the dataset. In this embodiment of the invention, SHAP feature importance analysis is first performed. Based on the constructed RF model, the contribution (SHAP value) of each feature to the model's prediction results is evaluated, and the importance value of each feature is calculated based on the mean absolute SHAP value. The results are as follows... Figure 4 As shown, the order of importance is as follows: OM > pH > Clay > TN > TP > D 50 >Powder > Sand. Therefore, when evaluating the adsorption effect of tetracycline on sediment seeds, it is necessary to focus on the organic matter content and pH of the sediment.
[0029] In summary, the RF prediction model established in this embodiment of the invention exhibits excellent performance (test set R). 2 =0.65, RMSE=0.48). Furthermore, the adsorption design and experimental conditions were further optimized through SHAP eigenvalue importance analysis. The eigenvalue importance analysis revealed the priority order of input feature types as: OM > pH > Clay > TN > TP > D. 50 >Powder>Sand. This example provides valuable assistance for predictive modeling research on pollutant adsorption in aquatic environments.
[0030] S5. Using the optimal machine learning model, the water and soil distribution coefficient of tetracycline in wetland sediment is predicted with importance index features as input.
[0031] Example 2: Tetracycline adsorption prediction device based on machine learning, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, it implements the tetracycline adsorption prediction method based on machine learning as described in Example 1.
[0032] A computer-readable storage medium storing a program that, when executed by a processor, implements the steps of the machine learning-based tetracycline adsorption prediction method as described in Example 1.
[0033] The above is a further description of the present invention in conjunction with specific embodiments, and the scope of protection of the present invention is not limited thereto.
Claims
1. A method for predicting tetracycline adsorption based on machine learning, characterized by: The steps include the following: S1. Obtain the dataset of tetracycline adsorption in sediment and distinguish between the input variables and output variables of the dataset. The input variables include the molecular and solid descriptive properties of the sediment, and the output variables include the water-soil partition coefficient of tetracycline in the sediment. S2. Perform data preprocessing on the dataset of tetracycline adsorbed in the sediment to obtain the preprocessed dataset; S3. Employing grid search technology, various machine learning models are hyperparameter optimized and trained using a preprocessed dataset, and the optimal machine learning model is selected through evaluation of each model. S4. Based on the optimal machine learning model, perform SHAP feature importance analysis to obtain the importance ranking of input features affecting adsorption capacity prediction, and obtain the feature importance index of the dataset. S5. Using the optimal machine learning model, the water and soil distribution coefficient of tetracycline in wetland sediment is predicted with importance index features as input.
2. The method for predicting tetracycline adsorption capacity based on machine learning according to claim 1, characterized in that, The machine learning models include the synchronously constructed gradient boosting tree model CatB, random forest RF, and the gradient boosting model XGBoost that automatically processes class features.
3. The method for predicting tetracycline adsorption based on machine learning according to claim 1, characterized in that, The molecular descriptive properties described in step S1 include pH value, organic matter content (OM), total nitrogen content (TN), and total phosphorus content (TP); the solid descriptive properties include particle size (D). 50 The dataset includes clay content (Clay), silt content (Powder), and sand content (Sand). The output variables of the dataset include the soil-water distribution coefficient of sediment to tetracycline.
4. The method for predicting tetracycline adsorption capacity based on machine learning according to claim 1, characterized in that, In step S3, the evaluation metrics for model selection are the prediction determination coefficient and the mean squared error. The closer the determination coefficient is to 1 and the smaller the mean squared error, the better the model.
5. The method for predicting tetracycline adsorption capacity based on machine learning according to claim 1, characterized in that, In step S4, the SHAP feature importance analysis first obtains the average absolute SHAP value of each input feature; then, based on the average absolute SHAP value, the importance value of each input feature is calculated and sorted to obtain the feature importance index of the dataset.
6. A machine learning-based device for predicting tetracycline adsorption, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the tetracycline adsorption prediction method based on machine learning as described in any one of claims 1-5.
7. A computer-readable storage medium on which a program is stored, characterized in that, When the program is executed by the processor, it implements the steps of the machine learning-based tetracycline adsorption prediction method as described in any one of claims 1-5.