A training method and device of a classification model, an apparatus and a storage medium
Patent Information
- Application Number
- CN202211139418.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-19
- Publication Date
- 2026-09-18
- Estimated Expiration
- 2042-09-19
AI Technical Summary
[0005]现有的去偏方式需要修改原有的分类模型内部的分类逻辑,不能直接兼容原有分类模型,灵活性较差
[0023]By acquiring the sample dataset corresponding to the preset sensitive attributes and determining the sample categories of each attribute value corresponding to the preset sensitive attributes, the sample dataset is sampled based on the current sampling ratio between the sample categories of each attribute value. A current sample data subset is obtained, and the preset classification model is trained in the current round based on this subset. Based on the current predicted category and label category corresponding to each sample data in the current sample data subset, the next sampling ratio between the sample categories of each attribute value is determined. This allows the determination of the next sampling ratio in the next round of training based on the degree of bias present in the current round of training. The preset classification model is then trained in the next round based on this next sampling ratio until the preset convergence condition is met, at which point the preset classification model training ends, resulting in a fair target classification model. By adjusting the sampling ratio between the sample categories of each attribute value in each round of training, the number of samples in each attribute value sample category corresponding to the preset sensitive attributes in each round of training can be controlled, gradually removing the bias present in the classification model and obtaining a final target classification model that guarantees fairness. This ensures classification accuracy, and since only the number of samples in each attribute value sample category needs to be adjusted, without adjusting the internal classification logic of the classification model, it can be directly compatible with the original classification model, improving flexibility.
Smart Images

