Random forest-based diagnostic method for pneumocystis jirovecii pneumonia
By employing a random forest-based diagnostic method that integrates multi-dimensional features and optimizes the model architecture, the invasiveness and performance limitations of the diagnosis of Pneumocystis jirovecii pneumonia have been addressed. This approach achieves a diagnosis with high accuracy, non-invasiveness, and broad applicability, suitable for individuals with different immune statuses.
Patent Information
- Application Number
- CN202610639526.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-05-11
- Publication Date
- 2026-06-30
AI Technical Summary
Existing diagnostic methods for Pneumocystis pneumonia are highly invasive, have low detection rates, and lack specificity. Existing machine learning models have limited performance and cannot achieve non-invasiveness, high diagnostic performance, broad adaptability, and strong robustness.
A random forest-based diagnostic approach is adopted. By integrating clinical, laboratory, and imaging features, and using permutation importance, Gini importance, and mutual information indicators to screen features, a CART classification tree random forest model is constructed. Hyperparameters and training set differentiation are optimized to achieve feature distillation and redundancy removal, thereby improving the model's generalization ability and interpretability.
It achieves non-invasive, high-accuracy diagnosis of Pneumocystis pneumonia, is applicable to people with different immune statuses, has a near-zero rate of missed diagnosis and misdiagnosis, has high interpretability, and meets clinical diagnostic needs.
Smart Images

