Heart disease prediction method and device, electronic equipment and storage medium
By combining LightGBM and neural network models, the limitations of early detection and accurate prediction in cardiac prediction are solved, achieving more efficient and accurate cardiac risk assessment.
Patent Information
- Application Number
- CN202411504501.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-26
- Publication Date
- 2025-02-18
AI Technical Summary
The existing heart disease prediction methods have limitations in early detection and precise prediction, making it difficult to effectively identify high-risk populations and provide personalized treatment options.
Using a combination method of LightGBM model and neural network model, the LightGBM model is trained to generate decision path indexes, and a neural network model is constructed for heart disease prediction.
It improves the accuracy and efficiency of heart disease prediction, can better capture potential patterns and nonlinear relationships in complex data, and enhances the generalization ability and interpretability of the model.
Smart Images

Figure CN119480139A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the fields of medical informatics and medical engineering technology, and to the application of machine learning and artificial intelligence technologies in the diagnosis and prediction of heart disease. Background Art
[0002] Heart disease is one of the leading causes of death worldwide, and early prevention and intervention are crucial to reducing morbidity and mortality. According to the World Health Organization, more than 17 million people die from cardiovascular disease each year, accounting for about 31% of global deaths. Faced with such a severe situation, how to identify high-risk groups early through advanced technical means and provide personalized treatment plans has become an important issue in the medical field. However, due to the complex pathogenesis of heart disease and the involvement of multiple risk factors, traditional diagnostic methods have limitations in early detection and accurate prediction. In recent years, with the rapid development of machine learning technology, the application of intelligent prediction models has provided new solutions for heart disease prediction.
[0003] Machine learning, especially the Boosting algorithm based on decision trees, has been widely used in medical data analysis. The Boosting algorithm can handle high-dimensional data and complex nonlinear relationships well by constructing multiple weak learners and gradually optimizing the prediction accuracy. At the same time, deep learning technology based on neural networks has also shown great application potential in the medical field in recent years. Neural networks can effectively capture potential patterns and nonlinear relationships in complex data through multi-level learning structures. Summary of the invention
[0004] The embodiments of the present application provide a heart disease prediction method, device, electronic device and storage medium for addressing the limitations and accuracy deficiencies of existing heart disease prediction.
[0005] According to one aspect of the present application, a method for predicting heart disease is provided, comprising:
[0006] Obtaining historical data related to heart disease and preprocessing the historical data to obtain preprocessed data;
[0007] Using the preprocessed data to train the LightGBM model and generate a decision path index;
[0008] Constructing a neural network model, wherein the input layer of the neural network model adopts the features corresponding to the decision path index, the middle layer of the neural network model adopts a standard fully connected layer and a Dropout layer is placed after the fully connected layer, and the output layer of the neural network adopts a sigmoid function for classification;
[0009] Training the neural network model using the preprocessed data until the neural network model converges;
[0010] The converged neural network model is used to predict heart disease.
[0011] Furthermore, the historical data related to heart disease include: age, gender, chest pain type, resting blood pressure, serum cholesterol level, fasting blood glucose level, resting electrocardiogram results, maximum heart rate, exercise-induced angina, ST segment depression, ST segment slope, number of major blood vessels and defect type.
[0012] Furthermore, the preprocessing of the historical related data includes:
[0013] Missing values were handled by replacing them with the mean of the corresponding feature;
[0014] Normalization was used for indicators that varied greatly between patients;
[0015] Gender, angina type, and thalassemia type were processed using one-hot encoding;
[0016] Binary categorical variables are represented by binary values.
[0017] Furthermore, the LightGBM model uses a decision tree framework based on gradient boosting for feature selection and decision tree construction, including:
[0018] Optimize the loss function in each round of iteration in, is the predicted value With the actual value y i The loss between Ω(f) represents the complexity of the model, including the number of leaf nodes in the tree and the depth of the tree. i represents each sample in the dataset. Indicates the accumulation of losses for all samples;
[0019] A new decision tree h is generated in each iteration m (x0 is the negative gradient of the fitting loss function in, is the negative gradient of the sample in the mth iteration;
[0020] Using the decision tree h m (x) Update the prediction function F m (x) = F m-1 (x)+η·h m (x), where h m (x) is the decision tree of the mth round, and η is the learning rate.
[0021] Furthermore, the input layer of the neural network model adopts the features corresponding to the decision path index, including:
[0022] After each decision tree is built, the LightGBM model generates a set of leaf node indexes for each sample and forms a vector X = (x1, x2, ..., x n ), where n is the number of decision trees, and each x i Represents the index of a sample in the leaf node of the i-th tree.
[0023] Furthermore, the cross entropy loss function of the neural network model is:
[0024]
[0025] Among them, y is the actual label, is the probability predicted by the model and N is the number of samples.
[0026] Furthermore, the neural network model uses the Adam optimization algorithm to automatically adjust weights and learning rates.
[0027] A second aspect of the present application provides a device for predicting heart disease, comprising:
[0028] A data acquisition module, used to obtain historical data related to heart disease and preprocess the historical data to obtain preprocessed data;
[0029] A first training module, used to train the LightGBM model using the preprocessed data and generate a decision path index;
[0030] A construction module, used to construct a neural network model, wherein the input layer of the neural network model adopts the features corresponding to the decision path index, the middle layer of the neural network model adopts a standard fully connected layer and a Dropout layer is placed after the fully connected layer, and the output layer of the neural network adopts a sigmoid function for classification;
[0031] A second training module, used for training the neural network model using the preprocessed data until the neural network model converges;
[0032] The prediction module is used to predict heart disease using the converged neural network model.
[0033] The third aspect of the present application provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the electronic device implements the method described in the first aspect of the present application.
[0034] The fourth aspect of the present application provides a computer-readable storage medium, which is used to store a computer program. When the computer program runs on a computer, the computer executes the method described in the first aspect of the present application.
[0035] In the embodiment of the present application, a method for predicting heart disease is provided, including: obtaining historical data related to heart disease and preprocessing the historical data to obtain preprocessed data; using the preprocessed data to train the LightGBM model and generate a decision path index; constructing a neural network model, the input layer of the neural network model uses the features corresponding to the decision path index, the middle layer of the neural network model uses a standard fully connected layer and a Dropout layer is placed after the fully connected layer, and the output layer of the neural network uses a sigmoid function for classification; using the preprocessed data to train the neural network model until the neural network model converges; using the converged neural network model to predict heart disease. The present application solves the technical problems of limitations and defects in accuracy in the early prediction of heart disease. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] The drawings constituting a part of the present application are used to provide a further understanding of the present application. The illustrative embodiments and descriptions of the present application are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0037] Figure 1 is a flow chart of a method for predicting heart disease according to an embodiment of the present application.
[0038] Figure 2 is a schematic diagram of a heart disease prediction device according to an embodiment of the present application.
[0039] Figure 3 It is a schematic diagram of the structure of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0040] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present application can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0041] It should be noted that the steps shown in the flowcharts of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and that, although a logical order is shown in the flowcharts, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0042] like Figure 1FIG. 1 is a flowchart of a heart disease prediction method provided in an embodiment of the present application. As can be seen from the figure, the heart disease prediction method includes the following steps:
[0043] Step S101, obtaining historical data related to heart disease and preprocessing the historical data to obtain preprocessed data. The preprocessing mainly includes cleaning, standardizing and one-hot encoding the data to prepare for model training.
[0044] Step S102: Use the preprocessed data to train the LightGBM model and generate a decision path index. Use the LightGBM model to replace the convolution module of the traditional decision tree, and use the enhanced feature extraction structure to extract data features, which reflect the decision process of each sample in the LightGBM model.
[0045] Step S103: construct a neural network model, and the definitions of each layer of the model are as follows: Figure 2 As shown in the neural network model, the final heart disease prediction model is obtained by optimizing the network parameters through multiple iterations: the input layer of the neural network model adopts the features corresponding to the decision path index, the middle layer of the neural network model adopts a standard fully connected layer and a Dropout layer is placed after the fully connected layer, and the output layer of the neural network adopts a sigmoid function for classification.
[0046] Step S104: training the neural network model using the preprocessed data until the neural network model converges.
[0047] Step S105: Use the converged neural network model to predict heart disease. Use the trained neural network model to evaluate the risk of heart disease on new patient data, analyze the prediction results of the model, and evaluate and adjust the model effect according to actual clinical results.
[0048] In certain preferred embodiments, historical data related to heart disease are obtained through the Kaggle public heart disease database, including: age, gender, chest pain type, resting blood pressure, serum cholesterol content, fasting blood glucose level, resting electrocardiogram results, maximum heart rate, exercise-induced angina, ST segment depression, ST segment slope, number of major vessels, and defect type.
[0049] In some preferred embodiments, the preprocessing of the historical related data includes:
[0050] Missing values were handled by replacing them with the mean of the corresponding feature;
[0051] Normalization is used for indicators such as chol (cholesterol content) that vary greatly among different patients;
[0052] Gender, angina type, and thalassemia type are processed using one-hot encoding, which can help the model interpret and utilize data more accurately, thereby improving the accuracy of heart disease prediction;
[0053] Binary categorical variables, for example, certain variables like fbs (fasting blood glucose level) and exang (exercise-induced angina) are represented by binary values and can be used directly for model training without the need for one-hot encoding. These variables are already provided in a suitable format and are directly represented as binary values of 0 or 1, where 1 indicates a positive test or condition is met and 0 indicates the opposite.
[0054] In some preferred embodiments, the LightGBM model uses a decision tree framework based on gradient boosting for feature selection and decision tree construction, including:
[0055] Optimize the loss function in each round of iteration in, is the predicted value With the actual value y i The loss between Ω(f) represents the complexity of the model, including the number of leaf nodes in the tree and the depth of the tree. i represents each sample in the dataset. Indicates the accumulation of losses for all samples;
[0056] A new decision tree h is generated in each iteration m (x) Negative gradient of the fitting loss function in, is the negative gradient of the sample in the mth iteration;
[0057] Using the decision tree h m (x) Update the prediction function F m (x) = F m-1 (x)+η·h m (x), where h m (x) is the decision tree of the mth round, and η is the learning rate.
[0058] By gradually adding new decision trees and integrating the prediction results of these learners to enhance the overall prediction ability of the model. LightGBM reduces computing time and memory usage by using a gradient boosting algorithm with histogram optimization, binning the features of the data, and building decision trees based on these bins, thereby improving efficiency when processing large data sets.
[0059] In some preferred embodiments, the input layer of the neural network model uses features corresponding to the decision path index, including:
[0060] After each decision tree is built, the LightGBM model generates a set of leaf node indexes for each sample and forms a vector X = (x1, x2, ..., x n ), where n is the number of decision trees, and each x i Represents the index of a sample in the leaf node of the i-th tree.
[0061] These leaf node indexes serve as important inputs for subsequent steps. They not only reflect the decision-making process of the model, but also provide a unique set of structured features for each sample, which are very informative. By collecting these leaf node indexes, we can convert the decision path of each sample into a quantitative feature form for feeding the neural network model in the next stage. Specifically, for each sample point, its leaf node position in all trees is encoded as a vector, which is then used as the input feature of the deep network. This method effectively bridges the tree-based model and the neural network-based model, leveraging their respective advantages to improve the prediction accuracy of the final model.
[0062] After the LightGBM model is trained, the model can output the index of the final leaf node in each decision tree for each sample; these indexes capture the in-depth details of the model's decision path for each sample; the principle of inputting leaf node indexes as feature vectors into the neural network model is based on converting the structured data of classification decisions into numerical features, which can be simplified by the following formula: Feature Vector = encode (Leaf Indices), where the encode function is responsible for converting leaf node indexes into numerical feature vectors suitable for neural networks; the leaf node index vector is input into the neural network model as input data, mainly to utilize the ability of deep learning networks to mine the complex patterns and associations that may be contained in these decision paths; in this step, the neural network model usually includes multiple layers, each layer is designed to extract different levels of abstract features from the input data; the fully connected layer captures different data patterns by learning weighted combinations of input features, the principle is:
[0063] h=σ(Wx+b)
[0064] Among them, W is the weight matrix, b is the bias vector, σ is the activation function, ReLU is used here, and h is the output feature vector; the ReLU activation function is f(z)=max(0,z); through the superposition of layers, the neural network model can gradually extract more and more advanced feature representations, which can better capture the complex patterns in the data, thereby improving the accuracy of heart disease risk prediction; the Dropout layer is added to prevent overfitting. The Dropout layer randomly discards the output of some neurons during training; the operation of this layer can be regarded as random sampling of the network structure to improve the generalization ability of the model.
[0065] In the above embodiments, sigmoid is used as the activation function, which is suitable for binary classification problems. The sigmoid function can compress the input value between 0 and 1. The formula is
[0066] This function maps any real number to the interval (0,1) and is suitable for outputting predicted probabilities. When making predictions, the model obtains the final output value through forward propagation calculations. The data of each case passes through the input layer and, after multiple transformations, is finally passed to the output layer. In the output layer, after conversion through the sigmoid function, the output value represents the probability of the case suffering from heart disease.
[0067] In some preferred embodiments, the cross entropy loss function of the neural network model is:
[0068]
[0069] Among them, y is the actual label, is the probability predicted by the model and N is the number of samples.
[0070] In some embodiments, the preprocessed heart disease-related data set is used to batch process and iteratively learn the neural network model. In order to optimize the performance of the model, the preprocessed data set is used to train the neural network model until the neural network model converges, including:
[0071] The data is divided into multiple batches for processing, and each batch of data is iterated through the network for multiple learning. In this way, the model can repeatedly adjust its parameters on each batch of data, thereby gradually improving the ability to recognize and process data features; after each iteration, the cross entropy loss function is used to evaluate the deviation between the model output and the actual label; the cross entropy loss function formula is:
[0072]
[0073] Among them, y is the actual label, is the probability predicted by the model, and N is the number of samples; the model uses the Adam optimization algorithm to automatically adjust weights and learning rates. The optimization process aims to reduce prediction errors and improve overall model performance; early stopping techniques are implemented to monitor the loss on the validation set to prevent overfitting; early stopping techniques rely on monitoring the loss of the validation set over several consecutive training cycles. If the validation loss does not improve significantly within the set number of cycles, training is terminated early; this method not only saves training time, but also protects the model's generalization ability on unseen data; the criteria for early stopping are usually set as:
[0074]
[0075] Among them, val_loss t is the validation loss of the current cycle, n is the number of cycles examined, and ∈ is a small tolerance used to determine the strictness of stopping; through these detailed calculation and adjustment steps, the neural network model is gradually optimized during the training process, and finally an efficient model that can accurately predict the risk of heart disease is obtained.
[0076] In some embodiments, the step of training the neural network model using the preprocessed data until the neural network model converges includes:
[0077] The model is verified by the test set to evaluate its prediction performance.
[0078] The key performance indicators for evaluating its prediction performance include: accuracy, recall and ROC-AUC (Receiver Operating Characteristic-Area Under Curve).
[0079] The accuracy is used to predict the ratio of the number of correct patients to the total number of patients, reflecting the performance of the model on the overall sample;
[0080] The recall rate is the proportion of all actual heart disease patients that the model correctly identifies, and the formula is:
[0081]
[0082] TP stands for true positive, i.e., valid use cases that are correctly identified; FP stands for false positive, i.e., invalid use cases that are incorrectly identified;
[0083] The ROC-AUC is an indicator used to measure the ability of the model to distinguish between diseased and non-disease patients. The higher the AUC value, the better the diagnostic ability of the model.
[0084] In some embodiments, necessary parameter adjustments and optimizations are performed based on the performance of the model in actual applications. By defining a candidate set of learning rate, maximum tree depth, number of trees, and maximum number of leaf nodes, a grid search method (GridSearchCV) combined with cross-validation is used to systematically search the parameter space. During this process, each parameter combination is trained and verified on multiple subsets to ensure that the parameter configuration that optimizes the model performance is found.
[0085] The learning rate was set to vary between 0.01 and 0.2, the maximum tree depth was adjusted from 3 to 10, and other parameters were also consistent with the learning rate. The optimal solution was sought within a range. Finally, the model fit was best when max_depth = 8, n_estimators = 90, learning_rate = 0.12, colsample_bytree = 0.8, num_leaves = 13, and subsample = 0.6 was found.
[0086] The same neural network model is grid searched to optimize various parameters by defining different numbers of neurons, different layers, activation functions, and Dropout coefficients. Each parameter combination is trained and verified on multiple subsets to ultimately find the parameter configuration that optimizes the model performance.
[0087] In some embodiments, the Adam optimizer is selected to automatically adjust the learning rate to adapt to different data characteristics; at the same time, two callback mechanisms, EarlyStopping and ModelCheckpoint, are introduced to avoid overfitting and ensure that the best model is saved during the training process.
[0088] In some embodiments, the learning rate is adjusted through the ReduceLROnPlateau callback, which reduces the learning rate when the verification performance of the model no longer improves. This helps the model to adjust the weights more finely when approaching the optimal solution. The Dropout layer randomly discards some neurons to reduce the overfitting of the model to the training data. It is finally determined that Dropout at 0.2 can provide the best regularization effect, and the number of neurons is set to 128. When the relu activation function is used, each indicator is the optimal value.
[0089] In this embodiment, the accuracy of the trained neural network model on the test set is 0.9845, and the recall rate is 1, indicating that the model successfully identified each of the actual cases of heart disease. In addition, the ROC-AUC score of the model is 0.9928, indicating that the model has an extremely low false positive rate. The embodiments of the present invention can still maintain a high accuracy of prediction tasks in real and complex heart disease scenarios. The evaluation results prove that the improved combination of LightGBM and neural network model has certain advantages in heart disease prediction tasks.
[0090] The embodiments of the present application have at least the following advantages:
[0091] (1) Efficiency of feature extraction: The LightGBM model automatically extracts key features from the data and effectively identifies the most important factors for predicting heart disease. This process does not require manual feature selection, which greatly reduces reliance on human intervention and improves the efficiency of feature extraction. At the same time, this automated feature extraction reduces unnecessary redundant features and improves the training efficiency and overall performance of the model.
[0092] (2) Multi-level combination of models: This paper adopts a multi-level combination model of LightGBM and neural network, which fully utilizes the efficiency of LightGBM in processing structured data and the ability of neural network in processing nonlinear complex patterns. Through this combination, the model has good adaptability in different dimensions, which can effectively cope with the complexity of data and capture the potential nonlinear relationship in the data.
[0093] (3) Improve the generalization ability of the model: During the model training process, through the feature selection ability of LightGBM, a large number of irrelevant or minor features are eliminated, reducing the risk of overfitting of the model, thereby improving the generalization ability of the model on different data sets. This enables the model to have a higher prediction effect in different populations and different scenarios, and is not prone to performance degradation due to differences in data sets.
[0094] (4) Interpretability of decision paths: Unlike traditional "black box" neural network models, the decision path index generated by LightGBM can provide interpretability about the feature selection and prediction process, helping medical practitioners understand the contribution of each feature to the final prediction result. Improving the interpretability of the model is very important for medical diagnosis, which helps doctors to make more scientific analysis and judgments on the patient's condition, thereby enhancing their trust in the model's prediction results.
[0095] (5) Modular design facilitates integration: The present invention divides feature extraction and risk prediction separately through modular design. LightGBM is responsible for feature extraction and screening, and the neural network is used for the final prediction of heart disease risk. This modular design facilitates the integration and expansion of the system, allowing the model to be adjusted and optimized according to different application scenarios, and also provides convenience for subsequent model upgrades and maintenance.
[0096] Another embodiment of the present application provides a device for predicting heart disease, comprising:
[0097] A data acquisition module, used to obtain historical data related to heart disease and preprocess the historical data to obtain preprocessed data;
[0098] A first training module, used to train the LightGBM model using the preprocessed data and generate a decision path index;
[0099] A construction module, used to construct a neural network model, wherein the input layer of the neural network model adopts the features corresponding to the decision path index, the middle layer of the neural network model adopts a standard fully connected layer and a Dropout layer is placed after the fully connected layer, and the output layer of the neural network adopts a sigmoid function for classification;
[0100] A second training module, used for training the neural network model using the preprocessed data until the neural network model converges;
[0101] The prediction module is used to predict heart disease using the converged neural network model.
[0102] It should be noted that, although several units or subunits of the device are mentioned in the above detailed description, this division is merely exemplary and not mandatory. In fact, according to the embodiments of the present application, the features and functions of two or more units described above can be embodied in one unit. Conversely, the features and functions of one unit described above can be further divided into multiple units to be embodied.
[0103] Based on the same inventive concept as the above-mentioned method embodiment, an electronic device is also provided in an embodiment of the present application, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the electronic device implements the prediction method in the above-mentioned embodiment.
[0104] In one embodiment, the electronic device may be a server. In this embodiment, the structure of the electronic device may be as follows: Figure 3 As shown, it includes a memory 2001 , a communication module 2003 and one or more processors 2002 .
[0105] The memory 2001 is used to store computer programs executed by the processor 2002. The memory 2001 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system and programs required for running the instant messaging function, etc.; the data storage area may store various instant messaging information and operation instruction sets, etc.
[0106] The memory 2001 may be a volatile memory, such as a random-access memory (RAM); the memory 2001 may also be a non-volatile memory, such as a read-only memory, a flash memory, a hard disk drive (HDD) or a solid-state drive (SSD); or the memory 2001 may be any other medium that can be used to carry or store a desired computer program in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto. The memory 2001 may be a combination of the above memories.
[0107] The processor 2002 may include one or more central processing units (CPU) or a digital processing unit, etc. The processor 2002 is used to implement the above-mentioned audio data processing method when calling the computer program stored in the memory 2001 .
[0108] The communication module 2003 is used to communicate with terminal devices and other servers.
[0109] The specific connection medium between the memory 2001, the communication module 2003 and the processor 2002 is not limited in the embodiment of the present application. Figure 3 In the embodiment, the memory 2001 and the processor 2002 are connected via a bus 2004. The bus 2004 is Figure 3 The arrows in the figure are used to describe the connection between other components, which is only for illustrative purposes and is not intended to be limiting. Bus 2004 can be divided into address bus, data bus, control bus, etc. For ease of description, Figure 3 The diagram only uses one arrow, but does not describe only one bus or one type of bus.
[0110] Based on the same inventive concept as the above method embodiment, an embodiment of the present invention also provides a computer-readable storage medium, the computer-readable storage medium is used to store a computer program, when the computer program is run on a computer, the electronic device implements the control method in the above embodiment. The computer-readable storage medium can be a readable signal medium or a readable storage medium. The readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of readable storage media (non-exhaustive list) include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0111] Based on the same inventive concept as the above-mentioned method embodiment, an embodiment of the present invention further provides a computer program product, the computer program product including a computer program. When the program product is run on an electronic device, the computer program is used to enable the electronic device to execute the steps of the control method according to various exemplary embodiments of the present application described above in this specification. The program product may adopt any combination of one or more readable media. These computer program commands may be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the commands executed by the processor of the computer or other programmable data processing device generate commands for implementing the steps in the process Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0112] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications falling within the scope of the present application.
Claims
1. A method for predicting heart disease, characterized in that: include: Obtaining historical data related to heart disease and preprocessing the historical data to obtain preprocessed data; Using the preprocessed data to train the LightGBM model and generate a decision path index; Constructing a neural network model, wherein the input layer of the neural network model adopts the features corresponding to the decision path index, the middle layer of the neural network model adopts a standard fully connected layer and a Dropout layer is placed after the fully connected layer, and the output layer of the neural network adopts a sigmoid function for classification; Training the neural network model using the preprocessed data until the neural network model converges; The converged neural network model is used to predict heart disease.
2. The method according to claim 1, characterized in that The historical data related to heart disease include: age, gender, chest pain type, resting blood pressure, serum cholesterol level, fasting blood glucose level, resting electrocardiogram results, maximum heart rate, exercise-induced angina, ST segment depression, ST segment slope, number of major blood vessels and defect type.
3. The method according to claim 2, characterized in that The preprocessing of the historical related data includes: Missing values were handled by replacing them with the mean of the corresponding feature; Normalization was used for indicators that varied greatly between patients; Gender, angina type, and thalassemia type were processed using one-hot encoding; Binary categorical variables are represented by binary values.
4. The method according to claim 2, characterized in that: The LightGBM model uses a gradient-boosted decision tree framework for feature selection and decision tree construction, including: Optimize the loss function in each round of iteration in, is the predicted value With the actual value y i The loss between Ω(f) represents the complexity of the model, including the number of leaf nodes in the tree and the depth of the tree. i represents each sample in the dataset. Indicates the accumulation of losses for all samples; A new decision tree h is generated in each iteration m (x) Negative gradient of the fitting loss function in, is the negative gradient of the sample in the mth iteration; Using the decision tree h m (x) Update the prediction function F m (x) = F m-1 (x)+η·h m (x), where h m (x) is the decision tree of the mth round, and η is the learning rate.
5. The method according to claim 4, characterized in that The input layer of the neural network model uses features corresponding to the decision path index, including: After each decision tree is built, the LightGBM model generates a set of leaf node indexes for each sample and forms a vector X = (x1, x2, ..., x n ), where n is the number of decision trees, and each x i Represents the index of a sample in the leaf node of the i-th tree.
6. The method according to claim 1, characterized in that The cross entropy loss function of the neural network model is: Among them, y is the actual label, is the probability predicted by the model and N is the number of samples.
7. The method according to claim 1, characterized in that The neural network model uses the Adam optimization algorithm to automatically adjust weights and learning rates.
8. A heart disease prediction device, characterized in that: include: A data acquisition module, used to obtain historical data related to heart disease and preprocess the historical data to obtain preprocessed data; A first training module, used to train the LightGBM model using the preprocessed data and generate a decision path index; A construction module, used to construct a neural network model, wherein the input layer of the neural network model adopts the features corresponding to the decision path index, the middle layer of the neural network model adopts a standard fully connected layer and a Dropout layer is placed after the fully connected layer, and the output layer of the neural network adopts a sigmoid function for classification; A second training module, used for training the neural network model using the preprocessed data until the neural network model converges; The prediction module is used to predict heart disease using the converged neural network model.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the electronic device implements the method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium is used to store a computer program, and when the computer program is run on a computer, the computer is caused to execute the method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Heart disease prediction method based on dual feature selection and XGBoost algorithm
CN111243751A
Electricity stealing user identification method and device combining cloud end and side end
CN113408676A
Construction method and system of tumor onset risk prediction model for assisted reproduction of children
CN117877744A
Model training method and device, storage medium and electronic equipment
CN118709754A