Figure CN115456089B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of trusted artificial intelligence technology, and in particular to a method, apparatus, device and storage medium for training a classification model. Background Technology
[0002] With the rapid development of computer technology, machine learning models are widely used in applications such as image classification, fraud detection, sentiment analysis, facial recognition, speech understanding, autonomous driving, medical diagnosis, and recommender systems. However, due to biases in training data labeling and model design regarding certain sensitive attributes, the trained classification models may reinforce these biases and discriminations in application, leading to unfairness in the decision-making process.
[0003] Currently, in order to alleviate the unfairness that occurs in the application of classification models, constraint terms or regularization terms can be added to the classification models to promote the elimination of bias.
[0004] However, in the process of realizing this invention, the inventors discovered at least the following problems in the prior art:
[0005] Existing methods for removing bias require modification of the classification logic within the original classification model, making them incompatible with the original classification model and lacking flexibility. Summary of the Invention
[0006] This invention provides a training method, apparatus, device, and storage medium for a classification model, which removes biases in the classification model, ensures classification accuracy, and is directly compatible with existing classification models, thus improving flexibility.
[0007] In a first aspect, embodiments of the present invention provide a method for training a classification model, comprising:
[0008] Obtain the sample dataset corresponding to the preset sensitive attributes, and determine the sample category of each attribute value corresponding to the preset sensitive attributes;
[0009] Based on the current sampling ratio between sample categories of each attribute value, the sample dataset is sampled to obtain a current sample data subset, and the preset classification model is trained in the current round based on the current sample data subset;
[0010] Based on the current predicted category and label category corresponding to each sample data in the current sample data subset, determine the next sampling ratio between sample categories of each attribute value;
[0011] The preset classification model is trained again based on the next sampling ratio until the preset convergence condition is met. At this point, the training of the preset classification model ends, and a target classification model that ensures fairness is obtained.
[0012] Secondly, embodiments of the present invention also provide a training apparatus for a classification model, comprising:
[0013] The attribute value sample category determination module is used to obtain the sample dataset corresponding to the preset sensitive attribute and determine the category of each attribute value sample corresponding to the preset sensitive attribute.
[0014] The current round training module is used to sample the sample dataset based on the current sampling ratio between sample categories of each attribute value, obtain the current sample data subset, and perform current round training on the preset classification model based on the current sample data subset;
[0015] The next sampling ratio determination module is used to determine the next sampling ratio between sample categories of each attribute value based on the current predicted category and label category corresponding to each sample data in the current sample data subset.
[0016] The target classification model determination module is used to train the preset classification model in the next round based on the next sampling ratio until the preset convergence condition is met. At this point, the training of the preset classification model ends, and a target classification model that ensures fairness is obtained.
[0017] Thirdly, embodiments of the present invention also provide an electronic device, the electronic device comprising:
[0018] One or more processors;
[0019] Memory, used to store one or more programs;
[0020] When the one or more programs are executed by the one or more processors, the one or more processors implement the training method for the classification model provided in any embodiment of the present invention.
[0021] Fourthly, embodiments of the present invention also provide a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements a training method for a classification model as provided in any embodiment of the present invention.
[0022] The embodiments of the above invention have the following advantages or beneficial effects:
[0023] By acquiring the sample dataset corresponding to the preset sensitive attributes and determining the sample categories of each attribute value corresponding to the preset sensitive attributes, the sample dataset is sampled based on the current sampling ratio between the sample categories of each attribute value. A current sample data subset is obtained, and the preset classification model is trained in the current round based on this subset. Based on the current predicted category and label category corresponding to each sample data in the current sample data subset, the next sampling ratio between the sample categories of each attribute value is determined. This allows the determination of the next sampling ratio in the next round of training based on the degree of bias present in the current round of training. The preset classification model is then trained in the next round based on this next sampling ratio until the preset convergence condition is met, at which point the preset classification model training ends, resulting in a fair target classification model. By adjusting the sampling ratio between the sample categories of each attribute value in each round of training, the number of samples in each attribute value sample category corresponding to the preset sensitive attributes in each round of training can be controlled, gradually removing the bias present in the classification model and obtaining a final target classification model that guarantees fairness. This ensures classification accuracy, and since only the number of samples in each attribute value sample category needs to be adjusted, without adjusting the internal classification logic of the classification model, it can be directly compatible with the original classification model, improving flexibility. Attached Figure Description
[0024] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0025] Figure 1 This is a flowchart of a training method for a classification model provided in an embodiment of the present invention;
[0026] Figure 2 This is a flowchart of a training method for a classification model provided in an embodiment of the present invention;
[0027] Figure 3 This is a flowchart of a training method for a classification model provided in an embodiment of the present invention;
[0028] Figure 4 This is a schematic diagram of the structure of a training device for a classification model provided in an embodiment of the present invention;
[0029] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation
[0030] The present invention will now be described in further detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and not intended to limit it. Furthermore, it should be noted that, for ease of description, the accompanying drawings show only the parts relevant to the present invention, and not all of the structures.
[0031] Figure 1 This is a flowchart illustrating a training method for a classification model according to an embodiment of the present invention. This embodiment is applicable to training classification models with sensitive attributes to ensure fairness during classification. The method can be executed by a training device for the classification model, which can be implemented in software and / or hardware and integrated into an electronic device. Figure 1 As shown, the method specifically includes the following steps:
[0032] S110. Obtain the sample dataset corresponding to the preset sensitive attributes, and determine the sample category of each attribute value corresponding to the preset sensitive attributes.
[0033] The preset sensitive attributes can be sensitive attributes that need to be protected and are pre-defined based on business requirements. Preset sensitive attributes can include one or more sensitive attributes. Sensitive attributes can refer to human-related attributes such as age, gender, and race. The sample dataset can be a collection of sample data containing the preset sensitive attributes; for example, the sample dataset is S = {(x1, a1, y1), ..., (x... n ,a n ,y n Each sample data point may include sample feature information x. i 1. The attribute value a corresponding to the preset sensitive attribute i and tag category y i The attribute value sample category can refer to a sample category that may be biased and whose sample size needs to be controlled. In this embodiment, the number of attribute value sample categories can be multiple.
[0034] Specifically, this embodiment can have two methods for classifying attribute value samples. One implementation involves dividing the dataset based on all attribute values of a preset sensitive attribute and the various label categories of the classification model, obtaining the attribute value sample categories corresponding to the preset sensitive attribute. In this case, the attribute value sample categories do not contain pre-classification prediction category information. For example, for a binary classification model, when the preset sensitive attribute is gender, four attribute value sample categories can be obtained: positive samples with a male label of 1, negative samples with a male label of 0, positive samples with a female label of 1, and negative samples with a female label of 0. Another implementation involves using a pre-trained classification model to determine the pre-classification prediction category corresponding to each sample data in the dataset, and then dividing the dataset based on all attribute values of the preset sensitive attribute, the various label categories of the classification model, and the various pre-classification prediction categories, obtaining the attribute value sample categories corresponding to the preset sensitive attribute. In this case, the attribute value sample categories contain pre-classification prediction category information. For example, for a binary classification model, if the preset sensitive attribute is gender, eight attribute value sample categories can be obtained, namely: positive samples with male label 1 and predicted value 1, positive samples with male label 1 and predicted value 0, negative samples with male label 0 and predicted value 1, negative samples with male label 0 and predicted value 0, positive samples with female label 1 and predicted value 1, positive samples with female label 1 and predicted value 0, negative samples with female label 0 and predicted value 1, and negative samples with female label 0 and predicted value 0.
[0035] S120. Based on the current sampling ratio between sample categories of each attribute value, sample the sample dataset to obtain the current sample data subset, and train the preset classification model in the current round based on the current sample data subset.
[0036] Here, the current sampling ratio can refer to the ratio of the number of samples corresponding to each attribute value sample category in the current training round. The current sample data subset can include all sample data corresponding to each attribute value sample category obtained by sampling based on the current sampling ratio. The current sample data subset can refer to a subset of the sample dataset. The preset classification model can be any pre-set original classification model whose classification results may contain biases or discrimination. The preset classification model can be a binary classification model or a multi-class classification model.
[0037] Specifically, in the first round of training, the initial sampling ratio between each attribute value sample category can be set based on the number of attribute value sample categories. For example, if there are two attribute value sample categories, the initial sampling ratio for these two attribute value sample categories can be set to 0.5:0.5, so that the number of samples corresponding to each attribute value sample category is the same in the first round of training. Alternatively, different initial sampling ratios can be set based on business needs, such as 0.3:0.7. In the current round of training, based on the current sampling ratio, sampling is performed from the sample dataset. The number of samples corresponding to each attribute value sample category in the current sample data subset obtained by sampling satisfies the current sampling ratio. Existing classification model training methods can be used to train the preset classification model in the current round based on the current sample data subset, thus directly ensuring compatibility with the original classification model without modifying the internal classification logic of the preset classification model. For example, the current training process can be as follows: input the sample feature information of each sample data in the current sample data subset into the preset classification model to be trained for classification prediction. Based on the output of the preset classification model, the current predicted category corresponding to each sample data can be obtained. Based on the loss function, the training error is determined according to the current predicted category and the label category. The training error is then backpropagated to the preset classification model to adjust the network parameters in the preset classification model, thereby completing the current training.
[0038] S130. Based on the current predicted category and label category corresponding to each sample data in the current sample data subset, determine the next sampling ratio between the sample categories of each attribute value.
[0039] Here, the current predicted category can refer to the predicted category output by the pre-defined classification model in the current training round. The label category can refer to the labeled true category. The next sampling ratio can refer to the ratio between the number of samples corresponding to each attribute value sample category in the next training round.
[0040] Specifically, based on the current predicted category and label category corresponding to each sample data obtained in the current training round, the degree of bias of the preset classification model for each attribute value sample category in the current training round can be determined. Based on this degree of bias, the next sampling ratio in the next training round can be determined, thereby further eliminating bias by adjusting the number of samples corresponding to each attribute value sample category in the next training round. If the degree of bias for a certain attribute value sample category in the current training round is greater, the number of samples corresponding to that attribute value sample category in the next sampling round will be adjusted more significantly.
[0041] For example, S130 may include: determining the next sampling weight corresponding to each attribute value sample category based on the current predicted category and label category corresponding to each sample data in the current sample data subset; normalizing the next sampling weight corresponding to each attribute value sample category to determine the next sampling ratio between each attribute value sample category.
[0042] Specifically, the degree of bias corresponding to each attribute value sample category in the current training round can be determined based on the current predicted category and label category corresponding to each sample data in the current sample data subset. This embodiment can use prediction accuracy to characterize the degree of bias; for example, the higher the prediction accuracy, the greater the degree of bias. The next sampling weight in the next training round can be determined based on the degree of bias corresponding to each attribute value sample category. For example, the greater the bias, the lower the next sampling weight, thus reducing the number of samples in the next training round. For instance, if the prediction accuracy for men is higher in the current training round, making them an advantageous group, while the accuracy for women is lower, making them a disadvantaged group, then the sampling weight for male samples in the next training round will be reduced, and the sampling weight for female samples will be increased, thereby guiding the preset classification model to classify female samples more accurately and reducing the classification accuracy for male samples. By normalizing the next sampling weights corresponding to each attribute value sample category, the ratio between the normalized next sampling weights is determined as the next sampling ratio between each attribute value sample category.
[0043] S140. Based on the next sampling ratio, the preset classification model is trained in the next round until the preset convergence condition is met. The training of the preset classification model ends, and the target classification model with guaranteed fairness is obtained.
[0044] Specifically, similar to the current training process, the sample dataset can be sampled based on the next sampling ratio to obtain the next sample data subset, and the preset classification model can be trained again based on the next sample data subset. If the preset classification model still has bias after the next training, for example, there are two situations: ① If the classification accuracy of males is still higher, then the next sampling weight of male samples is further reduced and the next sampling weight of female samples is increased; ② If the classification accuracy of females exceeds that of males, then the sampling weight of female samples is reduced and the next sampling weight of male samples is increased, thereby adjusting the next sampling ratio again, and iterative training is performed based on the adjusted sampling ratio. For example, the next sampling ratio can be used as the current sampling ratio to return to step S120 for iterative training until the preset convergence condition is met, at which point the training ends. At this point, the preset classification model after training can be used as the target classification model that can ensure fairness. The preset convergence condition can refer to the change of the next sampling ratio determined after the current training tending to be gradual, that is, the degree of bias of the preset classification model has reached a minimum. By adjusting the sampling ratio between the categories of attribute value samples in each round of training, the bias in the pre-defined classification model can be gradually reduced to zero, and the sampling weights of each attribute value sample category will converge. The resulting pre-defined classification model is the debiased target classification model, ensuring classification accuracy. Furthermore, only the number of samples in each attribute value sample category needs to be adjusted, without modifying the internal classification logic of the classification model. This allows for direct compatibility with existing classification models and improves flexibility.
[0045] The technical solution of this embodiment obtains a sample dataset corresponding to a preset sensitive attribute and determines the sample category of each attribute value corresponding to the preset sensitive attribute. Based on the current sampling ratio between the sample categories of each attribute value, the sample dataset is sampled to obtain a current sample data subset, and the preset classification model is trained in the current round based on the current sample data subset. Based on the current predicted category and label category corresponding to each sample data in the current sample data subset, the next sampling ratio between the sample categories of each attribute value is determined. Thus, the next sampling ratio in the next round of training can be determined based on the degree of bias present in the current round of training, and the preset classification model is trained in the next round based on the next sampling ratio until the preset convergence condition is met, at which point the training of the preset classification model ends, and a target classification model that ensures fairness is obtained. By adjusting the sampling ratio between the sample categories of each attribute value in each round of training, the number of samples in each attribute value sample category corresponding to the preset sensitive attribute in each round of training can be controlled, gradually removing the bias present in the classification model, obtaining a final target classification model that can ensure fairness, ensuring classification accuracy, and only requiring adjustment of the number of samples in each attribute value sample category without adjusting the classification logic inside the classification model, thus directly compatible with the original classification model and improving flexibility.
[0046] Figure 2 This is a flowchart illustrating a training method for a classification model according to an embodiment of the present invention. Based on the above embodiments, this embodiment describes in detail the process of determining the next sampling weight corresponding to each attribute value sample category when the attribute value sample category does not contain pre-classification predicted category information. Explanations of terms that are the same as or corresponding to those in the above embodiments are not repeated here.
[0047] See Figure 2 The training method for a classification model provided in this embodiment specifically includes the following steps:
[0048] S210. Obtain the sample dataset corresponding to the preset sensitive attributes.
[0049] S220. Based on the attribute values and tag categories corresponding to the preset sensitive attributes, the sample categories of each attribute value corresponding to the preset sensitive attributes are determined.
[0050] Specifically, the attribute values and label categories corresponding to the preset sensitive attribute can be directly divided to obtain the sample categories of each attribute value corresponding to the preset sensitive attribute. At this time, each attribute value sample category does not contain the pre-classified predicted category information. For example, for a binary classification model, there are two label categories with labels 1 and 0. When the preset sensitive attribute is gender, there are two attribute values: male and female. By dividing these two attribute values and these two label categories, four attribute value sample categories can be obtained, namely: positive samples of male with label 1, negative samples of male with label 0, positive samples of female with label 1, and negative samples of female with label 0.
[0051] S230. Based on the current sampling ratio between sample categories of each attribute value, sample the sample dataset to obtain the current sample data subset, and train the preset classification model in the current round based on the current sample data subset.
[0052] S240. Determine the first attribute value sample category that matches the preset fairness index from each attribute value sample category.
[0053] The preset fairness indicators can be pre-set based on business needs, representing the fairness metrics that the classification model must meet. For example, preset fairness indicators may include, but are not limited to: equal opportunity, equal probability, or population parity (i.e., demographic equality). Among these, equal opportunity... This refers to the output result. The protected sensitive attribute A is conditionally independent of the label Y=1, i.e. Equal probability This refers to the output result. The protected attribute A is conditionally independent of the label Y, i.e. Population parity It can refer to the output result. It is independent of the sensitive attribute A in all cases, that is when and When the value equals 0, it indicates that the classification model satisfies equal opportunity, equal probability, and population parity, respectively. The first attribute value sample category can refer to the attribute value sample category that needs to be removed from the various attribute value sample categories. The number of first attribute value sample categories can be one or more.
[0054] Specifically, based on a preset fairness index, the first attribute value sample category that needs to be removed from all attribute value sample categories can be selected from all the attribute value sample categories to meet the preset fairness index.
[0055] For example, when the attribute value sample category does not contain pre-classified predicted category information, S240 may include: if the preset fairness index is equal opportunity, then the positive sample category corresponding to each sensitive attribute value with bias in the preset sensitive attributes is taken as the first attribute value sample category; if the preset fairness index is equal probability, then both the positive sample category and the negative sample category corresponding to each sensitive attribute value with bias in the preset sensitive attributes are taken as the first attribute value sample category.
[0056] Specifically, when the preset fairness criterion is equal opportunity, the positive sample category Y=1 corresponding to each biased sensitive attribute value A=a in the preset sensitive attributes can be used as the first attribute value sample category. For example, positive samples labeled 1 for males and positive samples labeled 1 for females can both be used as the first attribute value sample categories. For instance, if only one preset sensitive attribute exists, the positive sample category for each attribute value of that preset sensitive attribute can be used as the first attribute value sample category. If at least two preset sensitive attributes exist, the combination of biased target sensitive attribute values corresponding to at least two preset sensitive attributes is determined, and the positive sample category of the combination of at least two preset sensitive attributes as target sensitive attribute values is used as the first attribute value sample category. For example, if there are two sensitive attributes, race (including Black, White, and Asian) and gender (including Male and Female), these two sensitive attributes can be combined in pairs to obtain sensitive attribute value combinations containing one race attribute value and one gender attribute value. Based on the classification task, it can be detected whether each sensitive attribute value combination is biased. For example, if the sensitive attribute value combination of White Male and Black Female is biased, these two sensitive attribute value combinations can be used as target sensitive attribute value combinations, and positive samples with a label of 1 for White Male and positive samples with a label of 1 for Black Female can be used as the first attribute value sample category.
[0057] When the preset fairness criterion is equal probability, the positive sample category Y=1 and the negative sample category Y=0 corresponding to each biased sensitive attribute value A=a in the preset sensitive attributes can be used as the first attribute value sample category. For example, the four attribute value sample categories are: positive samples with male label 1, negative samples with male label 0, positive samples with female label 1, and negative samples with female label 0. For instance, if only one preset sensitive attribute exists, the positive and negative sample categories for each attribute value can be used as the first attribute value sample category. If at least two preset sensitive attributes exist, the biased target sensitive attribute value combinations corresponding to at least two preset sensitive attributes are determined, and the positive and negative sample categories of the at least two preset sensitive attributes that are target sensitive attribute value combinations are used as the first attribute value sample category.
[0058] It should be noted that when the attribute value sample category does not contain pre-classified predicted category information, the two fairness indicators of equal opportunity or equal probability can be used to evaluate and remove bias.
[0059] S250. Based on the current sampling weight corresponding to the first attribute value sample category, the current predicted category and label category corresponding to each sample data in the current sample data subset, determine the next sampling weight corresponding to the first attribute value sample category.
[0060] For example, when the attribute value sample category does not contain pre-classification prediction category information, S250 may include: determining the prediction accuracy corresponding to the first attribute value sample category based on the current prediction category and label category corresponding to each sample data in the current sample data subset; and determining the next sampling weight corresponding to the first attribute value sample category based on the prediction accuracy and the current sampling weight corresponding to the first attribute value sample category.
[0061] Specifically, for each first attribute value sample category, the prediction accuracy corresponding to that first attribute value sample category can be determined based on the current predicted category and label category corresponding to each sample data in the current sample data subset. For example, if the first attribute value sample category is: positive samples with male label 1, then based on the current predicted category corresponding to each sample data with male label 1, the correctly predicted sample data corresponding to that category can be determined, and the ratio between the correctly predicted sample data and the total number of samples can be used as the prediction accuracy corresponding to that first attribute value sample category. Similarly, the prediction accuracy corresponding to each first attribute value sample category can be determined, and the current sampling weight corresponding to each first attribute value sample category can be adjusted based on the prediction accuracy corresponding to each first attribute value sample category, and the adjusted current sampling weight can be used as the next sampling weight. For example, if the prediction accuracy of the positive sample category with male label 1 is greater than that of the positive sample category with female label 1, then the current sampling weight corresponding to the positive sample category with male label 1 is reduced by a preset amount, and the current sampling weight corresponding to the positive sample category with female label 1 is increased by a preset amount. In this way, the sampling weight is gradually increased or decreased based on the preset amount until the preset classification model after training has no bias.
[0062] S260. Determine the current sampling weight corresponding to the second attribute value sample category as the next sampling weight corresponding to the second attribute value sample category, wherein the second attribute value sample category refers to other attribute value sample categories besides the first attribute value sample category.
[0063] The second attribute value sample category can refer to the attribute value sample category that does not require bias removal from the various attribute value sample categories. The number of second attribute value sample categories can be one or more.
[0064] Specifically, for each second attribute value sample category that does not require bias removal, the current sampling weight corresponding to the second attribute value sample category can be directly determined as the next sampling weight corresponding to that second attribute value sample category, without adjusting the number of samples of the second attribute value sample category in the next round of training.
[0065] S270. Normalize the next sampling weights corresponding to each attribute value sample category to determine the next sampling ratio between each attribute value sample category.
[0066] S280. Based on the next sampling ratio, the preset classification model is trained in the next round until the preset convergence condition is met. The training of the preset classification model ends, and the target classification model with guaranteed fairness is obtained.
[0067] The technical solution of this embodiment determines the sample categories of each attribute value corresponding to the preset sensitive attribute by dividing the data based on the attribute values and label categories corresponding to the preset sensitive attribute. Under this attribute value sample category division method, the bias in the classification model can be gradually removed by controlling the number of samples of each attribute value sample category corresponding to the preset sensitive attribute in each round of training, so as to obtain a final target classification model that can guarantee fairness and ensure classification accuracy. Moreover, only the number of samples of each attribute value sample category needs to be adjusted, without adjusting the classification logic inside the classification model, so it can be directly compatible with the original classification model and improves flexibility.
[0068] Figure 3 This is a flowchart illustrating a training method for a classification model according to an embodiment of the present invention. Based on the above embodiments, this embodiment details the process of determining the next sampling weight corresponding to each attribute value sample category when the attribute value sample category contains pre-classification predicted category information. Explanations of terms that are the same as or corresponding to those in the above embodiments are not repeated here.
[0069] See Figure 3 The training method for a classification model provided in this embodiment specifically includes the following steps:
[0070] S310. Obtain the sample dataset corresponding to the preset sensitive attributes.
[0071] S320. Based on the pre-trained classification model, pre-classify each sample data in the sample dataset corresponding to the preset sensitive attribute to obtain a sample dataset containing the pre-classified predicted category. Then, based on each attribute value, each label category and each pre-classified predicted category corresponding to the preset sensitive attribute, divide the sample data to determine the sample category of each attribute value corresponding to the preset sensitive attribute.
[0072] The pre-trained classification model can be a classification model obtained through pre-training. In this embodiment, the preset classification model can be further trained based on the pre-trained classification model to eliminate biases present in the pre-trained model. The pre-classified predicted category can be the category predicted by the pre-trained classification model.
[0073] Specifically, the sample feature information of each sample in the sample dataset can be input into a pre-trained classification model for classification prediction. Based on the output of the pre-trained classification model, the pre-classified predicted category corresponding to each sample can be obtained. At this time, each sample can include sample feature information, attribute values corresponding to preset sensitive attributes, label categories, and pre-classified predicted categories. Based on all attribute values of preset sensitive attributes in the sample dataset, each label category of the classification model, and each pre-classified predicted category, the sample categories of each attribute value corresponding to the preset sensitive attributes can be obtained. Each attribute value sample category obtained at this time contains pre-classified predicted category information. For example, in a binary classification model, there are two label categories with labels 1 and 0, and two pre-classified predicted categories with predicted categories 1 and 0. When the preset sensitive attribute is gender, there are two attribute values: male and female. By dividing these two attribute values, these two label categories, and these two pre-classified predicted categories, we can obtain eight attribute value sample categories, which are: positive samples with male label 1 and predicted value 1, positive samples with male label 1 and predicted value 0, negative samples with male label 0 and predicted value 1, negative samples with male label 0 and predicted value 0, positive samples with female label 1 and predicted value 1, positive samples with female label 1 and predicted value 0, negative samples with female label 0 and predicted value 1, and negative samples with female label 0 and predicted value 0.
[0074] S330. Based on the current sampling ratio between sample categories of each attribute value, sample the sample dataset to obtain the current sample data subset, and train the preset classification model in the current round based on the current sample data subset.
[0075] S340. Determine the first attribute value sample category that matches the preset fairness index from each attribute value sample category.
[0076] Specifically, based on a preset fairness index, the first attribute value sample category that needs to be removed from all attribute value sample categories can be selected from all the attribute value sample categories to meet the preset fairness index.
[0077] For example, when the attribute value sample category contains pre-classification prediction category information, S340 may include: if the preset fairness index is equal opportunity, then the pre-classification prediction accurate positive sample category corresponding to each sensitive attribute value with bias in the preset sensitive attributes is taken as the first attribute value sample category; if the preset fairness index is equal probability, then the pre-classification prediction accurate positive sample category and negative sample category corresponding to each sensitive attribute value with bias in the preset sensitive attributes are both taken as the first attribute value sample category; if the preset fairness index is population parity, then the pre-classification prediction positive sample category and negative sample category corresponding to each sensitive attribute value with bias in the preset sensitive attributes are both taken as the first attribute value sample category.
[0078] Specifically, when the fairness criterion is assumed to be equal opportunity, it is required that, under the condition Y=1, the event must satisfy... The events A=1 are statistically independent, and the events... The event A = 0 is statistically independent, that is:
[0079]
[0080]
[0081] Therefore, when the preset fairness metric is equal opportunity, the pre-classified positive sample category corresponding to each sensitive attribute value A=a that exhibits bias in the preset sensitive attributes can be used as the first attribute value sample category. That is, for each sensitive attribute value A=a, when the label Y=1 and the predicted value... The attribute value sample category is used as the first attribute value sample category. For example, positive samples with a male label of 1 and a predicted value of 1 and positive samples with a female label of 1 and a predicted value of 1 are both used as the first attribute value sample category.
[0082] When the fairness criterion is assumed to be equal probability, the event must satisfy the condition that Y=1. The event A = 1 is statistically independent. The event A = 0 is statistically independent; under the condition Y = 0, the event... The event A = 0 is statistically independent. The event A = 1 is statistically independent, that is:
[0083]
[0084]
[0085]
[0086]
[0087] Therefore, when the preset fairness criterion is equal probability, the positive and negative sample categories that are accurately predicted in the pre-classification for each sensitive attribute value A=a, which contains bias, can be used as the first attribute value sample category. That is, for each sensitive attribute value A=a, when the label Y=1 and the predicted value... The attribute values of the sample categories and the predicted values under label Y=0. The attribute value sample category is used as the first attribute value sample category. For example, the positive sample with male label 1 and predicted value 1, the negative sample with male label 0 and predicted value 0, the positive sample with female label 1 and predicted value 1, and the negative sample with female label 0 and predicted value 0 are all used as the first attribute value sample category.
[0088] When the fairness indicator is preset as population parity, the event is required to be... The events A=1 are statistically independent, and the events... The event A = 0 is statistically independent, that is:
[0089]
[0090]
[0091] Therefore, when the fairness indicator is preset as population parity, the pre-classified predicted category corresponding to each biased sensitive attribute value A=a in the preset sensitive attributes can be set as the positive category. Both the positive and negative sample classes are used as the first attribute value sample class. That is, for each sensitive attribute value A = a, when the label Y = 1 and the predicted value is... The attribute values of the sample categories and the predicted values under label Y=0. The attribute value sample category is used as the first attribute value sample category. For example, the positive sample with male label 1 and predicted value 1, the negative sample with male label 0 and predicted value 1, the positive sample with female label 1 and predicted value 1, and the negative sample with female label 0 and predicted value 1 are all used as the first attribute value sample category.
[0092] S350. Based on the current sampling weight corresponding to the first attribute value sample category, the current prediction category and label category corresponding to each sample data in the current sample data subset, determine the next sampling weight corresponding to the first attribute value sample category.
[0093] For example, when the attribute value sample category contains pre-classified predicted category information, S250 may include: determining the current adjustment coefficient corresponding to the first attribute value sample category based on a preset fairness index and the current predicted category and label category corresponding to each sample data in the current sample data subset; multiplying the current sampling weight corresponding to the first attribute value sample category with the corresponding current adjustment coefficient, and using the multiplication result as the next sampling weight corresponding to the first attribute value sample category.
[0094] Specifically, for each first attribute value sample category, the current adjustment coefficient corresponding to the first attribute value sample category can be directly determined based on the conditions required by the preset fairness index. The current adjustment coefficient is then multiplied with the current sampling weight corresponding to the first attribute value sample category, and the result of the multiplication is used as the next sampling weight corresponding to the first attribute value sample category. This allows for a more accurate determination of the next sampling weight and further improves the debiasing efficiency and accuracy of the model.
[0095] For example, based on a preset fairness index and the current predicted category and label category corresponding to each sample data in the current sample data subset, the current adjustment coefficient corresponding to the sample category of the first attribute value is determined, including:
[0096] For each sample category with a first attribute value, obtain the current sensitive attribute value, the current label category, and the current pre-classification predicted category corresponding to the current sample category with the first attribute value;
[0097] If the preset fairness index is equal opportunity or equal probability, then based on the current predicted category and label category corresponding to each sample data in the current sample data subset, determine the following: the number of first samples with the current sensitive attribute value and the label category being the current label category; the number of second samples with the current label category and the current predicted category being the current pre-classification predicted category; the number of third samples with the current label category; and the number of fourth samples with the current sensitive attribute value and the current label category being the current predicted category being the current pre-classification predicted category. Based on the number of first, second, third, and fourth samples, determine the current adjustment coefficient corresponding to the current first attribute value sample category.
[0098] If the preset fairness indicator is population parity, then based on the current predicted category and label category corresponding to each sample data in the current sample data subset, determine the number of fifth samples with the current sensitive attribute value, the number of sixth samples whose current predicted category is the current pre-classified predicted category, the number of seventh samples with the current sensitive attribute value and whose current predicted category is the current pre-classified predicted category, and the total number of samples; and determine the current adjustment coefficient corresponding to the current first attribute value sample category based on the number of fifth samples, the number of sixth samples, the number of seventh samples, and the total number of samples.
[0099] Specifically, the current adjustment coefficient can be determined by using the category of each first attribute value sample as the current first attribute value sample category. For example, if the current first attribute value sample category is a positive sample with a male label of 1 and a predicted value of 1, then the current sensitive attribute value is male, the current label category is 1, and the current pre-classification predicted category is 1.
[0100] When the preset fairness metric is equal opportunity or equal probability, the number of samples with the current sensitive attribute value 'a' and the label category 'Y' can be determined based on the current predicted category and label category corresponding to each sample data in the current sample data subset. The first sample number |A=a∩Y=y| is defined as having the current sensitive attribute value 'a' and the label category 'Y' is defined as having the current label category 'y' and the current predicted category 'y' is defined as having the current sensitive attribute value 'a' and the label category 'Y' is defined as having the current predicted category 'y'. Predict the category for the current pre-classification Second sample size The label category Y is the third sample size of the current label category y |Y=y|, and the label category Y is the current label category y and the current predicted category has the current sensitive attribute value a. Predict the category for the current pre-classification The fourth sample size Based on the first sample size |A=a∩Y=y|, the second sample size The third sample size |Y=y| and the fourth sample size The current adjustment coefficient corresponding to the current sample category of the first attribute value can be determined. For example, the first sample size |A=a∩Y=y| can be multiplied by the second sample size. Obtain the first multiplication result R1, and combine the third sample size |Y=y| and the fourth sample size. The first and second multiplication results are multiplied to obtain the second multiplication result R2. The ratio R1 / R2 between the first and second multiplication results is determined as the current adjustment coefficient corresponding to the current first attribute value sample category. This allows for a more direct and accurate determination of the current adjustment coefficient corresponding to each first attribute value sample category.
[0101] When the fairness indicator is preset to population parity, the number of fifth samples with the current sensitive attribute value 'a' (|A=a|) and the current predicted category can be determined based on the current predicted category and label category corresponding to each sample data in the current sample data subset. Predict the category for the current pre-classification The sixth sample size Having the current sensitive attribute value 'a' and the current predicted category Predict the category for the current pre-classification The seventh sample size And the total number of samples |Y|, and can be determined based on the fifth sample size |A=a|, the sixth sample size Seventh Sample Size Given the total number of samples |Y|, determine the current adjustment coefficient corresponding to the current first attribute value sample category. For example, consider the fifth sample size |A=a| and the sixth sample size... Perform multiplication to obtain the third multiplication result R3, and then calculate the seventh sample size. Multiply the result by the total number of samples |Y| to obtain the fourth multiplication result R4. The ratio R3 / R4 between the third and fourth multiplication results is determined as the current adjustment coefficient corresponding to the current first attribute value sample category. This allows for a more direct and accurate determination of the current adjustment coefficient corresponding to each first attribute value sample category.
[0102] S360. Determine the current sampling weight corresponding to the second attribute value sample category as the next sampling weight corresponding to the second attribute value sample category, wherein the second attribute value sample category refers to other attribute value sample categories besides the first attribute value sample category.
[0103] The second attribute value sample category can refer to the attribute value sample category that does not require bias removal from the various attribute value sample categories. The number of second attribute value sample categories can be one or more.
[0104] Specifically, for each second attribute value sample category that does not require bias removal, the current sampling weight corresponding to the second attribute value sample category can be directly determined as the next sampling weight corresponding to that second attribute value sample category, without adjusting the number of samples of the second attribute value sample category in the next round of training.
[0105] S370. Normalize the next sampling weights corresponding to each attribute value sample category to determine the next sampling ratio between each attribute value sample category.
[0106] S380. Based on the next sampling ratio, the preset classification model is trained in the next round until the preset convergence condition is met. The training of the preset classification model ends, and the target classification model with guaranteed fairness is obtained.
[0107] The technical solution of this embodiment pre-classifies each sample data in the sample dataset corresponding to the preset sensitive attribute based on a pre-trained classification model, obtaining a sample dataset containing pre-classified predicted categories. It then divides the dataset based on each attribute value, each label category, and each pre-classified predicted category corresponding to the preset sensitive attribute, determining the sample category for each attribute value corresponding to the preset sensitive attribute. This attribute value sample category division method allows for a more accurate determination of the next sampling ratio corresponding to each attribute value sample category. By controlling the number of samples in each attribute value sample category corresponding to the preset sensitive attribute in each training round, biases in the classification model are gradually removed, resulting in a final target classification model that ensures fairness and guarantees classification accuracy. Furthermore, only the number of samples in each attribute value sample category needs to be adjusted, without needing to adjust the internal classification logic of the classification model, thus directly compatibility with existing classification models and improving flexibility.
[0108] The following are embodiments of the classification model training apparatus provided in this invention. This apparatus and the classification model training methods in the above embodiments belong to the same inventive concept. For details not described in detail in the embodiments of the classification model training apparatus, please refer to the embodiments of the classification model training methods described above.
[0109] Figure 4 This is a schematic diagram of a training device for a classification model provided in an embodiment of the present invention. This embodiment is applicable to training classification models with sensitive attributes to ensure fairness during classification. Figure 4 As shown, the device specifically includes: an attribute value sample category determination module 410, a current round training module 420, a next sampling ratio determination module 430, and a target classification model determination module 440.
[0110] The module 410 for determining the category of attribute value samples is used to obtain the sample dataset corresponding to the preset sensitive attributes and determine the category of each attribute value sample corresponding to the preset sensitive attributes. The module 420 for training the current round is used to sample the sample dataset based on the current sampling ratio between each attribute value sample category to obtain the current sample data subset, and to train the preset classification model in the current round based on the current sample data subset. The module 430 for determining the next sampling ratio is used to determine the next sampling ratio between each attribute value sample category based on the current predicted category and label category corresponding to each sample data in the current sample data subset. The module 440 for determining the target classification model is used to train the preset classification model in the next round based on the next sampling ratio, until the preset convergence condition is met, at which point the training of the preset classification model ends, and a target classification model that ensures fairness is obtained.
[0111] The technical solution of this embodiment obtains a sample dataset corresponding to a preset sensitive attribute and determines the sample category of each attribute value corresponding to the preset sensitive attribute. Based on the current sampling ratio between the sample categories of each attribute value, the sample dataset is sampled to obtain a current sample data subset, and the preset classification model is trained in the current round based on the current sample data subset. Based on the current predicted category and label category corresponding to each sample data in the current sample data subset, the next sampling ratio between the sample categories of each attribute value is determined. Thus, the next sampling ratio in the next round of training can be determined based on the degree of bias present in the current round of training, and the preset classification model is trained in the next round based on the next sampling ratio until the preset convergence condition is met, at which point the training of the preset classification model ends, and a target classification model that ensures fairness is obtained. By adjusting the sampling ratio between the sample categories of each attribute value in each round of training, the number of samples in each attribute value sample category corresponding to the preset sensitive attribute in each round of training can be controlled, gradually removing the bias present in the classification model, obtaining a final target classification model that can ensure fairness, ensuring classification accuracy, and only requiring adjustment of the number of samples in each attribute value sample category without adjusting the classification logic inside the classification model, thus directly compatible with the original classification model and improving flexibility.
[0112] Optionally, the attribute value sample category determination module 410 is specifically used for:
[0113] Based on the attribute values and tag categories corresponding to the preset sensitive attributes, the sample categories of each attribute value corresponding to the preset sensitive attributes are determined; or...
[0114] Based on the pre-trained classification model, each sample data in the sample dataset corresponding to the preset sensitive attribute is pre-classified to obtain a sample dataset containing the pre-classified predicted categories. Based on each attribute value, each label category and each pre-classified predicted category corresponding to the preset sensitive attribute, the sample categories of each attribute value corresponding to the preset sensitive attribute are divided to determine the sample categories of each attribute value corresponding to the preset sensitive attribute.
[0115] Optionally, the next sampling ratio determination module 430 includes:
[0116] The next sampling weight determination unit is used to determine the next sampling weight corresponding to the sample category of each attribute value based on the current predicted category and label category corresponding to each sample data in the current sample data subset.
[0117] The next sampling ratio determination unit is used to normalize the next sampling weights corresponding to each attribute value sample category and determine the next sampling ratio between each attribute value sample category.
[0118] Optionally, the next sampling weight determination unit includes:
[0119] The first attribute value sample category determination subunit is used to determine the first attribute value sample category that matches the preset fairness index from each attribute value sample category;
[0120] The first sampling weight determination subunit is used to determine the next sampling weight corresponding to the first attribute value sample category based on the current sampling weight corresponding to the first attribute value sample category, the current prediction category and label category corresponding to each sample data in the current sample data subset;
[0121] The second sampling weight determination subunit is used to determine the current sampling weight corresponding to the second attribute value sample category as the next sampling weight corresponding to the second attribute value sample category, wherein the second attribute value sample category refers to other attribute value sample categories besides the first attribute value sample category.
[0122] Optionally, when the attribute value sample category does not contain pre-classified predicted category information, the first attribute value sample category determines the sub-unit, specifically for:
[0123] If the preset fairness criterion is equal opportunity, then the positive sample category corresponding to each sensitive attribute value with bias in the preset sensitive attributes will be used as the first attribute value sample category; if the preset fairness criterion is equal probability, then both the positive and negative sample categories corresponding to each sensitive attribute value with bias in the preset sensitive attributes will be used as the first attribute value sample category.
[0124] Optionally, the first sampling weight determines the sub-unit, specifically for:
[0125] Based on the current predicted category and label category corresponding to each sample data in the current sample data subset, determine the prediction accuracy corresponding to the first attribute value sample category; based on the prediction accuracy and the current sampling weight corresponding to the first attribute value sample category, determine the next sampling weight corresponding to the first attribute value sample category.
[0126] Optionally, when the attribute value sample category contains pre-classification predicted category information, the first attribute value sample category determines the sub-unit, specifically for:
[0127] If the preset fairness criterion is equal opportunity, then the positive sample category that is accurately predicted in the pre-classification for each sensitive attribute value with bias in the preset sensitive attributes is taken as the first attribute value sample category; if the preset fairness criterion is equal probability, then both the positive and negative sample categories that are accurately predicted in the pre-classification for each sensitive attribute value with bias in the preset sensitive attributes are taken as the first attribute value sample category; if the preset fairness criterion is population parity, then both the positive and negative sample categories that are predicted to be positive in the pre-classification for each sensitive attribute value with bias in the preset sensitive attributes are taken as the first attribute value sample category.
[0128] Optionally, the first sampling weight determines the sub-unit, specifically including:
[0129] The current adjustment coefficient determination submodule is used to determine the current adjustment coefficient corresponding to the sample category of the first attribute value based on the preset fairness index and the current prediction category and label category corresponding to each sample data in the current sample data subset;
[0130] The first sampling weight determination submodule is used to multiply the current sampling weight corresponding to the first attribute value sample category with the corresponding current adjustment coefficient, and the multiplication result is used as the next sampling weight corresponding to the first attribute value sample category.
[0131] Optionally, the current adjustment coefficient determination submodule is specifically used for:
[0132] For each sample category with a first attribute value, obtain the current sensitive attribute value, the current label category, and the current pre-classification predicted category corresponding to the current sample category with the first attribute value;
[0133] If the preset fairness index is equal opportunity or equal probability, then based on the current predicted category and label category corresponding to each sample data in the current sample data subset, determine the following: the number of first samples with the current sensitive attribute value and the label category being the current label category; the number of second samples with the current label category and the current predicted category being the current pre-classification predicted category; the number of third samples with the current label category; and the number of fourth samples with the current sensitive attribute value and the current label category being the current predicted category being the current pre-classification predicted category. Based on the number of first, second, third, and fourth samples, determine the current adjustment coefficient corresponding to the current first attribute value sample category.
[0134] If the preset fairness indicator is population parity, then based on the current predicted category and label category corresponding to each sample data in the current sample data subset, determine the number of fifth samples with the current sensitive attribute value, the number of sixth samples whose current predicted category is the current pre-classified predicted category, the number of seventh samples with the current sensitive attribute value and whose current predicted category is the current pre-classified predicted category, and the total number of samples; and determine the current adjustment coefficient corresponding to the current first attribute value sample category based on the number of fifth samples, the number of sixth samples, the number of seventh samples, and the total number of samples.
[0135] Optionally, the current adjustment coefficient determination submodule is also specifically used for:
[0136] Multiply the first sample size and the second sample size to obtain the first multiplication result, and multiply the third sample size and the fourth sample size to obtain the second multiplication result. The ratio between the first multiplication result and the second multiplication result is determined as the current adjustment coefficient corresponding to the current first attribute value sample category.
[0137] Optionally, the current adjustment coefficient determination submodule is also specifically used for:
[0138] Multiply the fifth sample count and the sixth sample count to obtain the third multiplication result, and multiply the seventh sample count and the total sample count to obtain the fourth multiplication result. The ratio between the third multiplication result and the fourth multiplication result is determined as the current adjustment coefficient corresponding to the current first attribute value sample category.
[0139] The classification model training device provided in this embodiment of the invention can execute the classification model training method provided in any embodiment of the invention, and has the corresponding functional modules and beneficial effects for executing the classification model training method.
[0140] It is worth noting that in the embodiments of the training device for the above classification model, the various units and modules included are only divided according to functional logic, but are not limited to the above division, as long as the corresponding functions can be achieved; in addition, the specific names of each functional unit are only for easy differentiation and are not used to limit the scope of protection of the present invention.
[0141] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Figure 5 A block diagram is shown of an exemplary electronic device 12 suitable for implementing embodiments of the present invention. Figure 5 The electronic device 12 shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of the present invention.
[0142] like Figure 5 As shown, the electronic device 12 is represented in the form of a general-purpose computing device. The components of the electronic device 12 may include, but are not limited to: one or more processors or processing units 16, system memory 28, and bus 18 connecting different system components (including system memory 28 and processing unit 16).
[0143] Bus 18 represents one or more of several bus architectures, including a memory bus or memory controller, a peripheral bus, a graphics acceleration port, a processor, or a local bus using any of the various bus architectures. For example, these architectures include, but are not limited to, the Industry Standard Architecture (ISA) bus, the Micro Channel Architecture (MAC) bus, the Enhanced ISA bus, the Video Electronics Standards Association (VESA) local bus, and the Peripheral Component Interconnect (PCI) bus.
[0144] Electronic device 12 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by electronic device 12, including volatile and non-volatile media, removable and non-removable media.
[0145] System memory 28 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache memory 32. Electronic device 12 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, storage system 34 may be used to read and write non-removable, non-volatile magnetic media (… Figure 5 Not shown; usually referred to as a "hard drive"). Although Figure 5 Not shown, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk") and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to bus 18 via one or more data media interfaces. System memory 28 may include at least one program product having a set (e.g., at least one) of program modules configured to perform the functions of the embodiments of the present invention.
[0146] A program / utility 40 having a set (at least one) of program modules 42 may be stored, for example, in system memory 28. Such program modules 42 include, but are not limited to, an operating system, one or more application programs, other program modules, and program data. Each or some combination of these examples may include an implementation of a network environment. Program modules 42 typically perform the functions and / or methods described in the embodiments of the present invention.
[0147] Electronic device 12 can also communicate with one or more external devices 14 (e.g., keyboard, pointing device, display 24, etc.), and with one or more devices that enable a user to interact with electronic device 12, and / or with any device that enables electronic device 12 to communicate with one or more other computing devices (e.g., network card, modem, etc.). This communication can be performed via input / output (I / O) interface 22. Furthermore, electronic device 12 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public networks, such as the Internet) via network adapter 20. As shown, network adapter 20 communicates with other modules of electronic device 12 via bus 18. It should be understood that, although not shown in the figures, other hardware and / or software modules can be used in conjunction with electronic device 12, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0148] Processing unit 16 executes various functional applications and data processing by running programs stored in system memory 28, such as implementing a training method for a classification model provided in this embodiment, the method including:
[0149] Obtain the sample dataset corresponding to the preset sensitive attributes, and determine the sample category of each attribute value corresponding to the preset sensitive attributes;
[0150] Based on the current sampling ratio between sample categories of each attribute value, the sample dataset is sampled to obtain the current sample data subset, and the preset classification model is trained in the current round based on the current sample data subset;
[0151] Based on the current predicted category and label category corresponding to each sample data in the current sample data subset, determine the next sampling ratio between sample categories of each attribute value;
[0152] The preset classification model is trained again based on the next sampling ratio until the preset convergence condition is met. At this point, the training of the preset classification model ends, and a target classification model that ensures fairness is obtained.
[0153] Of course, those skilled in the art will understand that the processor can also implement the technical solution of the training method for the classification model provided in any embodiment of the present invention.
[0154] This embodiment provides a computer-readable storage medium storing a computer program thereon. When executed by a processor, the program implements the training method steps of the classification model provided in any embodiment of the present invention. The method includes:
[0155] Obtain the sample dataset corresponding to the preset sensitive attributes, and determine the sample category of each attribute value corresponding to the preset sensitive attributes;
[0156] Based on the current sampling ratio between sample categories of each attribute value, the sample dataset is sampled to obtain the current sample data subset, and the preset classification model is trained in the current round based on the current sample data subset;
[0157] Based on the current predicted category and label category corresponding to each sample data in the current sample data subset, determine the next sampling ratio between sample categories of each attribute value;
[0158] The preset classification model is trained again based on the next sampling ratio until the preset convergence condition is met. At this point, the training of the preset classification model ends, and a target classification model that ensures fairness is obtained.
[0159] The computer storage medium of this invention can be any combination of one or more computer-readable media. A computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. For example, a computer-readable storage medium can be, but is not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples (a non-exhaustive list) of computer-readable storage media include: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this document, a computer-readable storage medium can be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.
[0160] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, capable of sending, propagating, or transmitting programs for use by or in connection with an instruction execution system, apparatus, or device.
[0161] Program code contained on a computer-readable medium may be transmitted using any suitable medium, including but not limited to: wireless, wire, optical fiber, RF, etc., or any suitable combination thereof.
[0162] Computer program code for performing the operations of this invention can be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, and C++, as well as conventional procedural programming languages—such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0163] Those skilled in the art will understand that the modules or steps of the present invention described above can be implemented using general-purpose computing devices. They can be centralized on a single computing device or distributed across a network of multiple computing devices. Optionally, they can be implemented using computer-executable program code, thereby allowing them to be stored in a storage device for execution by a computing device, or they can be fabricated as separate integrated circuit modules, or multiple modules or steps can be fabricated as a single integrated circuit module. Thus, the present invention is not limited to any particular combination of hardware and software.
[0164] Note that the above description is merely a preferred embodiment of the present invention and the technical principles employed. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and various obvious changes, readjustments, and substitutions can be made without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in detail through the above embodiments, the present invention is not limited to the above embodiments, and may include many other equivalent embodiments without departing from the concept of the present invention, the scope of which is determined by the scope of the appended claims.
Claims
1. A method for training a classification model, characterized in that, include: Obtain the sample dataset corresponding to the preset sensitive attribute, and pre-classify each sample data in the sample dataset corresponding to the preset sensitive attribute based on the pre-trained classification model to obtain a sample dataset containing the pre-classified predicted category. Then, divide the sample dataset based on each attribute value, each label category and each pre-classified predicted category corresponding to the preset sensitive attribute to determine the sample category of each attribute value corresponding to the preset sensitive attribute. Based on the current sampling ratio between sample categories of each attribute value, the sample dataset is sampled to obtain a current sample data subset, and the preset classification model is trained in the current round based on the current sample data subset, wherein the preset classification model is the pre-trained classification model; If the preset fairness metric is equal opportunity, then the positive sample category with accurate pre-classification prediction corresponding to each sensitive attribute value with bias in the preset sensitive attributes is taken as the first attribute value sample category; if the preset fairness metric is equal probability, then both the positive and negative sample categories with accurate pre-classification prediction corresponding to each sensitive attribute value with bias in the preset sensitive attributes are taken as the first attribute value sample category; if the preset fairness metric is population parity, then both the positive and negative sample categories with positive pre-classification prediction corresponding to each sensitive attribute value with bias in the preset sensitive attributes are taken as the first attribute value sample category. Based on the current sampling weight corresponding to the first attribute value sample category, the current prediction category and label category corresponding to each sample data in the current sample data subset, the next sampling weight corresponding to the first attribute value sample category is determined; The current sampling weight corresponding to the second attribute value sample category is determined as the next sampling weight corresponding to the second attribute value sample category, wherein the second attribute value sample category refers to other attribute value sample categories besides the first attribute value sample category; Normalize the next sampling weights corresponding to each attribute value sample category to determine the next sampling ratio between each attribute value sample category; The preset classification model is trained again based on the next sampling ratio until the preset convergence condition is met. At this point, the training of the preset classification model ends, and a target classification model that ensures fairness is obtained for image classification.
2. The method according to claim 1, characterized in that, The step of determining the next sampling weight corresponding to the first attribute value sample category based on the current sampling weight corresponding to the first attribute value sample category, the current predicted category and label category corresponding to each sample data in the current sample data subset, includes: Based on the preset fairness index and the current prediction category and label category corresponding to each sample data in the current sample data subset, determine the current adjustment coefficient corresponding to the sample category of the first attribute value; The current sampling weight corresponding to the first attribute value sample category is multiplied by the corresponding current adjustment coefficient, and the result of the multiplication is used as the next sampling weight corresponding to the first attribute value sample category.
3. The method according to claim 2, characterized in that, The step of determining the current adjustment coefficient corresponding to the first attribute value sample category based on the preset fairness index and the current predicted category and label category corresponding to each sample data in the current sample data subset includes: For each of the first attribute value sample categories, obtain the current sensitive attribute value, current label category, and current pre-classification prediction category corresponding to the current first attribute value sample category; If the preset fairness index is equal opportunity or equal probability, then based on the current predicted category and label category corresponding to each sample data in the current sample data subset, determine the following: a first number of samples with the current sensitive attribute value and the label category of the current label category; a second number of samples with the label category of the current label category and the current predicted category of the current pre-classification prediction category; a third number of samples with the label category of the current label category; and a fourth number of samples with the current sensitive attribute value and the label category of the current label category and the current predicted category of the current pre-classification prediction category. Based on the first number of samples, the second number of samples, the third number of samples, and the fourth number of samples, determine the current adjustment coefficient corresponding to the current first attribute value sample category. If the preset fairness indicator is population parity, then based on the current predicted category and label category corresponding to each sample data in the current sample data subset, determine the number of fifth samples with the current sensitive attribute value, the number of sixth samples whose current predicted category is the current pre-classified predicted category, the number of seventh samples with the current sensitive attribute value and whose current predicted category is the current pre-classified predicted category, and the total number of samples; and determine the current adjustment coefficient corresponding to the current first attribute value sample category based on the number of fifth samples, the number of sixth samples, the number of seventh samples, and the total number of samples.
4. The method according to claim 3, characterized in that, The step of determining the current adjustment coefficient corresponding to the current first attribute value sample category based on the first sample quantity, the second sample quantity, the third sample quantity, and the fourth sample quantity includes: Multiply the first sample count and the second sample count to obtain a first multiplication result, and multiply the third sample count and the fourth sample count to obtain a second multiplication result, and determine the ratio between the first multiplication result and the second multiplication result as the current adjustment coefficient corresponding to the current first attribute value sample category; The step of determining the current adjustment coefficient corresponding to the current first attribute value sample category based on the fifth sample quantity, the sixth sample quantity, the seventh sample quantity, and the total sample quantity includes: The fifth sample count and the sixth sample count are multiplied together to obtain the third multiplication result, and the seventh sample count and the total sample count are multiplied together to obtain the fourth multiplication result. The ratio between the third multiplication result and the fourth multiplication result is determined as the current adjustment coefficient corresponding to the current first attribute value sample category.
5. A training device for a classification model, characterized in that, include: The attribute value sample category determination module is used to obtain the sample dataset corresponding to the preset sensitive attribute, and pre-classify each sample data in the sample dataset corresponding to the preset sensitive attribute based on the pre-trained classification model to obtain a sample dataset containing the pre-classified predicted category. Based on each attribute value, each label category and each pre-classified predicted category corresponding to the preset sensitive attribute, the module divides the data to determine the sample category of each attribute value corresponding to the preset sensitive attribute. The current round training module is used to sample the sample dataset based on the current sampling ratio between the sample categories of each attribute value, obtain a current sample data subset, and perform current round training on the preset classification model based on the current sample data subset, wherein the preset classification model is the pre-trained classification model; The next sampling ratio determination module is used as follows: if the preset fairness index is equal opportunity, then the pre-classified predicted positive sample category corresponding to each biased sensitive attribute value in the preset sensitive attributes is taken as the first attribute value sample category; if the preset fairness index is equal probability, then both the pre-classified predicted positive and negative sample categories corresponding to each biased sensitive attribute value in the preset sensitive attributes are taken as the first attribute value sample category; if the preset fairness index is population parity, then both the pre-classified predicted positive and negative sample categories corresponding to each biased sensitive attribute value in the preset sensitive attributes are taken as the first attribute value sample category; based on the current sampling weight corresponding to the first attribute value sample category, the current predicted category and label category corresponding to each sample data in the current sample data subset, the next sampling weight corresponding to the first attribute value sample category is determined; the current sampling weight corresponding to the second attribute value sample category is determined as the next sampling weight corresponding to the second attribute value sample category, wherein the second attribute value sample category refers to other attribute value sample categories besides the first attribute value sample category; the next sampling weight corresponding to each attribute value sample category is normalized to determine the next sampling ratio between each attribute value sample category; The target classification model determination module is used to train the preset classification model in the next round based on the next sampling ratio until the preset convergence condition is met. At this point, the training of the preset classification model ends, and a target classification model that ensures fairness is obtained for image classification.
6. An electronic device, characterized in that, The electronic device includes: One or more processors; Memory, used to store one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the training method for the classification model as described in any one of claims 1-4.
7. A computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by the processor, the program implements the training method for the classification model as described in any one of claims 1-4.