A model training method, a risk prediction method, an electronic device, and a storage medium
By jointly training and optimizing the loss values of models such as Random Forest and XGBoost, the overfitting problem of a single model in medical risk prediction is solved, achieving higher prediction accuracy and training efficiency.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- HITACHI LTD
- Filing Date
- 2023-09-04
- Publication Date
- 2026-06-05
Smart Images

Figure CN117290723B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of risk management, and in particular to a model training method, a risk prediction method, an electronic device, and a storage medium. Background Technology
[0002] With the advent of the era of medical big data, related companies have gradually realized the value of data through methods such as machine learning. At the same time, with the deepening of the concept of "integrated medical and elderly care", the public's awareness of health care and disease prevention has gradually increased, and they are increasingly looking forward to obtaining accurate assessments of their own physical condition.
[0003] Existing technologies have proposed methods for predicting risks by building models. However, most of these methods use a single model, which leads to inaccurate predictions due to the reliance on a single judgment method. Summary of the Invention
[0004] To address the aforementioned issues, this application proposes a model training method, a risk prediction method, an electronic device, and a storage medium that can train two different models, thereby improving the prediction accuracy of the trained model and mitigating the overfitting problem to some extent.
[0005] In a first aspect, this application provides a model training method, comprising: acquiring training samples, the training samples including training input values and real sample values; inputting the training input values into a first model to obtain a first predicted value, and inputting the training input values into a second model to obtain a second predicted value; calculating a third predicted value based on the first predicted value and the second predicted value; and calculating a loss value based on the third predicted value and the real sample values, the loss value being used to adjust the first model and the second model.
[0006] According to the model training method of the first aspect of this application, a third predicted value is obtained by calculating the first predicted value obtained by the first model and the second predicted value obtained by the second model, and a loss value is calculated based on the third predicted value, so that the loss value can be used to describe the loss of both the first and second models simultaneously. Ultimately, joint optimization of the first and second models is achieved, which can improve the prediction accuracy of the trained model and, to some extent, solve the overfitting problem.
[0007] In one possible implementation of the first aspect above, calculating the loss value based on the third predicted value and the true sample value includes calculating the loss value based on the third predicted value and the true sample value using a loss function.
[0008] The loss function is:
[0009]
[0010] In Formula 1, Y is the third predicted value, and I is the true sample value. i ω is the sample bias value, ω is a preset hyperparameter, and i is a natural number that indicates that the training sample is the i-th training sample.
[0011] In one possible implementation of the first aspect above, calculating the loss value based on the third predicted value and the true sample value includes:
[0012] Based on the loss function, the loss value is calculated according to the third predicted value and the true sample value.
[0013] The loss function is:
[0014]
[0015] In formula 2, Y is the third predicted value, Y is the true sample value, and i is a natural number representing that the training sample is the i-th training sample.
[0016] In one possible implementation of the first aspect above, calculating a third predicted value based on the first predicted value and the second predicted value includes: obtaining a first weight value and a second weight value; weighting the first predicted value using the first weight value and weighting the second predicted value using the second weight value; and calculating a third predicted value based on the weighted first predicted value and the weighted second predicted value.
[0017] In one possible implementation of the first aspect above, obtaining the first weight value and the second weight value includes: obtaining the first weight value and the second weight value using a third model.
[0018] In one possible implementation of the first aspect above, the method further includes: optimizing the first model, the second model, and the third model based on the loss value to make the loss function converge.
[0019] In one possible implementation of the first aspect above, the sample bias value is 1 when the training sample is defined as positive; and the sample bias value is 0 when the training sample is defined as negative.
[0020] In one possible implementation of the first aspect above, the training sample set includes a plurality of said training samples; the value of the hyperparameter ω depends on the number of said training samples defined as positive in the training sample set, and when the number of said training samples defined as positive in the first training sample set is greater than the number of said training samples defined as positive in the second training sample set, the hyperparameter ω corresponding to the first training sample set is not less than the hyperparameter ω corresponding to the second training sample set.
[0021] Secondly, this application provides a model training method, including: acquiring risk data related to user risk;
[0022] The risk data is input into a trained prediction model to obtain a prediction result, wherein the prediction model is trained using the model training method described in the first aspect above.
[0023] Thirdly, this application provides an electronic device, including: one or more processors; one or more memories; the one or more memories storing one or more programs, which, when executed by the one or more processors, cause the electronic device to perform the risk prediction method described in the second aspect.
[0024] Fourthly, this application provides a readable storage medium storing instructions that, when executed on a computer, cause the computer to perform the risk prediction method described in the second aspect.
[0025] The beneficial effects achieved by the embodiments of the second to fourth aspects are the same as those of the first aspect. Please refer to the description of the first aspect for details, which will not be repeated here. Attached Figure Description
[0026] Figure 1 According to some embodiments of this application, a schematic diagram of the structure of an electronic device is shown.
[0027] Figure 2 According to some embodiments of this application, a schematic flowchart of a model training method is shown.
[0028] Figure 3 According to some embodiments of this application, a schematic flowchart is shown in a model training method for calculating a third predicted value based on a first predicted value and a second predicted value.
[0029] Figure 4 According to some embodiments of this application, a flowchart of another model training method is shown. Detailed Implementation
[0030] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0031] It should be noted that although functional modules are divided in the device schematic diagram and a logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than the module division in the device or the order in the flowchart. The terms "first," "second," etc., in the specification, claims, and the aforementioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence.
[0032] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of this application only and is not intended to limit this application.
[0033] The following explains the terms that may be involved in this implementation.
[0034] A decision tree is a predictive model that represents a mapping between object attributes and object values. Each node in the tree represents an object, each branch represents a possible attribute value, and each leaf node corresponds to the value of the object represented by the path from the root node to that leaf node. The input and output of a decision tree are in one-to-one correspondence; that is, a decision tree has exactly one output for any given input.
[0035] Random Forest is a weak learner based on decision trees, suitable for classification and regression problems. A random forest model integrates multiple decision trees, forming a random forest. Each decision tree has a voting result, and the class with the most votes is the final model prediction.
[0036] XGBoost (eXtreme Gradient Boosting) is a weak learner based on decision trees. The decision trees in XGBoost are arranged sequentially; the generation of each subsequent decision tree considers the predictions of the previous one, taking into account any biases. New samples are sequentially fed into each decision tree in XGBoost. In the first decision tree, there is a predicted value; in the second, a predicted value, and so on, until all decision trees have been reached. Finally, the values from each decision tree are summed to obtain the final prediction. XGBoost uses a second-order Taylor expansion to optimize the objective function (loss function) and employs a regularization term to simplify the model and avoid overfitting.
[0037] Genetic Algorithms (GA) are methods that simulate natural selection and genetic mechanisms to solve problems, primarily used to find optimal solutions. Because biological evolution and the process of finding optimal solutions to certain problems share commonalities—both involve generating or searching for optimal solutions—algorithms based on natural selection, gene recombination, and gene mutation to simulate biological evolution mechanisms have emerged. These are commonly called genetic algorithms, which have ultimately evolved into a stochastic global search and optimization algorithm. The object of study in genetic algorithms is a population, a collection of many individuals. Corresponding to the problem being solved, each individual represents a solution, and the population represents the set of these solutions. Initially, all solutions may not be optimal. Through encoding, selection, crossover, and mutation of these solutions, evolution occurs generation by generation, and the globally optimal solution to the problem can be found from the offspring.
[0038] The background of this application is briefly described below.
[0039] The purpose of this application is to further improve the prediction accuracy of the trained model and, to some extent, solve the problem of overfitting.
[0040] Specifically, in predictive models applicable to medical purposes, predicting health or disease risk can be simplified to a regression problem of solving an unknown function for multiple variables. However, there may be multiple unknown functions, corresponding to different diseases, physical conditions, environmental factors, etc. Obtaining all unknown functions is impossible. Therefore, multiple weak learners (such as decision trees) can be used to represent a possible function, and ensemble weak learners can be used to replace solving multiple unknown functions. In the health risk prediction problem, the data used for training includes, as input data, various physical factors, environmental factors, lifestyle habits, medical history, etc. of the user; and as output data, comparison values, the actual disease status, severity, and length of hospital stay, etc.
[0041] In this application, the desired model output data is a risk prediction value (e.g., the risk of contracting a disease, a risk score for physical health, or the risk of hospitalization after contracting a disease). This risk prediction value can be presented as a numerical value used for evaluation; for example, 0 can be represented as no risk and 1 as a certainty of a negative event. Alternatively, the risk prediction value can be a graded representation of a certain risk, such as dividing risk levels into four levels: A, B, C, and D, with level A representing the highest risk and level D representing the lowest. Furthermore, the risk prediction value can represent a maximum likelihood inference; for example, regarding the risk of hospitalization after contracting a disease, a possible number of days of hospitalization, such as 15 days, can be given as the risk prediction value.
[0042] In known technologies, a model integrating multiple weak learners has been proposed to solve this type of risk problem. However, comparing the results of the trained model with the test set reveals that in the health field, a single model is prone to result bias after training, for example, it may be more biased towards representing results with higher risk or more biased towards representing results with lower risk.
[0043] Furthermore, due to limitations in data sources, the obtained sample sets are generally imbalanced, which can easily lead to overfitting when training a single model.
[0044] The hardware architecture in which the method of this application can be implemented is briefly described below.
[0045] Figure 1 A schematic diagram of an electronic device 100 is shown according to some embodiments of this application.
[0046] To address this problem, this application proposes a model training method and a risk prediction method, corresponding to the first and second aspects of this application, respectively. These methods can be applied, for example, to... Figure 1 The illustrated electronic device 100 includes one or more processors 101 and one or more memories 102. The memories 102 store one or more programs, which, when executed by the processors 101, cause the electronic device to perform the risk prediction method of the second embodiment. Furthermore, the electronic device 100 may also include a communication bus 103 and a communication interface 104. The communication bus 103 enables communication between the processors 102 and the memories 101, and the communication interface 104 communicates with external devices using various existing methods.
[0047] In this application, the electronic device corresponding to the model training method of the first aspect of this application is, for example, a consumer-grade computer system such as a desktop, laptop, handheld computer, notebook computer, or ultra-mobile personal computer (UMPC), or a server, which may be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms, or a terminal device with outstanding computing power.
[0048] The electronic device 100 corresponding to the risk prediction method of the second aspect of this application requires relatively weak computing power, and therefore can be applied to smaller or lower-power terminal devices, such as portable small terminal devices like smartphones, PDAs, tablets, and industrial terminals. Furthermore, some programmable devices with independent memory, such as microcontrollers, digital signal processors (DSPs), and field-programmable gate arrays (FPGAs), can also execute the method of the second aspect of this application. However, without considering cost or convenience, the electronic device 100 can also be an electronic device as applicable to the first aspect of this application. Alternatively, with technological advancements and increased computing power in portable or small computing devices, the model training method of the first aspect can also be implemented on electronic devices with relatively weak computing power.
[0049] The model training method proposed in the first aspect of this application is described below.
[0050] Figure 2 The present invention provides a schematic flowchart of a model training method based on some embodiments thereof.
[0051] refer to Figure 2 Easy to understand Figure 2 The model training method shown is one round of multi-round training, which includes four steps from S100 to S400.
[0052] In step S100, training samples for this round of training are obtained through pre-input data. For example, a training set for training the model is obtained from locations such as hospitals and statistical institutions, or through methods such as questionnaires and accumulated case studies, before training begins. This training set includes multiple training samples, which include training input values and real sample values. Each training sample in the training set has been pre-cleaned to remove samples that may cause noise to the training, such as removing duplicates and data that is obviously contrary to common sense. In some embodiments, cleaning the training set also includes converting the data into a specific format. In other embodiments, a pre-trained cleaning model is used to judge the reasonableness of the data to complete the data cleaning.
[0053] In step S200, the same training input values are input into the first model and the second model, respectively. The training input values can be individual numerical values, arrays, or digitized images. In this step, "input" also signifies specific processing and formatting for the corresponding model to meet its input requirements. For example, some first models require arrays in a specific format, so the training input values need to be formatted to meet this requirement. Similarly, some second models preprocess the training input values before input, so the training input values are input into a preset algorithm, and the algorithm's output value is used as the final input value for the second model. However, all these methods should be included within the aforementioned "input" or training input values. Likewise, the first predicted value output by the first model and the second predicted value output by the second model also need to undergo similar transformations to unify their formats.
[0054] In step S300, the first and second predicted values, using the same format, are used to calculate the third predicted value. In this step, the first and second predicted values can be input into a single model to calculate the third predicted value. This model can be, for example, a trained neural network model including at least one convolutional layer, a normalization layer, and an activation layer. Alternatively, an untrained neural network model can be used, and its structure will be optimized in subsequent processing steps to complete the training. Another example is a pre-defined algorithm. It should be noted that in the embodiments described later in the second aspect, the third predicted value is the final prediction result (or risk prediction value) output from the trained model. The data format of the third predicted value is determined by the various models and algorithms in steps S100 to S300, but for easier user understanding, it is preferable to use or convert it into a format easily understood by humans, such as a single real number or letter.
[0055] In step S400, the loss value is calculated based on the third predicted value and the true sample values corresponding to the input in the training set. This loss value allows the first and second models to be adjusted to complete one round of training. It should be noted that the loss value here should be interpreted broadly. It can represent not only a real or imaginary number, but also a multi-dimensional array, or, in image processing embodiments, a two-dimensional or three-dimensional image. It can also represent the structural differences between the true and predicted functions. The loss value reflects the gap, distance, or difference between the true and predicted values. Therefore, anything that reflects the "loss" of prediction itself should be considered a loss value.
[0056] Repeat steps S100 to S400 above to complete multiple rounds of training until the training objective is achieved, thus obtaining the trained model. The training objective may include, for example, reaching the preset maximum number of training rounds, narrowing the loss value to a certain preset range, the loss function for calculating the loss value converging, a certain metric reaching a preset target, or the training samples in the training set being exhausted.
[0057] In steps S100 to S400 above, to conveniently demonstrate the main beneficial effects of this application, the description focuses on one round of multi-round training, while the initialization of the first and second models is omitted. In specific implementations, corresponding initialization methods can be adopted for the specific types of the first and second models. The method of establishing the initial model does not affect the realization of the beneficial effects of this application, so it is not limited, and various known initialization methods can be used.
[0058] Based on steps S100 to S400 above, the output values of the first and second models are unified by calculating a third predicted value from the first and second predicted values. A loss value is then calculated using the third predicted value and the true sample value, and this loss value is used to adjust the first and second models, completing the joint optimization of the first and second models. Therefore, the first and second models are well integrated, and the accuracy of the risk prediction value output by the joint model obtained through training is higher than that of known techniques. Furthermore, because two different models are used simultaneously, and the structures and output results of the two models differ after training, the probability of overfitting can be reduced to some extent.
[0059] In some embodiments, the loss value in step S400 is calculated using a preset loss function; therefore, step S400 further includes step S401: calculating the loss value based on the third predicted value and the true sample value using the loss function. The loss function is, for example:
[0060]
[0061] In formula 1, This is the third predicted value, Y is the true sample value, and I is the third predicted value. i ω is the sample bias value, ω is a preset hyperparameter, and i is a natural number representing that the training sample is the i-th training sample. When only one training sample is input in each round of training, the natural number i can also represent that the current round of training is the i-th round.
[0062] Formula 1 will be explained in detail below.
[0063] Formula 1 is a loss function designed to take into account the sample distribution in typical data sources in the health risk domain. In the health risk domain, data sources from hospitals often exhibit a large number of true values, meaning that most true sample values are for patients with the disease (defined as positive for training samples). Alternatively, questionnaires from schools often show a large number of non-patients with the disease, meaning that most true sample values are for patients with the disease (defined as negative for training samples). Therefore, this application designs a loss function as shown in Formula 1, which can take into account the sample distribution and thus improve the accuracy of the trained model.
[0064] Specifically, when the training samples are defined as positive, the sample bias value I i The sample bias value I is 1 when the training sample is defined as negative. i The value is 0. This completes the classification of different samples. When the sample bias value I... i When the value is 1, Formula 1 retains only the left-hand side term. When the sample bias value I... i When the value is 0, Equation 1 retains only the right-hand side. Based on the above settings, the bias in the distribution of samples in the training set can be balanced, thus solving the problem of potential overfitting.
[0065] Furthermore, to preserve the biased features of the sample distribution, Equation 1 includes a pre-defined hyperparameter ω. This hyperparameter ω is obtained, for example, by inputting the entire training set into another pre-trained model. The characteristic of the hyperparameter ω is that its value increases as the number of positive training samples in a training set (or sample set) increases, thereby improving training performance. The hyperparameter ω can also be obtained through an additional iterative algorithm. The core idea of this iteration is to reduce the loss function. Therefore, an additional algorithm or model can be set up with the loss function and training samples as input, using the reduction of the loss function as the objective function, and the hyperparameter ω as the output value of this algorithm or model.
[0066] According to the above embodiment, by setting the hyperparameter ω and the sample bias value I... i This improved the accuracy of the trained model and increased training efficiency.
[0067] In other embodiments, in step S400, considering the different targets of the output third predicted value, step S402 is set as Formula 2 as follows.
[0068]
[0069] In formula 2, The third predicted value is Y, the true sample value is Y, and i is a natural number representing that the current training sample is the i-th training sample. When only one training sample is input in each round of training, the natural number i can also represent that the current round of training is the i-th round.
[0070] Unlike Equation 1, Equation 2 applies to the third predicted value in health risk problems where the imbalance in the training set's sample distribution has little impact. Illustratively, Equation 1 applies when the third predicted value represents whether or not the individual is ill, while Equation 2 applies when the third predicted value represents the number of days of hospitalization. Clearly, in health risk problems, the training set does not exhibit sample imbalance related to the number of days of hospitalization. Therefore, for the case of the number of days of hospitalization, the loss function is solely a regression problem; however, for the case of whether or not the individual is ill, considering the sample distribution, the loss function simultaneously considers both regression and selection problems.
[0071] The loss values calculated using Formulas 1 and 2 above can be used to adjust the structure of the first and / or second models, thereby optimizing them. When the first model is a random forest model, for example, the random forest can be pruned based on the loss value, removing decision trees or leaf nodes that are far from the loss value. When the second model is an XGBoost model, for example, the leaf node values can be optimized using gradient descent or Newton's method based on the loss value. When the first and second models are other models, suitable adjustment / optimization methods can also be used.
[0072] The above embodiments enable the selection of appropriate loss functions for different problems, thereby improving the efficiency of model training.
[0073] Figure 3 According to some embodiments of this application, a schematic flowchart of a model training method is shown.
[0074] refer to Figure 3 In some embodiments, step S300 further includes steps S301 to S303. Step S01: Obtain a first weight value and a second weight value; Step S302: Weight the first predicted value using the first weight value and weight the second predicted value using the second weight value; Step S303: Calculate a third predicted value based on the weighted first predicted value and the weighted second predicted value.
[0075] Specifically, in order to better obtain the third predicted value, this application sets up Formula 3.
[0076]
[0077] In Formula 3, Y1 is the third predicted value, Y2 is the first predicted value, α is the second predicted value, and β is the first weight value.
[0078] By reasonably setting weight values through steps S301 to S303, the accuracy of the third predicted value can be increased.
[0079] In step S301, the first weight value α and the second weight value β can be obtained by, for example, preset empirical parameters or by a preset algorithm.
[0080] For example, a third model can be used to obtain the first and second weight values. This third model could be a well-known model or algorithm for the optimization problem, such as gridded optimization, stochastic optimization, or a Bayesian optimization method using the aforementioned loss function as the objective function. Alternatively, the third model could be a pre-trained neural network model that calculates the gradients of α and β, using Equation 1 or Equation 2, or an independent loss function, as the loss function for the third model, and then optimizing it using the gradient descent algorithm.
[0081] In some specific embodiments, the third model is, for example, a genetic algorithm, i.e., evolutionary optimization. In this embodiment, the first weight value α and the second weight value β are used as evolutionary factors, and Equation 1 or Equation 2 is used as the loss function (or objective function). Multiple populations are constructed on different training sets, and iterative evolution is performed with the goal of minimizing the loss function of Equation 1 or Equation 2, while optimizing the first weight value α and the second weight value β, thereby adjusting the weights of the first and second models to achieve the desired third prediction value. The accuracy of predictions has increased.
[0082] In the various embodiments of the first aspect described above, the first model, the second model, and the third model use the same loss function (Formula 1 or Formula 2), calculate consistent loss values, and optimize themselves using this loss function. Therefore, in the embodiments of the first aspect of this application, the first model, the second model, and the third model are merged. Based on a sample set in the health risk domain, optimizations are performed on regression, classification, and optimization problems respectively, thereby improving the reliability of the prediction results of the model trained by this model training method.
[0083] After multiple rounds of training using the training methods described in the above embodiments, a trained model can be obtained. In some embodiments, the trained model will also be tested to evaluate the training effectiveness.
[0084] When testing the model, a test set that does not overlap with or partially overlaps with the training samples is used. The test set includes multiple test samples, comprising test input values and test true values. The test input values correspond to the training input values in the training samples, and the test true values correspond to the true sample values in the training samples. The data sources for the test set are the same as those for the training set. To improve testing performance, it is preferable to distribute the samples in a test set that differs from the training set. Since health risk data is mostly sensitive data, difficult to obtain or costly to acquire, from a cost-saving perspective, randomly generated samples can be used as the test set. However, it should be noted that in this field, noise added to the test samples can significantly affect the accuracy of the true sample values (or test true values), so using generated data as the test set or training set is generally not considered.
[0085] The testing method involves inputting the test input values of the test samples into the trained model to obtain the predicted test values, and then comparing the predicted test values with the actual test values. The evaluation metrics are as follows:
[0086] For classification problems (using the model in Formula 1):
[0087] TP (True Positive): The prediction is positive and the prediction is correct (the actual value is 1, and the prediction is also 1).
[0088] FP (False Positive): Predicted as positive, but the prediction is wrong (the actual value is 0, but the prediction is 1);
[0089] TN (True Negative): The prediction is negative and the prediction is correct (the actual value is 0, and the prediction is also 0).
[0090] FN (False Negative): Predicted as negative, but the prediction is incorrect (the actual value is 1, but the prediction is 0).
[0091] The performance evaluation metrics for classification models include:
[0092] Accuracy: The number of correctly classified samples divided by the total number of samples.
[0093]
[0094] Precision: The proportion of samples correctly predicted as positive out of all samples predicted as positive, also known as the accuracy rate.
[0095]
[0096] Recall: The proportion of samples that are actually positive that are correctly predicted; also known as the completeness of the sample count.
[0097]
[0098] Precision and recall are contradictory metrics. Generally, a high precision often leads to a low recall, and vice versa. If both metrics are desirable, the F1 score of the model can be calculated.
[0099] F1 score: The harmonic mean of precision and recall.
[0100]
[0101] Classification problem (using Formula 2):
[0102]
[0103] Y represents the test predicted value, and Y represents the test true value.
[0104] In some embodiments, thresholds are set for each of the above indicators. When one or more indicators fail to meet the set thresholds, the trained model is deemed unqualified.
[0105] The above testing methods can effectively evaluate the prediction accuracy of the trained model.
[0106] The risk prediction method proposed in the second aspect of this application is described below.
[0107] The risk prediction method of the second aspect of this application can be deployed in, for example... Figure 1 The electronic device 100 is based on a model trained using the training method described in the first aspect. Specifically, the risk prediction method includes: obtaining risk data related to user risk through a human-computer interaction interface or a data acquisition device; then inputting the risk data into the trained model and obtaining the prediction result output by the model. It is readily understood that this prediction result is actually the third prediction value in the embodiment of the first aspect.
[0108] Risk prediction methods can include multiple trained models for different risk data. The output prediction results will vary depending on the model. In some specific embodiments, optional prediction results may include: risk of developing a specific disease, risk of hospitalization for a specific disease, and length of hospitalization for a specific disease; the specific diseases mentioned above include, for example, retinopathy, cardiomegaly, dyslipidemia, myocardial infarction, cerebral infarction, hypertension, diabetes, and kidney disease; the risk data mentioned above includes, for example, age, BMI, blood pressure, blood lipids, lifestyle habits, medications, complications, etc. The type of prediction results output will also change based on different models and different risk data. The type of prediction results may include, for example, the risk of developing the selected disease, whether the disease will be severe enough to require hospitalization, and the number of days the patient may need to be hospitalized. Disease risk may be represented using probability values from 0 to 1, hospitalization risk may be represented using ratings such as A, B, C, and D, and the number of days of hospitalization may be a specific number. In some embodiments, a particular model can further predict the user's future medical expenses.
[0109] In some embodiments, the electronic device 100 may further include a visualization interface. The electronic device can transmit: a first agent that inputs a prediction target, and a second agent that inputs risk data. The electronic device 100 selects a suitable trained model based on the first and / or second agents, and inputs the risk data into the model to obtain a prediction result corresponding to the first and / or second agents. This prediction result is displayed on the visualization interface by the electronic device 100, allowing the user to intuitively understand the prediction result. The first agent includes selecting multiple specific diseases, such that the prediction result corresponds to a risk probability table for different diseases output by the first agent. The aforementioned first and second agents are signals generated within the electronic device through user interaction with the human-computer interaction device.
[0110] Through the application of the second aspect of this application, a comprehensive and easy-to-understand medical data mining result can be obtained, which can provide predictions of medical expenses in certain future years and the risk of developing eight major diseases (the eight major diseases include retinopathy, cardiomegaly, lipid dysplasia, myocardial infarction, cerebral infarction, hypertension, diabetes, and kidney disease). The prediction results will greatly enhance the value of medical information resources and even be extended to the field of commercial applications.
[0111] It is readily understood that the training method of the first aspect of this application is designed for the risk prediction method of the second aspect. Therefore, the training samples in the first aspect are, for example, risk data training samples, which include risk data input values and actual occurrence values; their first predicted value is a first predicted risk value, their second predicted value is a second predicted risk value, and their third predicted value is a third predicted risk value. Here, the risk occurrence value refers to a actually occurring risk event. In some embodiments, the risk data is user health data.
[0112] Figure 4 According to some embodiments of this application, a flowchart of another model training method is shown.
[0113] refer to Figure 4 The model training method is used to train a risk prediction model, including steps S500 to S800. Step S500: Obtain risk data training samples, which include risk data input values and actual occurrence values; Step S600: Input the risk data training input values into a first model to obtain a first predicted risk value, and input the risk data training input values into a second model to obtain a second predicted risk value; Step S700: Calculate a third predicted risk value based on the first and second predicted risk values; Step S800: Calculate a loss value based on the third predicted risk value and the actual occurrence value. The first model is, for example, a random forest model, and the second model is, for example, an XGBoost model. The selection of the first and second models is based on experience and is suitable for risk prediction. In the field of risk prediction, random forest and XGBoost models are experimentally tested and are considered relatively accurate models. The loss value obtained in step S800 is used to adjust the first and second models. It is readily understood that the various embodiments described in the first aspect above are also designed to meet the needs of risk prediction models.
[0114] While the above embodiments mention that the risk prediction method of the second aspect of this application is applied to the prediction of health risks, it is not limited thereto. Clearly, the method of this embodiment can also be used for other risk issues, such as predicting the risk of forest fires based on factors like temperature, humidity, rainfall, wind speed, and population movement, and predicting the intensity of forest fires and their duration, given limited firefighting resources, using different models.
[0115] Although the above embodiments mention that the model training method of the first aspect of this application uses a specific loss function to obtain the loss value, it is not limited thereto. In some embodiments, a loss image and a real image can be obtained by binarizing the real and predicted values, and then the loss image can be obtained by subtracting the two images. Finally, a preset algorithm is used to convert the loss image into a loss value.
[0116] While the above embodiments mention that the model training method of the first aspect of this application uses loss values to optimize the architecture of the first model and / or the second model and / or the third model, it is not limited thereto. In some embodiments, for example, the second model may be degraded while optimizing the first model. This is because the purpose of this application is to reduce the final loss value and obtain a more accurate third prediction value. In certain specific cases, adjusting a model to degrade it can better achieve this purpose.
[0117] Furthermore, this application also proposes a computer-readable storage medium. This computer-readable storage medium includes volatile or non-volatile, removable or non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, computer program modules, or other data). Computer-readable storage media include, but are not limited to, RAM (Random Access Memory), ROM (Read-Only Memory), EEPROM (Electrically Erasable Programmable Read-Only Memory), flash memory or other memory technologies, CD-ROM (Compact Disc Read-Only Memory), DVD or other optical disc storage, magnetic cartridges, magnetic tapes, disk storage or other magnetic storage devices, or any other medium that can be used to store desired information and is accessible by a computer. The model training method or risk prediction method of this application is stored on a computer-readable storage medium.
[0118] Those skilled in the art will understand that all or some of the steps in the methods disclosed above, as well as the functional modules / units in the systems and devices, can be implemented as software, firmware, hardware, or appropriate combinations thereof.
[0119] It is understood that, as used herein, the term “module” may refer to or include, or be part of, an application-specific integrated circuit (ASIC), electronic circuitry, a processor (shared, dedicated, or grouped) and / or memory that executes one or more software or firmware programs, combinational logic circuitry, and / or other suitable hardware components that provide the described functionality.
[0120] It is understood that in the various embodiments of this application, the processor may be a microprocessor, a digital signal processor, a microcontroller, etc., and / or any combination thereof. According to another aspect, the processor may be a single-core processor, a multi-core processor, etc., and / or any combination thereof.
[0121] The embodiments disclosed in this application can be implemented in hardware, software, firmware, or a combination of these implementation methods. Embodiments of this application can be implemented as computer programs or program code executable on a programmable system, the programmable system including at least one processor, a storage system (including volatile and non-volatile memory and / or storage elements), at least one input device, and at least one output device.
[0122] Program code can be applied to input instructions to execute the functions described in this application and generate output information. The output information can be applied to one or more output devices in a known manner. For the purposes of this application, the processing system includes any system having a processor such as, for example, a digital signal processor (DSP), a microcontroller, an application-specific integrated circuit (ASIC), or a microprocessor.
[0123] The program code can be implemented using a high-level procedural language or an object-oriented programming language to communicate with the processing system. Assembly language or machine language can also be used when needed. In fact, the mechanisms described in this application are not limited to any particular programming language. In either case, the language can be a compiled language or an interpreted language.
[0124] In some cases, the disclosed embodiments may be implemented in hardware, firmware, software, or any combination thereof. The disclosed embodiments may also be implemented as instructions carried or stored thereon on one or more temporary or non-temporary machine-readable (e.g., computer-readable) storage media, which may be read and executed by one or more processors. For example, the instructions may be distributed via a network or through other computer-readable media. Therefore, machine-readable media may include any mechanism for storing or transmitting information in a machine-readable (e.g., computer-readable) form, including but not limited to floppy disks, optical disks, CD-ROMs, magneto-optical disks, read-only memory (ROM), random access memory (RAM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), magnetic cards or optical cards, flash memory, or tangible machine-readable storage for transmitting information (e.g., carrier waves, infrared signals, digital signals, etc.) using the Internet in the form of electrical, optical, acoustic, or other propagation signals. Therefore, machine-readable media include any type of machine-readable medium suitable for storing or transmitting electronic instructions or information in a machine-readable (e.g., computer-readable) form.
[0125] In the accompanying drawings, some structural or methodological features may be shown in a specific arrangement and / or order. However, it should be understood that such a specific arrangement and / or order may not be necessary. Rather, in some embodiments, these features may be arranged in a manner and / or order different from that shown in the illustrative drawings. Furthermore, the inclusion of structural or methodological features in a particular figure does not imply that such features are required in all embodiments, and in some embodiments, these features may be omitted or may be combined with other features.
[0126] It should be noted that all units / modules mentioned in the device embodiments of this application are logical units / modules. Physically, a logical unit / module can be a physical unit / module, a part of a physical unit / module, or a combination of multiple physical units / modules. The physical implementation of these logical units / modules themselves is not the most important factor; the combination of functions implemented by these logical units / modules is the key to solving the technical problems proposed in this application. Furthermore, to highlight the innovative aspects of this application, the above-described device embodiments of this application have not introduced units / modules that are not closely related to solving the technical problems proposed in this application. This does not mean that the above-described device embodiments do not contain other units / modules.
[0127] It should be noted that in the examples and description of this patent, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one" does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0128] Although this application has been illustrated and described with reference to certain preferred embodiments thereof, those skilled in the art will understand that various changes in form and detail may be made thereto without departing from the scope of this application.
Claims
1. A model training method, characterized in that, The method includes: Obtain risk data training samples, which include risk data input values and actual occurrence values; The risk data input value is input into the first model to obtain the first predicted risk value, and the risk data input value is input into the second model to obtain the second predicted risk value; The first and second weight values are obtained using the third model; The first predicted risk value is weighted using the first weight value, and the second predicted risk value is weighted using the second weight value. Calculate the third predicted risk value based on the weighted first predicted risk value and the weighted second predicted risk value; The loss value is calculated based on the third predicted risk value and the actual occurrence value. This loss value is used to adjust the first model and the second model. The risk data input values include: various physical factors, environmental factors, lifestyle habits, and medical history of the user; the actual occurrence values include: the actual illness status, severity, and number of days of hospitalization.
2. The model training method according to claim 1, characterized in that, The calculation of the loss value based on the third predicted risk value and the actual occurrence value includes: Based on the loss function, the loss value is calculated according to the third predicted risk value and the actual occurrence value. The loss function is: (Official 1) In Formula 1, It is the third predicted risk value. This is the actual occurrence value. It is the sample bias value. is a preset hyperparameter, i is a natural number and represents that the risk data training sample is the i-th risk data training sample.
3. The model training method according to claim 1, characterized in that, The calculation of the loss value based on the third predicted risk value and the actual occurrence value includes: Based on the loss function, the loss value is calculated according to the third predicted risk value and the actual occurrence value. The loss function is: (Official 2) In formula 2, It is the third predicted risk value. It is the actual occurrence value, where i is a natural number and represents that the risk data training sample is the i-th risk data training sample.
4. The model training method according to claim 1, characterized in that, Also includes: The first model, the second model, and the third model are optimized based on the loss value to make the loss function converge.
5. The model training method according to claim 2, characterized in that, When the risk data training sample is defined as positive, the sample bias value is 1; When the risk data training sample is defined as negative, the sample bias value is 0.
6. The model training method according to claim 2, characterized in that, The risk data training sample set includes multiple risk data training samples; The hyperparameters The value depends on the number of positive risk data training samples in the risk data training sample set, and when the number of positive risk data training samples in the first risk data training sample set is greater than the number of positive risk data training samples in the second risk data training sample set, the hyperparameter corresponding to the first risk data training sample set... The hyperparameters should not be less than those corresponding to the second risk data training sample set. .
7. A risk prediction method, characterized in that, include: Obtain risk data related to user risk; The risk data is input into a trained prediction model to obtain a prediction result, wherein the prediction model is trained using the model training method described in any one of claims 1 to 6.
8. An electronic device, characterized in that, include: One or more processors; One or more memories; the one or more memories store one or more programs that, when executed by the one or more processors, cause the electronic device to perform the risk prediction method of claim 7.
9. A readable storage medium, characterized in that, The storage medium stores instructions that, when executed on a computer, cause the computer to perform the risk prediction method of claim 7.