Skip to main content

Discussion on machine learning technology to predict tacrolimus blood concentration in patients with nephrotic syndrome and membranous nephropathy in real-world settings



Given its narrow treatment window, high toxicity, adverse effects, and individual differences in its use, we collected and sorted data on tacrolimus use by real patients with kidney diseases. We then used machine learning technology to predict tacrolimus blood concentration in order to provide a basis for tacrolimus dose adjustment and ensure patient safety.


This study involved 913 hospitalized patients with nephrotic syndrome and membranous nephropathy treated with tacrolimus. We evaluated data related to patient demographics, laboratory tests, and combined medication. After data cleaning and feature engineering, six machine learning models were constructed, and the predictive performance of each model was evaluated via external verification.


The XGBoost model outperformed other investigated models, with a prediction accuracy of 73.33%, F-beta of 91.24%, and AUC of 0.5531.


Through this exploratory study, we could determine the ability of machine learning to predict TAC blood concentration. Although the results prove the predictive potential of machine learning to some extent, in-depth research is still needed to resolve the XGBoost model’s bias towards positive class and thereby facilitate its use in real-world settings.

Peer Review reports


Tacrolimus (TAC, FK506) is a new immunosuppressant that functions by inhibiting the activity of calcineurin and interfering with T cell activation and cytokine transcription after binding to intracellular FK binding protein. Recent studies have shown that TAC is effective in the treatment of a variety of chronic kidney diseases [1, 2]. However, its narrow treatment window, high toxicity, adverse effects, and individual differences in pharmacokinetics and pharmacodynamics have hindered its application in clinical treatment. Therefore, in clinical use, monitoring the blood concentration, adjusting the treatment plan, and administering individualized dosages of TAC are necessary to achieve the best treatment effect [3].

Real-world medical data are widely stored in hospital information systems, which include comprehensive diagnostic and treatment information. The optimization, upgrading, and popularization of hospital information systems not only provide a basis for the medical treatment of patients but also supply real-world data for retrospective research. Machine learning (ML) is a set of computer algorithms driven by data [4]. Its algorithms include the following: artificial neural network, decision tree, random forest, and support vector machine. ML is suitable for analyzing and mining real-world data in enormous quantities, high dimensions, complex relationships, and diverse forms. The rapid speed and strong generalizability of ML support its wide use in clinical decision-making. The application of ML algorithms to individualized medicine will aid in the understanding of precision medicine in clinical practice [5, 6]. The purpose of this study was to explore the influencing factors of TAC blood concentration in real-world settings using ML technology to predict TAC blood concentration and assist clinicians in adjusting TAC dosage, ensuring patient safety, and reducing adverse drug reactions.


Study population

The data of patients with nephrotic syndrome and/or membranous nephropathy treated with TAC in PLA General Hospital from January 1, 2013, to December 31, 2020, were collected retrospectively. The inclusion criteria were as follows: (1) diagnosis of nephrotic syndrome or membranous nephropathy; and (2) administration of TAC during hospitalization. The exclusion criteria were as follows: (1) use of TAC only during surgery; (2) TAC administration by skin test; and (3) patients with any missing data. This study was approved by the Ethics Committee of the Chinese People's Liberation Army General Hospital [S2022-278–01].

The data mining and modeling processes are shown in Fig. 1. Following the cleaning step, the final data set comprised 913 patients and the blood TAC concentrations from 1829 blood tests. Data from January 1, 2013, to December 31, 2019, including 821 patients and 1,649 blood tests, were randomly divided into a training set and a test set at an 8:2 ratio. The data from January 1, 2020, to December 31, 2020, including 115 patients and 180 blood tests, were used as the external validation set (Fig. 2).

Fig. 1
figure 1

Flow chart of data mining and modeling

Fig. 2
figure 2

Division of datasets

Data extraction

