Machine learning model training method, device and computer readable storage medium
By determining the distribution density ratio of the source and target domain sample data in transfer learning and adjusting the sample weight, the negative transfer problem caused by data differences in transfer learning is solved, and the performance of the machine learning model is improved.
Patent Information
- Application Number
- CN201911107807.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-11-13
- Publication Date
- 2025-03-18
- Estimated Expiration
- 2040-04-21
AI Technical Summary
In transfer learning, due to the difference in data between the source and target domains, negative migration is prone to occur, resulting in low performance of the model obtained by the transfer.
By obtaining the sample data of the source domain and the target domain, determining its distribution density ratio, determining the weight of the source domain sample data based on the distribution density ratio, combining and adjusting the weight of the training sample data, and performing model training to obtain a machine learning model with improved performance.
By controlling the degree of influence of source domain sample data in model training, make full use of source domain sample data, and at the same time reduce its negative impact on model training, highlighting the impact of target domain sample data on model training, thereby reducing the probability of negative migration and improving model performance.
Smart Images

Figure CN110852446B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a machine learning model training method, apparatus, computer-readable storage medium, and computer equipment. Background Art
[0002] Transfer learning refers to a learning process that uses the similarities between data, tasks, or models to apply models learned in the old domain (i.e., source domain) to the new domain (i.e., target domain). Simply put, similarity is the basis of transfer. The two scenarios where the transfer occurs need to have a certain degree of similarity, but at the same time there are differences, resulting in the model trained with source domain data cannot be directly used for target domain prediction. Through transfer learning, the model parameters that have been learned in the source domain (which can also be understood as the knowledge learned by the model) can be shared with the new model of the target domain in some way, without the need to learn from scratch like most networks, thereby speeding up and optimizing the learning efficiency of the model.
[0003] However, due to the data differences between the source domain and the target domain, transfer learning is prone to negative transfer, that is, the effect after transfer is poor or even degraded, and the performance of the transferred model is low. Summary of the invention
[0004] Based on this, it is necessary to provide a machine learning model training method, apparatus, computer-readable storage medium and computer device to address the technical problem that transfer learning is prone to negative transfer that affects the performance of the model obtained by transfer.
[0005] A machine learning model training method, comprising:
[0006] Obtain source domain sample data and target domain sample data for the machine learning model to be trained;
[0007] Determining a distribution density ratio between the target domain sample data and the source domain sample data;
[0008] Determine the source domain sample weights corresponding to each of the source domain sample data according to the distribution density ratio;
[0009] Obtaining training sample data according to the source domain sample data and the target domain sample data, and determining the training sample weights corresponding to the training sample data respectively according to the source domain sample weights and the target domain sample weights corresponding to the target domain sample data respectively;
[0010] The training sample data is trained according to the training sample weights, and when a training end condition is met, a trained machine learning model is obtained.
[0011] A machine learning model training device, the device comprising:
[0012] A sample data acquisition module, used to acquire source domain sample data and target domain sample data of a machine learning model to be trained;
[0013] A density ratio determination module, used to determine the distribution density ratio between the target domain sample data and the source domain sample data;
[0014] A source domain sample weight determination module, used to determine the source domain sample weights corresponding to each of the source domain sample data according to the distribution density ratio;
[0015] A training sample weight determination module, used to obtain training sample data according to the source domain sample data and the target domain sample data, and determine the training sample weights corresponding to the training sample data according to the source domain sample weights and the target domain sample weights corresponding to the target domain sample data;
[0016] The model training module is used to train the training sample data according to the training sample weights, and obtain a trained machine learning model when the training end condition is met.
[0017] A computer-readable storage medium stores a computer program, which, when executed by a processor, causes the processor to perform the steps of the machine learning model training method as described above.
[0018] A computer device comprises a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of the machine learning model training method as described above.
[0019] The above-mentioned machine learning model training method, device, computer-readable storage medium and computer equipment determine the source domain sample weights corresponding to each source domain sample data according to the distribution density ratio between the target domain sample data and the source domain sample data, obtain the training sample data according to the source domain sample data and the target domain sample data, and determine the training sample weights corresponding to the training sample data according to the source domain sample weights and the target domain sample weights corresponding to the target domain sample data, and then train the training sample data according to the training sample weights to obtain a trained machine learning model. By controlling the influence of the source domain sample data in the model training through the source domain sample weights determined by the distribution density ratio between the target domain sample data and the source domain sample data, the source domain sample data can be fully utilized while reducing the influence of the source domain sample data on the model training, thereby highlighting the influence of the target domain sample data on the training model, reducing the probability of negative transfer phenomenon, and improving the performance of the trained machine learning model. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1An application environment diagram of a machine learning model training method in one embodiment;
[0021] Figure 2 A flowchart of a machine learning model training method in one embodiment;
[0022] Figure 3 A schematic diagram of a flow chart for determining a distribution density ratio in one embodiment;
[0023] Figure 4 A flowchart of a machine learning model training method in one embodiment;
[0024] Figure 5 A structural block diagram of a machine learning model training device in one embodiment;
[0025] Figure 6 FIG. 4 is a structural block diagram of a computer device in one embodiment. DETAILED DESCRIPTION
[0026] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0027] Figure 1 FIG. 1 is an application environment diagram of a machine learning model training method in an embodiment. (Example: Refer to Figure 1 , the machine learning model training method is applied to a transfer learning system. The transfer learning system includes a server 120. The server 120 can be implemented as an independent server or a server cluster consisting of multiple servers. )
[0028] like Figure 2 As shown, in one embodiment, a machine learning model training method is provided. This embodiment mainly applies this method to the above Figure 1 The server 120 in FIG. Figure 2 , the machine learning model training method specifically includes the following steps:
[0029] S202, obtaining source domain sample data and target domain sample data of the machine learning model to be trained.
[0030] Transfer learning specifically solves the problem that the two scenarios need to have a certain similarity, but at the same time there are differences, resulting in the model trained with source domain data cannot be directly used for target domain prediction. It relaxes the assumption of "training and test data follow the same distribution" in machine learning. When a small amount of data is annotated in the target domain (not enough to train a classifier), a classifier with good performance can be trained by combining a large number of labeled samples in the source domain. According to the form of migration, it can be divided into instance-based transfer learning, feature-based transfer learning, model-based transfer learning and relationship-based transfer learning. Instance-based migration refers to assigning different weights to source domain samples based on the similarity of the two scenarios to train models for prediction / classification in the target domain; feature-based transfer learning refers to mapping the source domain and target domain to a common feature subspace respectively through feature changes, and using machine learning methods to build a model in the common subspace to complete the prediction of the target domain; model-based transfer learning assumes that the source domain and target domain can share some model parameters, and uses the source domain parameters to initialize the target domain model or impose certain restrictions on the target domain parameters, such as the Fine-Tune technology in deep learning.
[0031] In transfer learning, the domain consists of data and the probability distribution that generates these data. D is generally used to represent the domain, and P represents a probability distribution. In particular, there are two basic domains: the source domain and the target domain. The source domain is the object to be migrated, which generally has sufficient labeled samples; the target domain is the object that is ultimately expected to be obtained (with label information). Transfer learning completes the migration of knowledge from the source domain to the target domain. The learning goal in transfer learning is the task, which consists of two parts: a label and a function. Depending on whether the source domain and the target domain are labeled, it can be divided into inductive migration, direct migration, and unsupervised migration. This embodiment is based on transfer learning to train the machine learning model.
[0032] Among them, the machine learning model to be trained is the model that needs to be trained, and can be specifically a machine learning model obtained by transfer learning, such as a classifier. The source domain sample data is the sample data in the source domain that is transferred in transfer learning, and the target domain sample data is the sample data in the target domain. Generally, the amount of source domain sample data is sufficient to train the model corresponding to the source domain, while the amount of labeled target domain sample data in the target domain sample data is small, which is not enough to directly train the machine learning model. Therefore, it is necessary to perform transfer training from the source domain based on transfer learning to obtain the required machine learning model. In specific applications, the source domain sample data and the target domain sample data can be collected from the corresponding fields.
[0033] S204: Determine a distribution density ratio between the target domain sample data and the source domain sample data.
[0034] The distribution density ratio is the ratio of the marginal distribution of the target domain to the source domain in transfer learning. The marginal distribution is the probability distribution of some variables in the multidimensional random variable. The difference between the target domain and the source domain is mainly reflected in the different data distribution, including the possible differences in marginal distribution and conditional distribution. The difference in the two types of distribution will affect the performance of the final model in the target domain.
[0035] The distribution density ratio can be expressed as Among them, β is the distribution density ratio, X t represents the target domain sample data, X s represents the source domain sample data, P(X t ) is the marginal distribution of the target domain sample data, P(X s ) is the marginal distribution of the source domain sample data, and the ratio of the two reflects the difference between the prior distribution of the target domain and the source domain. There are many density ratio estimation methods to determine the distribution density ratio, which can be roughly divided into two categories: direct estimation and indirect estimation. Indirect estimation requires first calculating the marginal distribution of the source domain and the target separately, and then calculating the ratio. The calculation is large and the process is complicated; direct estimation means that the ratio of the two is directly estimated without calculating the marginal distribution first.
[0036] S206, determining the source domain sample weights corresponding to each source domain sample data according to the distribution density ratio.
[0037] The contribution of labeled samples in the source domain and the target domain to the model may be different, and the importance of each sample in the source domain and the target domain is also different. The source domain sample weight represents the influence of each source domain sample data on the machine learning model to be trained. The larger the source domain sample weight, the greater the influence of the corresponding source domain sample data on the machine learning model to be trained. By rationally utilizing the sample data in the source domain and the target domain, the probability of negative transfer can be reduced and the performance of the trained machine learning model can be improved.
[0038] In this embodiment, after obtaining the distribution density ratio between the target domain sample data and the source domain sample data, the source domain sample weights corresponding to each source domain sample data are determined according to the distribution density ratio. Specifically, the distribution density ratio can be normalized and used as the source domain sample weights corresponding to each source domain sample data.
[0039] S208, obtaining training sample data according to the source domain sample data and the target domain sample data, and determining training sample weights corresponding to the training sample data according to the source domain sample weights and the target domain sample weights corresponding to the target domain sample data.
[0040] The training sample data is the training data of the machine learning model to be trained, which can be obtained based on the source domain sample data and the target domain sample data. For example, the source domain sample data and the target domain sample data with labels can be combined as the training sample data. After obtaining the training sample data, for each source domain sample data in the training sample data, the training sample weight is determined according to its corresponding source domain sample weight; for the target domain sample data in the training sample data, the training sample weight is determined according to its corresponding target domain sample weight.
[0041] S210, training the training sample data according to the training sample weights, and obtaining a trained machine learning model when the training end condition is met.
[0042] After determining the training sample data and the training sample weights corresponding to each training sample data, the training sample data is trained according to the training sample weights. When the training end conditions are met, such as when the number of training times reaches the number threshold or the training output meets the accuracy conditions, the training is terminated to obtain a trained machine learning model. During model training, a corresponding training sample weight is set for each training sample data. Each training sample weight will directly affect the model parameters of the machine learning model, thereby affecting the performance of the trained machine learning model. The difference in data distribution between the source domain and the target domain is the main reason for the decline in the performance of the source domain model in the target domain, such as the decline in the prediction accuracy of the prediction model. By controlling the influence of the source domain sample data in the model training through the source domain sample weight determined by the distribution density ratio between the target domain sample data and the source domain sample data, the source domain sample data can be fully utilized while reducing the influence of the source domain sample data on the model training, thereby highlighting the influence of the target domain sample data on the training model, alleviating the negative transfer phenomenon, and improving the performance of the trained machine learning model.
[0043] The above-mentioned machine learning model training method determines the source domain sample weights corresponding to each source domain sample data according to the distribution density ratio between the target domain sample data and the source domain sample data, obtains the training sample data according to the source domain sample data and the target domain sample data, and determines the training sample weights corresponding to the training sample data according to the source domain sample weights and the target domain sample weights corresponding to the target domain sample data, and then trains the training sample data according to the training sample weights to obtain a trained machine learning model. By controlling the influence of the source domain sample data in the model training through the source domain sample weights determined by the distribution density ratio between the target sample data and the source domain sample data, the source domain sample data can be fully utilized while reducing the influence of the source domain sample data on the model training, thereby highlighting the influence of the target domain sample data on the training model, reducing the probability of the negative transfer phenomenon, and improving the performance of the trained machine learning model.
[0044] In one embodiment, Figure 3 As shown, the process of determining the distribution density ratio, that is, determining the distribution density ratio between the target domain sample data and the source domain sample data, includes:
[0045] S302 , performing data standardization processing on the source domain sample data and the target domain sample data to obtain source domain standardized samples corresponding to the source domain sample data and target domain standardized samples corresponding to the target domain sample data.
[0046] In this embodiment, when the feature dimensions of the source domain sample data and the target domain sample data are high, dimension reduction processing is performed, and the distribution density ratio between the target domain sample data and the source domain sample data is directly estimated by a density ratio estimation algorithm. Specifically, when determining the distribution density ratio, data standardization processing is performed on the source domain sample data and the target domain sample data. For example, the source domain sample data and the target domain sample data can be subjected to data standardization processing by a z-score zero mean normalization method to obtain source domain standardized samples corresponding to the source domain sample data and target domain standardized samples corresponding to the target domain sample data. After the source domain sample data and the target domain sample data are subjected to data standardization processing, the data range of the obtained source domain standardized samples and the target domain standardized samples can be mapped to a relative interval range for subsequent processing.
[0047] S304, when the feature dimensions of the source domain sample data and the target domain sample data are greater than a preset dimension threshold, dimension reduction processing is performed on the source domain standardized samples and the target domain standardized samples respectively to obtain the reduced-dimensional source domain standardized samples and the reduced-dimensional target domain standardized samples.
[0048] Determine the characteristic dimensions of the source domain sample data and the target domain sample data. Generally, in transfer learning, the characteristic dimensions of the source domain sample data and the target domain sample data are the same. When the characteristic dimensions of the source domain sample data and the target domain sample data are greater than the preset dimension threshold, it indicates that the characteristic dimensions of the source domain sample data and the target domain sample data are high. As the characteristic dimension increases, the number of samples required for density ratio estimation will increase exponentially, which is the "curse of dimensionality". When the distribution density ratio is directly estimated by the density ratio estimation algorithm, the number of estimated samples is limited, resulting in limited estimation accuracy. Among them, the dimension threshold can be determined according to actual needs, such as being set according to the accuracy of the distribution density ratio determined by the density ratio estimation algorithm. When the feature dimension of the source domain sample data and the target domain sample data is greater than the preset dimension threshold, the source domain standardized samples and the target domain standardized samples are respectively subjected to dimensionality reduction processing. For example, LFDA (Local Fisher linear discriminant analysis) can be used to perform dimensionality reduction processing on the source domain standardized samples and the target domain standardized samples, respectively, and the high-dimensional features can be mapped to the low-dimensional space to obtain the reduced-dimensional source domain standardized samples and the reduced-dimensional target domain standardized samples, thereby ensuring the accuracy of the distribution density ratio estimation directly performed through the density ratio estimation algorithm.
[0049] S306, determining the dimensionality reduction distribution density ratio between the target domain standardized samples after dimensionality reduction and the source domain standardized samples after dimensionality reduction through a density ratio estimation algorithm, and using the dimensionality reduction distribution density ratio as the distribution density ratio between the target domain sample data and the source domain sample data.
[0050] The density ratio of the target domain standardized samples after dimensionality reduction and the source domain standardized samples after dimensionality reduction is estimated through the density ratio estimation algorithm to obtain the dimensionality reduction distribution density ratio between the target domain standardized samples after dimensionality reduction and the source domain standardized samples after dimensionality reduction, and the dimensionality reduction distribution density ratio is used as the distribution density ratio between the target domain sample data and the source domain sample data.
[0051] In specific implementation, the density ratio estimation algorithm can use the uLSIF (Unconstrained Least-Squares Importance Fitting) algorithm. uLSIF needs to calculate the marginal distribution of the source domain and the target domain respectively, and directly estimate the ratio of the two distributions, which greatly reduces the amount of calculation and can also give a more accurate estimate. uLSIF approximates the density ratio through a set of linear weighted Gaussian kernels, as shown in the following formula (1):
[0052]
[0053] Among them, β(x) is the density ratio estimation result of uLSIF, x is the variable for density ratio estimation; b represents the number of Gaussian kernels, which can be specified arbitrarily, and is generally 100; a is the weighting coefficient; K is the Gaussian kernel function, c is the parameter of the Gaussian kernel function, and σ is the Gaussian kernel width, which can be determined by the k-fold cross-validation theorem, such as the 10-fold cross-validation theorem. Among them, the k-fold cross-validation theorem can effectively avoid the impact of randomness when dividing the training set and the test set on the evaluation results. Specifically, during the k-fold cross-validation process, the sample data is randomly divided into k parts, and k-1 parts are randomly selected as the training set each time, and the remaining 1 part is used as the test set. When a round of training is completed, k-1 parts are randomly selected again to train the data. After several rounds (less than k), the loss function is selected to evaluate the optimal model and parameters. The average error rate of these k models on their respective validation sets is taken as the evaluation result of the classifier, and k is generally greater than 3. uLSIF can be used to accurately determine the dimensionality reduction distribution density ratio between the target domain standardized samples after dimensionality reduction and the source domain standardized samples after dimensionality reduction. The dimensionality reduction distribution density ratio can be used as the distribution density ratio between the target domain sample data and the source domain sample data.
[0054] In one embodiment, data standardization is performed on source domain sample data and target domain sample data to obtain source domain standardized samples corresponding to the source domain sample data and target domain standardized samples corresponding to the target domain sample data, including: determining the mean and standard deviation of the source domain sample data; using the source domain sample data and the target domain sample data as data to be standardized, and determining the data difference between the data to be standardized and the mean; determining the ratio of the data difference to the standard deviation, and using the ratio as the standardized samples corresponding to the data to be standardized; the standardized samples include the source domain standardized samples corresponding to the source domain sample data and the target domain standardized samples corresponding to the target domain sample data.
[0055] In this embodiment, the source domain sample data and the target domain sample data are subjected to data standardization processing by the z-score zero mean normalization method. Specifically, the mean and standard deviation of the source domain sample data are determined, and the mean and standard deviation can be obtained by statistically processing the source domain sample data. The source domain sample data and the target domain sample data are used as data to be standardized, and the data difference between the data to be standardized and the mean is determined. Specifically, the source domain sample data and the target domain sample data can be respectively subtracted from the mean of the source domain sample data to obtain the data difference. The ratio of the data difference to the standard deviation is determined, and the ratio is used as the standardized sample corresponding to the data to be standardized, wherein the standardized sample includes the source domain standardized sample corresponding to the source domain sample data and the target domain standardized sample corresponding to the target domain sample data, thereby realizing data standardization processing of the source domain sample data and the target domain sample data.
[0056] In a specific application, the data standardization expression is: Among them, x is a standardized sample with a mean of 0 and a variance of 1; x is the source domain sample data, is the mean of the source domain sample data, and σ is the standard deviation of the source domain sample data.
[0057] In one embodiment, when the characteristic dimension of the source domain sample data and the target domain sample data is greater than a preset dimension threshold, the source domain standardized samples and the target domain standardized samples are respectively subjected to dimension reduction processing to obtain the reduced-dimensional source domain standardized samples and the reduced-dimensional target domain standardized samples, including: determining unlabeled target domain standardized samples from the target domain standardized samples, the unlabeled target domain standardized samples are obtained by performing data standardization processing on the unlabeled target domain sample data in the target domain sample data; determining the characteristic dimension of the source domain sample data and the target domain sample data; when the characteristic dimension is greater than a preset dimension threshold, the source domain standardized samples and the unlabeled target domain standardized samples are respectively subjected to dimension reduction processing to obtain the reduced-dimensional source domain standardized samples and the reduced-dimensional unlabeled target domain standardized samples, and the reduced-dimensional unlabeled target domain standardized samples are used as the reduced-dimensional target domain standardized samples.
[0058] In this embodiment, considering that there are few labeled samples in the target domain and labels are very precious, the existing label training model should be reasonably used, so the density ratio estimation process is performed through the source domain standardized samples and the target domain standardized samples without labels. Among them, the unlabeled target domain standardized samples are obtained by performing data standardization processing on the unlabeled target domain sample data in the target domain sample data.
[0059] Specifically, after obtaining the source domain standardized samples corresponding to the source domain sample data and the target domain standardized samples corresponding to the target domain sample data, unlabeled target domain standardized samples are determined from the target domain standardized samples. The unlabeled target domain standardized samples are obtained by performing data standardization processing on the unlabeled target domain sample data in the target domain sample data. Generally, the target domain sample data in the target domain includes a large amount of unlabeled target domain sample data and a small amount of labeled target domain sample data. In this example, the distribution density ratio is estimated using the unlabeled target domain sample data. The feature dimensions of the source domain sample data and the target domain sample data are determined. The feature dimensions can be determined based on the data features of the source domain sample data and the target domain sample data.
[0060] Query the preset dimension threshold, which is preset according to actual needs. Compare the feature dimension and dimension threshold of the source domain sample data and the target domain sample data. If the feature dimension is greater than the preset dimension threshold, perform dimensionality reduction processing on the source domain standardized samples and the unlabeled target domain standardized samples respectively to obtain the reduced-dimensional source domain standardized samples and the reduced-dimensional unlabeled target domain standardized samples, and use the reduced-dimensional unlabeled target domain standardized samples as the reduced-dimensional target domain standardized samples. In this way, the high-dimensional source domain standardized samples and the unlabeled target domain standardized samples are reduced-dimensional to ensure the accuracy of the density ratio estimation processing.
[0061] In one embodiment, the method further includes: when the feature dimension is not greater than the dimension threshold, determining the low-dimensional distribution density ratio between the unlabeled target domain standardized samples and the source domain standardized samples through a density ratio estimation algorithm, and using the low-dimensional distribution density ratio as the distribution density ratio between the target domain sample data and the source domain sample data.
[0062] In this embodiment, when the feature dimension of the source domain sample data and the target domain sample data is not greater than the dimension threshold, it indicates that the sample features of the source domain sample data and the target domain sample data are in a low-dimensional space, and a density ratio estimation process can be directly performed using a density ratio estimation algorithm. Specifically, when the feature dimension is not greater than the dimension threshold, the low-dimensional distribution density ratio between the unlabeled target domain standardized samples and the source domain standardized samples is determined using a density ratio estimation algorithm, and the low-dimensional distribution density ratio can be used as the distribution density ratio between the target domain sample data and the source domain sample data, thereby accurately determining the distribution density ratio between the target domain sample data and the source domain sample data.
[0063] In one embodiment, determining the source domain sample weights corresponding to each source domain sample data respectively according to the distribution density ratio includes: normalizing the distribution density ratio to obtain the source domain sample weights corresponding to each source domain sample data respectively.
[0064] According to the difference in data distribution between the source domain and the target domain, different weights are assigned to the source domain samples. If the LR classifier is used, assuming that the conditional probabilities of the source domain and the target domain are equal, then we have formula (2):
[0065]
[0066] in, is the classifier parameter, P(X t ) is the marginal distribution of the target domain sample data, P(X s ) is the marginal distribution of the source domain sample data, N s is the data volume of the source domain sample data. From formula (2), we can see that when the source domain sample weight takes the ratio of the two distributions, the classifier trained with the source domain samples can replace the target domain samples for modeling, that is, model transfer is achieved.
[0067] In this embodiment, the distribution density ratio is normalized and used as the source domain sample weight corresponding to each source domain sample data. Specifically, when determining the source domain sample weight corresponding to each source domain sample data according to the distribution density ratio, the obtained distribution density ratio is normalized to obtain the source domain sample weight corresponding to each source domain sample data, and the value of the source domain sample weight is in the range of [0,1].
[0068] In one embodiment, obtaining training sample data according to source domain sample data and target domain sample data includes: extracting labeled target domain sample data from the target domain sample data; and using the source domain sample data and the labeled target domain sample data as training sample data.
[0069] In this embodiment, training sample data for model training is obtained based on the source domain sample data and the target domain sample data with labels. Specifically, when obtaining the training sample data based on the source domain sample data and the target domain sample data, the labeled target domain sample data is extracted from the target domain sample data. The amount of labeled target domain sample data is generally small and insufficient to support a separate training model, and its value for model training is high. The training sample data is obtained based on the labeled target domain sample data and the source domain sample data. Specifically, the source domain sample data and the labeled target domain sample data can be directly used as training sample data, and model training is performed based on the training sample data to obtain the required machine learning model.
[0070] In one embodiment, it also includes: determining the sample quantity of labeled target domain sample data in the target domain sample data; when the sample quantity is greater than a preset sample quantity threshold, determining the target domain sample weights corresponding to each labeled target domain sample data respectively through an iterative algorithm.
[0071] In this embodiment, before determining the training sample weights corresponding to the training sample data, the target domain sample weights corresponding to each labeled target domain sample data in the training sample data are determined. The target domain sample weights represent the degree of influence of the corresponding target domain sample data on the model when the model is trained by the corresponding target domain sample data. Specifically, the number of samples of the labeled target domain sample data in the target domain sample data is determined. Specifically, the number of samples of the labeled target domain sample data can be obtained by statistically analyzing the labeled target domain sample data, and the number of samples is compared with the preset sample number threshold. The sample number threshold T can be flexibly set. For example, if T=100, when the number of samples is greater than the preset sample number threshold, the target domain sample weights corresponding to each labeled target domain sample data are determined by an iterative algorithm. Specifically, the target domain sample weights corresponding to each labeled target domain sample data can be determined by the Adaboost algorithm. The Adaboost algorithm is an iterative algorithm. Its core idea is to train different classifiers (weak classifiers) for the same training set, and then combine these weak classifiers to form a stronger final classifier (strong classifier). By iteratively processing the Adaboost algorithm, the target domain sample weights corresponding to each labeled target domain sample data can be determined.
[0072] In one embodiment, determining the target domain sample weights respectively corresponding to each labeled target domain sample data through an iterative algorithm includes: determining the initialization weights respectively corresponding to each labeled target domain sample data, and using the initialization weights as current weights; training the labeled target domain sample data according to the current weights, and determining weight update coefficients according to errors in the training process; updating the current weights by the weight update coefficients to obtain updated weights; determining the number of training times, and when the number of training times reaches a preset iteration threshold, determining the target domain sample weights respectively corresponding to each labeled target domain sample data according to the updated weights.
[0073] In this embodiment, an iterative process is performed through the Adaboost algorithm to determine the target domain sample weights corresponding to each labeled target domain sample data. Specifically, when determining the target domain sample weights corresponding to each labeled target domain sample data, the initialization weights corresponding to each labeled target domain sample data are determined, and the initialization weights are used as the current weights. Among them, the initialization weights can be set in advance, such as setting the initialization weights to normalized equal weights, and using the initialization weights as the current weights, that is, as the weights during the current training. The labeled target domain sample data are trained according to the current weights. Specifically, a classifier, such as an LR classifier, can be trained, and the weight update coefficient is determined according to the error in the training process. Specifically, the output result of the trained LR classifier and the corresponding input label can be obtained, the error of the current training can be determined according to the label and the output result, and the weight update coefficient is calculated according to the error. After obtaining the weight update coefficient, the current weight is updated by the weight update coefficient to obtain the updated weight, and the number of training times is determined. When the number of training times reaches the preset iteration threshold, it indicates that the number of training times has reached the requirement, and then the target domain sample weights corresponding to each labeled target domain sample data are determined according to the updated weights. For example, the updated weights can be normalized and used as the target domain sample weights corresponding to each labeled target domain sample data. In addition, when the number of training times does not reach the iteration threshold, it returns to execute the training of the labeled target domain sample data according to the current weight, and determines the weight update coefficient according to the error in the training process to perform the next iterative training process.
[0074] In a specific application, the labeled target domain sample data constitutes a labeled dataset N t is the amount of labeled target domain sample data. When determining the target domain sample weight corresponding to the labeled target domain sample data, the weight is initialized and each sample in the target domain is set to an equal weight, that is, Normalized weights As the current weight. According to the current weight and the current weight, train the LR classifier and classify the target domain samples. Let the classifier output result be h t (x i ), labelled as c(x i ), calculate the error in the target domain Determine the weight update coefficient β t =ε t / (1-ε t ), update the current weight according to the weight update coefficient to get the updated weight Determine the number of training times. If the number of training times is less than the preset iteration threshold N, the updated weights are used as the current weights, and the training of the LR classifier is returned according to the current weights and the current weights for the next training iteration. When the number of training times reaches N, the updated weights of the last training are normalized and used as the target domain sample weights corresponding to each labeled target domain sample data.
[0075] In one embodiment, the process further includes: when the number of samples is not greater than a sample number threshold, determining that the target domain sample weights respectively corresponding to each labeled target domain sample data are the same.
[0076] In this embodiment, when the number of samples of the labeled target domain sample data in the target domain sample data does not meet the sample number threshold of the training iteration, the target domain sample weights corresponding to each labeled target domain sample data are directly determined. Specifically, when the sample number is not greater than the sample number threshold, the target domain sample weights corresponding to each labeled target domain sample data are set to equal weights, that is, the target domain sample weights corresponding to each labeled target domain sample data are the same. If it is set α i is the target domain sample weight corresponding to the i-th labeled target domain sample data, N t is the total amount of labeled target domain sample data.
[0077] In one embodiment, determining the training sample weights corresponding to the training sample data respectively according to the source domain sample weights and the target domain sample weights corresponding to the target domain sample data respectively includes: determining a source domain weight balancing factor corresponding to the source domain sample data and a target domain weight balancing factor corresponding to the target domain sample data; obtaining the source domain sample weights of the source domain sample data in the training sample data according to the product of the source domain weight balancing factor and the source domain sample weight; obtaining the target domain sample weights of the target domain sample data in the training sample data according to the product of the target domain weight balancing factor and the target domain sample weight; the training sample weights include the source domain sample weights and the target domain sample weights.
[0078] In this embodiment, a balance factor is set for the source domain and the target domain, and the source domain sample weights corresponding to each source domain sample data and the target domain sample weights corresponding to each target domain sample data in the training sample data are further adjusted.
[0079] Specifically, when determining the training sample weights corresponding to the training sample data, the source domain weight balancing factor corresponding to the source domain sample data and the target domain weight balancing factor corresponding to the target domain sample data are determined. Among them, the balancing factor is used to adjust the overall influence of all data in the source domain and all data in the target domain on the model training. The sum of the source domain weight balancing factor and the target domain weight balancing factor is 1, and their respective values can be set according to needs, such as being set to be equal, or being adjusted according to the difference between the source domain sample data and the target domain sample data. If the difference between the source domain sample data and the target domain sample data is large, the contribution of the source domain sample data to the model is reduced, that is, the source domain weight balancing factor is reduced; when the difference between the source domain sample data and the target domain sample data is small, the source domain contribution can be increased, that is, the source domain weight balancing factor is increased to maximize the use of label information in the source domain.
[0080] The source domain sample weight of the source domain sample data in the training sample data is obtained according to the product of the source domain weight balancing factor and the source domain sample weight, and the target domain sample weight of the target domain sample data in the training sample data is obtained according to the product of the target domain weight balancing factor and the target domain sample weight, so as to determine the weights corresponding to the source domain sample data and the target domain sample data in the training sample data. The training sample weight includes the source domain sample weight and the target domain sample weight. Specifically, for the source domain sample data in the training sample data, it corresponds to the source domain sample weight; the target domain sample data in the training sample data corresponds to the target domain sample weight.
[0081] In a specific application, considering that the labeled samples in the source domain and the target domain may contribute differently to the model, and the importance of each sample in the source domain and the target domain is also different, different weights are assigned to the source domain and the target domain samples, and a balance factor is set to control the overall impact of the source domain and the target domain data on the model, so as to reasonably utilize the sample labels in the source domain and the target domain and reduce the probability of negative transfer. Among them, the trained model is a classifier, and the classifier uses logistic regression, then there is formula (3),
[0082]
[0083] in, is the classifier parameter, α i , β i denotes the weight of the i-th sample in the target domain and the source domain, respectively, and λ t ,λ s are the target domain balance factor and the source domain balance factor, respectively, which are used to represent the contribution of the target domain and the source domain to the model, and λ s +λ t =1, γ represents the regularization coefficient, and θ represents the model coefficient of the logistic regression model.
[0084] In one embodiment, a machine learning model training method is provided, which is applied to the prediction of default probability in financial risk control scenarios. The user default probability in scenario A can be predicted. If the business of scenario A is in the early stage of going online, the number of labeled samples in scenario A is small, and there are a large number of unlabeled samples. However, there is another scenario B similar to scenario A, and a large number of labeled samples in scenario B can be collected. Training sample data is constructed based on a large number of unlabeled samples in scenario A + a small number of labeled samples in scenario A and a large number of labeled samples in scenario B, and the training sample weights of each training sample data are determined. The training sample data is trained according to the training sample weights to obtain a machine learning model that can effectively predict the default probability in scenario A.
[0085] Specifically, the source domain sample data carries labels, and the dataset it consists of is The target domain sample data includes a dataset consisting of labeled target domain sample data. and a dataset consisting of unlabeled target domain sample data Among them, N s is the amount of sample data in the source domain, N t is the amount of labeled target domain sample data, N t,u is the data volume of the target domain sample data without labels. Generally speaking, the data volume of the source domain sample data and the target domain sample data without labels is larger, while the data volume of the target domain sample data with labels is smaller.
[0086] All data, that is, source domain sample data and target domain sample data, are normalized by using the z-score zero mean normalization method. When the feature dimensions of the source domain sample data and the target domain sample data are high, the source domain dataset D is normalized by using the LFDA algorithm. s and the target domain unlabeled dataset D t,u Perform dimensionality reduction processing, and use the uLSIF algorithm to estimate the density ratio of the reduced-dimensional data to calculate the distribution density ratio of the edge distribution of the two domains The obtained distribution density ratio weight is normalized to obtain the source domain sample weights corresponding to the source domain sample data
[0087] For the target domain, there is a labeled dataset D t,l , judge N t Is it greater than a certain threshold T (such as 100), if N t If the value is greater than the threshold T, the Adaboost algorithm is used to determine the target domain sample weight corresponding to each target domain sample data. Specifically, the sample weight of the base classifier trained by the Adaboost algorithm for the last time can be normalized and used as the target domain sample weight, that is, the target domain sample weight As the target domain sample contribution; if Nt is less than the threshold T, and each sample in the target domain is set to have equal weight, that is, Specifically, when determining the target domain sample weights corresponding to the labeled target domain sample data, the weights are initialized and each sample in the target domain is set to an equal weight, that is, Normalized weights As the current weight. According to the current weight and the current weight, train the LR classifier and classify the target domain samples. Let the classifier output result be h t (x i ), labelled as c(x i ), calculate the error in the target domain Determine the weight update coefficient β t =ε t / (1-ε t ), update the current weight according to the weight update coefficient to get the updated weight Determine the number of training times. If the number of training times is less than the preset iteration threshold N, the updated weight is used as the current weight, and the training of the LR classifier according to the current weight and the current weight is returned to perform the next training iteration. When the number of training times reaches N, the updated weight of the last training is normalized as the target domain sample weight corresponding to each labeled target domain sample data. Determine the target domain balance factor λ t and source domain balance factor λ s .
[0088] α i , β i and λ t ,λ s Multiply them respectively to determine the final training sample weights, and finally use the labeled samples in the source domain and the target domain to jointly train the LR classifier for prediction in the target domain, that is, for scenario A to make effective default probability prediction.
[0089] In one embodiment, Figure 4 As shown, a machine learning model training method is provided, including:
[0090] S402, obtaining source domain sample data and target domain sample data of a machine learning model to be trained;
[0091] S404, determining the mean and standard deviation of the source domain sample data;
[0092] S406, using the source domain sample data and the target domain sample data as data to be standardized, and determining the data difference between the data to be standardized and the mean;
[0093] S408, determining a ratio of the data difference to the standard deviation, and using the ratio as a standardized sample corresponding to the data to be standardized; the standardized sample includes a source domain standardized sample corresponding to the source domain sample data and a target domain standardized sample corresponding to the target domain sample data;
[0094] S410, determining an unlabeled target domain standardized sample from the target domain standardized sample, where the unlabeled target domain standardized sample is obtained by performing data standardization processing on the unlabeled target domain sample data in the target domain sample data;
[0095] S412, determining feature dimensions of source domain sample data and target domain sample data;
[0096] S414, when the feature dimension is greater than a preset dimension threshold, performing dimensionality reduction processing on the source domain standardized samples and the unlabeled target domain standardized samples respectively, to obtain the reduced-dimensionality source domain standardized samples and the reduced-dimensionality unlabeled target domain standardized samples, and using the reduced-dimensionality unlabeled target domain standardized samples as the reduced-dimensionality target domain standardized samples;
[0097] S416, determining the dimensionality reduction distribution density ratio between the target domain standardized samples after dimensionality reduction and the source domain standardized samples after dimensionality reduction by using a density ratio estimation algorithm, and using the dimensionality reduction distribution density ratio as the distribution density ratio between the target domain sample data and the source domain sample data;
[0098] S418, normalizing the distribution density ratio to obtain source domain sample weights corresponding to each source domain sample data;
[0099] S420, extracting labeled target domain sample data from the target domain sample data;
[0100] S422, using the source domain sample data and the labeled target domain sample data as training sample data;
[0101] S424, determining a source domain weight balancing factor corresponding to the source domain sample data and a target domain weight balancing factor corresponding to the target domain sample data;
[0102] S426, obtaining the source domain sample weight of the source domain sample data in the training sample data according to the product of the source domain weight balancing factor and the source domain sample weight;
[0103] S428, obtaining a target domain sample weight of the target domain sample data in the training sample data according to the product of the target domain weight balancing factor and the target domain sample weight; the training sample weight includes a source domain sample weight and a target domain sample weight;
[0104] S430, training the training sample data according to the training sample weights, and obtaining a trained machine learning model when the training end condition is met.
[0105] In addition, it also includes a process of determining the target domain sample weights, specifically including: determining the sample number of the target domain sample data with labels in the target domain sample data; when the sample number is greater than the preset sample number threshold, determining the initialization weights corresponding to each of the target domain sample data with labels, and using the initialization weights as the current weights; training the target domain sample data with labels according to the current weights, and determining the weight update coefficient according to the error in the training process; updating the current weights by the weight update coefficients to obtain the updated weights; determining the number of training times, and when the number of training times reaches the preset iteration threshold, determining the target domain sample weights corresponding to each of the target domain sample data with labels according to the updated weights. When the sample number is not greater than the sample number threshold, determining that the target domain sample weights corresponding to each of the target domain sample data with labels are the same.
[0106] Figure 4 FIG. 1 is a flow chart of a method for training a machine learning model in one embodiment. It should be understood that although Figure 4 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 4 At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.
[0107] like Figure 5 As shown, in one embodiment, a machine learning model training device 500 is provided, comprising:
[0108] A sample data acquisition module 502 is used to acquire source domain sample data and target domain sample data of a machine learning model to be trained;
[0109] A density ratio determination module 504 is used to determine the distribution density ratio between the target domain sample data and the source domain sample data;
[0110] A source domain sample weight determination module 506 is used to determine the source domain sample weights corresponding to each source domain sample data according to the distribution density ratio;
[0111] The training sample weight determination module 508 is used to obtain training sample data according to the source domain sample data and the target domain sample data, and determine the training sample weights corresponding to the training sample data according to the source domain sample weights and the target domain sample weights corresponding to the target domain sample data;
[0112] The model training module 510 is used to train the training sample data according to the training sample weights, and obtain a trained machine learning model when the training end condition is met.
[0113] In one embodiment, the density ratio determination module 504 includes a standardization processing module, a sample dimension reduction processing module and a density ratio estimation processing module; wherein: the standardization processing module is used to perform data standardization processing on the source domain sample data and the target domain sample data to obtain source domain standardized samples corresponding to the source domain sample data and target domain standardized samples corresponding to the target domain sample data; the sample dimension reduction processing module is used to perform dimension reduction processing on the source domain standardized samples and the target domain standardized samples respectively when the feature dimensions of the source domain sample data and the target domain sample data are greater than a preset dimension threshold to obtain the reduced source domain standardized samples and the reduced target domain standardized samples; the density ratio estimation processing module is used to determine the reduced dimension distribution density ratio between the reduced target domain standardized samples and the reduced source domain standardized samples through a density ratio estimation algorithm, and use the reduced dimension distribution density ratio as the distribution density ratio between the target domain sample data and the source domain sample data.
[0114] In one embodiment, the standardization processing module includes a standardization parameter determination module, a data difference determination module and a ratio determination module; wherein: the standardization parameter determination module is used to determine the mean and standard deviation of the source domain sample data; the data difference determination module is used to use the source domain sample data and the target domain sample data as the data to be standardized, and determine the data difference between the data to be standardized and the mean; the ratio determination module is used to determine the ratio of the data difference to the standard deviation, and use the ratio as the standardized sample corresponding to the data to be standardized; the standardized samples include source domain standardized samples corresponding to the source domain sample data and target domain standardized samples corresponding to the target domain sample data.
[0115] In one embodiment, the sample dimension reduction processing module includes an unlabeled sample extraction module, a feature dimension determination module and a dimension reduction processing module; wherein: the unlabeled sample extraction module is used to determine the unlabeled target domain standardized samples from the target domain standardized samples, and the unlabeled target domain standardized samples are obtained by performing data standardization processing on the unlabeled target domain sample data in the target domain sample data; the feature dimension determination module is used to determine the feature dimension of the source domain sample data and the target domain sample data; the dimension reduction processing module is used to perform dimension reduction processing on the source domain standardized samples and the unlabeled target domain standardized samples respectively when the feature dimension is greater than a preset dimension threshold, to obtain the source domain standardized samples after dimension reduction and the unlabeled target domain standardized samples after dimension reduction, and use the unlabeled target domain standardized samples after dimension reduction as the target domain standardized samples after dimension reduction.
[0116] In one embodiment, a density ratio direct estimation module is further included, which is used to determine the low-dimensional distribution density ratio between the unlabeled target domain standardized samples and the source domain standardized samples through a density ratio estimation algorithm when the feature dimension is not greater than the dimension threshold, and use the low-dimensional distribution density ratio as the distribution density ratio between the target domain sample data and the source domain sample data.
[0117] In one embodiment, the source domain sample weight determination module 506 includes a normalization processing module, which is used to perform normalization processing on the distribution density ratio to obtain the source domain sample weight corresponding to each source domain sample data.
[0118] In one embodiment, the training sample weight determination module 508 includes a label sample extraction module and a training sample determination module; wherein: the label sample extraction module is used to extract labeled target domain sample data from the target domain sample data; the training sample determination module is used to use the source domain sample data and the labeled target domain sample data as training sample data.
[0119] In one embodiment, it also includes a sample quantity determination module and an iterative algorithm processing module; wherein: the sample quantity determination module is used to determine the sample quantity of labeled target domain sample data in the target domain sample data; the iterative algorithm processing module is used to determine the target domain sample weights corresponding to each labeled target domain sample data through an iterative algorithm when the sample quantity is greater than a preset sample quantity threshold.
[0120] In one embodiment, the iterative algorithm processing module includes a current weight determination module, an update coefficient determination module, an update weight module and an iteration end module; wherein: the current weight determination module is used to determine the initialization weights corresponding to each labeled target domain sample data, and use the initialization weights as the current weights; the update coefficient determination module is used to train the labeled target domain sample data according to the current weights, and determine the weight update coefficients according to the errors in the training process; the update weight module is used to update the current weights by the weight update coefficients to obtain updated weights; the iteration end module is used to determine the number of training times, and when the number of training times reaches a preset iteration threshold, the target domain sample weights corresponding to each labeled target domain sample data are determined according to the updated weights.
[0121] In one embodiment, an equal weight setting module is further included, which is used to determine that the target domain sample weights corresponding to each labeled target domain sample data are the same when the sample number is not greater than the sample number threshold.
[0122] In one embodiment, the training sample weight determination module 508 includes a balancing factor determination module, a source domain balancing factor processing module and a target domain balancing factor processing module; wherein: the balancing factor determination module is used to determine the source domain weight balancing factor corresponding to the source domain sample data and the target domain weight balancing factor corresponding to the target domain sample data; the source domain balancing factor processing module is used to obtain the source domain sample weight of the source domain sample data in the training sample data according to the product of the source domain weight balancing factor and the source domain sample weight; the target domain balancing factor processing module is used to obtain the target domain sample weight of the target domain sample data in the training sample data according to the product of the target domain weight balancing factor and the target domain sample weight; the training sample weight includes the source domain sample weight and the target domain sample weight.
[0123] Figure 6 The internal structure diagram of a computer device in one embodiment is shown. The computer device may specifically be Figure 1 or server 120. Figure 6 As shown, the computer device includes a processor, a memory, and a network interface connected through a system bus. Among them, the memory includes a non-volatile storage medium and an internal memory. The non-volatile storage medium of the computer device stores an operating system and may also store a computer program, which, when executed by the processor, enables the processor to implement a machine learning model training method. The internal memory may also store a computer program, which, when executed by the processor, enables the processor to execute a machine learning model training method.
[0124] Those skilled in the art will understand that Figure 6 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0125] In one embodiment, the machine learning model training device provided in the present application can be implemented in the form of a computer program, which can be used in Figure 6 The computer device shown in the figure is run on the computer device. The memory of the computer device can store various program modules that constitute the machine learning model training device, such as: Figure 5 The sample data acquisition module 502, density ratio determination module 504, source domain sample weight determination module 506 and training sample weight determination module 508 are shown. The computer program composed of various program modules enables the processor to execute the steps in the machine learning model training method of each embodiment of the present application described in this specification.
[0126] For example, Figure 6 The computer device shown can be Figure 5 The sample data acquisition module 502 in the machine learning model training device shown acquires the source domain sample data and the target domain sample data of the machine learning model to be trained. The computer device can determine the distribution density ratio between the target domain sample data and the source domain sample data through the density ratio determination module 504. The computer device can determine the source domain sample weights corresponding to each source domain sample data according to the distribution density ratio through the source domain sample weight determination module 506. The computer device can obtain the training sample data according to the source domain sample data and the target domain sample data through the training sample weight determination module 508, and determine the training sample weights corresponding to the training sample data according to the source domain sample weights and the target domain sample weights corresponding to the target domain sample data. The computer device can train the training sample data according to the training sample weights through the model training module 510, and obtain a trained machine learning model when the training end condition is met.
[0127] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of the above-mentioned machine learning model training method. The steps of the machine learning model training method here may be the steps of the machine learning model training method in each of the above-mentioned embodiments.
[0128] In one embodiment, a computer-readable storage medium is provided, which stores a computer program. When the computer program is executed by a processor, the processor executes the steps of the above-mentioned machine learning model training method. The steps of the machine learning model training method here can be the steps in the machine learning model training method of each of the above-mentioned embodiments.
[0129] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the program can be stored in a non-volatile computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0130] The technical features of the above embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0131] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A machine learning model training method, comprising: Obtain source domain sample data and target domain sample data for the machine learning model to be trained; Determine a distribution density ratio between the target domain sample data and the source domain sample data, where the distribution density ratio is used to characterize a data distribution difference between the target domain sample data and the source domain sample data; Normalizing the distribution density ratio to obtain source domain sample weights corresponding to each source domain sample data; Obtaining training sample data according to the source domain sample data and the target domain sample data; Determine a source domain weight balancing factor corresponding to the source domain sample data and a target domain weight balancing factor corresponding to the target domain sample data, wherein the source domain weight balancing factor represents a model contribution of the data in the source domain, and the target domain weight balancing factor represents a model contribution of the data in the target domain; Obtaining a source domain sample weight of the source domain sample data in the training sample data according to the product of the source domain weight balancing factor and the source domain sample weight; Obtaining the target domain sample weight of the target domain sample data in the training sample data according to the product of the target domain weight balancing factor and the target domain sample weight corresponding to the target domain sample data; Obtaining a training sample weight for the training sample data according to the source domain sample weight and the target domain sample weight; The training sample data is trained according to the training sample weights, and when a training end condition is met, a trained machine learning model is obtained.
2. The method according to claim 1, characterized in that The determining of the distribution density ratio between the target domain sample data and the source domain sample data comprises: Performing data standardization processing on the source domain sample data and the target domain sample data to obtain source domain standardized samples corresponding to the source domain sample data and target domain standardized samples corresponding to the target domain sample data; When the feature dimensions of the source domain sample data and the target domain sample data are greater than a preset dimension threshold, performing dimensionality reduction processing on the source domain standardized samples and the target domain standardized samples respectively to obtain a reduced-dimensional source domain standardized sample and a reduced-dimensional target domain standardized sample; The dimensionality reduction distribution density ratio between the target domain standardized samples after dimensionality reduction and the source domain standardized samples after dimensionality reduction is determined by a density ratio estimation algorithm, and the dimensionality reduction distribution density ratio is used as the distribution density ratio between the target domain sample data and the source domain sample data.
3. The method according to claim 2, characterized in that The performing data standardization processing on the source domain sample data and the target domain sample data to obtain source domain standardized samples corresponding to the source domain sample data and target domain standardized samples corresponding to the target domain sample data comprises: Determine the mean and standard deviation of the source domain sample data; Using the source domain sample data and the target domain sample data as data to be standardized, and determining a data difference between the data to be standardized and the mean; Determine the ratio of the data difference to the standard deviation, and use the ratio as the standardized sample corresponding to the data to be standardized; the standardized sample includes the source domain standardized sample corresponding to the source domain sample data and the target domain standardized sample corresponding to the target domain sample data.
4. The method according to claim 2, characterized in that: When the feature dimensions of the source domain sample data and the target domain sample data are greater than a preset dimension threshold, the source domain standardized samples and the target domain standardized samples are respectively subjected to dimensionality reduction processing to obtain the reduced-dimensional source domain standardized samples and the reduced-dimensional target domain standardized samples, including: Determining an unlabeled target domain standardized sample from the target domain standardized samples, where the unlabeled target domain standardized sample is obtained by performing data standardization processing on the unlabeled target domain sample data in the target domain sample data; Determining feature dimensions of the source domain sample data and the target domain sample data; When the feature dimension is greater than a preset dimension threshold, the source domain standardized samples and the unlabeled target domain standardized samples are respectively subjected to dimensionality reduction processing to obtain the reduced-dimensionality source domain standardized samples and the reduced-dimensionality unlabeled target domain standardized samples, and the reduced-dimensionality unlabeled target domain standardized samples are used as the reduced-dimensionality target domain standardized samples.
5. The method according to claim 4, characterized in that Also includes: When the feature dimension is not greater than the dimension threshold, a low-dimensional distribution density ratio between the unlabeled target domain standardized samples and the source domain standardized samples is determined by a density ratio estimation algorithm, and the low-dimensional distribution density ratio is used as the distribution density ratio between the target domain sample data and the source domain sample data.
6. The method according to claim 1, characterized in that The obtaining of training sample data according to the source domain sample data and the target domain sample data comprises: Extracting labeled target domain sample data from the target domain sample data; The source domain sample data and the labeled target domain sample data are used as training sample data.
7. The method according to claim 1, characterized in that Also includes: Determine the number of samples of the target domain sample data with labels in the target domain sample data; When the sample quantity is greater than a preset sample quantity threshold, the target domain sample weights respectively corresponding to each labeled target domain sample data are determined by an iterative algorithm.
8. The method according to claim 7, characterized in that Determining the target domain sample weights corresponding to each labeled target domain sample data by an iterative algorithm includes: Determine the initialization weights corresponding to the labeled target domain sample data, and use the initialization weights as the current weights; Training the labeled target domain sample data according to the current weights, and determining a weight update coefficient according to an error during the training process; The current weight is updated by using the weight update coefficient to obtain an updated weight; The number of training times is determined, and when the number of training times reaches a preset iteration threshold, the target domain sample weights respectively corresponding to each labeled target domain sample data are determined according to the update weights.
9. The method according to claim 7, characterized in that: Also includes: When the sample quantity is not greater than the sample quantity threshold, it is determined that the target domain sample weights respectively corresponding to each labeled target domain sample data are the same.
10. A machine learning model training device, characterized in that: The device comprises: A sample data acquisition module, used to acquire source domain sample data and target domain sample data of a machine learning model to be trained; a density ratio determination module, used to determine a distribution density ratio between the target domain sample data and the source domain sample data, wherein the distribution density ratio is used to characterize a data distribution difference between the target domain sample data and the source domain sample data; A source domain sample weight determination module, used to normalize the distribution density ratio to obtain the source domain sample weight corresponding to each source domain sample data; A training sample weight determination module is used to obtain training sample data according to the source domain sample data and the target domain sample data; determine a source domain weight balancing factor corresponding to the source domain sample data and a target domain weight balancing factor corresponding to the target domain sample data, the source domain weight balancing factor representing the model contribution of the data in the source domain, and the target domain weight balancing factor representing the model contribution of the data in the target domain; obtain the source domain sample weight of the source domain sample data in the training sample data according to the product of the source domain weight balancing factor and the source domain sample weight; obtain the target domain sample weight of the target domain sample data in the training sample data according to the product of the target domain weight balancing factor and the target domain sample weight corresponding to the target domain sample data; obtain the training sample weight of the training sample data according to the source domain sample weight and the target domain sample weight; The model training module is used to train the training sample data according to the training sample weights, and obtain a trained machine learning model when the training end condition is met.
11. The device according to claim 10, characterized in that The density ratio determination module comprises: A standardization processing module, used to perform data standardization processing on the source domain sample data and the target domain sample data to obtain source domain standardized samples corresponding to the source domain sample data and target domain standardized samples corresponding to the target domain sample data; A sample dimension reduction processing module, used for, when the feature dimensions of the source domain sample data and the target domain sample data are greater than a preset dimension threshold, performing dimension reduction processing on the source domain standardized sample and the target domain standardized sample respectively, to obtain the source domain standardized sample after dimension reduction and the target domain standardized sample after dimension reduction; The density ratio estimation processing module is used to determine the dimensionality reduction distribution density ratio between the target domain standardized samples after dimensionality reduction and the source domain standardized samples after dimensionality reduction through a density ratio estimation algorithm, and use the dimensionality reduction distribution density ratio as the distribution density ratio between the target domain sample data and the source domain sample data.
12. The device according to claim 11, characterized in that The standardization processing module includes: A standardization parameter determination module, used to determine the mean and standard deviation of the source domain sample data; a data difference determination module, configured to use the source domain sample data and the target domain sample data as data to be standardized, and determine a data difference between the data to be standardized and the mean; A ratio determination module is used to determine the ratio of the data difference to the standard deviation, and use the ratio as the standardized sample corresponding to the data to be standardized; the standardized sample includes a source domain standardized sample corresponding to the source domain sample data and a target domain standardized sample corresponding to the target domain sample data.
13. The device according to claim 11, characterized in that The sample dimension reduction processing module includes: an unlabeled sample extraction module, used to determine an unlabeled target domain standardized sample from the target domain standardized sample, wherein the unlabeled target domain standardized sample is obtained by performing data standardization processing on the unlabeled target domain sample data in the target domain sample data; A feature dimension determination module, used to determine the feature dimensions of the source domain sample data and the target domain sample data; The dimension reduction processing module is used to perform dimension reduction processing on the source domain standardized samples and the unlabeled target domain standardized samples respectively when the feature dimension is greater than a preset dimension threshold, so as to obtain the source domain standardized samples after dimension reduction and the unlabeled target domain standardized samples after dimension reduction, and use the unlabeled target domain standardized samples after dimension reduction as the target domain standardized samples after dimension reduction.
14. The device according to claim 13, characterized in that The device also includes: A density ratio direct estimation module is used to determine the low-dimensional distribution density ratio between the unlabeled target domain standardized samples and the source domain standardized samples through a density ratio estimation algorithm when the feature dimension is not greater than the dimension threshold, and use the low-dimensional distribution density ratio as the distribution density ratio between the target domain sample data and the source domain sample data.
15. The device according to claim 10, characterized in that The training sample weight determination module comprises: A label sample extraction module, used to extract labeled target domain sample data from the target domain sample data; The training sample determination module is used to use the source domain sample data and the labeled target domain sample data as training sample data.
16. The device according to claim 10, characterized in that The device also includes: A sample quantity determination module, used to determine the sample quantity of the target domain sample data with labels in the target domain sample data; The iterative algorithm processing module is used to determine the target domain sample weights corresponding to each labeled target domain sample data through an iterative algorithm when the sample quantity is greater than a preset sample quantity threshold.
17. The device according to claim 16, characterized in that The iterative algorithm processing module includes: A current weight determination module is used to determine the initialization weights corresponding to each labeled target domain sample data, and use the initialization weights as current weights; An update coefficient determination module, used to train the labeled target domain sample data according to the current weights, and determine the weight update coefficients according to the errors in the training process; A weight updating module, used to update the current weight by using the weight updating coefficient to obtain an updated weight; The iteration end module is used to determine the number of training times. When the number of training times reaches a preset iteration threshold, the target domain sample weights corresponding to each labeled target domain sample data are determined according to the updated weights.
18. The device according to claim 16, characterized in that The device also includes: The equal weight setting module is used to determine that the target domain sample weights respectively corresponding to each labeled target domain sample data are the same when the sample quantity is not greater than the sample quantity threshold.
19. A computer-readable storage medium storing a computer program, wherein when the computer program is executed by a processor, the processor is caused to perform the steps of the method according to any one of claims 1 to 9.
20. A computer device comprising a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of the method according to any one of claims 1 to 9.
Citation Information
Patent Citations
Network intrusion detection method based on active learning and migration learning
CN109462610A
Machine learning model training method and apparatus, server, and storage medium
US20190318202A1