Random forest-based method for predicting risk of pneumocystis jirovecii pneumonia
By constructing a random forest-based risk prediction method for Pneumocystis jirovecii pneumonia, integrating PCP-specific clinical features and optimizing the model, the problem of insufficient specificity and accuracy in the prognostic assessment of Pneumocystis jirovecii pneumonia in existing technologies is solved. This achieves efficient and accurate prediction for immunocompromised individuals, improving the model's adaptability and predictive performance.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- NANJING UNIV OF POSTS & TELECOMM
- Filing Date
- 2026-05-11
- Publication Date
- 2026-07-14
Smart Images

Figure CN122392892A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of medical data prediction and machine learning, specifically a method for predicting the risk of Pneumocystis jirovecii pneumonia based on random forest. Background Technology
[0002] Pneumocystis pneumonia (PCP) is an interstitial pneumonia caused by Pneumocystis jirovecii infection. It is an opportunistic infection that primarily affects immunocompromised individuals with reduced CD4+ T cells, including HIV / AIDS patients, lymphoma patients, organ transplant recipients on long-term immunosuppressant therapy, and those on long-term high-dose glucocorticoid therapy. The core clinical manifestations are fever, dry cough, and progressive dyspnea. The disease progresses rapidly, and the mortality rate is over 50% in untreated patients. Even with treatment, the mortality rate in non-HIV / AIDS patients can reach 40%. Prognosis heavily depends on early diagnosis and accurate disease assessment.
[0003] Currently, clinical assessment of prognosis in Pneumocystis jirovecii pneumonia (PCP) largely relies on traditional clinical scores (such as CURB-65), single physicochemical indicators (such as serum lactate dehydrogenase (LDH) and 1,3-β-D-glucan), or physician clinical experience, which has significant limitations: First, traditional scores are designed for community-acquired pneumonia and lack specificity for PCP, failing to adapt to the pathogenesis characteristics of immunocompromised individuals; second, single indicators cannot comprehensively reflect the complexity of the disease, as the synergistic effects of multiple factors such as CD4+ T cell count, ventilator use, and underlying disease type are not fully considered; third, subjective experience-based assessments are easily affected by individual differences, resulting in poor predictive consistency and accuracy, making it difficult to meet the needs of early clinical intervention and treatment optimization.
[0004] Machine learning algorithms have demonstrated significant advantages in the field of medical prognosis prediction. Among them, the random forest algorithm, due to its strong resistance to overfitting, ability to handle high-dimensional data, and ability to quantify feature importance, has been widely used in prognostic modeling of pulmonary infectious diseases such as community-acquired pneumonia and hospital-acquired pneumonia. However, existing technologies have significant gaps and shortcomings in the field of PCP prognostic prediction, specifically manifested as follows:
[0005] Lack of scenario adaptability: Existing prognostic prediction models for pulmonary infection are all designed with community-acquired pneumonia in immune-normal hosts as the core scenario. They do not adapt to the core pathogenesis characteristics of PCP, which is highly prevalent in immunocompromised populations. The feature indicators they include do not cover the core influencing factors such as PCP-specific immune function impairment, etiological characteristics of opportunistic infections, and immunosuppression-related underlying diseases. The specificity for prognostic assessment of PCP patients is seriously insufficient, and the model generalization ability is extremely poor.
[0006] Blindness in feature engineering: Existing prognostic assessments for PCP mostly remain at the level of single-factor analysis of a single physicochemical indicator. A few exploratory studies based on machine learning only use the single Gini importance for feature screening, which easily leads to problems such as high-dimensional feature redundancy and weak clinical relevance. A multi-dimensional, evidence-based feature system for PCP has not been constructed.
[0007] The model lacks customized optimization: Existing studies only directly call the default parameters and standardized process of the general random forest algorithm, without customized optimization for the characteristics of PCP prognosis prediction, such as a relatively limited sample size, a low proportion of positive outcome events, and high feature dimensions. This results in problems such as undirected optimization of hyperparameters, easy overfitting of the model, and insufficient generalization ability.
[0008] Insufficient clinical interpretability: Most existing medical prognostic machine learning models are black box models, which can only output prognostic classification results and cannot quantify the influence weight of each clinical feature on PCP prognosis. Clinicians cannot identify the high-risk factors for patients' prognosis, making it difficult to guide the optimization of clinical treatment plans and limiting their clinical application value.
[0009] Lack of long-term application adaptation design: Most existing models are static models with fixed parameters and have not been designed with a dynamic iterative optimization mechanism for clinical data. They cannot adapt to the model iteration needs brought about by the update of PCP diagnosis and treatment guidelines, changes in the high-risk population spectrum, and upgrades in clinical testing technologies. Their performance will gradually decline in long-term clinical applications. Summary of the Invention
[0010] To address the issues of poor specificity and insufficient accuracy in existing methods for assessing the prognosis of Pneumocystis jirovecii pneumonia (PCP), this invention proposes a risk prediction method for PCP based on random forests. By integrating PCP-specific clinical features and utilizing an optimized random forest algorithm to construct a model, this method achieves efficient and accurate prediction of patient prognosis, providing data support for clinical treatment decisions and prognostic management. The technical solution provided by this invention is as follows:
[0011] The first aspect is a method for predicting the risk of Pneumocystis jirovecii pneumonia based on random forests, which includes the following steps:
[0012] Step 1: Collect case data of patients with Pneumocystis jirovecii pneumonia to form a raw dataset; the case data includes clinical characteristics, laboratory characteristics, and imaging characteristics;
[0013] Step 2: Clean the original dataset, normalize the feature encoding, and divide it into training set, test set, and validation set;
[0014] Step 3: Calculate the importance score of each feature based on three indicators: permutation importance, Gini importance, and mutual information. Then, convert the score into a feature sampling probability distribution using the softmax function. Select features with sampling probabilities higher than a preset threshold and construct a feature set for model training.
[0015] Step 4: Build a random forest model and train and optimize it;
[0016] Step 5: Use the test set to verify the model performance and output the trained Pneumocystis jirovecii pneumonia risk prediction model;
[0017] Step 6: Input the standardized test sample into the trained Pneumocystis jirovecii pneumonia risk prediction model, and the model outputs the prognosis of the subject to be diagnosed.
[0018] Preferably, the case data specifically includes:
[0019] Clinical features: age, sex, type of immunodeficiency, duration of symptoms, degree of fever, and grade of dyspnea;
[0020] Laboratory characteristics: hexamine silver staining results, Pneumocystis jirovecii DNA, 1,3-β-D-glucan content, Δ lactate dehydrogenase, procalcitonin, CD4+ T cell count, CD4+ T cell percentage, C-reactive protein, and complete blood count indicators;
[0021] Imaging features: distribution of ground-glass opacities on chest CT, presence of consolidation, and cyst formation.
[0022] Preferably, the cleaning, feature encoding, and normalization in step 2 are as follows: samples with a missing value ratio exceeding 20% are removed, and the remaining missing values are filled with the median or mode of the corresponding feature; outliers are identified and removed using the 3σ criterion or box plot method; categorical features are converted into numerical features using one-hot encoding or label encoding; and continuous features are standardized using Z-score.
[0023] Preferably, the basic building block of the random forest model in step 4 is a CART classification tree. The CART tree grows by recursively dividing from top to bottom until the stopping conditions are met. The stopping conditions include: the node depth reaches the maximum depth, the number of samples in the node is less than the minimum number of samples required for the division, the node division cannot further improve the node purity, and there are no available features for division. If any of the conditions are met, the node will stop dividing and become a leaf node. The category of the leaf node is the category with the most samples in the node.
[0024] Preferably, the random forest model uses random sampling with replacement for the training set. Each decision tree randomly draws N samples from the original training set to form its own dedicated training set; each decision tree is trained only on its own dedicated sampling set.
[0025] Preferably, the random forest model adopts an aggregation strategy: after all decision trees have been trained, when making predictions on new samples, an ensemble voting method is used to determine the final result: each decision tree independently classifies the new sample and outputs its own predicted category; the prediction results of all decision trees are counted, and the category with the most votes is the final prediction result of the random forest.
[0026] Secondly, the risk prediction device for Pneumocystis jirovecii pneumonia based on random forest includes a data acquisition module, a data preprocessing module, a feature engineering module, a model calculation module, and a result output module connected in sequence. The model calculation module stores a model constructed using the risk prediction method for Pneumocystis jirovecii pneumonia based on random forest.
[0027] Compared with the prior art, the beneficial effects achieved by the present invention are:
[0028] This invention constructs a dedicated random forest prognostic prediction model for PCP, achieving complete adaptation to the clinical scenario of PCP from the data set construction level: the included feature system comprehensively covers the core influencing factors specific to PCP, such as immunodeficiency type, CD4+ T cell count / percentage, and history of immunosuppressive therapy; the control group is set up with non-PCP opportunistic lung infection samples that match the clinical differential diagnosis scenario of PCP; the dataset is divided using stratified sampling to ensure the consistency of the distribution of immunodeficiency subgroups.
[0029] This invention comprehensively covers all core factors affecting PCP prognosis by screening a PCP-specific feature set. While reducing feature dimensionality and avoiding model overfitting, it maximizes the retention of core prediction information, laying a data foundation for high-accuracy prediction by the model.
[0030] This invention uses a CART binary classification tree as the base classifier and designs a Gini coefficient optimization criterion for node partitioning and a tree growth stopping condition to adapt to the characteristics of PCP data, ensuring that a single decision tree can identify high-risk factors for PCP prognosis. It locks the optimal hyperparameter range for the characteristics of PCP tasks and improves the model's anti-overfitting ability and generalization performance through self-sampling and out-of-bag sample validation mechanisms. Attached Figure Description
[0031] The accompanying drawings are provided to further illustrate the invention and form part of the specification. They are used in conjunction with embodiments of the invention to explain the invention and do not constitute a limitation thereof. In the drawings:
[0032] Figure 1 This is a flowchart of the data preprocessing process of the present invention;
[0033] Figure 2 This is the core model architecture diagram of the present invention;
[0034] Figure 3 This is a graph showing the change in training accuracy of the present invention. Detailed Implementation
[0035] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0036] To make the above-mentioned objectives, features and effects of the present invention more apparent and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0037] Example 1: A method for predicting the risk of Pneumocystis jirovecii pneumonia based on random forest, including the following steps:
[0038] Step 1: Dataset construction. Collect case data of patients with Pneumocystis jirovecii pneumonia to form the original dataset; the case data includes clinical features, laboratory features and imaging features.
[0039] Step 1-1, Sample Inclusion and Labeling: Clinical case samples were collected and divided into a case group (patients diagnosed with Pneumocystis jirovecii pneumonia) and a control group (patients with lung infections other than Pneumocystis jirovecii pneumonia, including bacterial pneumonia, viral pneumonia, pulmonary cryptococcosis, pulmonary tuberculosis, etc.). The case group was diagnosed based on the detection of Pneumocystis jirovecii cysts or trophozoites in bronchoalveolar lavage fluid or lung tissue specimens (gold standard); the control group was diagnosed through pathogen detection, imaging examinations, and clinical treatment follow-up.
[0040] Step 1-2, Feature Indicator Screening: Based on clinical diagnosis and treatment data, feature indicators related to Pneumocystis jirovecii pneumonia are screened, divided into clinical features, laboratory features, and imaging features, specifically including:
[0041] Clinical features: age, sex, type of immunodeficiency, duration of symptoms, degree of fever, and grade of dyspnea;
[0042] Laboratory characteristics: hexamine silver staining results, Pneumocystis jirovecii DNA, 1,3-β-D-glucan content, Δ lactate dehydrogenase, procalcitonin, CD4+ T cell count, CD4+ T cell percentage, C-reactive protein (high sensitivity), and routine blood tests.
[0043] Imaging features: distribution of ground-glass opacities on chest CT (bilateral / unilateral, perihilar / subpleural), presence of consolidation, and cystic formation.
[0044] Step 2, data preprocessing, involves cleaning the original dataset, normalizing feature encoding, and dividing it into training, testing, and validation sets. Specific steps include:
[0045] Step 2-1, Data Review and Cleaning: Remove samples with more than 20% missing values, and fill the remaining missing values with the median (continuous indicator) or mode (categorical indicator) of the corresponding feature; remove outliers (identified by the 3σ criterion or box plot method).
[0046] Step 2-2, Feature Encoding and Normalization: For categorical features (such as gender, presence or absence of symptoms, and imaging features), one-hot encoding or label encoding is used to convert them into numerical features; for continuous features, Z-score standardization is used (X_norm=(X-μ) / σ) to eliminate the influence of dimensions.
[0047] Step 2-3 Dataset Splitting: The preprocessed dataset is randomly divided into training, testing, and validation sets in a 7:2:1 ratio to ensure that the proportions of patients with Pneumocystis jirovecii pneumonia, non-pneumonia patients, and healthy individuals are consistent across the three sets, thus avoiding data bias.
[0048] Step 3, feature engineering optimization, specifically includes:
[0049] Step 3-1, Feature Filtering: Calculate the importance score of each feature based on three indicators: permutation importance, Gini importance, and mutual information. Normalize and average the scores, and convert them into feature sampling probability distributions using the softmax function. Prioritize retaining high-value features with sampling probabilities ≥ 0.6.
[0050] Step 3-2, Feature Fusion: The selected high-value features are integrated dimensionally to construct a feature set for model training.
[0051] Step 4, Random Forest Model Construction and Optimization:
[0052] Step 4-1, Bootstrap Sampling: To ensure that each decision tree has "distinctiveness" (diversity is the core of improving the performance of ensemble models), Random Forest uses random sampling with replacement (bootstrap sampling) on the training set. The specific process is as follows:
[0053] Assuming the original training set has N samples, for each decision tree, N samples are randomly selected from the original training set to form the tree's dedicated training set.
[0054] Because sampling with replacement occurs, some samples will be drawn multiple times (into the training set of the tree), while some samples may never be drawn. These are called out-of-bag samples, which account for approximately 37% of the original samples.
[0055] Each decision tree is trained only on its own dedicated sample set, and they are independent of each other with no information exchange.
[0056] The core significance of autopilot sampling is to ensure that the training data of each decision tree is different, avoiding high homogeneity among multiple trees. After integration, it can effectively reduce the variance of the model (reduce overfitting). Out-of-bag samples can be directly used for model evaluation without the need for additional test set division, saving data resources.
[0057] Step 4-2, Aggregation Strategy: After all decision trees have been trained, when making predictions on new samples, an ensemble voting method is used to determine the final result (specific to classification tasks):
[0058] Each decision tree independently classifies new samples and outputs its own predicted category;
[0059] The prediction results of all decision trees are statistically analyzed, and a majority voting system (hard voting) is used. The category with the most votes is the final prediction result of the random forest.
[0060] Step 5, Model Validation and Output: Use the test set to validate the model performance and output the trained Pneumocystis jirovecii pneumonia risk prediction model.
[0061] Step 6: Input the standardized test sample into the trained Pneumocystis jirovecii pneumonia risk prediction model, and the model outputs the prognosis of the subject to be diagnosed.
[0062] The random forest model in step 4 is based on the CART classification tree. Each base learner (base model) in a random forest is a CART tree, and in classification tasks, the CART tree is a binary decision tree, whose kernel determines the learning ability of a single tree.
[0063] The node partitioning criterion is the minimization of impurity. CART classification trees construct their tree structure by recursively partitioning the feature space. Each internal node selects only one feature for binary classification. The core principle of partitioning is minimizing node impurity, corresponding to the criterion parameter in random forests, with two possible criteria:
[0064] Gini coefficient: measures the disorder of node samples, with a value range of [0, 0.5]. The smaller the value, the higher the purity of the node (the more concentrated the samples are in a certain class). Its calculation formula is as follows:
[0065]
[0066] in It is a node The Middle The proportion of samples in each class. The partitioning logic is to select the feature and threshold that minimizes the weighted sum of the Gini coefficients of the left and right child nodes after partitioning, and then complete the node partitioning.
[0067] Information entropy: Also measures node purity, its value ranges from [0,1], with smaller values indicating higher purity. Its calculation formula is as follows:
[0068]
[0069] when This item is ignored. The partitioning logic is to select the feature and threshold that maximizes the information gain (weighted sum of original node entropy and child node entropy) after partitioning.
[0070] The Gini coefficient is used by default in sklearn because information entropy involves logarithmic operations, which are computationally more expensive; and when the sample class distribution is relatively uniform, the two methods have almost the same splitting effect, making the Gini coefficient more efficient in engineering.
[0071] Furthermore, the growth and stopping of the decision tree in the random forest model in step 4 are as follows:
[0072] CART trees grow using a top-down recursive partitioning approach until a stopping condition is met. This corresponds to hyperparameters such as the maximum depth of a random forest and the minimum number of samples required for partitioning. The core stopping condition includes:
[0073] 1. The node depth has reached its maximum depth;
[0074] 2. The number of samples in a node is less than the minimum number of samples required for the partition;
[0075] 3. The impurity (Gini / entropy) of the nodes is already very low (close to 0), and partitioning cannot further improve the purity of the nodes;
[0076] 4. No features are available for segmentation (all features have been used up or there is no discriminative power).
[0077] If any condition is met, the node will stop splitting and become a leaf node. The category of the leaf node is the category with the most samples in that node (as the prediction result of a single tree).
[0078] This embodiment uses accuracy, precision, recall, and F1 score for model evaluation. Accuracy is the proportion of correctly classified samples out of the total samples; precision is the proportion of samples predicted as malicious but actually classified as positive; recall is the proportion of samples actually containing malicious statements that were correctly predicted as malicious; the F1 score is the harmonic mean of precision and recall, and is an important scoring metric for model evaluation. The model performance meets the following requirements: accuracy ≥ 0.869, precision ≥ 0.909, recall ≥ 0.555, and F1 score ≥ 0.689.
[0079] Example 2: A random forest-based risk prediction device for Pneumocystis jirovecii pneumonia, comprising a data acquisition module, a data preprocessing module, a feature engineering module, a model calculation module, and a result output module connected in sequence. The model calculation module stores the model constructed by the method described in Example 1.
[0080] Example 3: The computer-readable storage medium of this example stores a computer program that, when executed by a processor, implements the steps in the random forest-based Pneumocystis jirovecii pneumonia risk prediction method of Example 1.
[0081] The computer-readable storage medium in this embodiment can be an internal storage unit of the terminal, such as the terminal's hard disk or memory; the computer-readable storage medium in this embodiment can also be an external storage device of the terminal, such as a plug-in hard disk, smart memory card, secure digital card, flash memory card, etc. equipped on the terminal; furthermore, the computer-readable storage medium can include both the terminal's internal storage unit and external storage devices.
[0082] The computer-readable storage medium of this embodiment is used to store computer programs and other programs and data required by the terminal. The computer-readable storage medium can also be used to temporarily store data that has been output or will be output.
[0083] Example 4: The computer device of this example includes a processor, a memory, and a computer program stored in the memory and executable on the processor. When the processor executes the program, it implements the steps in the random forest-based Pneumocystis jirovecii pneumonia risk prediction method of Example 1.
[0084] In this embodiment, the processor can be a central processing unit, or other general-purpose processors, digital signal processors, application-specific integrated circuits, off-the-shelf programmable gate arrays or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor, etc. The memory can include read-only memory and random access memory, and provides instructions and data to the processor. A portion of the memory can also include non-volatile random access memory. For example, the memory can also store device type information.
[0085] Those skilled in the art will clearly understand that each implementation can be achieved using software plus the necessary general-purpose hardware platform, or of course, hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0086] The above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art can still modify the technical solutions described in the foregoing embodiments or make equivalent substitutions for some of the technical features. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A method for predicting the risk of Pneumocystis jirovecii pneumonia based on random forest, characterized in that, Includes the following steps: Step 1: Collect case data of patients with Pneumocystis jirovecii pneumonia to form a raw dataset; the case data includes clinical characteristics, laboratory characteristics, and imaging characteristics; Step 2: Clean the original dataset, normalize the feature encoding, and divide it into training set, test set, and validation set; Step 3: Calculate the importance score of each feature based on three indicators: permutation importance, Gini importance, and mutual information. Then, convert the score into a feature sampling probability distribution using the softmax function. Select features with sampling probabilities higher than a preset threshold and construct a feature set for model training. Step 4: Build a random forest model and train and optimize it; Step 5: Use the test set to verify the model performance and output the trained Pneumocystis jirovecii pneumonia risk prediction model; Step 6: Input the standardized test sample into the trained Pneumocystis jirovecii pneumonia risk prediction model, and the model outputs the prognosis of the subject to be diagnosed.
2. The method for predicting the risk of Pneumocystis jirovecii pneumonia based on random forest according to claim 1, characterized in that, The case data specifically includes: Clinical features: age, sex, type of immunodeficiency, duration of symptoms, degree of fever, and grade of dyspnea; Laboratory characteristics: hexamine silver staining results, Pneumocystis jirovecii DNA, 1,3-β-D-glucan content, Δ lactate dehydrogenase, procalcitonin, CD4+ T cell count, CD4+ T cell percentage, C-reactive protein, and complete blood count indicators; Imaging features: distribution of ground-glass opacities on chest CT, presence of consolidation, and cyst formation.
3. The method for predicting the risk of Pneumocystis jirovecii pneumonia based on random forest according to claim 2, characterized in that, Step 2, cleaning, feature encoding, and normalization, specifically involves: removing samples with more than 20% missing values and filling the remaining missing values with the median or mode of the corresponding feature; identifying and removing outliers using the 3σ criterion or box plot method; converting categorical features into numerical features using one-hot encoding or label encoding; and standardizing continuous features using Z-score.
4. The method for predicting the risk of Pneumocystis jirovecii pneumonia based on random forest according to claim 3, characterized in that, Step 4: The basic building block of the random forest model is the CART classification tree. The CART tree grows by recursively partitioning from top to bottom until the stopping conditions are met. The stopping conditions include: the node depth reaches the maximum depth, the number of samples in the node is less than the minimum number of samples required for partitioning, the node partitioning cannot further improve the node purity, and there are no available features for partitioning. If any of the conditions are met, the node will stop partitioning and become a leaf node. The category of the leaf node is the category with the most samples in that node.
5. The method for predicting the risk of Pneumocystis jirovecii pneumonia based on random forest according to claim 4, characterized in that, The Random Forest model uses random sampling with replacement for the training set. Each decision tree randomly draws N samples from the original training set to form its own dedicated training set; each decision tree is trained only on its own dedicated sampling set.
6. The method for predicting the risk of Pneumocystis jirovecii pneumonia based on random forest according to claim 4, characterized in that, The random forest model employs an aggregation strategy: after all decision trees have been trained, when making predictions on new samples, an ensemble voting method is used to determine the final result: each decision tree independently classifies the new sample and outputs its own predicted category; the prediction results of all decision trees are counted, and the category with the most votes is the final prediction result of the random forest.
7. A random forest-based device for predicting the risk of Pneumocystis jirovecii pneumonia, characterized in that, It includes a data acquisition module, a data preprocessing module, a feature engineering module, a model calculation module, and a result output module that are connected in sequence. The model calculation module stores the model constructed by the random forest-based Pneumocystis jirovecii pneumonia risk prediction method as described in any one of claims 1-6.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the steps in the method for predicting the risk of Pneumocystis jirovecii pneumonia based on random forest as described in any one of claims 1-6.
9. A computer device comprising a processor, a memory, 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 steps in the method for predicting the risk of Pneumocystis jirovecii pneumonia based on random forest as described in any one of claims 1-6.