The relevant patient information was extracted from the database, including demographic, laboratory, and medical order information. Demographic information included data on age, sex, height, and weight. The laboratory information included the blood TAC concentrations, serum creatinine levels, sample receiving times, and result indicators. The medical order information included the name of the medication, dose, frequency of administration, and start and end times of the treatment. Because the medical order consisted of long-term information, it was split by frequency and processed into time-series data. To facilitate data processing, we stored patient hospitalization information in a tree structure rather than a two-dimensional table to build the data set (Fig. 3).

Fig. 3
figure 3

Patient information in a tree structure

Data processing

First, data distribution was drawn according to the demographic information, and samples with outliers were deleted. Second, the medication and laboratory information were associated according to time. When there were multiple administrations of TAC before the collection of blood samples, we selected the data from the last TAC administration before sample collection to ascertain the test results matched the corresponding TAC administration. Additionally, a box plot was drawn for the time interval between the last administration and sample-receiving time, and only the samples between quartile 1 (Q1) and quartile 3 (Q3) were reserved to eliminate samples whose medication information was not related to the laboratory information. Seven doses of TAC were administered, and we organized them by the frequency of use as follows: 2.0, 1.0, 1.5, 3.0, 0.5, 2.5, and 4.0 mg.

In terms of combined medication, we extracted information on some of the most commonly prescribed medications by clinicians, including compound α-ketoacid, Shenyankangfu, ShenYanShu, Shenshuaining, Huangkui, Bailing, pidotimod, methylprednisolone, prednisone acetate, mycophenolate mofetil, and tripterygium glycoside. The variables of combined medication were dummy variables. Patients who had used one of these drugs between two blood tests were recorded as 1, and those who did not were recorded as 0.

Although blood concentration is a continuous variable, it was treated as a dummy variable in this study and classified according to the safe range of blood drug concentration [7, 8]. Concentrations were defined as 0 within the safety range, and those outside the safety range were defined as 1.

In this study, the blood concentration ratio of TAC classes 0 to 1 was unbalanced at 3:7. Therefore, we used the over-sampling method, SMOTE (Synthetic Minority Oversampling Technique), to balance the data. The core of SMOTE is to insert randomly generated new samples between those of minority and adjacent categories to increase the number of minority categories and improve the unbalanced distribution of the data set [9]. As XGBoost and LightGBM (LGBM) algorithms have hyperparameters for processing unbalanced data, we directly adjusted the super parameters without additional SMOTE processing of data for these algorithms.

Feature selection

The extracted variables included demographic information (age, sex, height, and weight), laboratory information (numerical results and collection time of blood TAC concentration and serum creatinine levels), medical order information (drug name, medication time, and dose), and medication combinations.

Various tools from different models were used to calculate the importance value of each factor. For example, logistic regression (LR), random forest, and AdaBoost (adaptive boosting) used the eli5 Library in SK-learn to visually display the value of each feature, whereas XGBoost and LGBM used their own algorithms. We removed the features with relatively low importance to reduce the feature dimension, simplify the model, and improve its generalization ability.

Model building

Classification algorithms in supervised learning included LR, artificial neural network, Naïve Bayes, and integration algorithms. In this study, six ML models, LR, random forest, AdaBoost, gradient boost decision tree, XGBoost, and LGBM, were established to classify and predict the blood concentration of TAC. All models except for LR belonged to the Ensemble Algorithms, which integrate several weak classifiers into one strong classifier. The Ensemble Algorithms have rapid speed and strong generalization ability, and they are suitable for application in many fields, including medical diagnosis [10].

In the process of model establishment, Grid Search was used to choose the hyperparameter of the model. Grid Search uses an exhaustive method to train the learner with the hyperparameter in the user-defined range, and then find the optimal value for the hyperparameter within this range. Table 1 lists the core hyperparameters of the six models. In addition, the threshold was continuously adjusted to achieve the best performance of the model.

Table 1 Hyperparameters for models

Model assessment

The evaluation criteria of binary factors generally include accuracy, precision, recall, F-1 score, and area under the curve (AUC) and come from the confusion matrix (Table 2). Accuracy refers to the prediction accuracy of positive sample results and was calculated as follows:

$$\mathrm{Accuracy}=\frac{TP + TN}{TP + TN + FP + FN}$$

where TP is true positive, TN is true negative, FP is false positive, and FN is false negative.

Table 2 Confusion matrix

Recall refers to how many positive samples in the data set are identified and can be calculated as follows:

$$\mathrm{Recall} =\frac{TP}{TP + FN}$$

In the ideal state, accuracy and recall are as high as possible; however, the two factors are inversely related, and a balance must be achieved. Therefore, the F-beta score was used to reflect the comprehensive situation of the model. The F-beta score was calculated using the following formula:

$$F - beta = 1 + \beta^{2} \times \frac{Precision \times Recall }{{\beta^{2} \times Precision + Recall}}$$

where precision is calculated using Eq. 4, \(\beta\) equals 1, and the F-beta score is calculated using Eq. 5.

$$\mathrm{Precision} =\frac{TP}{TP + FP}$$
$$\mathrm{F}1=2\times \frac{Precision \times Recall}{Precision +Recall}$$

When the accuracy and recall are equally important, they are given the same weight, that is, beta = 1 (F-1 score). However, in this study, type II errors were particularly important. Thus, we closely monitored situations in which patients with abnormal blood concentrations were not assessed, which had a negative effect on the treatment outcomes. Type II errors were generally measured by recall. Therefore, in this study, greater weight was given to recall, where beta = 2 (F-2 score). The F-beta score was > 0 and < 1, and the larger the value, the better the performance of the model. Finally, when the AUC was > 0.5, the model was meaningful. AUC can be calculated as follows:

$$\mathrm{AUC} =\frac{1 + TPR - FPR}{2}$$

where true positive rate (TPR) and false positive rate (FPR) are calculated using Eqs. 7 and 8, respectively.

$$\mathrm{TPR} =\frac{TP}{TP + FN}$$
$$\mathrm{FPR} =\frac{FP}{FP + TN}$$


Baseline information

Data from 913 patients and 1829 blood tests were included in this study. The baseline information of the study population is shown in Table 3. Continuous variables are presented as median (interquartile range [IQR]) and categorical variables as frequency (percentage). The median age of the patients in this study was 53 (39–64) years, median weight was 72 (64–80) kg, median height was 170 (162–174) cm, median serum creatinine level was 80.9 (65.8–103.1) μmol/L, and proportion of male patients was 66%. Additionally, the proportion of combined medication was as follows: 8.64% for compound α-ketoacid, 6.01% for Shenyankangfu, 12.30% for ShenYanShu, 6.51% for Shenshuaining, 45.05% for Huangkui, 39.58% for Bailing, 46.53% for pidotimod, 29.36% for methylprednisolone, 16.07% for prednisone acetate, 1.04% for mycophenolate mofetil, and 2.35% for tripterygium glycoside.

Table 3 Baseline information

Model performance

The prediction performance of the six models is shown in Table 4. In terms of accuracy, only XGBoost and LGBM displayed an accuracy of > 70%; the accuracy of XGBoost was higher than that of LGBM at 73.33%. The accuracy of the other models was low, and the effect was poor. We evaluated type II errors through the recall rate. A higher recall rate means that more patients with abnormal blood drug concentrations were correctly predicted, and clinicians can therefore adjust the dosage to reach effective and safe blood drug concentrations. However, when the probability of type II errors was low, the probability of type I errors increased. Therefore, XGBoost performed the best in balancing type I and II errors (F-beta score = 0.9124). In addition, the AUC value of XGBoost was the highest among all models. Therefore, considering the generalization ability and accuracy of the model, we believe that the XGBoost model is ideal for predicting the blood concentration of TAC.

Table 4 Performance of the models

Feature analysis

