CN115456089A - Training method, device, equipment and storage medium of classification model - Google Patents

Training method, device, equipment and storage medium of classification model Download PDF

Info

Publication number
CN115456089A
CN115456089A CN202211139418.1A CN202211139418A CN115456089A CN 115456089 A CN115456089 A CN 115456089A CN 202211139418 A CN202211139418 A CN 202211139418A CN 115456089 A CN115456089 A CN 115456089A
Authority
CN
China
Prior art keywords
sample
current
attribute value
class
preset
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211139418.1A
Other languages
Chinese (zh)
Inventor
何凤翔
胡郅昊
傅少鹏
陶大程
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Jingdong Century Trading Co Ltd
Beijing Wodong Tianjun Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Wodong Tianjun Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Jingdong Century Trading Co Ltd, Beijing Wodong Tianjun Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN202211139418.1A priority Critical patent/CN115456089A/en
Publication of CN115456089A publication Critical patent/CN115456089A/en
Priority to PCT/CN2023/097746 priority patent/WO2024060670A1/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • G06N3/084Backpropagation, e.g. using gradient descent

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • General Health & Medical Sciences (AREA)
  • Biomedical Technology (AREA)
  • Biophysics (AREA)
  • Computational Linguistics (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Evolutionary Computation (AREA)
  • Artificial Intelligence (AREA)
  • Molecular Biology (AREA)
  • Computing Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Mathematical Physics (AREA)
  • Software Systems (AREA)
  • Health & Medical Sciences (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The embodiment of the invention discloses a training method, a training device, equipment and a storage medium of a classification model, and relates to the technical field of trusted artificial intelligence. The method comprises the following steps: acquiring a sample data set corresponding to a preset sensitive attribute, and determining an attribute value sample category corresponding to the preset sensitive attribute; sampling the sample data set based on the current sampling proportion among the attribute value sample classes to obtain a current sample data subset, and performing on-round training on a preset classification model based on the current sample data subset; determining a next sampling proportion between attribute value sample classes based on a current prediction class and a label class corresponding to each sample data in a current sample data subset; and performing next round training on the preset classification model based on the next sampling proportion until the preset classification model training is finished when the preset convergence condition is met at present, and obtaining a target classification model for guaranteeing fairness, so that prejudices existing in the classification model are removed, the classification model is compatible with the original classification model, and the flexibility is improved.

Description

Training method, device, equipment and storage medium of classification model
Technical Field
The embodiment of the invention relates to the technical field of trusted artificial intelligence, in particular to a training method, a device, equipment and a storage medium of a classification model.
Background
With the rapid development of computer technology, machine learning models are widely used, such as image classification, fraud detection, emotion analysis, face recognition, speech understanding, automatic driving, medical diagnosis, recommendation systems, and the like. Due to the fact that bias exists on certain sensitive attributes in training data labeling and model design, the trained classification model can strengthen bias and discrimination on the sensitive attributes in application, and unfairness in a decision making process is caused.
At present, in order to alleviate the unfairness phenomenon of the classification model in the application, bias elimination can be promoted by adding a constraint term or a regularization term in the classification model.
However, in the process of implementing the present invention, the inventor finds that at least the following problems exist in the prior art:
the existing depolarization method needs to modify the classification logic inside the original classification model, cannot be directly compatible with the original classification model, and is poor in flexibility.
Disclosure of Invention
The embodiment of the invention provides a training method, a training device, equipment and a storage medium of a classification model, which are used for removing bias existing in the classification model, ensuring classification accuracy, being directly compatible with the original classification model and improving flexibility.
In a first aspect, an embodiment of the present invention provides a method for training a classification model, including:
acquiring a sample data set corresponding to a preset sensitive attribute, and determining each attribute value sample category corresponding to the preset sensitive attribute;
sampling the sample data set based on the current sampling proportion among the sample classes of the attribute values to obtain a current sample data subset, and performing on-round training on a preset classification model based on the current sample data subset;
determining a next sampling proportion among all attribute value sample classes based on a current prediction class and a label class corresponding to each sample data in the current sample data subset;
and performing next round training on the preset classification model based on the next sampling proportion until the preset convergence condition is met, and finishing the training of the preset classification model to obtain the target classification model for guaranteeing fairness.
In a second aspect, an embodiment of the present invention further provides a training apparatus for a classification model, including:
the attribute value sample class determining module is used for acquiring a sample data set corresponding to a preset sensitive attribute and determining each attribute value sample class corresponding to the preset sensitive attribute;
the on-turn training module is used for sampling the sample data set based on the current sampling proportion among the sample classes of the attribute values to obtain a current sample data subset, and carrying out on-turn training on a preset classification model based on the current sample data subset;
the next sampling proportion determining module is used for determining the next sampling proportion among all the attribute value sample classes based on the current prediction class and the label class corresponding to each sample data in the current sample data subset;
and the target classification model determining module is used for carrying out next round of training on the preset classification model based on the next sampling proportion until the preset convergence condition is met at present, finishing the training of the preset classification model and obtaining the target classification model for guaranteeing fairness.
In a third aspect, an embodiment of the present invention further provides an electronic device, where the electronic device includes:
one or more processors;
a memory for storing one or more programs;
when executed by the one or more processors, cause the one or more processors to implement a method of training a classification model as provided by any embodiment of the invention.
In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the method for training a classification model according to any embodiment of the present invention.
The embodiment of the invention has the following advantages or beneficial effects:
the method comprises the steps of obtaining a sample data set corresponding to a preset sensitive attribute, and determining each attribute value sample category corresponding to the preset sensitive attribute; sampling the sample data set based on the current sampling proportion among the sample classes of the attribute values to obtain a current sample data subset, and performing on-round training on a preset classification model based on the current sample data subset; and determining the next sampling proportion among the sample classes of each attribute value based on the current prediction class and the label class corresponding to each sample data in the current sample data subset, so that the next sampling proportion in the next round of training can be determined based on the bias degree existing in the round of training, and the next round of training is performed on the preset classification model based on the next sampling proportion until the preset convergence condition is met currently, the training of the preset classification model is finished, and the target classification model for guaranteeing fairness is obtained. By adjusting the sampling proportion among all attribute value sample categories in each round of training, the number of samples of all attribute value sample categories corresponding to preset sensitive attributes in each round of training can be controlled, prejudices existing in the classification model are gradually removed, a target classification model which can finally guarantee fairness is obtained, classification accuracy is guaranteed, only the number of samples of all attribute value sample categories needs to be adjusted, classification logic in the classification model does not need to be adjusted, the original classification model can be directly compatible, and flexibility is improved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the embodiments or the description of the prior art will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and other drawings can be obtained by those skilled in the art without creative efforts.
FIG. 1 is a flowchart of a method for training a classification model according to an embodiment of the present invention;
FIG. 2 is a flowchart of a method for training a classification model according to an embodiment of the present invention;
FIG. 3 is a flowchart of a method for training a classification model according to an embodiment of the present invention;
FIG. 4 is a schematic structural diagram of a training apparatus for classification models according to an embodiment of the present invention;
fig. 5 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting of the invention. It should be further noted that, for the convenience of description, only some structures related to the present invention are shown in the drawings, not all of them.
Fig. 1 is a flowchart of a method for training a classification model according to an embodiment of the present invention, which is applicable to training a classification model with presence-sensitive attributes to ensure fairness in classification of the classification model. The method may be performed by a training apparatus for classification models, which may be implemented by software and/or hardware, integrated in an electronic device. As shown in fig. 1, the method specifically includes the following steps:
s110, acquiring a sample data set corresponding to the preset sensitive attribute, and determining each attribute value sample category corresponding to the preset sensitive attribute.
The preset sensitive attribute may be a sensitive attribute that needs to be protected and is set in advance based on the service requirement. The preset sensitivity attribute may include one or more sensitivity attributes. The sensitive attribute may refer to an age, a gender, an ethnicity, and the like, which are related to a person. The sample data set may comprise a pre-sample setLet the set of sample data of the sensitive attribute be, for example, S = { (x) for the sample data set 1 ,a 1 ,y 1 ),…,(x n ,a n ,y n ) }. Each sample data may include sample feature information x i And presetting an attribute value a corresponding to the sensitive attribute i And label category y i . The attribute value sample class may refer to a sample class in which there may be a bias that requires control over the number of samples. The number of attribute value sample categories in this embodiment may be plural.
Specifically, the present embodiment may have two ways of dividing the attribute value sample class. As an implementation manner, all attribute values of the preset sensitive attribute in the sample data set and all label classes of the classification model may be classified to obtain all attribute value sample classes corresponding to the preset sensitive attribute, where the attribute value sample class at this time does not include the pre-classification prediction class information. For example, for a classification model of two classes, when the predetermined sensitivity attribute is gender, 4 attribute value sample classes can be obtained, which are: a positive sample with a male label of 1, a negative sample with a male label of 0, a positive sample with a female label of 1, and a negative sample with a female label of 0. As another implementation manner, a pre-classification prediction category corresponding to each sample data in the sample data set may also be determined by using a pre-training classification model, and all attribute values of the preset sensitive attribute in the sample data set, each label category of the classification model, and each pre-classification prediction category are divided to obtain each attribute value sample category corresponding to the preset sensitive attribute, where the attribute value sample category at this time includes information of the pre-classification prediction category. For example, for a classification model of two classes, when the preset sensitive attribute is gender, 8 attribute value sample classes can be obtained, which are: a positive exemplar with a male label of 1 and a predicted value of 1, a positive exemplar with a male label of 1 and a predicted value of 0, a negative exemplar with a male label of 0 and a predicted value of 1, a negative exemplar with a male label of 0 and a predicted value of 0, a positive exemplar with a female label of 1 and a predicted value of 1, a positive exemplar with a female label of 1 and a predicted value of 0, a negative exemplar with a female label of 0 and a predicted value of 1, and a negative exemplar with a female label of 0 and a predicted value of 0.
And S120, sampling the sample data set based on the current sampling proportion among the sample classes of the attribute values to obtain a current sample data subset, and performing current training on the preset classification model based on the current sample data subset.
The current sampling ratio may be a ratio between the number of samples corresponding to each attribute value sample class in the current round of training. The current sample data subset may include all sample data corresponding to each attribute value sample class obtained by sampling based on the current sampling proportion. The current sample data subset may refer to a subset of the sample data set. The preset classification model can be preset, and the classification result can be any one of the original classification models with biased discrimination. The preset classification model can be a two-classification model or a multi-classification model.
Specifically, in the first round of training, the initial sampling ratio between the respective attribute value sample classes may be set based on the number of attribute value sample classes. For example, if there are two attribute value sample classes, the initial sampling ratio corresponding to the two attribute value sample classes may be set to 0.5:0.5, so that the number of samples corresponding to each attribute value sample category sampled in the first training is the same, or different initial sampling ratios can be set based on the traffic demand, such as 0.3:0.7, etc. In the current-round training, sampling is carried out from the sample data set based on the current sampling proportion, the number of samples corresponding to each attribute value sample category in the current sample data subset obtained through sampling meets the current sampling proportion, and the current-round training mode of the classification model can be utilized, so that the current-round training of the classification model is carried out on the preset classification model based on the current sample data subset, the original classification model can be directly compatible, and the classification logic in the preset classification model does not need to be modified. For example, when the training process of a round may be: inputting sample characteristic information in each sample data in the current sample data subset into a preset classification model to be trained for classification prediction, obtaining a current prediction category corresponding to each sample data based on the output of the preset classification model, determining a training error according to the current prediction category and a label category based on a loss function, reversely transmitting the training error to the preset classification model, and adjusting network parameters in the preset classification model, thereby completing current round training.
S130, determining a next sampling proportion among all attribute value sample classes based on the current prediction class and the label class corresponding to each sample data in the current sample data subset.
The current prediction category may be a prediction category output by a preset classification model in the current round of training. The tag class may refer to the true class of the tag. The next sampling ratio may refer to a ratio between the number of samples corresponding to each attribute value sample class in the next round of training.
Specifically, the bias degree of the preset classification model in each attribute value sample category in the current round of training may be determined based on the current prediction category and the label category corresponding to each sample data obtained in the current round of training, and the next sampling proportion in the next round of training may be determined based on the bias degree, so that the bias is further eliminated by adjusting the number of samples corresponding to each attribute value sample category in the next round of training. And if the bias degree of a certain attribute value sample class in the round of training is larger, adjusting the number of samples of the lower round corresponding to the attribute value sample class to be larger.
Exemplarily, S130 may include: determining a next sampling weight corresponding to each attribute value sample class based on a current prediction class and a label class corresponding to each sample data in the current sample data subset; and normalizing the next sampling weight corresponding to each attribute value sample category to determine the next sampling proportion among the attribute value sample categories.
Specifically, the bias degree corresponding to each attribute value sample class in the current round of training may be determined based on the current prediction class and the label class corresponding to each sample data in the current sample data subset. The embodiment can use the prediction accuracy to represent the bias degree, for example, the higher the prediction accuracy, the greater the bias degree. The next sampling weight in the next round of training can be determined based on the bias degree corresponding to each attribute value sample class. For example, the greater the degree of bias, the lower the sampling weight is decreased to reduce the number of samples in the lower round of training. For example, when the prediction accuracy of a male in a round of training is high and the male is a dominant population, the accuracy of a female is low and the male is a disadvantaged population, the sampling weight of the male sample in the next round of training is reduced, and the sampling weight of the female sample is increased, so that the preset classification model is guided to classify the female sample more accurately, and the classification accuracy of the male sample is reduced. And normalizing the next sampling weight corresponding to each attribute value sample type, and determining the ratio of the next sampling weights obtained after normalization as the next sampling proportion among the attribute value sample types.
S140, performing next round training on the preset classification model based on the next sampling proportion until the preset convergence condition is met, and finishing the training of the preset classification model to obtain the target classification model for guaranteeing fairness.
Specifically, similar to the current training process, the sample data set may be sampled based on the next sampling proportion, the next sample data subset is obtained, and the next training round is performed on the preset classification model based on the next sample data subset. If there is a bias in presetting the classification model after the next round of training, for example, two situations are included: (1) if the classification accuracy of the male is still higher, further reducing the next sampling weight of the male sample, and increasing the next sampling weight of the female sample; (2) if the classification accuracy of the female exceeds that of the male, the sampling weight of the female sample is reduced, the next sampling weight of the male sample is increased, so that the next sampling proportion is adjusted again, and iterative training is performed based on the adjusted sampling proportion. For example, the next sampling ratio may be used as the current sampling ratio to return to the manner of performing step S120 for iterative training until the training is finished when the preset convergence condition is currently satisfied, at which time the preset classification model after the training is finished may be used as the target classification model that can ensure fairness. The preset convergence condition may mean that the change of the next sampling proportion determined after the round of training tends to be smooth, that is, the bias degree of the preset classification model reaches the minimum degree. By adjusting the sampling proportion among the sample classes of each attribute value in each round of training, the bias existing in the preset classification model gradually tends to zero, the sampling weight of each sample class of the attribute value can be converged, the obtained preset classification model is the target classification model after the bias is removed, the classification accuracy is ensured, only the sample quantity of each sample class of the attribute value needs to be adjusted, the classification logic in the classification model does not need to be adjusted, the original classification model can be directly compatible, and the flexibility is improved. .
According to the technical scheme, a sample data set corresponding to the preset sensitive attribute is obtained, and the sample types of all attribute values corresponding to the preset sensitive attribute are determined; sampling the sample data set based on the current sampling proportion among the attribute value sample categories to obtain a current sample data subset, and performing on-the-go training on a preset classification model based on the current sample data subset; and determining the next sampling proportion among the sample classes of each attribute value based on the current prediction class and the label class corresponding to each sample data in the current sample data subset, so that the next sampling proportion in the next round of training can be determined based on the bias degree existing in the round of training, and the next round of training is performed on the preset classification model based on the next sampling proportion until the preset convergence condition is met currently, the training of the preset classification model is finished, and the target classification model for guaranteeing fairness is obtained. By adjusting the sampling proportion among all attribute value sample categories in each round of training, the number of samples of all attribute value sample categories corresponding to preset sensitive attributes in each round of training can be controlled, prejudices existing in a classification model are gradually removed, a target classification model which can guarantee fairness finally is obtained, classification accuracy is guaranteed, only the number of samples of all attribute value sample categories needs to be adjusted, classification logic in the classification model does not need to be adjusted, and therefore the original classification model can be directly compatible, and flexibility is improved.
Fig. 2 is a flowchart of a method for training a classification model according to an embodiment of the present invention, and this embodiment describes in detail a process of determining a next sampling weight corresponding to each attribute value sample class on the basis of the foregoing embodiments and in a case that the attribute value sample class does not include pre-classification prediction class information. Wherein explanations of the same or corresponding terms as those of the above embodiments are omitted.
Referring to fig. 2, the training method of the classification model provided in this embodiment specifically includes the following steps:
s210, obtaining a sample data set corresponding to the preset sensitive attribute.
S220, dividing based on each attribute value corresponding to the preset sensitivity attribute and each label category, and determining each attribute value sample category corresponding to the preset sensitivity attribute.
Specifically, each attribute value and each label category corresponding to the preset sensitive attribute may be directly divided to obtain each attribute value sample category corresponding to the preset sensitive attribute, and each obtained attribute value sample category does not include the pre-classification prediction category information. For example, for a classification model of the second classification, there are two label classes with labels 1 and 0, and when the preset sensitive attribute is gender, there are two attribute values of male and female, and by dividing the two attribute values and the two label classes, 4 attribute value sample classes can be obtained, which are respectively: a positive swatch with a male label of 1, a negative swatch with a male label of 0, a positive swatch with a female label of 1, and a negative swatch with a female label of 0.
And S230, sampling the sample data set based on the current sampling proportion among the sample classes of the attribute values to obtain a current sample data subset, and performing current training on the preset classification model based on the current sample data subset.
S240, determining a first attribute value sample class matched with the preset fairness index from all attribute value sample classes.
The preset fairness index can be preset based on the service requirement, and the classification model needs to meet the fairness index. For example, the preset fairness indicators may include, but are not limited to: equal chance, or equal population price (i.e., demographically equal). Wherein the chance is equal
Figure BDA0003852866010000101
Means to output the result
Figure BDA0003852866010000102
And the protected sensitive attribute a is conditionally independent when given the label Y =1, i.e.
Figure BDA0003852866010000103
Figure BDA0003852866010000104
Equal probability
Figure BDA0003852866010000105
Means to output the result
Figure BDA0003852866010000106
Conditional independently of the protected attribute A given the label Y, i.e.
Figure BDA0003852866010000107
Figure BDA0003852866010000108
Average price of population
Figure BDA0003852866010000109
May refer to outputting the result
Figure BDA00038528660100001010
In any case independent of the sensitivity attribute A, i.e.
Figure BDA0003852866010000111
Figure BDA0003852866010000112
When in use
Figure BDA0003852866010000113
And
Figure BDA0003852866010000114
and when the number is equal to 0, the classification model is shown to respectively meet the equal chance, equal probability and equal population price. The first attribute value sample class may refer to an attribute value sample class that needs bias removal among the respective attribute value sample classes. The number of the first attribute value sample classes is one or more.
Specifically, the first attribute value sample category which needs to be subjected to bias removal when the preset fairness index is met can be screened out from all the divided attribute value sample categories based on the preset fairness index.
Illustratively, when the attribute value sample class does not contain the pre-classification prediction class information, S240 may include: if the preset fairness index is equal in chance, taking a positive sample class corresponding to each sensitive attribute value with prejudice in the preset sensitive attributes as a first attribute value sample class; and if the preset fairness index is equal in probability, taking the positive sample class and the negative sample class corresponding to each sensitivity attribute value with prejudice in the preset sensitivity attributes as the first attribute value sample class.
Specifically, when the preset fairness index is equal opportunity, a positive sample class Y =1 corresponding to each sensitivity attribute value a = a having bias in the preset sensitivity attributes may be used as the first attribute value sample class, for example, a positive sample with a male label of 1 and a positive sample with a female label of 1 are used, and both of the two attribute value sample classes are used as the first attribute value sample class. For example, if there is only one preset sensitive attribute, the positive sample class of which the preset sensitive attribute is each attribute value may be used as the first attribute value sample class. If at least two preset sensitive attributes exist, determining a prejudice target sensitive attribute value combination corresponding to the at least two preset sensitive attributes, and taking a positive sample class with the at least two preset sensitive attributes as the target sensitive attribute value combination as a first attribute value sample class. For example, if there are two sensitive attributes of race (including black, white, and yellow) and gender (including male and female), two sensitive attributes may be combined to obtain a sensitive attribute value combination including a race attribute value and a gender attribute value, and whether there is a bias in each sensitive attribute value combination is detected based on a classification task, for example, there is a bias in two sensitive attribute value combinations of white male and black female, the two sensitive attribute values may be combined into a target sensitive attribute value combination, and a positive sample with a white male tag of 1 and a positive sample with a black female tag of 1 are used as the first attribute value sample category.
When the preset fairness index is equal to probability, a positive sample class Y =1 and a negative sample class Y =0 corresponding to each sensitivity attribute value a = a having bias in the preset sensitivity attribute may be used as the first attribute value sample class, for example, a positive sample with a male label of 1, a negative sample with a male label of 0, a positive sample with a female label of 1, and a negative sample with a female label of 0 are used, and these 4 attribute value sample classes are all used as the first attribute value sample class. For example, if there is only one preset sensitive attribute, the preset sensitive attribute may be a positive sample class and a negative sample class of each attribute value as the first attribute value sample class. If at least two preset sensitive attributes exist, determining a biased target sensitive attribute value combination corresponding to the at least two preset sensitive attributes, and taking a positive sample class and a negative sample class of the target sensitive attribute value combination as a first attribute value sample class.
When the attribute value sample class does not include the pre-classification prediction class information, the estimation and the de-bias can be performed by using two fairness indexes of equal chance or equal probability.
S250, determining the next sampling weight corresponding to the first attribute value sample type based on the current sampling weight corresponding to the first attribute value sample type, and the current prediction type and the label type corresponding to each sample data in the current sample data subset.
Illustratively, when the attribute value sample class does not contain the pre-classification prediction class information, S250 may include: determining the prediction accuracy corresponding to the first attribute value sample category based on the current prediction category and the label category corresponding to each sample data in the current sample data subset; and determining a next sampling weight corresponding to the first attribute value sample class based on the prediction accuracy and the current sampling weight corresponding to the first attribute value sample class.
In particular, for each first attribute value sample class, the prediction accuracy corresponding to that first attribute value sample class may be determined based on the current prediction class and label class corresponding to each sample data in the current subset of sample data. For example, if the first attribute value sample type is: and if the male label is a positive sample with a male label of 1, determining correctly predicted sample data corresponding to the sample type based on the current prediction type corresponding to each sample data with the male label of 1, and taking the ratio of the correctly predicted sample data to the total sample number as the prediction accuracy corresponding to the first attribute value sample type. Similarly, the prediction accuracy corresponding to each first attribute value sample category may be determined, the current sampling weight corresponding to each first attribute value sample category may be adjusted based on the prediction accuracy corresponding to each first attribute value sample category, and the adjusted current sampling weight may be used as the next sampling weight. For example, if the prediction accuracy corresponding to the positive sample category with the male label of 1 is greater than the prediction accuracy corresponding to the positive sample category with the female label of 1, the current sampling weight corresponding to the positive sample category with the male label of 1 is decreased by a preset amplitude, and the current sampling weight corresponding to the positive sample category with the female label of 1 is increased by the preset amplitude, so that the sampling weight is gradually increased or decreased based on the preset amplitude until the trained preset classification model has no bias.
S260, determining the current sampling weight corresponding to the second attribute value sample class as the next sampling weight corresponding to the second attribute value sample class, where the second attribute value sample class is other attribute value sample classes except the first attribute value sample class.
The second attribute value sample class may refer to an attribute value sample class that does not need to be bias-removed in each attribute value sample class. The number of the second attribute value sample classes is one or more.
Specifically, for each second attribute value sample class that does not need to be bias-removed, the current sampling weight corresponding to the second attribute value sample class may be directly determined as the next sampling weight corresponding to the second attribute value sample class, and the number of samples of the second attribute value sample class in the next training cycle does not need to be adjusted.
S270, normalizing the next sampling weight corresponding to each attribute value sample type, and determining the next sampling proportion among the attribute value sample types.
S280, performing next round training on the preset classification model based on the next sampling proportion until the preset convergence condition is met, and finishing the training of the preset classification model to obtain a target classification model for guaranteeing fairness.
According to the technical scheme, the attribute value sample classes corresponding to the preset sensitive attributes are determined by dividing the attribute values and the label classes based on the preset sensitive attributes, so that bias existing in the classification model can be gradually removed by controlling the number of samples of the attribute value sample classes corresponding to the preset sensitive attributes in each round of training in the attribute value sample class dividing mode, a target classification model which can guarantee fairness finally is obtained, classification accuracy is guaranteed, only the number of samples of each attribute value sample class needs to be adjusted, classification logic in the classification model does not need to be adjusted, and therefore the original classification model can be directly compatible, and flexibility is improved.
Fig. 3 is a flowchart of a method for training a classification model according to an embodiment of the present invention, and this embodiment describes in detail a process of determining a next sampling weight corresponding to each attribute value sample class in a case that the attribute value sample class includes pre-classification prediction class information based on the foregoing embodiments. Wherein explanations of the same or corresponding terms as those of the above embodiments are omitted.
Referring to fig. 3, the training method of the classification model provided in this embodiment specifically includes the following steps:
s310, obtaining a sample data set corresponding to the preset sensitive attribute.
S320, pre-classifying each sample data in the sample data set corresponding to the preset sensitive attribute based on the pre-training classification model to obtain the sample data set containing the pre-classification prediction categories, and dividing the sample data set based on each attribute value corresponding to the preset sensitive attribute, each label category and each pre-classification prediction category to determine each attribute value sample category corresponding to the preset sensitive attribute.
The pre-trained classification model may be a classification model obtained based on pre-training, and the pre-trained classification model in this embodiment may be further trained on the basis of the pre-trained classification model to eliminate bias existing in the pre-trained classification model. The pre-classified prediction classes may be classes predicted by a pre-trained classification model.
Specifically, the sample feature information in each sample data in the sample data set may be input into a pre-trained classification model for classification prediction, and a pre-classified prediction category corresponding to each sample data is obtained based on the output of the pre-trained classification model, where each sample data may include the sample feature information, an attribute value corresponding to a preset sensitive attribute, a label category, and a pre-classified prediction category. All attribute values of the preset sensitive attribute, all label categories of the classification model and all pre-classification prediction categories in the sample data set are divided to obtain all attribute value sample categories corresponding to the preset sensitive attribute, and each attribute value sample category obtained at the moment contains pre-classification prediction category information. For example, for a classification model of two classes, there are two label classes with labels of 1 and 0, and two pre-classification prediction classes with prediction classes of 1 and 0, when the preset sensitive attribute is gender, there are two attribute values of male and female, and 8 attribute value sample classes can be obtained by dividing the two attribute values, the two label classes, and the two pre-classification prediction classes, respectively: a positive exemplar with a male label of 1 and a predicted value of 1, a positive exemplar with a male label of 1 and a predicted value of 0, a negative exemplar with a male label of 0 and a predicted value of 1, a negative exemplar with a male label of 0 and a predicted value of 0, a positive exemplar with a female label of 1 and a predicted value of 1, a positive exemplar with a female label of 1 and a predicted value of 0, a negative exemplar with a female label of 0 and a predicted value of 1, and a negative exemplar with a female label of 0 and a predicted value of 0.
S330, sampling the sample data set based on the current sampling proportion among the attribute value sample categories to obtain a current sample data subset, and performing current training on the preset classification model based on the current sample data subset.
S340, determining a first attribute value sample class matched with the preset fairness index from all attribute value sample classes.
Specifically, based on a preset fairness index, a first attribute value sample category which needs to be bias-removed when the preset fairness index is met is screened from all divided attribute value sample categories.
Illustratively, when the attribute value sample class contains pre-classified prediction class information, S340 may include: if the preset fairness index is equal in chance, taking a positive sample class with accurate pre-classification prediction corresponding to each sensitive attribute value with prejudice in the preset sensitive attributes as a first attribute value sample class; if the preset fairness index is equal in probability, taking the positive sample class and the negative sample class which are accurate in pre-classification prediction and correspond to each sensitive attribute value with prejudice in the preset sensitive attributes as the first attribute value sample class; and if the preset fairness index is a population price, taking a positive sample class and a negative sample class, which are respectively of a positive class and a positive class corresponding to each sensitive attribute value with prejudice in the preset sensitive attributes, as the first attribute value sample class.
Specifically, when the fairness index is preset to be chance equalization, the event is required to be satisfied under the condition of Y =1
Figure BDA0003852866010000161
And event A =1, and event
Figure BDA0003852866010000162
And event a =0, i.e.:
Figure BDA0003852866010000163
Figure BDA0003852866010000164
accordingly, when the preset fairness index is chance equalization, the pre-classified accurately predicted positive sample class corresponding to each sensitive attribute value a = a with bias in the preset sensitive attributes can be used as the first attribute value sample class, that is, for each sensitive attribute value a = a, the label Y =1 and the predicted value are set
Figure BDA0003852866010000165
As a first attribute value sample class. For example, a positive sample with a male label of 1 and a predictive value of 1 and a positive sample with a female label of 1 and a predictive value of 1 are taken as the first attribute value sample class.
When the preset fairness index is probability equalization, the requirement is that under the condition of Y =1, the event is satisfied
Figure BDA0003852866010000166
Statistically independent of event A =1, event
Figure BDA0003852866010000171
And event a =0 is statistically independent; event under condition of Y =0
Figure BDA0003852866010000172
Statistically independent of event A =0, event
Figure BDA0003852866010000173
And event a =1, i.e.:
Figure BDA0003852866010000174
Figure BDA0003852866010000175
Figure BDA0003852866010000176
Figure BDA0003852866010000177
accordingly, when the preset fairness index is probability equalization, the positive sample class and the negative sample class corresponding to each sensitive attribute value a = a with bias in the preset sensitive attributes and with accurate pre-classification prediction can be both used as the first attribute value sample class, that is, for each sensitive attribute value a = a, the label Y =1 and the predicted value is set
Figure BDA0003852866010000178
And the sum of the attribute value sample class of (1) is labeled Y =0 and the predicted value is
Figure BDA0003852866010000179
As a first attribute value sample class. For example, a positive exemplar whose male label is 1 and whose predicted value is 1, a negative exemplar whose male label is 0 and whose predicted value is 0, a positive exemplar whose female label is 1 and whose predicted value is 1, and a negative exemplar whose female label is 0 and whose predicted value is 0 are all taken as the first attribute value exemplar category.
When the preset fairness index is the population price, requiring the event
Figure BDA00038528660100001710
And event A =1, and event
Figure BDA00038528660100001711
And event a =0, i.e.:
Figure BDA00038528660100001712
Figure BDA00038528660100001713
accordingly, when the preset fairness index is a population price average, the pre-classification prediction category corresponding to each sensitivity attribute value A = a with bias in the preset sensitivity attributes can be set as a positive category
Figure BDA00038528660100001714
Is taken as the first attribute value sample class, i.e. for each sensitive attribute value a = a, at label Y =1 and the value predicted is the positive sample class and the negative sample class of
Figure BDA00038528660100001715
And the sum of the attribute value sample class of (1) is labeled Y =0 and the predicted value is
Figure BDA00038528660100001716
As a first attribute value sample class. For example, a positive exemplar whose male label is 1 and whose predicted value is 1, a negative exemplar whose male label is 0 and whose predicted value is 1, a positive exemplar whose female label is 1 and whose predicted value is 1, and a negative exemplar whose female label is 0 and whose predicted value is 1 are all regarded as the first attribute value exemplar category.
S350, determining a next sampling weight corresponding to the first attribute value sample type based on the current sampling weight corresponding to the first attribute value sample type, and the current prediction type and the label type corresponding to each sample data in the current sample data subset.
Exemplarily, when the attribute value sample class contains the pre-classified prediction class information, S250 may include: determining a current adjustment coefficient corresponding to the first attribute value sample type based on a preset fairness index and a current prediction type and a label type corresponding to each sample data in the current sample data subset; and multiplying the current sampling weight corresponding to the first attribute value sample class by the corresponding current adjusting coefficient, and taking the obtained multiplication result as the next sampling weight corresponding to the first attribute value sample class.
Specifically, for each first attribute value sample class, a current adjustment coefficient corresponding to the first attribute value sample class may be directly determined based on a condition that a preset fairness index requirement is satisfied, the current adjustment coefficient is multiplied by a current sampling weight corresponding to the first attribute value sample class, and an obtained multiplication result is used as a next sampling weight corresponding to the first attribute value sample class, so that the next sampling weight may be determined more accurately, and the deskew efficiency and accuracy of the model are further improved.
Exemplarily, determining a current adjustment coefficient corresponding to the first attribute value sample class based on a preset fairness index and a current prediction class and a label class corresponding to each sample data in the current sample data subset includes:
for each first attribute value sample category, acquiring a current sensitive attribute value, a current label category and a current pre-classification prediction category corresponding to the current first attribute value sample category;
if the preset fairness index is equal in chance or equal in probability, determining the number of first samples with current sensitive attribute values and label classes as current label classes, the number of second samples with label classes as current label classes and current prediction classes as current pre-classification prediction classes, the number of third samples with label classes as current label classes and the number of fourth samples with current sensitive attribute values, label classes as current label classes and current prediction classes as current pre-classification prediction classes based on the current prediction classes and label classes corresponding to each sample data in the current sample data subset; determining a current adjustment coefficient corresponding to the current first attribute value sample type according to the first sample quantity, the second sample quantity, the third sample quantity and the fourth sample quantity;
if the preset fairness index is a population mean price, determining the number of fifth samples with current sensitive attribute values, the number of sixth samples with current prediction categories as current pre-classification prediction categories, the number of seventh samples with current sensitive attribute values and current prediction categories as current pre-classification prediction categories and the total number of samples based on the current prediction categories and label categories corresponding to each sample data in the current sample data subset; and determining a current adjustment coefficient corresponding to the current first attribute value sample category according to the fifth sample number, the sixth sample number, the seventh sample number and the total sample number.
In particular, each first attribute value sample class may be used as a current first attribute value sample class to determine a corresponding current adjustment factor. For example, if the current first attribute value sample type is: and if the male label is a positive sample with 1 and the predicted value is 1, the current sensitive attribute value is male, the current label category is 1 and the current pre-classification prediction category is 1.
When the preset fairness index is equal in chance or equal in probability, the first sample quantity | a = a ∞ Y = Y |, which has the current sensitive attribute value a and the label type Y is the current label type Y, and the label type Y is the current label type Y and the current prediction type Y is determined based on the current prediction type and label type corresponding to each sample data in the current sample data subset
Figure BDA0003852866010000191
Predicting categories for current pre-classification
Figure BDA0003852866010000192
Second number of samples of
Figure BDA0003852866010000201
The label type Y is the third sample number of the current label type Y | Y = Y |, and has the current sensitivity attribute value a and the label type Y is the current label type Y and the current prediction type
Figure BDA0003852866010000202
Predicting categories for current pre-classification
Figure BDA0003852866010000203
Fourth number of samples of
Figure BDA0003852866010000204
According to the first sample quantity | A = a & Y = Y |, the second sample quantity
Figure BDA0003852866010000205
Third number of samples | Y = Y |, and fourth number of samples
Figure BDA0003852866010000206
A current adjustment factor may be determined for the current first attribute value sample class. For example, the first number of samples | a = a & = Y | and the second number of samples may be multiplied by
Figure BDA0003852866010000207
Obtaining a first multiplication result R1, and combining the third number of samples | Y = Y | and the fourth number of samples |
Figure BDA0003852866010000208
And multiplying to obtain a second multiplication result R2, and determining the ratio R1/R2 between the first multiplication result and the second multiplication result as the current adjustment coefficient corresponding to the current first attribute value sample type, so that the current adjustment coefficient corresponding to each first attribute value sample type can be directly and more accurately determined.
When the preset fairness index is a population fair, the fifth sample number | a = a |, which has the current sensitivity attribute value a, and the current prediction category may be determined based on the current prediction category and the label category corresponding to each sample data in the current sample data subset
Figure BDA0003852866010000209
Predicting categories for current pre-classification
Figure BDA00038528660100002010
Of the sixth sample number
Figure BDA00038528660100002011
Current prediction class with current sensitivity attribute value a
Figure BDA00038528660100002012
Predicting categories for current pre-classification
Figure BDA00038528660100002013
Of the seventh number of samples
Figure BDA00038528660100002014
And the total number of samples | Y |, and may be according to the fifth number of samples | a = a |, the sixth number of samples
Figure BDA00038528660100002015
Number of seventh samples
Figure BDA00038528660100002016
And the total number | Y | of the samples, and determining the current adjustment coefficient corresponding to the current first attribute value sample type. For example, the fifth number of samples | a = a | and the sixth number of samples are set
Figure BDA00038528660100002017
Multiplying to obtain a third multiplication result R3, and counting a seventh sample
Figure BDA00038528660100002018
And the total number of samples | Y | is multiplied to obtain a fourth multiplication result R4, and the ratio R3/R4 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 type, so that the current adjustment coefficient corresponding to each first attribute value sample type can be directly and more accurately determined.
And S360, determining the current sampling weight corresponding to the second attribute value sample class as the next sampling weight corresponding to the second attribute value sample class, wherein the second attribute value sample class refers to other attribute value sample classes except the first attribute value sample class.
The second attribute value sample class may refer to an attribute value sample class that does not need to be bias-removed in each attribute value sample class. The number of the second attribute value sample classes is one or more.
Specifically, for each second attribute value sample class that does not need to be bias-removed, the current sampling weight corresponding to the second attribute value sample class may be directly determined as the next sampling weight corresponding to the second attribute value sample class, and the number of samples of the second attribute value sample class in the next training cycle does not need to be adjusted.
And S370, normalizing the next sampling weight corresponding to each attribute value sample category, and determining the next sampling proportion among the attribute value sample categories.
And S380, performing next round training on the preset classification model based on the next sampling proportion until the preset convergence condition is met, and finishing the training of the preset classification model to obtain a target classification model for guaranteeing fairness.
According to the technical scheme of the embodiment, each sample data in the sample data set corresponding to the preset sensitive attribute is pre-classified based on the pre-training classification model to obtain the sample data set containing the pre-classification prediction classes, each attribute value corresponding to the preset sensitive attribute, each label class and each pre-classification prediction class are divided to determine each attribute value sample class corresponding to the preset sensitive attribute, so that the next sampling proportion corresponding to each attribute value sample class can be more accurately determined in the attribute value sample class division mode, the bias existing in the classification model is gradually removed by controlling the number of samples of each attribute value sample class corresponding to the preset sensitive attribute in each training cycle, the target classification model which can guarantee fairness finally is obtained, the classification accuracy is ensured, only the number of samples of each attribute value sample class needs to be adjusted, the classification logic in the classification model does not need to be adjusted, and the original classification model can be directly compatible, and the flexibility is improved.
The following is an embodiment of the training apparatus for a classification model according to an embodiment of the present invention, which belongs to the same inventive concept as the training method for a classification model according to the above embodiments, and reference may be made to the embodiment of the training method for a classification model in the embodiment of the training apparatus for a classification model, details of which are not described in detail.
Fig. 4 is a schematic structural diagram of a training apparatus for a classification model according to an embodiment of the present invention, which is applicable to training a classification model with presence-sensitive attributes to ensure fairness in classification of the classification model. As shown in fig. 4, the apparatus specifically includes: an attribute value sample class determination module 410, an on-round training module 420, a next sample ratio determination module 430, and a target classification model determination module 440.
The attribute value sample type determining module 410 is configured to obtain a sample data set corresponding to a preset sensitive attribute, and determine each attribute value sample type corresponding to the preset sensitive attribute; the in-round training module 420 is configured to sample a sample data set based on a current sampling ratio between sample categories of each attribute value to obtain a current sample data subset, and perform in-round training on a preset classification model based on the current sample data subset; a next sampling ratio determining module 430, configured to determine, based on a current prediction category and a tag category corresponding to each sample data in the current sample data subset, a next sampling ratio among the attribute value sample categories; and the target classification model determining module 440 is configured to perform a next round of training on the preset classification model based on a next sampling proportion until the preset convergence condition is currently met, and the training of the preset classification model is finished to obtain a target classification model for guaranteeing fairness.
According to the technical scheme, a sample data set corresponding to the preset sensitive attribute is obtained, and the sample types of all attribute values corresponding to the preset sensitive attribute are determined; sampling the sample data set based on the current sampling proportion among the sample classes of the attribute values to obtain a current sample data subset, and performing on-round training on a preset classification model based on the current sample data subset; and determining the next sampling proportion among the sample classes of each attribute value based on the current prediction class and the label class corresponding to each sample data in the current sample data subset, so that the next sampling proportion in the next round of training can be determined based on the bias degree existing in the round of training, and the next round of training is performed on the preset classification model based on the next sampling proportion until the preset convergence condition is met currently, the training of the preset classification model is finished, and the target classification model for guaranteeing fairness is obtained. By adjusting the sampling proportion among all attribute value sample categories in each round of training, the number of samples of all attribute value sample categories corresponding to preset sensitive attributes in each round of training can be controlled, prejudices existing in the classification model are gradually removed, a target classification model which can finally guarantee fairness is obtained, classification accuracy is guaranteed, only the number of samples of all attribute value sample categories needs to be adjusted, classification logic in the classification model does not need to be adjusted, the original classification model can be directly compatible, and flexibility is improved.
Optionally, the attribute value sample class determining module 410 is specifically configured to:
dividing based on each attribute value and each label category corresponding to the preset sensitivity attribute, and determining each attribute value sample category corresponding to the preset sensitivity attribute; or,
and classifying each sample data in the sample data set corresponding to the preset sensitive attribute in advance based on a pre-training classification model to obtain the sample data set containing a pre-classification prediction category, and classifying the sample data set based on each attribute value corresponding to the preset sensitive attribute, each label category and each pre-classification prediction category to determine each attribute value sample category corresponding to the preset sensitive attribute.
Optionally, the next sample ratio determining module 430 includes:
the next sampling weight determining unit is used for determining the next sampling weight corresponding to each attribute value sample type based on the current prediction type and the label type corresponding to each sample data in the current sample data subset;
and the next sampling proportion determining unit is used for carrying out normalization processing on the next sampling weight corresponding to each attribute value sample category and determining the next sampling proportion among the attribute value sample categories.
Optionally, the next sampling weight determining unit includes:
the first attribute value sample type determining subunit is used for determining a first attribute value sample type matched with a preset fairness index from each attribute value sample type;
the first sampling weight determining subunit is configured to determine, based on a current sampling weight corresponding to the first attribute value sample class, and a current prediction class and a tag class corresponding to each sample data in the current sample data subset, a next sampling weight corresponding to the first attribute value sample class;
and the second sampling weight determining subunit is configured to determine the current sampling weight corresponding to the second attribute value sample class as a next sampling weight corresponding to the second attribute value sample class, where the second attribute value sample class is another attribute value sample class except the first attribute value sample class.
Optionally, when the attribute value sample class does not include the pre-classification prediction class information, the first attribute value sample class determination subunit is specifically configured to:
if the preset fairness index is equal in chance, taking a positive sample class corresponding to each sensitive attribute value with bias in the preset sensitive attributes as a first attribute value sample class; and if the preset fairness index is equal in probability, taking the positive sample class and the negative sample class corresponding to each biased sensitive attribute value in the preset sensitive attributes as the first attribute value sample class.
Optionally, the first sampling weight determining subunit is specifically configured to:
determining the prediction accuracy corresponding to the first attribute value sample class based on the current prediction class and the label class corresponding to each sample data in the current sample data subset; and determining a next sampling weight corresponding to the first attribute value sample class based on the prediction accuracy and the current sampling weight corresponding to the first attribute value sample class.
Optionally, when the attribute value sample class includes pre-classification prediction class information, the first attribute value sample class determination subunit is specifically configured to:
if the preset fairness index is equal in chance, taking a positive sample class with accurate pre-classification prediction corresponding to each sensitive attribute value with prejudice in the preset sensitive attributes as a first attribute value sample class; if the preset fairness index is equal in probability, taking the positive sample class and the negative sample class which are accurate in pre-classification prediction and correspond to each sensitive attribute value with prejudice in the preset sensitive attributes as the first attribute value sample class; and if the preset fairness index is a population price, taking a positive sample class and a negative sample class, which are respectively of a positive class and a positive class corresponding to each sensitive attribute value with prejudice in the preset sensitive attributes, as the first attribute value sample class.
Optionally, the first sampling weight determining subunit specifically includes:
the current adjustment coefficient determining submodule is used for determining a current adjustment coefficient corresponding to the first attribute value sample category based on a preset fairness index and a current prediction category and a label category corresponding to each sample data in the current sample data subset;
and the first sampling weight determining submodule is used for multiplying the current sampling weight corresponding to the first attribute value sample class by the corresponding current adjusting coefficient, and the obtained multiplication result is used as the next sampling weight corresponding to the first attribute value sample class.
Optionally, the current adjustment coefficient determining sub-module is specifically configured to:
for each first attribute value sample category, acquiring a current sensitive attribute value, a current label category and a current pre-classification prediction category corresponding to the current first attribute value sample category;
if the preset fairness index is equal in chance or equal in probability, determining the number of first samples with current sensitive attribute values and label categories as current label categories, the number of second samples with label categories as current label categories and current prediction categories as current pre-classification prediction categories, the number of third samples with label categories as current label categories and the number of fourth samples with current sensitive attribute values and label categories as current label categories and current prediction categories as current pre-classification prediction categories based on the current prediction categories and label categories corresponding to each sample datum in the current sample data subset; determining a current adjustment coefficient corresponding to the current first attribute value sample type according to the first sample quantity, the second sample quantity, the third sample quantity and the fourth sample quantity;
if the preset fairness index is a population equity, determining the number of fifth samples with current sensitive attribute values, the number of sixth samples with current prediction categories as current pre-classification prediction categories, the number of seventh samples with current sensitive attribute values and current prediction categories as current pre-classification prediction categories and the total number of samples based on the current prediction categories and label categories corresponding to each sample data in the current sample data subset; and determining a current adjustment coefficient corresponding to the current first attribute value sample category according to the fifth sample number, the sixth sample number, the seventh sample number and the total sample number.
Optionally, the current adjustment coefficient determining sub-module is further specifically configured to:
and multiplying the first sample number and the second sample number to obtain a first multiplication result, multiplying the third sample number and the fourth sample number to obtain a second multiplication result, and determining the ratio of the first multiplication result to the second multiplication result as the current adjustment coefficient corresponding to the current first attribute value sample category.
Optionally, the current adjustment coefficient determining sub-module is further specifically configured to:
and multiplying the fifth sample number and the sixth sample number to obtain a third multiplication result, multiplying the seventh sample number and the total sample number to obtain a fourth multiplication result, and determining the ratio of the third multiplication result to the fourth multiplication result as the current adjustment coefficient corresponding to the current first attribute value sample category.
The training device for the classification model provided by the embodiment of the invention can execute the training method for the classification model provided by any embodiment of the invention, and has the corresponding functional modules and beneficial effects of the training method for executing the classification model.
It should be noted that, in the embodiment of the training apparatus for classification models, the included units and modules are only divided according to functional logic, but are not limited to the above division, as long as the corresponding functions can be implemented; in addition, the specific names of the functional units are only for the convenience of distinguishing from each other, and are not used for limiting the protection scope of the present invention.
Fig. 5 is a schematic structural diagram of an electronic device according to an embodiment of the present invention. FIG. 5 illustrates a block diagram of an exemplary electronic device 12 suitable for use in implementing embodiments of the present invention. The electronic device 12 shown in fig. 5 is only an example and should not bring any limitation to the function and the scope of use of the embodiment of the present invention.
As shown in FIG. 5, electronic device 12 is embodied in the form of a general purpose computing device. The components of electronic device 12 may include, but are not limited to: one or more processors or processing units 16, a system memory 28, and a bus 18 that couples various system components including the system memory 28 and the processing unit 16.
Bus 18 represents one or more of any of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, and a processor or local bus using any of a variety of bus architectures. By way of example, such architectures include, but are not limited to, industry Standard Architecture (ISA) bus, micro-channel architecture (MAC) bus, enhanced ISA bus, video Electronics Standards Association (VESA) local bus, and Peripheral Component Interconnect (PCI) bus.
Electronic device 12 typically includes a variety of computer system readable media. Such media may be any available media that is accessible by electronic device 12 and includes both volatile and nonvolatile media, removable and non-removable media.
The 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. The electronic device 12 may further include other removable/non-removable, volatile/nonvolatile computer system storage media. By way of example only, storage system 34 may be used to read from and write to non-removable, nonvolatile magnetic media (not shown in FIG. 5 and commonly referred to as a "hard drive"). Although not shown in FIG. 5, a magnetic disk drive for reading from and writing to a removable, nonvolatile magnetic disk (e.g., a "floppy disk") and an optical disk drive for reading from or writing to a removable, nonvolatile 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 by 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 that are configured to carry out the functions of embodiments of the invention.
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 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which examples or some combination thereof may comprise an implementation of a network environment. Program modules 42 generally carry out the functions and/or methodologies of embodiments of the invention as described.
The electronic device 12 may also communicate with one or more external devices 14 (e.g., keyboard, pointing device, display 24, etc.), one or more devices that enable a user to interact with the electronic device 12, and/or any device (e.g., network card, modem, etc.) that enables the electronic device 12 to communicate with one or more other computing devices. Such communication may be through an input/output (I/O) interface 22. Also, the electronic device 12 may communicate with one or more networks (e.g., a Local Area Network (LAN), a Wide Area Network (WAN), and/or a public network such as the Internet) via the network adapter 20. As shown, the network adapter 20 communicates with other modules of the electronic device 12 via the bus 18. It should be understood that although not shown in the figures, other hardware and/or software modules may 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, to name a few.
The processing unit 16 executes programs stored in the system memory 28 to perform various functional applications and data processing, for example, to implement the steps of a classification model training method provided by the embodiment of the present invention, the method including:
acquiring a sample data set corresponding to a preset sensitive attribute, and determining each attribute value sample category corresponding to the preset sensitive attribute;
sampling the sample data set based on the current sampling proportion among the sample classes of the attribute values to obtain a current sample data subset, and performing on-round training on a preset classification model based on the current sample data subset;
determining a next sampling proportion among all attribute value sample classes based on a current prediction class and a label class corresponding to each sample data in a current sample data subset;
and performing next round training on the preset classification model based on the next sampling proportion until the preset convergence condition is met at present, and finishing the training of the preset classification model to obtain the target classification model for guaranteeing fairness.
Of course, those skilled in the art can understand that the processor may also implement the technical solution of the method for training the classification model provided in any embodiment of the present invention.
The present embodiment provides a computer-readable storage medium, on which a computer program is stored, which when executed by a processor, performs the method steps of training a classification model as provided in any of the embodiments of the present invention, the method comprising:
acquiring a sample data set corresponding to a preset sensitive attribute, and determining each attribute value sample category corresponding to the preset sensitive attribute;
sampling the sample data set based on the current sampling proportion among the attribute value sample categories to obtain a current sample data subset, and performing on-the-go training on a preset classification model based on the current sample data subset;
determining a next sampling proportion among all attribute value sample classes based on a current prediction class and a label class corresponding to each sample data in a current sample data subset;
and performing next round training on the preset classification model based on the next sampling proportion until the preset convergence condition is met at present, and finishing the training of the preset classification model to obtain the target classification model for guaranteeing fairness.
Computer storage media for embodiments of the present invention may take the form of any combination of one or more computer-readable media. The computer readable medium may be a computer readable signal medium or a computer readable storage medium. The computer-readable storage medium may be, for example but 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 the computer readable storage medium would include the following: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
A computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
Computer program code for carrying out operations for aspects of the present invention may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, smalltalk, C + + or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
It will be understood by those skilled in the art that the modules or steps of the present invention described above can be implemented by a general purpose computing device, they can be centralized in a single computing device or distributed over a network of multiple computing devices, and they can alternatively be implemented by program code executable by a computing device, so that they can be stored in a storage device and executed by a computing device, or they can be separately fabricated into various integrated circuit modules, or multiple modules or steps thereof can be fabricated into a single integrated circuit module. Thus, the present invention is not limited to any specific combination of hardware and software.
It is to be noted that the foregoing is only illustrative of the preferred embodiments of the present invention and the technical principles employed. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, although the present invention has been described in some detail by the above embodiments, the invention is not limited to the above embodiments, and may include other equivalent embodiments without departing from the spirit of the invention, and the scope of the invention is determined by the scope of the appended claims.

Claims (13)

1. A training method of a classification model is characterized by comprising the following steps:
acquiring a sample data set corresponding to a preset sensitive attribute, and determining each attribute value sample category corresponding to the preset sensitive attribute;
sampling the sample data set based on the current sampling proportion among the sample classes of the attribute values to obtain a current sample data subset, and performing on-round training on a preset classification model based on the current sample data subset;
determining a next sampling proportion among all attribute value sample classes based on a current prediction class and a label class corresponding to each sample data in the current sample data subset;
and performing next round training on the preset classification model based on the next sampling proportion until the preset convergence condition is met at present, and finishing the training of the preset classification model to obtain the target classification model for guaranteeing fairness.
2. The method according to claim 1, wherein the determining the respective attribute value sample categories corresponding to the preset sensitive attributes comprises:
dividing based on each attribute value corresponding to a preset sensitive attribute and each label category, and determining each attribute value sample category corresponding to the preset sensitive attribute; or,
the method comprises the steps of pre-classifying each sample data in a sample data set corresponding to a preset sensitive attribute based on a pre-training classification model to obtain the sample data set comprising a pre-classification prediction category, and dividing based on each attribute value corresponding to the preset sensitive attribute, each label category and each pre-classification prediction category to determine each attribute value sample category corresponding to the preset sensitive attribute.
3. The method of claim 1, wherein determining a next sampling ratio between respective attribute value sample classes based on a current prediction class and a label class corresponding to each sample data in a current subset of sample data comprises:
determining a next sampling weight corresponding to each attribute value sample class based on a current prediction class and a label class corresponding to each sample data in the current sample data subset;
and normalizing the next sampling weight corresponding to each attribute value sample category to determine the next sampling proportion among the attribute value sample categories.
4. The method of claim 3, wherein determining the next sampling weight for each sample data class of attribute values based on the current prediction class and label class for each sample data in the current subset of sample data comprises:
determining a first attribute value sample class matched with a preset fairness index from each attribute value sample class;
determining a next sampling weight corresponding to the first attribute value sample class based on the current sampling weight corresponding to the first attribute value sample class, and a current prediction class and a label class corresponding to each sample data in a current sample data subset;
and determining the current sampling weight corresponding to a second attribute value sample class as the next sampling weight corresponding to the second attribute value sample class, wherein the second attribute value sample class refers to other attribute value sample classes except the first attribute value sample class.
5. The method of claim 4, wherein when the attribute value sample class does not contain pre-classification prediction class information, the determining a first attribute value sample class matching a preset fairness index from among the attribute value sample classes comprises:
if the preset fairness index is equal in chance, taking a positive sample class corresponding to each biased sensitive attribute value in the preset sensitive attributes as a first attribute value sample class;
and if the preset fairness index is equal in probability, taking the positive sample class and the negative sample class corresponding to each biased sensitive attribute value in the preset sensitive attributes as the first attribute value sample class.
6. The method of claim 5, wherein determining the next sampling weight for the first attribute value sample class based on the current sampling weight for the first attribute value sample class, the current prediction class and the label class for each sample data in the current subset of sample data comprises:
determining the prediction accuracy corresponding to the first attribute value sample category based on the current prediction category and the label category corresponding to each sample data in the current sample data subset;
and determining a next sampling weight corresponding to the first attribute value sample class based on the prediction accuracy and the current sampling weight corresponding to the first attribute value sample class.
7. The method of claim 4, wherein when the attribute value sample class contains pre-classification prediction class information, the determining a first attribute value sample class matching a preset fairness index from among the attribute value sample classes comprises:
if the preset fairness index is equal in chance, taking the positive sample class with accurate pre-classification prediction corresponding to each sensitive attribute value with prejudice in the preset sensitive attributes as a first attribute value sample class;
if the preset fairness index is equal in probability, taking the positive sample class and the negative sample class which are accurate in pre-classification prediction and correspond to each sensitive attribute value with prejudice in the preset sensitive attributes as first attribute value sample classes;
and if the preset fairness index is a population price, taking the positive sample class and the negative sample class of which the pre-classification prediction class corresponding to each sensitivity attribute value with prejudice in the preset sensitivity attributes is a positive class as the first attribute value sample class.
8. The method of claim 7, wherein determining the next sampling weight for the first attribute value sample class based on the current sampling weight for the first attribute value sample class, the current prediction class and the label class for each sample data in the current subset of sample data comprises:
determining a current adjustment coefficient corresponding to the first attribute value sample type based on the preset fairness index and the current prediction type and label type corresponding to each sample data in the current sample data subset;
and multiplying the current sampling weight corresponding to the first attribute value sample class by the corresponding current adjusting coefficient, and taking the obtained multiplication result as the next sampling weight corresponding to the first attribute value sample class.
9. The method of claim 8, wherein determining the current adjustment factor corresponding to the first attribute value sample class based on the preset fairness index and the current prediction class and label class corresponding to each sample data in the current sample data subset comprises:
for each first attribute value sample category, acquiring a current sensitive attribute value, a current label category and a current pre-classification prediction category corresponding to the current first attribute value sample category;
if the preset fairness index is equal in chance or equal in probability, determining a first sample number which has the current sensitive attribute value and a label category which is the current label category, a second sample number which has the label category which is the current label category and a current prediction category which is the current pre-classification prediction category, a third sample number which has the label category which is the current label category and a fourth sample number which has the current sensitive attribute value, a label category which is the current label category and a current prediction category which is the current pre-classification prediction category based on the current prediction category and the label category which correspond to each sample data in the current sample data subset; determining a current adjustment coefficient corresponding to the current first attribute value sample type according to the first sample quantity, the second sample quantity, the third sample quantity and the fourth sample quantity;
if the preset fairness index is a population mean price, determining the number of fifth samples with the current sensitive attribute value, the number of sixth samples with the current prediction category as the current pre-classification prediction category, the number of seventh samples with the current sensitive attribute value and the current prediction category as the current pre-classification prediction category, and the total number of samples based on the current prediction category and the label category corresponding to each sample data in the current sample data subset; and determining a current adjustment coefficient corresponding to the current first attribute value sample category according to the fifth sample number, the sixth sample number, the seventh sample number and the total number of samples.
10. The method of claim 9, wherein determining the current adjustment coefficient corresponding to the current first attribute value sample class according to the first sample number, the second sample number, the third sample number, and the fourth sample number comprises:
multiplying the first sample number by the second sample number to obtain a first multiplication result, multiplying the third sample number by the fourth sample number to obtain a second multiplication result, and determining a ratio between the first multiplication result and the second multiplication result as a current adjustment coefficient corresponding to a current first attribute value sample class;
determining a current adjustment coefficient corresponding to a current first attribute value sample class according to the fifth sample number, the sixth sample number, the seventh sample number and the total number of samples, including:
and multiplying the fifth sample number and the sixth sample number to obtain a third multiplication result, multiplying the seventh sample number and the total number of the samples to obtain a fourth multiplication result, and determining the ratio of the third multiplication result to the fourth multiplication result as the current adjustment coefficient corresponding to the current first attribute value sample category.
11. A training device for classification models, comprising:
the attribute value sample class determining module is used for acquiring a sample data set corresponding to a preset sensitive attribute and determining each attribute value sample class corresponding to the preset sensitive attribute;
the on-turn training module is used for sampling the sample data set based on the current sampling proportion among the attribute value sample categories to obtain a current sample data subset, and carrying out on-turn training on a preset classification model based on the current sample data subset;
the next sampling proportion determining module is used for determining the next sampling proportion among all the attribute value sample classes based on the current prediction class and the label class corresponding to each sample data in the current sample data subset;
and the target classification model determining module is used for carrying out next round of training on the preset classification model based on the next sampling proportion until the preset convergence condition is met at present, finishing the training of the preset classification model and obtaining the target classification model for guaranteeing fairness.
12. An electronic device, characterized in that the electronic device comprises:
one or more processors;
a memory for storing one or more programs;
when executed by the one or more processors, cause the one or more processors to implement a method of training a classification model according to any one of claims 1-10.
13. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out a method of training a classification model according to any one of claims 1 to 10.
CN202211139418.1A 2022-09-19 2022-09-19 Training method, device, equipment and storage medium of classification model Pending CN115456089A (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN202211139418.1A CN115456089A (en) 2022-09-19 2022-09-19 Training method, device, equipment and storage medium of classification model
PCT/CN2023/097746 WO2024060670A1 (en) 2022-09-19 2023-06-01 Method and apparatus for training classification model, and device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211139418.1A CN115456089A (en) 2022-09-19 2022-09-19 Training method, device, equipment and storage medium of classification model

Publications (1)

Publication Number Publication Date
CN115456089A true CN115456089A (en) 2022-12-09

Family

ID=84305304

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211139418.1A Pending CN115456089A (en) 2022-09-19 2022-09-19 Training method, device, equipment and storage medium of classification model

Country Status (2)

Country Link
CN (1) CN115456089A (en)
WO (1) WO2024060670A1 (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116188919A (en) * 2023-04-25 2023-05-30 之江实验室 Test method and device, readable storage medium and electronic equipment
WO2024060670A1 (en) * 2022-09-19 2024-03-28 北京沃东天骏信息技术有限公司 Method and apparatus for training classification model, and device and storage medium

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109389142A (en) * 2017-08-08 2019-02-26 上海为森车载传感技术有限公司 Classifier training method
EP3809341A1 (en) * 2019-10-18 2021-04-21 Fujitsu Limited Inference verification of machine learning algorithms
CN114626507A (en) * 2022-03-15 2022-06-14 西安交通大学 Method, system, device and storage medium for generating confrontation network fairness analysis
CN115456089A (en) * 2022-09-19 2022-12-09 北京沃东天骏信息技术有限公司 Training method, device, equipment and storage medium of classification model

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2024060670A1 (en) * 2022-09-19 2024-03-28 北京沃东天骏信息技术有限公司 Method and apparatus for training classification model, and device and storage medium
CN116188919A (en) * 2023-04-25 2023-05-30 之江实验室 Test method and device, readable storage medium and electronic equipment

Also Published As

Publication number Publication date
WO2024060670A1 (en) 2024-03-28

Similar Documents

Publication Publication Date Title
CN115456089A (en) Training method, device, equipment and storage medium of classification model
CN110472675B (en) Image classification method, image classification device, storage medium and electronic equipment
CN110647912A (en) Fine-grained image recognition method and device, computer equipment and storage medium
CN109344257B (en) Text emotion recognition method and device, electronic equipment and storage medium
CN113064964A (en) Text classification method, model training method, device, equipment and storage medium
EP3620994A1 (en) Methods, apparatuses, devices, and computer-readable storage media for determining category of entity
CN110377733B (en) Text-based emotion recognition method, terminal equipment and medium
US20200210776A1 (en) Question answering method, terminal, and non-transitory computer readable storage medium
CN111125658A (en) Method, device, server and storage medium for identifying fraudulent users
CN113762508A (en) Training method, device, equipment and medium for image classification network model
CN111368878A (en) Optimization method based on SSD target detection, computer equipment and medium
CN111950647A (en) Classification model training method and device
CN113158656A (en) Ironic content identification method, ironic content identification device, electronic device, and storage medium
CN115393592A (en) Target segmentation model generation method and device, and target segmentation method and device
CN114817933A (en) Method and device for evaluating robustness of business prediction model and computing equipment
CN113239883A (en) Method and device for training classification model, electronic equipment and storage medium
CN113902944A (en) Model training and scene recognition method, device, equipment and medium
CN116662555B (en) Request text processing method and device, electronic equipment and storage medium
CN110059743B (en) Method, apparatus and storage medium for determining a predicted reliability metric
CN110826616B (en) Information processing method and device, electronic equipment and storage medium
CN116467451A (en) Text classification method and device, storage medium and electronic equipment
CN115730591A (en) User service method, device, equipment and storage medium based on knowledge graph
CN113033817B (en) OOD detection method and device based on hidden space, server and storage medium
CN115511104A (en) Method, apparatus, device and medium for training a contrast learning model
CN113762308A (en) Training method, classification method, device, medium and equipment of classification model

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination