Model training method and device, storage medium and processor
By dynamically adjusting the sample distribution density as the loss weight in model training, the model weight problem caused by imbalanced sample data is solved, the classification performance of difficult-to-separate samples is improved, and the overall prediction accuracy is improved.
Patent Information
- Application Number
- CN202411349549.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-25
- Publication Date
- 2025-01-17
AI Technical Summary
When building an intelligent prediction model, due to the unbalanced sample data, the large number of easy-to-segment samples leads to excessive attention and ignore difficult-to-segment samples, which reduces the classification performance of difficult-to-segment samples.
By dynamically adjusting the proportion of easy-to-segment samples and difficult-to-segment samples in the overall loss of the model, using prediction errors to determine the sample distribution density as the loss weight, adjust the weight of the sample during model training, reduce the impact of easy-to-segment samples, and improve the difficulty-to-segment samples Classification performance.
It effectively reduces the model's emphasis on easy-to-segment samples, improves the classification performance of difficult-to-segment samples, and improves the overall prediction accuracy of the model.
Smart Images

Figure CN119322970A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and in particular to a model training method, device, storage medium and processor. Background Art
[0002] With the rapid development of artificial intelligence technology, it has been widely used in various industries and fields. For example, in the field of medical health, artificial intelligence technology is used to transform clinical big data into clinically usable knowledge, and build intelligent prediction models to provide risk warnings for diseases.
[0003] However, in the process of building intelligent prediction models, we often encounter some unbalanced sample data processing, such as sample data with different sample numbers of different categories such as rare diseases. Since the number of normal samples in such data is much larger than the number of abnormal samples, the number of easy-to-classify samples is relatively large during the training process of the intelligent prediction model, causing the model to over-focus on easy-to-classify samples and ignore difficult-to-classify samples, resulting in a decrease in the model's classification performance for difficult-to-classify samples. Summary of the invention
[0004] Based on the above problems, the present application provides a model training method, device, storage medium and processor, the purpose of which is to improve the classification performance of the model for difficult-to-separate samples by dynamically adjusting the proportion of easy-to-separate samples and difficult-to-separate samples in the overall loss of the model when processing a training sample set in which the number of first-category samples is less than the number of second-category samples.
[0005] The embodiments of the present application disclose the following technical solutions:
[0006] In a first aspect, the present application provides a model training method, the method comprising:
[0007] Obtaining a training sample set for training an initial prediction model, wherein the training samples of the training sample set include first-class samples and second-class samples, the sample labels of the first-class samples are target labels, the sample labels of the second-class samples are non-target labels, and the number of the first-class samples in the training sample set is less than the number of the second-class samples;
[0008] Determine the prediction results corresponding to each training sample in the training sample set through the initial prediction model;
[0009] According to the prediction error obtained from the prediction result and the sample label of the corresponding training sample, the sample distribution density corresponding to each training sample is determined; wherein, for the i-th training sample in the training sample set, the number of errors of the prediction errors of all training samples in the error value interval with the prediction error of the i-th training sample as the center point is determined, and the sample distribution density corresponding to the i-th training sample is determined according to the number of errors;
[0010] According to the prediction results and sample distribution density of each training sample, a prediction loss function is constructed; in the prediction loss function, the sample distribution density is used as the loss weight of the corresponding prediction result, and the loss weight is negatively correlated with the corresponding sample distribution density;
[0011] The parameters of the initial prediction model are adjusted through the prediction loss function to obtain the prediction model; the prediction model is used to identify whether the data to be processed belongs to the target category corresponding to the target label, or belongs to other categories corresponding to the non-target label.
[0012] In an optional implementation, for the i-th training sample in the training sample set, determining the number of errors of the prediction errors of all training samples in an error value interval with the prediction error of the i-th training sample as the center point, and determining the sample distribution density corresponding to the i-th training sample according to the number of errors, including:
[0013] Determining a target length based on the number of training samples in the training sample set;
[0014] Take the prediction error of the i-th training sample as the center point and the target length as the radius to determine the error value interval corresponding to the i-th training sample;
[0015] The number of errors of the prediction errors of all training samples in the error value interval corresponding to the i-th training sample is counted, and the sample distribution density corresponding to the i-th training sample is determined according to the number of errors.
[0016] In an optional implementation, determining the sample distribution density corresponding to the i-th training sample according to the number of errors includes:
[0017] Determine the interval length of the error value interval corresponding to the i-th training sample;
[0018] Based on the number of errors and the interval length, the sample distribution density corresponding to the i-th training sample is determined.
[0019] In an optional implementation, before obtaining a training sample set for training an initial prediction model, the model training method further includes:
[0020] Acquire a target data set; the target data set includes a plurality of sample data, and each sample data includes a plurality of sub-data;
[0021] Determine the data missing rate of the sample data based on the missing conditions of the sub-data in each sample data, and obtain the data missing rate of each sample data;
[0022] The missing sub-data in each sample data is filled with data according to the data missing rate to obtain a training sample.
[0023] In an optional implementation, data filling processing is performed on the missing sub-data in the sample data according to the data missing rate of each sample data to obtain a training sample, including:
[0024] Determine whether the data missing rate of the sample data is less than a preset threshold;
[0025] If the data missing rate of the sample data is greater than or equal to the preset threshold, the sample data is deleted;
[0026] If the data missing rate of the sample data is less than a preset threshold, and the missing sub-data in the sample data is numerical data, all target sub-data in the target data set are obtained, and the missing sub-data in the sample data are filled based on the average value of all target sub-data to obtain a training sample; the data category of the target sub-data is the same as the data category of the missing sub-data, and the sample label of the sample data corresponding to the target sub-data is the same as the sample label of the sample data corresponding to the missing sub-data.
[0027] In an optional implementation, a prediction loss function is constructed according to the prediction results of each training sample and the sample distribution density, including:
[0028] Determining a target adjustment parameter based on the number of samples in the first category and the number of samples in the second category;
[0029] A prediction loss function is constructed based on the target adjustment parameters, the prediction results of each training sample and the sample distribution density.
[0030] In a second aspect of the present application, a model training device is provided, the device comprising:
[0031] An acquisition module is used to acquire a training sample set for training an initial prediction model, wherein the training samples of the training sample set include first-class samples and second-class samples, the sample labels of the first-class samples are target labels, the sample labels of the second-class samples are non-target labels, and the number of the first-class samples in the training sample set is less than the number of the second-class samples;
[0032] A prediction module, used to determine the prediction results corresponding to each training sample in the training sample set through an initial prediction model;
[0033] The sample distribution density determination module is used to determine the sample distribution density corresponding to each training sample according to the prediction error obtained from the prediction result and the sample label of the corresponding training sample; wherein, for the i-th training sample in the training sample set, the error number of the prediction errors of all training samples in the error value interval with the prediction error of the i-th training sample as the center point is determined, and the sample distribution density corresponding to the i-th training sample is determined according to the error number;
[0034] The loss function construction module is used to construct a prediction loss function according to the prediction results and sample distribution density of each training sample; in the prediction loss function, the sample distribution density is used as the loss weight of the corresponding prediction result, and the loss weight is negatively correlated with the corresponding sample distribution density;
[0035] The model training module is used to adjust the parameters of the initial prediction model through the prediction loss function to obtain the prediction model; the prediction model is used to identify whether the data to be processed belongs to the target category corresponding to the target label, or belongs to other categories corresponding to the non-target label.
[0036] Optionally, the sample distribution density determination module includes:
[0037] a length determination unit, configured to determine a target length based on the number of training samples in the training sample set;
[0038] An error value interval determination unit is used to determine the error value interval corresponding to the i-th training sample in the training sample set, taking the prediction error of the i-th training sample as the center point and the target length as the radius;
[0039] The sample distribution density determination unit is used to count the number of errors of the prediction errors of all training samples in the error value interval corresponding to the i-th training sample, and determine the sample distribution density corresponding to the i-th training sample according to the number of errors.
[0040] In a third aspect of the present application, a computer-readable storage medium is provided, in which a computer program is stored. When the computer program is executed by a processor, the model training method introduced in the first aspect is implemented.
[0041] In a fourth aspect of the present application, a processor is provided for running a computer program, and when the computer program is running, the model training method introduced in the first aspect is executed.
[0042] Compared with the prior art, this application has the following beneficial effects:
[0043] In the technical solution of the present application, when processing a training sample set in which the number of samples of the first category is less than the number of samples of the second category, the error value interval determined with the prediction error of each training sample as the center point can more accurately determine the true error level of each training sample, avoiding the problem of low accuracy of the error level of the determined training samples caused by approximate error estimation based on the similarity between the prediction errors of training samples in a fixed interval. Therefore, for the i-th training sample in the training sample set, by determining the number of errors of the prediction errors of all training samples in the error value interval with the prediction error of the i-th training sample as the center point, and determining the sample distribution density corresponding to the i-th training sample based on the number of errors, each training sample can be accurately determined. The corresponding sample distribution density can be used to accurately determine whether the training sample is an easy-to-separate sample or a difficult-to-separate sample according to the sample distribution density; a prediction loss function is constructed according to the prediction results and sample distribution density of each training sample, and the sample distribution density is used as the loss weight of the corresponding prediction result, so that the loss weight is negatively correlated with the corresponding sample distribution density. The prediction model is obtained by adjusting the parameters of the initial prediction model through the prediction loss function, which can dynamically adjust the proportion of easy-to-separate samples and difficult-to-separate samples in the overall loss of the model, reduce the proportion of easy-to-separate samples in the overall loss of the model, avoid the problem of the model's excessive focus on easy-to-separate samples and neglect of difficult-to-separate samples, resulting in a decrease in the classification performance of the model for difficult-to-separate samples, and improve the model's classification performance for difficult-to-separate samples. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0045] Figure 1 A flowchart of a model training method provided in an embodiment of the present application;
[0046] Figure 2 A flow chart of a sample distribution density determination process provided in an embodiment of the present application;
[0047] Figure 3 A schematic diagram of an error value interval provided in an embodiment of the present application;
[0048] Figure 4 A flowchart of a data filling process provided in an embodiment of the present application;
[0049] Figure 5 A flowchart of another data filling process provided in an embodiment of the present application;
[0050] Figure 6 A schematic diagram of the structure of a model training device provided in an embodiment of the present application;
[0051] Figure 7 A schematic diagram of the structure of a sample distribution density determination module provided in an embodiment of the present application. DETAILED DESCRIPTION
[0052] As described above, in the process of building intelligent prediction models, we often encounter the problem of processing some unbalanced sample data. Since the number of normal samples in such data is much larger than the number of abnormal samples, during the training process of the intelligent prediction model, the model pays too much attention to easy-to-classify samples and ignores difficult-to-classify samples, resulting in a decrease in the classification performance of the model for difficult-to-classify samples.
[0053] After research, the inventors have proposed a model training method. When processing a training sample set in which the number of samples of the first category is less than the number of samples of the second category, the error value interval determined with the prediction error of each training sample as the center point can more accurately estimate the true error level of each training sample, avoiding the problem of low accuracy of the error level of the determined training samples caused by approximate error estimation based on the similarity between the prediction errors of training samples in a fixed interval. Therefore, for the ith training sample in the training sample set, by determining the error number of the prediction errors of all training samples in the error value interval with the prediction error of the ith training sample as the center point, and determining the sample distribution density corresponding to the ith training sample based on the error number, the accuracy of each training sample can be accurately determined. The sample distribution density corresponding to the training sample can accurately determine whether the training sample is an easy-to-separate sample or a difficult-to-separate sample based on the sample distribution density; the inventor also proposed to construct a prediction loss function based on the prediction results and sample distribution density of each training sample, and use the sample distribution density as the loss weight of the corresponding prediction result, so that the loss weight is negatively correlated with the corresponding sample distribution density, so that the prediction model is obtained by adjusting the parameters of the initial prediction model through the prediction loss function, which can dynamically adjust the proportion of easy-to-separate samples and difficult-to-separate samples in the overall loss of the model, reduce the proportion of easy-to-separate samples in the overall loss of the model, avoid the problem of the model's excessive focus on easy-to-separate samples and neglect of difficult-to-separate samples, resulting in a decrease in the classification performance of the model for difficult-to-separate samples, and improve the classification performance of the model for difficult-to-separate samples.
[0054] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0055] Exemplarily, the prediction model used in the model training method of the present application can be a model for processing text data, image data, audio data and other data, such as a machine learning model such as a logistic regression model, a decision tree model, a random forest model, and a deep learning model. Thus, the training samples can be sample data such as text samples, image samples, and audio samples in various fields, such as relevant data in the medical and health field, relevant data in the network security field, relevant data in the financial industry, and relevant image data in the medical imaging field.
[0056] For example, in the financial industry, a prediction model can be used to predict the risk level of illegal transactions of customers based on their transaction data. Usually, the number of illegal transactions (minority samples) is much lower than the number of normal transactions (majority samples). If the order of magnitude difference in the number of sample data is ignored during model training, and the model is trained directly using the sample data, the model will focus too much on easy-to-distinguish samples (i.e., normal transactions) and ignore difficult-to-distinguish samples (i.e., illegal transactions) during training, resulting in a decrease in the model's classification performance for difficult-to-distinguish samples. Therefore, when a trained prediction model is used to predict the risk level of illegal transactions of a customer based on the collected credit card transaction data of the customer, it is impossible to accurately identify the signal that the customer has engaged in illegal transactions, resulting in a low accuracy rate in model prediction.
[0057] For example, in the field of medical health, the number of patients with a certain rare disease (minority samples) is usually far less than the number of healthy individuals (majority samples). Take amyloidosis as an example. Amyloidosis is a rare blood system disease that affects multiple organs. Due to the lack of diagnosis opportunities and insufficient experience, manual diagnosis is prone to misdiagnosis and missed diagnosis. Therefore, the prediction model can be used to predict the patient's risk level based on the patient's examination index data. However, if the problem of the magnitude difference in the quantity of the above sample data is ignored during the model training process, and the model is directly trained through the above sample data, it will cause the model to over-focus on the sample data of healthy individuals and ignore the sample data of patients with rare diseases during the training process. Therefore, when the risk level of the patient is predicted based on the collected patient examination index data through the trained prediction model, the patient's risk level cannot be accurately predicted.
[0058] For example, in the field of medical imaging, the patient's risk level can be predicted through the patient's medical imaging images. Taking lung tumor disease as an example, the number of lung CT scan images of patients with lung tumor disease is much lower than the number of lung CT scan images of healthy individuals. If the problem of the magnitude difference in the number of sample data is ignored during the model training process, and the model is directly trained through the above sample data, it will cause the model to over-focus on the image features of the lung CT scan images of healthy individuals during the training process, while ignoring the image features of the lung CT scan images of patients with lung tumor disease. As a result, when the trained prediction model is used to predict the patient's risk level based on the collected lung CT scan images of the patient, the patient's risk level cannot be accurately predicted.
[0059] It should be noted that the model training method provided in the embodiments of the present application can be applied to other application scenarios of unbalanced sample data processing in addition to the above three application scenarios, and the present application does not limit this.
[0060] It should be noted that the model training method provided in the embodiment of the present application can be implemented by a computer device, which can be a terminal device or a server, wherein the server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server providing cloud computing services. Terminal devices include but are not limited to mobile phones, computers, intelligent voice interaction devices, smart home appliances, vehicle-mounted terminals, aircraft, etc. The terminal device and the server can be directly or indirectly connected via wired or wireless communication, and this application does not limit this.
[0061] Method Embodiment
[0062] The present application provides an embodiment of a model training method. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer device such as a set of computer executable instructions. In addition, although the logical order is shown in the flowchart, it is only an example order provided. In some cases, the steps shown or described can be executed in a different order from that here. In this embodiment, the computer device is a server as an example for explanation.
[0063] See also Figure 1 , which is a flow chart of a model training method provided in an embodiment of the present application, the method comprises the following steps:
[0064] Step S101, obtaining a training sample set for training an initial prediction model, wherein the training samples in the training sample set include first-category samples and second-category samples.
[0065] In step S101, the sample labels of the first category of samples are target labels, the sample labels of the second category of samples are non-target labels, and the number of the first category of samples in the training sample set is less than the number of the second category of samples.
[0066] Taking amyloidosis as an example, the first type of samples can be training samples corresponding to patients with amyloidosis, and the corresponding target label is 1; the second type of samples can be training samples corresponding to healthy individuals, and the corresponding non-target label is 0; the training sample set includes 50 training samples corresponding to patients with amyloidosis and 750 training samples corresponding to healthy individuals. Among them, each of the above training samples includes indicator data: x1: troponin I, x2: N-terminal pro-brain natriuretic peptide, x3: ejection fraction, x4: serum creatinine, x5: x6: albumin, x7: total bilirubin, x8: alkaline phosphatase, x9: heart ventricular septum thickness, x10: heart left ventricular posterior wall thickness, x11: heart left ventricular posterior wall thickness, x12: heart left ventricular posterior wall thickness, x13: heart left ventricular posterior wall thickness, x14: heart left ventricular posterior wall thickness, x15: heart left ventricular posterior wall thickness, x16: heart left ventricular posterior wall thickness, x17: heart left ventricular posterior wall thickness, x18: heart left ventricular posterior wall thickness, x19: heart left ventricular posterior wall thickness, x21: heart left ventricular posterior wall thickness, x22: heart left ventricular posterior wall thickness, x23: heart left ventricular posterior wall thickness, x24: heart left ventricular posterior wall thickness, x25: heart left ventricular posterior wall thickness, x26: heart left ventricular posterior wall thickness, x27: heart left ventricular posterior wall thickness, x28: heart left ventricular posterior wall thickness, x29: heart left ventricular posterior wall thickness, x30: heart left ventricular posterior wall thickness, 10 :age.
[0067] For the i-th training sample in the training sample set, it is expressed as follows:
[0068] <L i ; x1 (i) , x2 (i) , x3 (i) , x4 (i) , x5 (i) , x6 (i) , x7 (i) , x8 (i) , x9 (i) , x 10 (i) >
[0069] Among them, x1 (i) represents the value of troponin I of the i-th training sample, x2 (i) represents the value of N-terminal pro-brain natriuretic peptide of the i-th training sample, x3 (i) represents the ejection fraction of the i-th training sample... and so on. L i represents the sample label of the i-th training sample, L i 1 means that the i-th training sample is a first-class sample, L i A value of 0 indicates that the i-th training sample is a sample of the second category.
[0070] Step S102: Determine the prediction results corresponding to each training sample in the training sample set through the initial prediction model.
[0071] In this embodiment, the initial prediction model can be any one of the machine learning models such as logistic regression model, decision tree model, random forest model, deep learning model, etc., and is not limited here.
[0072] Taking the above amyloidosis as an example, for the i-th training sample in the training sample set, the initial prediction model can predict the probability value of the patient corresponding to the i-th training sample suffering from amyloidosis. in,
[0073] Step S103, determining the sample distribution density corresponding to each training sample according to the prediction error obtained from the prediction result and the sample label of the corresponding training sample.
[0074] In step S103, for the ith training sample in the training sample set, the number of errors of the prediction errors of all training samples in the error value interval with the prediction error of the ith training sample as the center point is determined, and the sample distribution density corresponding to the ith training sample is determined based on the number of errors.
[0075] In order to accurately determine the sample distribution density corresponding to each training sample, and thus accurately determine whether each training sample is an easy-to-classify sample or a difficult-to-classify sample, accurate training data is provided for subsequent model training. In the embodiment of the present application, the server can calculate the prediction error between the prediction result and the sample label of the corresponding training sample, and obtain the prediction error of each training sample. For the i-th training sample in the training sample set, the prediction error E i The calculation formula is shown in formula (1):
[0076]
[0077] Among them, E i ∈[0,1], is the prediction result. The server can determine the number of errors of the prediction errors of all training samples in the error value interval with the prediction error of the i-th training sample as the center point, and determine the sample distribution density corresponding to the i-th training sample according to the number of errors. Figure 2 , Figure 2 A flow chart of a sample distribution density determination process provided in an embodiment of the present application, the process comprising the following steps:
[0078] Step S1031 : determining a target length based on the number of training samples in the training sample set.
[0079] Step S1032: Taking the prediction error of the ith training sample as the center point and the target length as the radius, determine the error value interval corresponding to the ith training sample.
[0080] In order to accurately reflect the sample distribution density corresponding to each training sample, in this embodiment, the server can determine the target length according to the number of training samples in the training sample set, and use the target length as the radius of the error value interval. For example, when the number of training samples in the training sample set is large, the server can determine a shorter interval length (i.e., target length r, such as r=0.01) to more finely divide the error value interval [E i -r,E i +r]; when the number of training samples in the training sample set is small, the server may determine a longer interval length (e.g., r=0.1) to ensure that there are enough prediction errors of training samples in each error value interval. Figure 3 As shown, taking the prediction error E1 corresponding to the first training sample as the center point and the target length r as the radius, the error value interval corresponding to the first training sample is determined to be [E1-r, E1+r]; taking the prediction error E2 corresponding to the second training sample as the center point and the target length r as the radius, the error value interval corresponding to the second training sample is determined to be [E2-r, E2+r].
[0081] It should be noted that the error value interval determined with the prediction error of each training sample as the center point can more accurately estimate the true error level of each training sample, avoiding the problem of low accuracy of the error level of the determined training sample caused by approximate error estimation based on the similarity between the prediction errors of the training samples in a fixed interval; and the error value interval determined with the prediction error of each training sample as the center point can better adapt to the local changes in the distribution of the prediction error, especially when the prediction error distribution of the training sample is uneven, it can more accurately reflect the error characteristics of each training sample and the influence of the surrounding environment. In addition, the error value interval determined with the prediction error of each training sample as the center point can dynamically adjust the error value interval according to the actual situation of the prediction error of each training sample. For example, when the prediction error of the training sample is large or the prediction error fluctuates greatly, the error value interval can be appropriately expanded; when the prediction error of the training sample is small or the prediction error fluctuates slightly, the error value interval can be appropriately reduced.
[0082] Step S1033, counting the number of errors of the prediction errors of all training samples in the error value interval corresponding to the i-th training sample, and determining the sample distribution density corresponding to the i-th training sample according to the number of errors.
[0083] In this embodiment, the server may determine the interval length of the error value interval corresponding to the ith training sample; and then determine the sample distribution density corresponding to the ith training sample based on the error quantity and the interval length.
[0084] The server can use formula (2) and formula (3) to count the error number S (E) of the prediction errors of all training samples in the error value interval corresponding to the i-th training sample. i ).
[0085]
[0086]
[0087] Where n is the number of training samples in the training sample set. i ∈[0,1], so E i If there is a range less than 0 or greater than 1 in the error value interval, the server can determine the interval length of the error value interval corresponding to the i-th training sample through formula (4).
[0088] l(E i )=min(E i +r,1)-max(E i -r,0)(4)
[0089] Among them, min(E i +r, 1) means taking E i +r and 1, whichever is smaller; max(E i -r, 0) means take E i -r is the larger value between 0 and 0. The server can determine the sample distribution density D corresponding to the i-th training sample through formula (5): i .
[0090]
[0091] It should be noted that in the error value interval [E i -r,E i +r], since the easy-to-separate samples are usually densely distributed, the D corresponding to the easy-to-separate samples i Larger; the distribution of difficult samples is relatively scattered, so the D corresponding to the difficult samples i Therefore, based on the sample distribution density of the error value interval corresponding to each training sample, compared with the sample distribution density of the fixed interval, it can more accurately determine whether the training sample is a difficult sample or an easy sample.
[0092] Step S104, constructing a prediction loss function according to the prediction results and sample distribution density of each training sample; in the prediction loss function, the sample distribution density is used as the loss weight of the corresponding prediction result, and the loss weight is negatively correlated with the corresponding sample distribution density.
[0093] In order to dynamically adjust the proportion of easy-to-separate samples and difficult-to-separate samples in the overall loss of the model, reduce the proportion of easy-to-separate samples in the overall loss of the model, and improve the classification performance of the model for difficult-to-separate samples. In an embodiment of the present application, the server can use the sample distribution density as the loss weight of the corresponding prediction result based on the prediction results and sample distribution density of each training sample, so that the loss weight is negatively correlated with the corresponding sample distribution density, and construct a prediction loss function.
[0094] In order to adjust the weights of the first and second class samples in the prediction loss function, the weights of the first and second class samples in the overall loss of the model are balanced. In this embodiment, the server can determine the target adjustment parameter based on the number of the first class samples and the number of the second class samples, and construct the prediction loss function according to the target adjustment parameter, the prediction results of each training sample and the sample distribution density. The prediction loss function Loss is specifically shown in formula (6) and formula (7):
[0095]
[0096] Wherein, n is the number of training samples in the training sample set; β is the target adjustment parameter. If the positive sample is a minority class sample (i.e., a first class sample), the server may set β to a value greater than 0.5 based on the number of first class samples and the number of second class samples, for example, β = 0.9; L i represents the sample label; Represents the prediction result.
[0097] Step S105, adjusting the parameters of the initial prediction model by using the prediction loss function to obtain a prediction model.
[0098] In step S105, the prediction model is used to identify whether the data to be processed belongs to the target category corresponding to the target label, or belongs to other categories corresponding to the non-target label.
[0099] Optionally, the server may use multiple iterative training methods to adjust the parameters of the initial prediction model through the prediction loss function until the iterative training is stopped when the training cutoff condition is met to obtain the prediction model. Taking the above-mentioned amyloidosis as an example, the risk level of the target individual suffering from amyloidosis is identified through the trained prediction model based on the collected data to be processed corresponding to the target individual.
[0100] Based on the scheme introduced in the above steps S101 to S105, it can be known that in the present application, when processing a training sample set in which the number of first-category samples is less than the number of second-category samples, the true error level of each training sample can be estimated more accurately, thereby avoiding the problem of low accuracy of the error level of the determined training samples caused by approximate error estimation based on the similarity between the prediction errors of training samples within a fixed interval; thereby, by determining the sample distribution density corresponding to each training sample, it is possible to accurately determine whether the training sample is an easy-to-separate sample or a difficult-to-separate sample based on the sample distribution density; when constructing a prediction loss function, the sample distribution density is used as the loss weight of the corresponding prediction result, so that the loss weight is negatively correlated with the corresponding sample distribution density, thereby obtaining a prediction model by adjusting the parameters of the initial prediction model through the prediction loss function, and being able to dynamically adjust the proportion of easy-to-separate samples and difficult-to-separate samples in the overall loss of the model, thereby reducing the proportion of easy-to-separate samples in the overall loss of the model, and improving the classification performance of the model for difficult-to-separate samples.
[0101] In an optional embodiment, in order to provide reliable and complete training samples for model training and improve the accuracy of the model, before obtaining the training sample set for training the initial prediction model, the server may Figure 4 The data filling process shown preprocesses the sample data collected from multiple data centers, and the process includes the following steps:
[0102] Step S401, obtaining a target data set; the target data set includes a plurality of sample data, and each sample data includes a plurality of sub-data.
[0103] Taking the above amyloidosis as an example, the multiple sub-data included in each sample data may be: x1: troponin I, x2: N-terminal pro-brain natriuretic peptide, x3: ejection fraction, x4: serum creatinine, x5: albumin, x6: total bilirubin, x7: alkaline phosphatase, x8: heart ventricular septum thickness, x9: heart left ventricular posterior wall thickness, x10: heart posterior wall thickness, x11: heart posterior wall thickness, x12: heart posterior wall thickness, x13: heart posterior wall thickness, x14: heart posterior wall thickness, x15: heart posterior wall thickness, x16: heart posterior wall thickness, x17: heart posterior wall thickness, x18: heart posterior wall thickness, x19: heart posterior wall thickness, x20: heart posterior wall thickness, x21: heart posterior wall thickness, 10 :age.
[0104] Step S402: determine the data missing rate of the sample data based on the missing status of the sub-data in each sample data, and obtain the data missing rate of each sample data.
[0105] For example, if the multiple sub-data of the i-th training sample in the training sample set are missing three sub-data: x1: troponin I, x2: N-terminal pro-brain natriuretic peptide, and x3: ejection fraction, then the data missing rate of the i-th training sample is 30%.
[0106] Step S403 , performing data filling processing on the missing sub-data in the sample data according to the data missing rate of each sample data to obtain a training sample.
[0107] like Figure 5 As shown, the server can determine whether to delete the sample data by judging whether the data missing rate of the sample data is less than a preset threshold; if the data missing rate of the sample data is greater than or equal to the preset threshold, the server deletes the sample data; if the data missing rate of the sample data is less than the preset threshold, and the missing sub-data in the sample data is numerical data, the server obtains all target sub-data in the target data set, and fills the missing sub-data in the sample data based on the average value of all target sub-data to obtain a training sample; wherein the data category of the target sub-data is the same as the data category of the missing sub-data, and the sample label of the sample data corresponding to the target sub-data is the same as the sample label of the sample data corresponding to the missing sub-data.
[0108] Taking the above amyloidosis disease as an example, the server can set the target data set as the amyloidosis data set D pos (The sample labels of all sample data in this set are the target labels) and non-amyloidosis dataset D neg (The sample labels of all sample data in this set are non-target labels.) If the data missing rate of the sample data is 10%, which is less than the preset threshold of 40%, the server can determine that the sample data is D according to the sample label of the sample data. pos The data in the set, in this sample data, the missing sub-data is x1: Troponin I, the server can obtain D pos The x1: troponin I value (i.e., target sub-data) in all sample data in the set is used, and the average value of the x1: troponin I value in all sample data is calculated by formula (8), and the missing sub-data in the sample data are filled based on the average value to obtain the training sample. Among them, formula (8) is as follows:
[0109]
[0110] in, D pos The average value of the target sub-data in all sample data in the set; xj (i) represents the jth sub-data in each sample data; n represents D pos The number of target sub-data in all sample data in the set; N represents D pos The number of all sample data in the collection.
[0111] Optionally, if the sample label of the sample data determines that the sample data is the above D neg The server can obtain D negx3: The value of ejection fraction in all sample data in the set (i.e., the target sub-data), and the average value of x3: ejection fraction in all sample data is calculated by formula (9), and the missing sub-data in the sample data are filled based on the average value to obtain the training sample. Among them, formula (9) is as follows:
[0112]
[0113] in, D neg The average value of the target sub-data in all sample data in the set; n represents D neg The number of target sub-data in all sample data in the set; N represents D neg The number of all sample data in the collection.
[0114] Therefore, through the model training method provided by the embodiment of the present application, on the one hand, the true error level of each training sample can be estimated more accurately, avoiding the problem of low accuracy of the error level of the determined training sample caused by the similarity between the prediction errors of the training samples in a fixed interval, so that the sample distribution density corresponding to each training sample can be accurately determined, and the training sample can be accurately determined whether it is an easy-to-separate sample or a difficult-to-separate sample according to the sample distribution density; on the other hand, the proportion of easy-to-separate samples and difficult-to-separate samples in the overall loss of the model can be dynamically adjusted to reduce the proportion of easy-to-separate samples in the overall loss of the model, avoiding the problem of the model's classification performance of difficult-to-separate samples being reduced due to the model's excessive focus on easy-to-separate samples and neglecting difficult-to-separate samples, thereby improving the model's classification performance of difficult-to-separate samples. In addition, through the model training method provided by the embodiment of the present application, the missing sub-data of the sample data can be filled based on the missing rate of the sample data to obtain the training samples required for the model training, which can provide reliable and complete training samples for the model training and improve the accuracy of the model.
[0115] Device Embodiment
[0116] The embodiment of the present application provides a model training device, wherein: Figure 6 A schematic diagram of the structure of a model training device provided in an embodiment of the present application is shown in FIG. Figure 6 As shown, the device includes: an acquisition module 11, a prediction module 12, a sample distribution density determination module 13, a loss function construction module 14 and a model training module 15. Figure 6 You can see the connection relationship between several modules.
[0117] The acquisition module 11 is used to acquire a training sample set for training the initial prediction model, the training samples of the training sample set include first-class samples and second-class samples, the sample labels of the first-class samples are target labels, the sample labels of the second-class samples are non-target labels, and the number of the first-class samples in the training sample set is less than the number of the second-class samples;
[0118] The prediction module 12 is used to determine the prediction results corresponding to the training samples in the training sample set through the initial prediction model;
[0119] The sample distribution density determination module 13 is used to determine the sample distribution density corresponding to each training sample according to the prediction error obtained from the prediction result and the sample label of the corresponding training sample; wherein, for the i-th training sample in the training sample set, the error number of the prediction errors of all training samples in the error value interval with the prediction error of the i-th training sample as the center point is determined, and the sample distribution density corresponding to the i-th training sample is determined according to the error number;
[0120] The loss function construction module 14 is used to construct a prediction loss function according to the prediction results and sample distribution density of each training sample; in the prediction loss function, the sample distribution density is used as the loss weight of the corresponding prediction result, and the loss weight is negatively correlated with the corresponding sample distribution density;
[0121] The model training module 15 is used to adjust the parameters of the initial prediction model through the prediction loss function to obtain the prediction model; the prediction model is used to identify whether the data to be processed belongs to the target category corresponding to the target label, or belongs to other categories corresponding to the non-target label.
[0122] See also Figure 7 , Figure 7 The structure diagram of a sample distribution density determination module provided in an embodiment of the present application is shown in FIG. 1 , and the sample distribution density determination module includes: a length determination unit 21, an error value interval determination unit 22, and a sample distribution density determination unit 23. Figure 7 You can see the connection relationship between several modules.
[0123] Wherein, the length determination unit 21 is used to determine the target length based on the number of training samples in the training sample set;
[0124] The error value interval determination unit 22 is used to determine the error value interval corresponding to the i-th training sample in the training sample set by taking the prediction error of the i-th training sample as the center point and the target length as the radius;
[0125] The sample distribution density determination unit 23 is used to count the number of errors of the prediction errors of all training samples in the error value interval corresponding to the i-th training sample, and determine the sample distribution density corresponding to the i-th training sample according to the number of errors.
[0126] Optionally, the sample distribution density determination unit further includes: an interval length sub-determination unit and a sample distribution density determination sub-unit.
[0127] The interval length sub-determination unit is used to determine the interval length of the error value interval corresponding to the i-th training sample;
[0128] The sample distribution density determination subunit is used to determine the sample distribution density corresponding to the i-th training sample based on the number of errors and the interval length.
[0129] Optionally, the model training device also includes: a sample data acquisition module, a data missing rate determination module and a data filling processing module.
[0130] The sample data acquisition module is used to acquire a target data set; the target data set includes a plurality of sample data, and each sample data includes a plurality of sub-data;
[0131] A data missing rate determination module is used to determine the data missing rate of each sample data based on the missing status of the sub-data in the sample data, so as to obtain the data missing rate of each sample data;
[0132] The data filling processing module is used to perform data filling processing on the missing sub-data in the sample data according to the data missing rate of each sample data to obtain a training sample.
[0133] Optionally, the data filling processing module includes: a judgment unit, a data deletion unit and a data filling unit.
[0134] The judging unit is used to judge whether the data missing rate of the sample data is less than a preset threshold;
[0135] A data deletion unit, configured to delete the sample data if the data missing rate of the sample data is greater than or equal to a preset threshold;
[0136] A data filling unit is used to obtain all target sub-data in the target data set if the data missing rate of the sample data is less than a preset threshold and the missing sub-data in the sample data is numerical data, and fill the missing sub-data in the sample data based on the average value of all target sub-data to obtain a training sample; the data category of the target sub-data is the same as the data category of the missing sub-data, and the sample label of the sample data corresponding to the target sub-data is the same as the sample label of the sample data corresponding to the missing sub-data.
[0137] Optionally, the loss function construction module includes: a parameter determination unit and a loss function construction unit.
[0138] Wherein, the parameter determination unit is used to determine the target adjustment parameter based on the number of the first type of samples and the number of the second type of samples;
[0139] The loss function construction unit is used to construct a prediction loss function according to target adjustment parameters, prediction results of each training sample and sample distribution density.
[0140] Storage Medium Embodiments
[0141] The embodiment of the present application provides a computer-readable storage medium, on which a program is stored, wherein when the program is executed by a processor, some or all of the steps in the model training method described in the aforementioned method embodiment of the present application are implemented. The storage medium can be a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk, and other media that can store program codes.
[0142] Processor Embodiments
[0143] An embodiment of the present application provides a processor for running a program, wherein some or all of the steps in the model training method introduced in the aforementioned method embodiment are executed when the program is running.
[0144] It should be noted that each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment. The device embodiment described above is merely schematic, in which the unit described as a separate component may or may not be physically separated, and the component prompted as a unit may or may not be a physical unit, that is, it may be located in one place, or it may be distributed on multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative work.
[0145] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed in the present application should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A model training method, characterized in that: include: Acquire a training sample set for training an initial prediction model, wherein the training samples of the training sample set include first-class samples and second-class samples, the sample labels of the first-class samples are target labels, the sample labels of the second-class samples are non-target labels, and the number of the first-class samples in the training sample set is less than the number of the second-class samples; Determining prediction results corresponding to each of the training samples in the training sample set by using the initial prediction model; Determine the sample distribution density corresponding to each of the training samples according to the prediction error obtained from the prediction result and the sample label of the corresponding training sample; wherein, for the i-th training sample in the training sample set, determine the number of errors of the prediction errors of all training samples in the error value interval with the prediction error of the i-th training sample as the center point, and determine the sample distribution density corresponding to the i-th training sample according to the number of errors; Constructing a prediction loss function according to the prediction results of each of the training samples and the sample distribution density; in the prediction loss function, the sample distribution density is used as a loss weight of the corresponding prediction result, and the loss weight is negatively correlated with the corresponding sample distribution density; The initial prediction model is parameter adjusted by the prediction loss function to obtain a prediction model; the prediction model is used to identify whether the data to be processed belongs to the target category corresponding to the target label, or belongs to other categories corresponding to the non-target label.
2. The method according to claim 1, characterized in that: The step of determining, for the i-th training sample in the training sample set, the number of errors of the prediction errors of all training samples in an error value interval with the prediction error of the i-th training sample as the center point, and determining the sample distribution density corresponding to the i-th training sample according to the number of errors includes: Determining a target length based on the number of training samples in the training sample set; Taking the prediction error of the i-th training sample as the center point and the target length as the radius, determining the error value interval corresponding to the i-th training sample; The number of errors of prediction errors of all training samples in the error value interval corresponding to the i-th training sample is counted, and the sample distribution density corresponding to the i-th training sample is determined according to the number of errors.
3. The method according to claim 2, characterized in that The determining, according to the error quantity, the sample distribution density corresponding to the i-th training sample comprises: Determine the interval length of the error value interval corresponding to the i-th training sample; Based on the error quantity and the interval length, a sample distribution density corresponding to the i-th training sample is determined.
4. The method according to claim 1, characterized in that: Before obtaining a training sample set for training an initial prediction model, the method further includes: Acquire a target data set; the target data set includes a plurality of sample data, each of the sample data includes a plurality of sub-data; Determine the data missing rate of the sample data based on the missing status of the sub-data in each of the sample data, and obtain the data missing rate of each of the sample data; The missing sub-data in the sample data are filled with data according to the data missing rate of each sample data to obtain the training sample.
5. The method according to claim 4, characterized in that The step of performing data filling processing on the missing sub-data in the sample data according to the data missing rate of each sample data to obtain the training sample comprises: Determine whether the data missing rate of the sample data is less than a preset threshold; If the data missing rate of the sample data is greater than or equal to the preset threshold, deleting the sample data; If the data missing rate of the sample data is less than the preset threshold, and the missing sub-data in the sample data is numerical data, all target sub-data in the target data set are obtained, and the missing sub-data in the sample data are filled based on the average value of all the target sub-data to obtain the training sample; the data category of the target sub-data is the same as the data category of the missing sub-data, and the sample label of the sample data corresponding to the target sub-data is the same as the sample label of the sample data corresponding to the missing sub-data.
6. The method according to claim 1, characterized in that The step of constructing a prediction loss function according to the prediction results of each of the training samples and the sample distribution density includes: Determining a target adjustment parameter based on the number of samples of the first category and the number of samples of the second category; The prediction loss function is constructed according to the target adjustment parameter, the prediction results of each of the training samples and the sample distribution density.
7. A model training device, characterized in that: include: an acquisition module, configured to acquire a training sample set for training an initial prediction model, wherein the training samples of the training sample set include a first class of samples and a second class of samples, the sample labels of the first class of samples are target labels, the sample labels of the second class of samples are non-target labels, and the number of the first class of samples in the training sample set is less than the number of the second class of samples; A prediction module, used to determine the prediction results corresponding to each of the training samples in the training sample set through the initial prediction model; A sample distribution density determination module is used to determine the sample distribution density corresponding to each of the training samples according to the prediction error obtained by the prediction result and the sample label of the corresponding training sample; wherein, for the i-th training sample in the training sample set, the error number of the prediction errors of all training samples in the error value interval with the prediction error of the i-th training sample as the center point is determined, and the sample distribution density corresponding to the i-th training sample is determined according to the error number; A loss function construction module, used to construct a prediction loss function according to the prediction results of each of the training samples and the sample distribution density; in the prediction loss function, the sample distribution density is used as a loss weight of the corresponding prediction result, and the loss weight is negatively correlated with the corresponding sample distribution density; The model training module is used to adjust the parameters of the initial prediction model through the prediction loss function to obtain a prediction model; the prediction model is used to identify whether the data to be processed belongs to the target category corresponding to the target label, or belongs to other categories corresponding to the non-target label.
8. The device according to claim 7, characterized in that The sample distribution density determination module comprises: a length determination unit, configured to determine a target length based on the number of training samples in the training sample set; an error value interval determining unit, for an i-th training sample in the training sample set, taking the prediction error of the i-th training sample as a center point and taking the target length as a radius to determine an error value interval corresponding to the i-th training sample; The sample distribution density determination unit is used to count the number of errors of the prediction errors of all training samples in the error value interval corresponding to the i-th training sample, and determine the sample distribution density corresponding to the i-th training sample according to the number of errors.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by the processor, the model training method as described in claims 1-6 is implemented.
10. A processor, characterized in that: Used to run a computer program, which, when running, executes the model training method as described in claims 1-6.