Table 5 shows the performance of the XGBoost model under different quantitative features. The features were selected from top to bottom according to the feature importance of the XGBoost model. Although the recall rate of the model was 1 when the number of features in the model was three or less, the AUC was only 0.5, and the model was extremely poor with no effective discriminative ability. Thus, very few features will lead to the underfitting of the model. With an increase in the number of features during modeling, the evaluation indexes in Table 5 increased even if they slightly fluctuated. When the number of features was eight, all evaluation indexes were maximized (accuracy = 0.7333, F-beta = 0.9124, and AUC = 0.5531), and the performance of the model was the best. When the number of features increased beyond eight, the evaluation indexes decreased overall. Thus, too many features weakened the generalization ability of the model, causing the overfitting phenomenon. Therefore, the performance of the model was optimized when using the top eight features for modeling.

Table 5 Performance comparison of models according to number of features

As shown in Fig. 4, the top eight features in the XGBoost model in descending order were serum creatinine level, weight, age, height, TAC dosage, pidotimod, Bailing, and Huangkui usage. Among them, serum creatinine level was nearly twice as important as any other feature, indicating that serum creatinine has a significant effect on the blood concentration of TAC. Weight, age, and height were also more important than many other characteristics, whereas sex and some combined medications had relatively little influence on the model.

Fig. 4
figure 4

Feature importance of the XGBoost model


This study revealed that the XGBoost model—with an accuracy of 0.7333 and an F-beta score of 0.9124—showed the best effect that could be used to monitor the blood concentration of TAC. Zheng et al. [11] also achieved the best results in regression prediction of TAC blood concentration from real-world data using the XGBoost model. Thus, the XGBoost model has certain advantages for clinical data prediction in real-world settings.

The feature importance ranking of XGBoost revealed that the serum creatinine level of the patients with kidney diseases, particularly nephrotic syndrome and membranous nephropathy, had a significant effect on their blood TAC concentration, thus confirming that the blood TAC concentration is positively correlated with the serum creatinine level [12]. Weight and height also ranked high, in this study, as factors that affect the blood TAC concentration, which is consistent with the results from Zheng et al. [11, 13]. Patient age is routinely evaluated by researchers [14, 15]. In this study, it ranked third among all features. Finally, the importance of sex in the prediction model was relatively low and did not participate in the establishment of the final model.

Previous studies have focused on the effect of TAC combined with other drugs [16, 17], but did not evaluate the effect of the combination on blood TAC concentration. Our study showed that the combination of Bailing and Huangkui with TAC affects blood TAC concentration. However, although pidotimod also had a high importance value in our study, there are no reports to support this result. It is speculated that it may be related to the medication habits of physicians. These conclusions warrant future research.

In the last decade, a few studies have described the prediction of TAC concentration in the blood using ML technology. Additionally, the models used in previous research were mostly artificial neural networks and regression models [18, 19], the amount of data obtained was lower, the models were not verified externally, and the research is still in the exploratory stage. In this study, using patients with nephrotic syndrome and membranous nephropathy as examples, blood TAC concentration was classified according to the safe blood concentration range and predicted using a variety of ML models. The number of real-world samples included in this study was considerably more than that in previous research, and an external validation set was used to verify the model. Thus, the model results are more authentic and have clinical significance over previous models.

This study had several limitations. First, owing to the lack of information about blood sample collection time, we had to use the sample-receiving time. Ideally, the laboratory department can obtain the sample collection time in the future to further strengthen the integrity and analyzability of medical data. Second, more laboratory and genetic data should be analyzed.


In this study, an ML model was established to classify the blood TAC concentration in patients with nephrotic syndrome and membranous nephropathy. The over-sampling method was used to manage unbalanced data, the variables were screened according to their importance value, and the performance of the six models was compared. Finally, XGBoost was selected as the best prediction model, considering its accuracy of 0.7333, F-beta score of 0.9124, and AUC of 0.5531, which were higher than those of other models, demonstrating a better prediction ability. In the XGBoost model, serum creatinine, weight, age, height, TAC dose, and the use of pidotimod, Bailing, and Huangkui were the main influencing factors of blood TAC concentration. The low AUC and high sensitivity of the model also implies that it is biased towards positive class, which may have a negative impact on the prediction of clinical dose of TAC in patients with negative class. In this exploratory study, the ability of machine learning in predicting TAC blood concentration was investigated. The study findings prove the predictive potential of machine learning to a certain extent; however, further in-depth research is needed to resolve the model’s bias towards positive class.

