Liver cirrhosis detection method based on ZOA-XGboost
By introducing ZOA optimization algorithm in XGBoost, the problem of XGBoost's performance is affected when processing noise or outlier data sets is solved, the efficiency of parameter tuning and feature selection is improved, and more efficient and accurate detection of cirrhosis is achieved.
Patent Information
- Application Number
- CN202410253541.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-06
- Publication Date
- 2025-04-15
AI Technical Summary
XGBoost performs in dealing with data sets of noise or outliers and has inefficiency in parameter tuning and feature selection, especially under the requirements of diversity and complexity in the medical field.
The ZOA optimization algorithm is introduced, combined with XGBoost for parameter optimization and feature extraction, and improve the accuracy and efficiency of the model's parameter tuning.
It significantly improves the accuracy and reliability of cirrhosis detection, provides more efficient diagnostic support, is highly adaptable, and can play a role in a diverse medical scenario.
Smart Images

Figure CN119833051A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of medical detection recognition and machine learning, and in particular to a liver cirrhosis detection method based on ZOA-XGboost. Background Art
[0002] As a common and serious liver disease, early and accurate diagnosis of cirrhosis is of great significance for the treatment and prognosis of patients. With the continuous advancement of artificial intelligence technology, machine learning-based detection methods have provided new possibilities for the early diagnosis and monitoring of cirrhosis. In the field of medical health, the application of this method can provide doctors with more accurate and timely auxiliary diagnosis basis, and provide support for individualized treatment and health management of patients. As an advanced machine learning model, XGboost has excellent real-time performance and accuracy, and can quickly and accurately identify patients with cirrhosis. By analyzing a large amount of liver imaging data and physiological index data, XGboost can automatically identify early signs and risk factors of cirrhosis. Through continuous monitoring, not only can problems be detected in time at the early stage of cirrhosis, but also potential risks of cirrhosis can be predicted based on the patient's physiological indicators and behavioral patterns. For example, if abnormal liver function indicators and liver fibrosis are detected in patients, early warnings can also be issued to remind patients to seek medical treatment in time, or notify their families and doctors for further examination and intervention. Once a patient develops cirrhosis, the XGboost-based detection system can issue a warning immediately, allowing doctors or family members to understand the patient's condition in a timely manner and provide timely medical assistance to the patient, greatly reducing the serious consequences of delayed treatment of cirrhosis. In addition, the system can also provide doctors with long-term monitoring and analysis of the patient's condition through big data analysis, which helps to achieve individualized treatment plans and health management, and improve the patient's quality of life.
[0003] XGBoost (Extreme Gradient Boosting) is well-known in the field of machine learning for its high accuracy, especially when dealing with structured data. This high accuracy makes XGBoost have great potential in the diagnosis of complex diseases such as cirrhosis, and it can effectively support doctors to make accurate decisions. However, due to its strong reliance on accuracy, XGBoost faces challenges in dealing with noise or outliers in the dataset. If the dataset is not accurate enough or contains errors, the performance of XGBoost may be affected. In addition, although XGBoost can effectively handle large-scale datasets, there are still challenges in parameter tuning and feature selection. The model may require a lot of adjustments and optimizations to achieve optimal performance, which may lead to inefficiency in practical applications. Especially in the medical field, the diversity and complexity of data require the model to have not only high accuracy, but also flexibility and adaptability. If the model parameters are not adjusted accurately, the prediction performance will be reduced. Summary of the invention
[0004] In response to the above technical problems, the present technical solution provides a liver cirrhosis detection method based on ZOA-XGboost, in which the ZOA optimization algorithm is introduced into the model. The ZOA optimization algorithm shows higher accuracy and efficiency in the parameter search process, and can significantly improve the accuracy of parameter tuning. In the liver cirrhosis detection technology with XGBoost as the core, the ZOA algorithm is combined for feature extraction and model optimization, which can not only improve the overall performance, but also adjust the model parameters more accurately, further improving the accuracy and reliability of detection. In this way, the combination of XGBoost and ZOA algorithm provides a more accurate and efficient detection method for the diagnosis of liver cirrhosis, which can effectively solve the above problems.
[0005] The present invention is achieved through the following technical solutions:
[0006] A method for detecting liver cirrhosis based on ZOA-XGboost, comprising the following steps:
[0007] Step 1: Collect patient information and use the information to build a data set;
[0008] Step 2: Use Numpy, Pandas, and Matplotlib to analyze data and optimize the data set;
[0009] Step 3: Divide the data set into training set and test set;
[0010] Step 4: Use the zebra optimization algorithm ZOA to optimize the gamma parameter of XGboost and obtain the optimal gamma parameter; the specific operation method is:
[0011] S401: In the zebra optimization algorithm ZOA, each zebra is a candidate solution to the problem, and the zebras are located in a plane in the problem search space; the position of each zebra in the search space determines the value of the decision variable; each zebra of the ZOA member can be modeled using a vector, and the elements of the vector represent the values of the problem variables; the zebra population can be mathematically modeled using a matrix, and the initial positions of the zebras in the search space are randomly assigned; the ZOA overall matrix is specified as:
[0012]
[0013] Where: X is the zebra population; X i is the i-th zebra; x i,j is the value of the jth question variable raised by the i-th zebra, N is the number of zebras in the population; m is the number of decision variables;
[0014] S402: Each zebra may represent a candidate solution to the optimization problem, and thus an objective function may be evaluated based on the proposed values of each zebra for the problem variables; the values obtained for the objective function are specified as a vector using the following formula:
[0015]
[0016] Where: F is the vector of objective function values; F i is the objective function value obtained for the i-th zebra;
[0017] S403: Two natural behaviors of zebras in the wild have been used to update ZOA membership, including foraging and defense strategies against predators;
[0018] Wherein, the foraging behavior is in the first stage, when the population members search for food, they are updated according to the simulation of zebra behavior;
[0019] In the zebra herd, there is a species called the plains zebra, which is a pioneer herbivore that provides conditions for other species that need the shorter and more nutritious grasses below by devouring the canopy of upper and less nutritious grasses; in ZOA, the best members of the population are considered pioneer zebras and lead other population members towards their position in the search space; the position update of zebras during the foraging phase is mathematically modeled using the following formula:
[0020]
[0021]
[0022] In the formula: The new state of the i-th zebra based on the first phase; is its j-th dimension value; It is the pioneer zebra; PZ j is the j-th dimension of the Pioneer Zebra, r is a random number in the interval [0,1]; I is a random value belonging to the set {1, 2}.
[0023] The defense strategy against predators described above is simulated in the second stage to update the position of ZOA population members in the search space by simulating the defense strategy of zebras against predator attacks; zebras are more aggressive against smaller predators, and they confuse and intimidate hunters by gathering together; in the ZOA design, it is assumed that one of the following two situations occurs with the same probability: one is that a lion attacks a zebra and the zebra chooses an escape strategy; the other is that other predators attack the zebra and the zebra chooses an attack strategy;
[0024] In the first strategy, when the zebra is attacked by a lion, the zebra will avoid the lion's attack near its location; this strategy can be modeled using the following formula:
[0025]
[0026] In the formula: is the new state of the i-th zebra based on the second stage; is the value of its jth dimension; t is the iteration round; T is the maximum number of iterations; R is a constant equal to 0.01; P s is the probability of choosing one of two strategies randomly generated in the interval [0,1]; S1 is a lion attacking a zebra, so the zebra chooses the escape strategy; S2 is another predator attacking the zebra, and the zebra chooses the attack strategy; AZ is the state of the attacked zebra; AZ j is its j-th dimension value;
[0027] In the second strategy, when other predators attack one of the zebras, the other zebras in the group will move towards the attacked zebra and try to intimidate and confuse the predator by creating a defensive structure; when updating the position of the zebra, if the zebra has a better value for the objective function in the new position, the new position is accepted. This is modeled using the following formula:
[0028]
[0029] Where: is the value of its objective function;
[0030] Step 5: Use the training set to train the ZOA-XGboost detection model to obtain the detection model;
[0031] Step 6: Finally, the test set is input into the ZOA-XGboost detection model, and the liver cirrhosis detection results are output to achieve detection.
[0032] Furthermore, the specific operation method of collecting patient information in step 1 is: collecting information collected from the primary biliary cirrhosis PBC trial conducted by the Mayo Clinic between 1974 and 1984, with a total of 424 patients, and then using the information to establish a data set.
[0033] Furthermore, the specific operation method of using information to establish a data set in step 1 is:
[0034] S101: The data set has 424 records, with 4 types, including: 1. Healthy Liver; 2. Fatty Liver; 3. Liver Fibrosis; 4. Cirrhosis;
[0035] S102: Each type has 19 features including: 1. Patient identification (ID); 2. Number of observation days (N_Days); 3. Status (Status); 4. Type of medication used (Drug); 5. Age (Age); 6. Gender (Sex); 7. Whether there is ascites (Ascites); 8. Whether there is hepatomegaly (Hepatomegaly); 9. Whether there are spider nevi (Spiders); 10. Whether there is edema (Edema); 11. Bilirubin concentration (Bilirubin); 12. Cholesterol level (Cholesterol); 13. Albumin concentration (Albumin); 14. Copper concentration (Copper); 15. Alkaline phosphatase level (Alk_Phos); 16. Alanine aminotransferase level (SGOT); 17. Triglyceride concentration (Tryglicerides); 18. Platelet count (Platelets); 19. Prothrombin time (Prothrombin).
[0036] Furthermore, the specific operation method of step 2 is:
[0037] S201: Use the Numpy and Pandas libraries in Python to optimize the categories and convert the Stage column in the dataset into a binary classification. Use the np.where function to do this: if the value of the Stage column is 4, replace it with 1; otherwise, replace it with 0. After executing this function, the Stage column will only contain two values: 0 or 1; 1 indicates cirrhosis and 0 indicates other conditions. The multi-class classification problem is converted into a binary classification problem, where only cirrhosis (stage 4) is of interest.
[0038] S202: Use the replace function in the Pandas library to replace text data with numbers: Sex column, "M" is replaced by 0 for male, and "F" is replaced by 1 for female; Ascites column, "N" is replaced by 0 for no ascites, and "Y" is replaced by 1 for ascites; Drug column, "D-penicillamine" is replaced by 0, and "Placebo" is replaced by 1 for placebo; Hepatomegaly column, "N" is replaced by 0 for no hepatomegaly, and "Y" is replaced by 1 for hepatomegaly; Spiders column, "N" is replaced by 0 for no spider nevus, and "Y" is replaced by 1 for spider nevus; Edema column, "N" is replaced by 0 for no edema, "Y" is replaced by 1 for edema, and "S" is replaced by -1; Status column, "C" is replaced by 0, "CL" is replaced by 1, and "D" is replaced by -1 for death;
[0039] S203: Find the missing values of the numerical columns in the data set and fill them with the median; use the select_dtypes() function to select the columns in the data frame whose data types contain categorical data; use the isna() function to check the missing values in each selected column, which returns a new data frame in which the value of each cell is True if there is a missing value, or False if there is no missing value; use the sum() function to calculate the number of missing values in each column, thereby obtaining the total number of missing values for each categorical column; use the fillna() function to fill the missing values in the column; specifically, it uses the mode of the column to replace the missing values, and obtains the mode value through df[c].mode().values[0]; finally, the inplace=True parameter ensures that the replacement is performed in the original data frame;
[0040] S204: Use the plt.figure function in the Matplotlib library to create a large-sized graphics container; in this large figure, use the plt.subplot function to create a 3x3 sub-figure layout to display 9 different health indicators respectively; for each sub-figure: use the sns.kdeplot() function to draw the Kernel Density Estimation graph to show the distribution of the indicators.
[0041] Furthermore, the data set is divided into a training set and a test set as described in step three. The specific operation method is: the optimized data is divided into a training set and a test set according to an 8:2 ratio.
[0042] Furthermore, in step 5, the test set is input into the ZOA-XGboost detection model to output the liver cirrhosis detection result, including setting parameters for XGboost and ZOA. The specific parameter setting steps are as follows:
[0043] S501: learning rate (learning_rate) is 0.75;
[0044] S502: The maximum depth (max_depth) is 3;
[0045] S503: random seed (random_state) is 1;
[0046] S504: the evaluation indicator (eval_metric) is 'error';
[0047] S505: The zebra population size (popsize) is 20;
[0048] S506: The maximum number of iterations (Max_iteration) is 35;
[0049] S507: The weight threshold lower boundary (lb) is -5;
[0050] S508: The upper boundary of the weight threshold (ub) is 5;
[0051] S509: ZOA optimization obtains gamma (γ) = 5.5431.
[0052] Furthermore, the specific operation method of step six is:
[0053] S601: Input the test set data into the ZOA-XGboost-based detection model trained in step 5 for detection;
[0054] S602: After the detection based on the ZOA-XGboost detection model is completed, the category information obtained by the detection is output;
[0055] S603: Display the detection results in the test set.
[0056] Beneficial Effects
[0057] Compared with the prior art, the liver cirrhosis detection method based on ZOA-XGboost proposed in the present invention has the following beneficial effects:
[0058] (1) High-precision diagnosis: ZOA-XGBoost provides a new high-precision diagnosis method by combining XGBoost's ability to deeply analyze clinical data with ZOA's high efficiency in parameter optimization, which can deeply mine complex patterns and associations in clinical data and provide deeper insights. This combination enables the model to not only mine complex data patterns, but also adjust parameters more accurately to identify early signs of cirrhosis, which is not possible using XGBoost alone.
[0059] (2) Effective feature selection: By adding the ZOA algorithm, this method far exceeds the traditional XGBoost model in identifying key biomarkers closely related to liver cirrhosis. The model focuses on the most critical data features and avoids interference from irrelevant information. The simplified model not only speeds up the calculation, but also improves the generalization ability of the model, enabling it to maintain high accuracy in different clinical samples. This combination optimizes the feature selection process, reduces the interference of irrelevant information, and improves the generalization ability of the model in different clinical samples.
[0060] (3) Fast processing speed: The introduction of the ZOA algorithm greatly improves the processing efficiency of XGBoost, making the model faster when analyzing large amounts of data. This innovative combination provides faster diagnostic support for fast-paced medical environments, which is not possible using XGBoost alone. The model's fast processing capabilities are particularly suitable for emergency and high-pressure medical environments, providing doctors with immediate diagnostic support.
[0061] (4) Strong adaptability: The ZOA-XGBoost method shows higher adaptability when processing various types of medical data, whether it is structured electronic medical records or unstructured medical images. This unique combination makes it have excellent application potential in a variety of medical scenarios. The adaptability of this method enables it to play an important role in various medical scenarios, whether it is outpatient diagnosis or inpatient treatment.
[0062] (5) Improve patient prognosis: The high accuracy and rapid response of the ZOA-XGBoost method are crucial to improving early diagnosis and treatment planning for patients with cirrhosis. This combination of technologies not only improves the accuracy of diagnosis, but also helps provide patients with more personalized treatment plans, thereby significantly improving the success rate of treatment. BRIEF DESCRIPTION OF THE DRAWINGS
[0063] Figure 1 It is a schematic diagram of the overall process of the present invention.
[0064] Figure 2 It is the species number density diagram of the present invention.
[0065] Figure 3It is a characteristic distribution diagram of the present invention.
[0066] Figure 4 It is a stratified K-fold cross-validation ROC curve diagram of the present invention.
[0067] Figure 5 It is the XGBoostROC curve diagram of the present invention. DETAILED DESCRIPTION
[0068] The following will be combined with the accompanying drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. The described embodiments are only part of the embodiments of the present invention, rather than all the embodiments. Under the premise of not departing from the design concept of the present invention, various modifications and improvements made by ordinary persons in the art to the technical solutions of the present invention should all fall within the protection scope of the present invention.
[0069] Embodiment 1:
[0070] A method for detecting liver cirrhosis based on ZOA-XGboost, comprising the following steps:
[0071] Step 1: Collect patient information and use the information to build a data set.
[0072] The dataset was constructed using information collected from the Mayo Clinic Primary Biliary Cirrhosis (PBC) Trial conducted between 1974 and 1984 involving a total of 424 patients.
[0073] S101: There are 424 records in the dataset, with 4 types: 1. Healthy Liver: a liver that works normally without any damage or disease; 2. Fatty Liver: a disease caused by the accumulation of fat in liver cells; 3. Liver Fibrosis: a consequence of liver damage. After liver cells are damaged, the liver will produce scar tissue to repair the damage, causing the liver tissue to harden; 4. Cirrhosis: a consequence of liver damage. After liver cells are damaged, the liver will produce scar tissue to repair the damage, causing the liver tissue to harden.
[0074] S102: Each type has 19 features including: 1. Patient identification (ID); 2. Number of observation days (N_Days); 3. Status (Status); 4. Type of medication used (Drug); 5. Age (Age); 6. Gender (Sex); 7. Whether there is ascites (Ascites); 8. Whether there is hepatomegaly (Hepatomegaly); 9. Whether there are spider nevi (Spiders); 10. Whether there is edema (Edema); 11. Bilirubin concentration (Bilirubin); 12. Cholesterol level (Cholesterol); 13. Albumin concentration (Albumin); 14. Copper concentration (Copper); 15. Alkaline phosphatase level (Alk_Phos); 16. Alanine aminotransferase level (SGOT); 17. Triglyceride concentration (Tryglicerides); 18. Platelet count (Platelets); 19. Prothrombin time (Prothrombin).
[0075] Step 2: Use Numpy, Pandas, and Matplotlib to analyze data and optimize the data set.
[0076] S201: There is class imbalance in the dataset, with more examples of some classes than other classes. This makes it difficult to train the model and obtain the desired accuracy. Use the Numpy and Pandas libraries in python to perform category optimization and convert the Stage column in the dataset into a binary classification. Use the np.where function: If the value of the Stage column is 4, replace it with 1. Otherwise, replace it with 0. After executing this function, the Stage column will only contain two values: 0 or 1. 1 represents cirrhosis and 0 represents other cases. The multi-class classification problem is transformed into a binary classification problem, where we only care about whether it is cirrhosis (stage 4), such as Figure 2 As shown;
[0077] S202: The dataset has two different types of data: numerical data (age, cholesterol, platelets, etc.); categorical data (drug, sex, spider, etc.), so we will have to use different imputations for each type. For the numerical type, the median will be used to avoid bias in the presence of outliers. For the categorical type, we will impute the most frequent class. Use the replace function in the Pandas library to replace the text data with numbers: Sex column, "M" (male) is replaced by 0, "F" (female) is replaced by 1; Ascites column, where "N" (no ascites) is replaced by 0, "Y" (with ascites) is replaced by 1; Drug column, where "D-penicillamine" is replaced by 0, "Placebo" (placebo) is replaced by 1; Hepatomegaly column, where "N" (no hepatomegaly) is replaced by 0, "Y" (with ascites) is replaced by 1 "(with liver enlargement) is replaced by 1; Spiders column, where "N" (no spider nevus) is replaced by 0, "Y" (with spider nevus) is replaced by 1; Edema column, where "N" (no edema) is replaced by 0, "Y" (with edema) is replaced by 1, and "S" is replaced by -1; Status column, where "C" is replaced by 0, "CL" is replaced by 1, and "D" (death) is replaced by -1; In this way, the original categorical data is converted into numerical data, which is easier to use in mathematical models or algorithms.
[0078] S203: The first 312 cases in the dataset participated in randomized trials and contained essentially complete data. Another 112 patients did not participate in clinical trials but agreed to record basic measurements and be followed up for survival. Six of them were lost to follow-up shortly thereafter.
[0079] To find the missing values of the numerical columns in the data set and fill these missing values with the median. Use the select_dtypes() function to select the columns in the data frame whose data types contain categorical data; use the isna() function to check the missing values in each selected column, which returns a new data frame in which the value of each cell is True or False; use the sum() function to calculate the number of missing values in each column, thereby obtaining the total number of missing values for each categorical column; use the fillna() function to fill the missing values in the column. Specifically, it replaces the missing values with the mode of the column, and obtains the mode value through df[c].mode().values[0]; finally, the inplace=True parameter ensures that the replacement is performed in the original data frame.
[0080] S204: Use the plt.figure function in the Matplotlib library to create a large-sized graphic container. In this large figure, to display 9 different health indicators, use the plt.subplot function to create a 3x3 sub-graph layout. For each sub-graph: Use the sns.kdeplot() function to draw a Kernel Density Estimation graph to display the distribution of the indicators, such as Figure 3 shown.
[0081] Step 3: Divide the data set into training set and test set; divide the optimized data into training set and test set according to 8:2.
[0082] Step 4: Use the zebra optimization algorithm ZOA to optimize the gamma parameter of XGboost and obtain the optimal gamma parameter; the specific operation method is:
[0083] S401: ZOA is a population-based optimizer that considers a zebra to be a member of its population. From a mathematical point of view, each zebra is a candidate solution to the problem, as well as the plane of the zebra in the problem search space. The position of each zebra in the search space determines the value of the decision variable; each zebra that is a member of the ZOA can be modeled using a vector, and the elements of this vector represent the values of the problem variables; the zebra population can be mathematically modeled using a matrix, and the initial position of the zebra in the search space is randomly assigned; the ZOA population matrix is specified as:
[0084]
[0085] Where: X is the zebra population; X i is the i-th zebra; x i,j is the value of the j-th question variable raised by the i-th zebra, N is the number of zebras in the population; m is the number of decision variables.
[0086] S402: Each zebra may represent a candidate solution to the optimization problem, and thus an objective function may be evaluated based on the proposed values of each zebra for the problem variables; the values obtained for the objective function are specified as a vector using the following formula:
[0087]
[0088] Where: F is the vector of objective function values; F i is the objective function value obtained for the i-th zebra.
[0089] S403: Two natural behaviors of zebras in the wild have been used to update ZOA membership, including foraging and defense strategies against predators.
[0090] Among them, the foraging behavior is in the first stage, and the population members are updated according to the simulation of zebra behavior when searching for food.
[0091] In the zebra herd, there is a species called the plains zebra, which is a pioneer herbivore that provides conditions for other species that need the shorter and more nutritious grasses below by devouring the canopy of upper and less nutritious grasses; in ZOA, the best members of the population are considered pioneer zebras and lead other population members towards their position in the search space; the position update of zebras during the foraging phase is mathematically modeled using the following formula:
[0092]
[0093]
[0094] In the formula: The new state of the i-th zebra based on the first phase; is its j-th dimension value; It is the pioneer zebra; PZ j is the j-th dimension of the Pioneer Zebra, r is a random number in the interval [0,1]; I is a random value belonging to the set {1, 2}.
[0095] The defense strategy against predators described in the second stage simulates the zebra's defense strategy against predator attacks to update the position of ZOA population members in the search space; zebras are more aggressive against smaller predators, and they confuse and intimidate hunters by gathering together; in the ZOA design, it is assumed that one of the following two situations occurs with the same probability: one is that a lion attacks a zebra and the zebra chooses an escape strategy; the other is that other predators attack the zebra and the zebra chooses an attack strategy.
[0096] In the first strategy, when the zebra is attacked by a lion, the zebra will avoid the lion's attack near its location; this strategy can be modeled using the following formula:
[0097]
[0098] In the formula: is the new state of the i-th zebra based on the second stage; is the value of its jth dimension; t is the iteration round; T is the maximum number of iterations; R is a constant equal to 0.01; P s is the probability of choosing one of two strategies randomly generated in the interval [0,1]; S1 is a lion attacking a zebra, so the zebra chooses the escape strategy; S2 is another predator attacking the zebra, and the zebra chooses the attack strategy; AZ is the state of the attacked zebra; AZ j is its j-th dimension value.
[0099] In the second strategy, when other predators attack one of the zebras, the other zebras in the group will move towards the attacked zebra and try to intimidate and confuse the predator by creating a defensive structure; when updating the position of the zebra, if the zebra has a better value for the objective function in the new position, the new position is accepted. This is modeled using the following formula:
[0100]
[0101] Where: is the value of its objective function.
[0102] Step 5: Use the training set to train the ZOA-XGboost detection model to obtain the detection model.
[0103] S501: The learning rate determines the degree to which the model accepts new knowledge in each iteration. A higher learning rate means that the model may learn faster. The learning rate (learning_rate) in this training is 0.75;
[0104] S502: The maximum depth determines the depth of the decision tree. Shallow trees may lead to underfitting, while deeper trees may lead to overfitting. The maximum depth (max_depth) in this training is 3;
[0105] S503: Random seed is used to ensure the same results in multiple runs, making the training and prediction of the model repeatable. In this training, the random seed (random_state) is 1;
[0106] S504: Evaluation indicators are used to measure the performance of the model. The 'error' indicator measures the classification error rate, that is, the ratio of the number of samples with prediction errors to the total number of samples. The evaluation indicator (eval_metric) in this training is 'error';
[0107] S505: In the ZOA optimization algorithm, the zebra population size refers to the number of zebra individuals in the search space. In this training, the zebra population size (popsize) is 20;
[0108] S506: The maximum number of iterations (Max_iteration) in this training is 35;
[0109] S507: The lower boundary of the weight threshold (lb) in this training is -5;
[0110] S508: The upper boundary (ub) of the weight threshold in this training is 5;
[0111] S509: The ZOA optimization results in gamma (γ) being 5.5431.
[0112] Step 6: Finally, the test set is input into the ZOA-XGboost detection model, and the liver cirrhosis detection results are output to achieve detection.
[0113] S601: Input the test set data into the ZOA-XGboost-based detection model trained in S500 for detection. The purpose of this detection process is to evaluate the performance of the model on unknown data and determine its prediction accuracy for actual data.
[0114] S602: After the detection based on the ZOA-XGboost detection model is completed, the detected category information is returned.
[0115] S603: Display the detection results in the test set.
[0116] like Figure 4 , Figure 5 As shown. The ROC curve (Receiver Operating Characteristic Curve) is a tool used to evaluate the performance of classification models, especially in the fields of medical diagnostic testing and machine learning. It is mainly used to show the relationship between the true positive rate (TPR) and the false positive rate (FPR) of the model at different thresholds. The following is a detailed introduction and mathematical formula of the ROC curve:
[0117] True positive rate (TPR): also known as sensitivity, it indicates the proportion of samples correctly identified as positive (disease positive) to all actual positive samples. The calculation formula is:
[0118]
[0119] Where: TP is the true positive class (True Positives), FN is the false negative class (False Negatives).
[0120] False Positive Rate (FPR): indicates the ratio of negative samples that are mistakenly identified as positive to all actual negative samples. The calculation formula is:
[0121]
[0122] Where: FP is False Positives, TN is True Negatives.
[0123] In the ROC curve, the horizontal axis represents FPR and the vertical axis represents TPR.
[0124] The area under the curve (AUC) is used to measure the overall performance of the model. The closer the AUC value is to 1, the better the performance of the model; an AUC value of 0.5 indicates no diagnostic value, which is equivalent to random guessing. The AUC of ZOA-XGBoost is 0.74, while the AUC of stratified K-fold cross validation is 0.65, which shows that the performance of the ZOA-XGBoost model is better than that of the stratified K-fold cross validation model.
[0125] The algorithm of this embodiment is compared with the traditional algorithm stratified K-fold cross validation, as shown in Table 1.
[0126] Table 1
[0127] algorithm AUC Stratified K-fold cross validation 65% ZOA-XGboost 74%
[0128] The AUC of stratified K-fold cross validation is 65%, while the AUC of ZOA-XGboost is 74%. From these figures, we can see that ZOA-XGboost has a clear advantage in accuracy and plays an auxiliary role in the detection of liver cirrhosis in medical treatment.
[0129] The above embodiments are only for illustrating the technical concept and features of the present invention, and their purpose is to enable people familiar with the technology to understand the content of the present invention and implement it accordingly, and they cannot be used to limit the protection scope of the present invention. Any equivalent transformation or modification made according to the spirit of the present invention should be included in the present invention.
Claims
1. A method for detecting liver cirrhosis based on ZOA-XGboost, characterized in that: The following steps are involved: Step 1: Collect patient information and use the information to build a data set; Step 2: Use Numpy, Pandas, and Matplotlib to analyze data and optimize the data set; Step 3: Divide the data set into training set and test set; Step 4: Use the zebra optimization algorithm ZOA to optimize the gamma parameter of XGboost and obtain the optimal gamma parameter; the specific operation method is: S401: In the zebra optimization algorithm ZOA, each zebra is a candidate solution to the problem, and the zebras are located in a plane in the problem search space; the position of each zebra in the search space determines the value of the decision variable; each zebra of the ZOA member can be modeled using a vector, and the elements of the vector represent the values of the problem variables; the zebra population can be mathematically modeled using a matrix, and the initial positions of the zebras in the search space are randomly assigned; the ZOA overall matrix is specified as: Where: X is the zebra population; X i is the i-th zebra; x i,j is the value of the jth question variable raised by the i-th zebra, N is the number of zebras in the population; m is the number of decision variables; S402: Each zebra may represent a candidate solution to the optimization problem, and thus the objective function may be evaluated based on the proposed values of each zebra for the problem variables; The values obtained for the objective function are specified as a vector using the following formula: Where: F is the vector of objective function values; F i is the objective function value obtained for the i-th zebra; S403: Two natural behaviors of zebras in the wild have been used to update ZOA membership, including foraging and defense strategies against predators; Wherein, the foraging behavior is in the first stage, when the population members search for food, they are updated according to the simulation of zebra behavior; In the zebra herd, there is a species called the plains zebra, which is a pioneer herbivore that provides conditions for other species that need the shorter and more nutritious grasses below by devouring the canopy of upper and less nutritious grasses; in ZOA, the best members of the population are considered pioneer zebras and lead other population members towards their position in the search space; the position update of zebras during the foraging phase is mathematically modeled using the following formula: In the formula: The new state of the i-th zebra based on the first phase; is the value of its jth dimension; F i new,P1 It is the pioneer zebra; PZ j is the j-th dimension of the Pioneer Zebra, r is a random number in the interval [0,1]; I is a random value belonging to the set {1, 2}. The defense strategy against predators described above is simulated in the second stage to update the position of ZOA population members in the search space by simulating the defense strategy of zebras against predator attacks; zebras are more aggressive against smaller predators, and they confuse and intimidate hunters by gathering together; in the ZOA design, it is assumed that one of the following two situations occurs with the same probability: one is that a lion attacks a zebra and the zebra chooses an escape strategy; the other is that other predators attack the zebra and the zebra chooses an attack strategy; In the first strategy, when the zebra is attacked by a lion, the zebra will avoid the lion's attack near its location; this strategy can be modeled using the following formula: In the formula: is the new state of the i-th zebra based on the second stage; is the value of its jth dimension; t is the iteration round; T is the maximum number of iterations; R is a constant equal to 0.01; P s is the probability of choosing one of two strategies randomly generated in the interval [0,1]; S1 is a lion attacking a zebra, so the zebra chooses the escape strategy; S2 is another predator attacking the zebra, and the zebra chooses the attack strategy; AZ is the state of the attacked zebra; AZ j is its j-th dimension value; In the second strategy, when other predators attack one of the zebras, the other zebras in the group will move towards the attacked zebra and try to intimidate and confuse the predator by creating a defensive structure; when updating the position of the zebra, if the zebra has a better value for the objective function in the new position, the new position is accepted. This is modeled using the following formula: Where: F i new,P2 is the value of its objective function; Step 5: Use the training set to train the ZOA-XGboost detection model to obtain the detection model; Step 6: Finally, the test set is input into the ZOA-XGboost detection model, and the liver cirrhosis detection results are output to achieve detection.
2. A method for detecting liver cirrhosis based on ZOA-XGboost according to claim 1, characterized in that: The specific operation method of collecting patient information in step 1 is: collecting information collected from the primary biliary cirrhosis PBC trial conducted by the Mayo Clinic between 1974 and 1984, with a total of 424 patients, and then using the information to establish a data set.
3. A method for detecting liver cirrhosis based on ZOA-XGboost according to claim 1 or 2, characterized in that: The specific operation method of using information to establish a data set in step 1 is: S101: The data set has 424 records, with 4 types, including:
1. Healthy Liver; 2. Fatty Liver; 3. Liver Fibrosis; 4. Cirrhosis; S102: Each type has 19 features including:
1. Patient identification (ID); 2. Number of observation days (N_Days); 3. Status (Status); 4. Type of medication used (Drug); 5. Age (Age); 6. Gender (Sex); 7. Whether there is ascites (Ascites); 8. Whether there is hepatomegaly (Hepatomegaly); 9. Whether there are spider nevi (Spiders); 10. Whether there is edema (Edema); 11. Bilirubin concentration (Bilirubin); 12. Cholesterol level (Cholesterol); 13. Albumin concentration (Albumin); 14. Copper concentration (Copper); 15. Alkaline phosphatase level (Alk_Phos); 16. Alanine aminotransferase level (SGOT); 17. Triglyceride concentration (Tryglicerides); 18. Platelet count (Platelets); 19. Prothrombin time (Prothrombin).
4. The method for detecting liver cirrhosis based on ZOA-XGboost according to claim 1, characterized in that: The specific operation method of step 2 is: S201: Use the Numpy and Pandas libraries in Python to optimize categories and convert the Stage column in the dataset into binary classification; Use the np.where function to do this: If the value of the Stage column is 4, replace it with 1; otherwise, replace it with 0; After executing this function, the Stage column will contain only two values: 0 or 1; 1 indicates cirrhosis and 0 indicates other conditions; The multi-class classification problem is transformed into a binary classification problem, where we only care about whether it is cirrhosis (stage 4); S202: Use the replace function in the Pandas library to replace text data with numbers: Sex column, "M" for male is replaced by 0, "F" for female is replaced by 1; Ascites column, "N" for no ascites is replaced by 0, "Y" for ascites is replaced by 1; Drug column, "D-penicillamine" is replaced by 0, "Placebo" for placebo is replaced by 1; Hepatomegaly column, where "N" is replaced by 0 for no hepatomegaly, and "Y" is replaced by 1 for hepatomegaly; Spiders column, where "N" is replaced by 0 for no spider nevus, and "Y" is replaced by 1 for spider nevus; Edema column, where "N" is replaced by 0 for no edema, "Y" is replaced by 1 for edema, and "S" is replaced by -1; Status column, where "C" is replaced by 0, "CL" is replaced by 1, and "D" is replaced by -1 for death; S203: Find the missing values of the numerical columns in the data set and fill them with the median; use the select_dtypes() function to select the columns in the data frame whose data types contain categorical data; use the isna() function to check the missing values in each selected column, which returns a new data frame in which the value of each cell is True if there is a missing value, or False if there is no missing value; use the sum() function to calculate the number of missing values in each column, thereby obtaining the total number of missing values for each categorical column; use the fillna() function to fill the missing values in the column; specifically, it uses the mode of the column to replace the missing values, and obtains the mode value through df[c].mode().values[0]; finally, the inplace=True parameter ensures that the replacement is performed in the original data frame; S204: Use the plt.figure function in the Matplotlib library to create a large-sized graphics container; in this large figure, use the plt.subplot function to create a 3x3 sub-figure layout to display 9 different health indicators respectively; for each sub-figure: use the sns.kdeplot() function to draw the Kernel Density Estimation graph to show the distribution of the indicators.
5. The method for detecting liver cirrhosis based on ZOA-XGboost according to claim 4, characterized in that: Step 3 divides the data set into a training set and a test set. The specific operation method is: divide the optimized data into a training set and a test set according to an 8:2 ratio.
6. The method for detecting liver cirrhosis based on ZOA-XGboost according to claim 1, characterized in that: In step 5, the test set is input into the ZOA-XGboost detection model to output the liver cirrhosis detection results, including parameter setting for XGboost and ZOA. The specific parameter setting steps are as follows: S501: learning rate (learning_rate) is 0.75; S502: The maximum depth (max_depth) is 3; S503: random seed (random_state) is 1; S504: the evaluation indicator (eval_metric) is 'error'; S505: The zebra population size (popsize) is 20; S506: The maximum number of iterations (Max_iteration) is 35; S507: The weight threshold lower boundary (lb) is -5; S508: The upper boundary of the weight threshold (ub) is 5; S509: ZOA optimization obtains gamma (γ) = 5.5431.
7. The method for detecting liver cirrhosis based on ZOA-XGboost according to claim 1, characterized in that: The specific operation method of step six is: S601: Input the test set data into the ZOA-XGboost-based detection model trained in step 5 for detection; S602: After the detection based on the ZOA-XGboost detection model is completed, the category information obtained by the detection is output; S603: Display the detection results in the test set.
Citation Information
Cited By
Wafer yield prediction method
CN121980405A