Figure CN122314360A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of medical diagnosis and machine learning, specifically to a method for diagnosing Pneumocystis pneumonia based on random forest. Background Technology
[0002] Pneumocystis pneumonia (PCP) is a fatal interstitial pneumonia caused by Pneumocystis jirovecii infection. It primarily occurs in immunocompromised individuals with reduced CD4+ T cells, including HIV patients, organ transplant recipients, those on long-term glucocorticoid / immunosuppressant therapy, and patients with autoimmune diseases. Clinically, it is characterized by fever, dry cough, and progressive dyspnea. The disease progresses rapidly, and without early and accurate diagnosis and timely targeted treatment, the mortality rate is extremely high. The mortality rate for untreated patients can exceed 50%, and the mortality rate for HIV-positive patients with PCP is as high as 99%. Early and accurate diagnosis is a crucial prerequisite for reducing patient mortality.
[0003] Currently, commonly used clinical methods for diagnosing PCP have insurmountable technical limitations, which are also the core pain points in clinical diagnosis and treatment:
[0004] The gold standard for pathogen detection is highly invasive and has poor accessibility: the detection rate of sputum smear microscopy is only 6%~30%, and the detection rate after inducing sputum expectoration with hypertonic saline nebulization is still only 60%~70%; although the sensitivity of bronchoalveolar lavage fluid (BALF) microscopy and transbronchial lung biopsy can reach 79%~89% and 94%~100% respectively, they are invasive procedures that cause damage to the patient's body and are completely unsuitable for patients with severe respiratory failure or those who cannot tolerate fiberoptic bronchoscopy. In addition, they require high levels of equipment and physician skills, making them impossible for primary healthcare institutions to carry out.
[0005] Non-invasive serological tests have difficulty balancing specificity and sensitivity: commonly used clinical serological indicators such as 1,3-β-D-glucan (BDG), lactate dehydrogenase (LDH), and procalcitonin are easily affected by other fungal infections, bacterial infections, tissue damage, and other factors. Detection alone can easily lead to false negative or false positive results, and cannot be used as a basis for diagnosis, but can only serve as an auxiliary reference.
[0006] In recent years, machine learning technology has been gradually applied to the field of PCP diagnosis. Existing research has attempted to build diagnostic models using algorithms such as logistic regression, extreme gradient boosting, support vector machines, and traditional random forests, but all of them have core technical defects and cannot be implemented in clinical practice. Specifically:
[0007] The existing models rely on a single dimension for feature utilization and lack a feature selection system: most models only use PCR test results and single serological indicators to build the model, without fully integrating non-invasive features from multiple dimensions such as clinical phenotype, serology, and imaging. The lack of feature information directly leads to a low upper limit for model diagnosis. For example, the accuracy of the logistic regression model based on nasopharyngeal swab PCR results is only 80%. At the same time, the existing models have not established a systematic feature selection system, resulting in serious feature redundancy and noise interference. They cannot lock in the core high-value features for PCP diagnosis, and the model generalization ability is extremely poor.
[0008] The algorithm architecture has inherent flaws, and hyperparameter optimization relies on human experience: existing single-algorithm models (logistic regression, support vector machine) are not good at fitting nonlinear data and cannot adapt to the heterogeneity of indicators under different immune states of PCP patients; extreme gradient boosting models are prone to overfitting, and their diagnostic performance drops sharply in low-prevalence populations; although traditional random forest models are more robust than single algorithms, they have not been optimized for PCP diagnosis scenarios, the random subspace partitioning of features and the growth rules of decision trees are not adapted to the scenario, and the hyperparameter configuration relies entirely on the experience of the developers, which cannot achieve the global optimal solution, resulting in the model performance not being able to break through.
[0009] Poor population adaptability and insufficient clinical applicability: Most existing models are only built and trained for HIV-infected individuals with PCP. The diagnostic sensitivity and specificity are greatly reduced for non-HIV-infected immunosuppressed individuals (organ transplant recipients, immunosuppressant users) and low-prevalence individuals with normal immune function, making them unable to meet the needs of PCP screening and diagnosis in all clinical scenarios.
[0010] Diagnostic performance cannot meet clinical needs, and interpretability and non-invasiveness cannot be balanced: The overall performance of existing machine learning models is insufficient, with most models having an accuracy of less than 95% and a recall of less than 90%, resulting in a high rate of missed diagnoses and false diagnoses. For lethal PCP, they cannot reach the performance threshold for clinical diagnosis. At the same time, although some deep learning models have slightly improved accuracy, they are black box models with extremely poor interpretability, which cannot gain clinical acceptance or guide clinical diagnosis and treatment decisions.
[0011] In summary, there is currently no PCP diagnostic model in the clinical and research fields that can simultaneously achieve non-invasiveness, high diagnostic performance, strong robustness, and wide adaptability. This invention, based on an optimized random forest algorithm, specifically addresses all the core pain points of existing technologies, providing a brand-new technical solution for the early diagnosis of PCP. Summary of the Invention
[0012] To address the shortcomings of existing diagnostic methods for Pneumocystis jirovecii pneumonia (PCP), such as high invasiveness, low detection rate, insufficient specificity, and limited performance of existing machine learning diagnostic models, this invention proposes a random forest-based diagnostic method for PCP. This method achieves non-invasive, high-accuracy, and multi-dimensional feature fusion-based PCP diagnosis, while also improving the model's adaptability to different immune states. The technical solution provided by this invention is as follows:
[0013] The first aspect is a diagnostic method for Pneumocystis jirovecii pneumonia based on random forests, which includes the following steps:
[0014] Step 1: Dataset Construction. Collect case data from patients with Pneumocystis jirovecii pneumonia, patients with non-PCP lung infections, and healthy individuals to form the original dataset. The case data includes clinical characteristics, laboratory characteristics, and imaging characteristics.
[0015] Step 2: Clean the original dataset, normalize the feature encoding, and divide it into training set, test set, and validation set;
[0016] 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.
[0017] Step 4: Build a random forest model and train and optimize it;
[0018] Step 5: Verify the model performance using the test set and output the trained Pneumocystis jirovecii pneumonia diagnostic model;
[0019] Step 6: Input the standardized test sample into the trained Pneumocystis jirovecii pneumonia diagnostic model. The model outputs the probability value that the subject is a patient with Pneumocystis jirovecii pneumonia.
[0020] Preferably, the case data specifically includes:
[0021] Clinical features: age, sex, type of immunodeficiency, duration of symptoms, degree of fever, and grade of dyspnea;
[0022] 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;
[0023] Imaging features: distribution of ground-glass opacities on chest CT, presence of consolidation, and cyst formation.
[0024] 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.
[0025] 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.
[0026] 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.
[0027] 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.
[0028] Secondly, the random forest-based diagnostic device for Pneumocystis jirovecii pneumonia 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 the model constructed by the random forest-based diagnostic method for Pneumocystis jirovecii pneumonia.
[0029] Compared with the prior art, the beneficial effects achieved by the present invention are:
[0030] This invention integrates three major indicators: permutation importance, Gini importance, and mutual information. By converting these into feature sampling probabilities, it accurately identifies high-value features, achieving a triple distillation and screening of features. This process retains core features that are statistically relevant to PCP diagnosis and have clear clinical significance, while completely eliminating redundant features and noise interference. This significantly improves the model's convergence speed and generalization ability, while ensuring the model's clinical interpretability.
[0031] This invention uses CART binary classification trees as base classifiers and optimizes the Gini coefficient minimization criterion for node partitioning in binary classification scenarios for PCP diagnosis. At the same time, it achieves training set differentiation for each decision tree through autopilot sampling and ensures the diversity of base classifiers through random feature subspace extraction. This reduces the risk of model overfitting from the root of the architecture and solves the problem of insufficient fitting ability of existing single algorithms for heterogeneous indicators of PCP patients.
[0032] This invention addresses the clinical needs of PCP diagnosis by optimizing the stopping conditions of CART trees. Through precise control of hyperparameters, it optimizes the number of decision trees, maximum tree depth, minimum number of samples for node splits, and minimum number of samples for leaf nodes. This ensures the learning ability of a single decision tree while avoiding overfitting caused by excessively deep tree structures. It also balances the computational efficiency and diagnostic performance of the model, making it suitable for the rapid computation needs of low-configuration equipment in primary healthcare institutions. This is a customized innovation that existing general-purpose random forest models have not implemented for PCP scenarios.
[0033] This invention enables diagnosis based on non-invasive / minimally invasive clinical, serological, and imaging data, requiring no invasive procedures and is tolerable to all populations. The model's overall performance far surpasses existing models of its kind, with near-zero false negative and false positive rates, meeting the diagnostic needs for life-threatening diseases. Furthermore, based on the feature importance output of the tree model, the contribution of each feature to the diagnostic result can be clearly explained, demonstrating excellent interpretability. It provides diagnostic decision support for clinicians and guides clinical identification and intervention of high-risk factors. It is currently the only PCP diagnostic model that combines non-invasiveness, high performance, interpretability, and universality, possessing extremely high clinical application value and promising prospects for widespread adoption. Attached Figure Description
[0034] 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:
[0035] Figure 1 This is a flowchart of the data preprocessing process of the present invention;
[0036] Figure 2 This is the core model architecture diagram of the present invention;
[0037] Figure 3 This is a graph showing the change in training accuracy of the present invention. Detailed Implementation
[0038] 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.
[0039] 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.
[0040] Example 1: Please refer to Figures 1 to 3 A random forest-based diagnostic method for Pneumocystis jirovecii pneumonia includes the following steps:
[0041] Step 1: Dataset Construction. Collect case data from patients with Pneumocystis jirovecii pneumonia, patients with non-PCP lung infections, and healthy individuals to form the original dataset. The case data includes clinical characteristics, laboratory characteristics, and imaging characteristics.
[0042] 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.
[0043] 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:
[0044] Clinical features: age, sex, type of immunodeficiency, duration of symptoms, degree of fever, and grade of dyspnea;
[0045] 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.
[0046] Imaging features: distribution of ground-glass opacities on chest CT (bilateral / unilateral, perihilar / subpleural), presence of consolidation, and cystic formation.
[0047] Step 2, data preprocessing, involves cleaning the original dataset, normalizing feature encoding, and dividing it into training, testing, and validation sets. Specific steps include:
[0048] 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).
[0049] Step 2-2, Feature Encoding and Normalization: Categorical features (such as gender, presence or absence of symptoms, and imaging features) are converted into numerical features using one-hot encoding or label encoding; continuous features are standardized using Z-score. Eliminate the influence of dimensions;
[0050] 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.
[0051] Step 3, feature engineering optimization, specifically includes:
[0052] 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.
[0053] Step 3-2, Feature Fusion: The selected high-value features are integrated dimensionally to construct a feature set for model training.
[0054] Step 4, Random Forest Model Construction and Optimization:
[0055] 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:
[0056] 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.
[0057] 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.
[0058] Each decision tree is trained only on its own dedicated sample set, and they are independent of each other with no information exchange.
[0059] 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.
[0060] 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):
[0061] Each decision tree independently classifies new samples and outputs its own predicted category;
[0062] 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.
[0063] Step 5, Model Validation and Output: Use the test set to validate the model performance and output the trained Pneumocystis pneumonia diagnostic model.
[0064] Step 6: Input the standardized test sample into the trained Pneumocystis jirovecii pneumonia diagnostic model. The model outputs the probability value that the subject is a patient with Pneumocystis jirovecii pneumonia.
[0065] 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.
[0066] 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:
[0067] 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:
[0068]
[0069] 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.
[0070] Information entropy: Also measures node purity, its value ranges from [0,1], with smaller values indicating higher purity. Its calculation formula is as follows:
[0071]
[0072] 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.
[0073] 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.
[0074] Furthermore, the growth and stopping of the decision tree in the random forest model in step 4 are as follows:
[0075] 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:
[0076] 1. The node depth has reached its maximum depth;
[0077] 2. The number of samples in a node is less than the minimum number of samples required for the partition;
[0078] 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;
[0079] 4. No features are available for segmentation (all features have been used up or there is no discriminative power).
[0080] 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).
[0081] 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 that were actually positive; recall is the proportion of samples that were actually malicious 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.992, average precision ≥ 0.991, average recall ≥ 0.995, and F1 score ≥ 0.993.
[0082] Example 2: A diagnostic device for Pneumocystis jirovecii pneumonia based on random forest, 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.
[0083] 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 diagnostic method for Pneumocystis jirovecii pneumonia of Example 1.
[0084] 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.
[0085] 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.
[0086] 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 diagnostic method for Pneumocystis jirovecii pneumonia of Example 1.
[0087] 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.
[0088] 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.
[0089] 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 diagnostic method for Pneumocystis jirovecii pneumonia based on random forest, characterized in that, Includes the following steps: Step 1: Dataset Construction. Collect case data from patients with Pneumocystis jirovecii pneumonia, other lung infections, and healthy individuals to form the original 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: Verify the model performance using the test set and output the trained Pneumocystis jirovecii pneumonia diagnostic model; Step 6: Input the standardized test sample into the trained Pneumocystis jirovecii pneumonia diagnostic model. The model outputs the probability value that the subject is a patient with Pneumocystis jirovecii pneumonia.
2. The method for diagnosing 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 diagnosing 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 diagnosing 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 diagnosing 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 diagnosing Pneumocystis 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 diagnostic device for Pneumocystis jirovecii pneumonia based on random forest, 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 diagnostic method for Pneumocystis jirovecii pneumonia 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 diagnosing Pneumocystis 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 diagnosing Pneumocystis pneumonia based on random forest as described in any one of claims 1-6.