Availability of data and materials

The data that support the findings of this study are available from the corresponding author upon reasonable request.



Serum creatinine


Compound α-ketoacid














Prednisone acetate


Mycophenolate mofetil


Tripterygium glycoside


Machine learning


Logistic regression


Area under the curve


Random forest


Gradient boost decision tree




  1. Kohli HS, Rajachandran R, Rathi M, Jha V, Sakhuja V. Tacrolimus in nephrotic syndrome resistant to first line therapy in adults: a prospective study. Nephrol Dial Transplant. 2013;28:401–2.

    Google Scholar 

  2. Zhang J, Zhang Y, Yang H. Effect of tacrolimus on renal function, blood lipids, cytokines and peripheral HMGB-1 and NF-κB in nephrotic syndrome patients. Chin J Biochem Pharm. 2015;3:115–8.

    Google Scholar 

  3. Gérard C, Stocco J, Hulin A, Blanchet B, Verstuyft C, Durand F, et al. Determination of the most influential sources of variability in tacrolimus trough blood concentrations in adult liver transplant recipients: a bottom-up approach. AAPS J. 2014;16:379–91.

    Article  CAS  Google Scholar 

  4. Koelzer VH, Sirinukunwattana K, Rittscher J, Mertz KD. Precision immunoprofiling by image analysis and artificial intelligence. Virchows Arch. 2019;474:511–22.

    Article  Google Scholar 

  5. Schork NJ. Artificial intelligence and personalized medicine. Cancer Treat Res. 2019;178:265–83.

    Article  CAS  Google Scholar 

  6. Shamout F, Zhu T, Clifton DA. Machine learning for clinical outcome prediction. IEEE Rev Biomed Eng. 2021;14:116–26.

    Article  Google Scholar 

  7. Santosh T, Liu H, Liu B. Effect of tacrolimus in idiopathic membranous nephropathy: a meta-analysis. Chin Med J. 2014;127:2693–9.

    CAS  Google Scholar 

  8. Liang Q, Li H, Xie X, Qu F, Li X, Chen J. The efficacy and safety of tacrolimus monotherapy in adult-onset nephrotic syndrome caused by idiopathic membranous nephropathy. Ren Fail. 2017;39:512–8.

    Article  CAS  Google Scholar 

  9. Dong H, He D, Wang F. SMOTE-XGBoost using Tree Parzen Estimator optimization for copper flotation method classification. Powder Technol. 2020;375:174–81.

    Article  CAS  Google Scholar 

  10. Dong X, Yu Z, Cao W, Shi Y, Ma Q. A survey on ensemble learning. Front Comput Sci. 2020;14:241–58.

    Article  Google Scholar 

  11. Zheng P, Yu Z, Li L, Liu S, Lou Y, Hao X, et al. Predicting blood concentration of tacrolimus in patients with autoimmune diseases using machine learning techniques based on real-world evidence. Front Pharmacol. 2021;12:727245.

    Article  CAS  Google Scholar 

  12. Jing-ge G. 郭景鸽. Chin Rem Clin. Takemosi zhiliao chengren jisu dikangxing shenbing zonghezheng xueyao nongdu yu linchuang xiaoguo ji buliang fanying de xiangguanxing yanjiu 他克莫司治疗成人激素抵抗型肾病综合征血药浓度与临床效果及不良反应的相关性分析 [Correlation analysis between blood concentration, clinical effect, and adverse reactions of tacrolimus in the treatment of the adult hormone-resistant nephrotic syndrome]. 2019;19:773–5.

  13. Sam WJ, Tham LS, Holmes MJ, Aw M, Quak SH, Lee KH, et al. Population pharmacokinetics of tacrolimus in whole blood and plasma in Asian liver transplant patients. Clin Pharmacokinet. 2006;45:59–75.

    Article  CAS  Google Scholar 

  14. Przepiorka D, Blamble D, Hilsenbeck S, Danielson M, Krance R, Chan KW. Tacrolimus clearance is age-dependent within the pediatric population. Bone Marrow Transplant. 2000;26:601–5.

    Article  CAS  Google Scholar 

  15. Staatz CE, Tett SE. Pharmacokinetic considerations relating to tacrolimus dosing in the elderly. Drugs Aging. 2005;22:541–57.

    Article  CAS  Google Scholar 

  16. Yan Xiao-hui LY, Feng Ting JG, Xiao-Ming W. Clinical effects of tacrolimus combined with okra capsule in treatment of refractory membranous nephropathy. Prog Mod Biomed. 2017;17:wpr-615041.

    Google Scholar 

  17. Li Y, Xu T, Qiu X, Tian B, Bi C, Yao L. Effectiveness of Bailing capsules in the treatment of lupus nephritis: a meta-analysis. Mol Med Rep. 2020;22:2132–40.

    Article  CAS  Google Scholar 

  18. Venkataramanan R, Shaw LM, Sarkozi L, Mullins R, Pirsch J, MacFarlane G, et al. Clinical utility of monitoring tacrolimus blood concentrations in liver transplant patients. J Clin Pharmacol. 2001;41:542–51.

    Article  CAS  Google Scholar 

  19. Tang J, Liu R, Zhang YL, Liu MZ, Hu YF, Shao MJ, et al. Application of machine-learning models to predict tacrolimus stable dose in renal transplant recipients. Sci Rep. 2017;7:42192.

    Article  CAS  Google Scholar 

Download references


The authors would like to thank the PLA General Hospital and the patients for their support and involvement in our study.


This research was supported by a grant from the Big Data and Artificial Intelligence Research and Development Project of the PLA General Hospital [reference: 2019MBD-002].

Author information

Authors and Affiliations



WY, HX, and LS designed the study. HS collected the data and provided guidance on data processing. HX and LS provided guidance on medication information. WY analyzed the data, performed the study, and wrote the manuscript. HX and ML revised the manuscript. All authors agreed to be accountable for the content of the work, and read and approved the final version of the manuscript.

Corresponding authors

Correspondence to Haili Xin or Minchao Liu.

Ethics declarations

Competing interests

The authors declare no competing interests.

Ethics approval and consent to participate

The risk posed by the study to subjects does not exceed the minimum risk. This study was approved by the Ethics Committee of the Chinese People's Liberation Army General Hospital [S2022-278–01]. The Ethics Committee of the Chinese People's Liberation Army General Hospital provided an exempt determination and waived informed consent. All methods were carried out in accordance with relevant guidelines and regulations.

Consent for publication

Not applicable.

Competing interest

The authors declare that the research was conducted in the absence of any commercial or financial relationships that could be construed as a potential conflict of interest.

Additional information

Publisher's Note

Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

Rights and permissions

Open Access This article is licensed under a Creative Commons Attribution 4.0 International License, which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons licence, and indicate if changes were made. The images or other third party material in this article are included in the article's Creative Commons licence, unless indicated otherwise in a credit line to the material. If material is not included in the article's Creative Commons licence and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder. To view a copy of this licence, visit The Creative Commons Public Domain Dedication waiver ( applies to the data made available in this article, unless otherwise stated in a credit line to the data.

Reprints and Permissions

About this article

Check for updates. Verify currency and authenticity via CrossMark

Cite this article

Yuan, W., Sui, L., Xin, H. et al. Discussion on machine learning technology to predict tacrolimus blood concentration in patients with nephrotic syndrome and membranous nephropathy in real-world settings. BMC Med Inform Decis Mak 22, 336 (2022).

Download citation

  • Received:

  • Accepted:

  • Published:

  • DOI:


  • Blood concentration prediction
  • Machine learning
  • Tacrolimus
  • Nephrotic syndrome
  • Membranous nephropathy