Data classification fairness enhancement method and device based on causal intervention

Counterfactual discrimination samples are generated by a variational autoencoder and generator group guided by a causal graph, which solves the problem of insufficient capture of causal structure in existing technologies, improves the fairness and interpretability of data classification, and is suitable for scenarios such as recruitment screening and medical services.

CN120632447APending Publication Date: 2025-09-12JINAN UNIVERSITY
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202510686764.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-26
Publication Date
2025-09-12

AI Technical Summary

Technical Problem

Existing counterfactual fairness enhancement methods lack intuitive operational guidance and cannot accurately capture the complete causal structure in the dataset, making it difficult to improve data classification fairness.

Method used

By constructing a causal relationship graph, using a variational autoencoder and a generator group to generate counterfactual discriminatory samples, combined with the discriminator for collaborative adversarial training, generating and correcting counterfactual fair samples, and retraining the classifier to improve fairness.

Benefits of technology

It achieves causal consistency modeling of data classification, generates high-quality counterfactual fair samples, and significantly improves the fairness and interpretability of the model. It is suitable for scenarios such as recruitment screening and medical services.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120632447A_ABST
    Figure CN120632447A_ABST
Patent Text Reader

Abstract

The invention provides a data classification fairness enhancement method and device based on causal intervention. Under the guidance of gradient and contribution degree, the causal intervention is used for reducing anti-fact prejudice in classification. The method comprises the following steps: extracting non-sensitive, sensitive and label features from input data; constructing an adversarial network comprising a variational auto-encoder, a discriminator and a causal relationship constrained generator group, and establishing a data generation model conforming to a causal inference theory; performing causal intervention under the guidance of gradient and correlation degree to obtain a global anti-fact discrimination sample; performing causal intervention under the guidance of the contribution degree and the association degree by using the global anti-fact discrimination sample to obtain a local anti-fact discrimination sample; and performing deviation correction on the anti-fact discrimination sample to obtain an anti-fact fair sample. According to the method, extensible data classification fairness enhancement is realized, the decision fairness is improved by generating the anti-fact fairness sample, and the method can be applied to the fields of recruitment, medical treatment, judicial and the like with relatively high fairness requirements.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of data science and machine learning technology, and in particular relates to a method, device, electronic device and storable medium for enhancing data classification fairness based on causal intervention, which is used to improve the fairness and explainability of classification decisions by generating counterfactual fair samples. Background Art

[0002] As artificial intelligence (AI) continues to influence recruitment, university admissions, credit services, healthcare, and criminal justice, societal concerns are growing about the risks these decision-making models may pose. Among these, the potential for unfair treatment of protected social groups is of particular concern. To promote the societal acceptance of AI in key areas, it is crucial to ensure data classification fairness and avoid potential bias based on sensitive attributes such as race, gender, and age. Counterfactual fairness, a concept of causal fairness at the individual level, has attracted considerable attention for its ability to assess decision bias and improve model fairness. Its core goal is to ensure that the outcomes of individuals' real-world decisions are consistent with those in counterfactual scenarios. Achieving counterfactual fairness relies on causal modeling and counterfactual reasoning techniques, which involve inferring the distribution of unobserved features from observed data, adjusting sensitive features, and calculating the corresponding outcome features. However, existing counterfactual fairness enhancement methods have significant shortcomings: First, they lack intuitive operational guidance, resulting in a lack of scalability. Second, when generating counterfactual data through the decoder during counterfactual reasoning, they fail to fully consider the causal relationships between features, resulting in an inability to accurately capture the complete causal structure of the dataset, making it difficult to truly improve counterfactual fairness in data classification from a causal perspective.

[0003] Therefore, designing a scalable data classification fairness enhancement method has become an important research direction to achieve data classification fairness. Summary of the Invention

[0004] The present invention aims to address the above-mentioned deficiencies in the prior art and proposes a method, device, electronic device and storable medium for enhancing the fairness of data classification based on causal intervention. The method first constructs an implicit causal model of the data set by analyzing the causal dependencies between features; then, under the dual guidance of gradient guidance and feature contribution analysis, causal intervention technology is used to generate counterfactual discrimination samples; these samples are then converted into counterfactual fairness samples through bias correction preprocessing; finally, the counterfactual fairness samples and the original sample set are mixed and the classifier is retrained, thereby significantly improving the fairness of data classification. The present invention can provide a decision support solution with both explainability and fairness guarantees for various application scenarios such as recruitment screening, medical services, criminal justice, etc.

[0005] In order to achieve the above object, the present invention adopts the following technical solutions:

[0006] The first object of the present invention is to provide a data classification fairness enhancement method based on causal intervention, comprising the following steps:

[0007] S1. Input recruitment screening or medical service training data D train , the training data D train Divided into non-sensitive features X, sensitive features S and label features Y, the non-sensitive features and label features are combined to represent H = (X, Y) and form the generated feature H, the non-sensitive features X, sensitive features S and label features Y are combined to represent the sample form D = (X, S, Y) and form the sample set D;

[0008] S2. Create a variational autoencoder Enc to extract unobserved features U from the sample set D. The unobserved features U represent unobserved potential factors that may affect the generated features. Create an independent generator G for each feature in the generated features. i ,i=1,…,|H|, all generators are grouped into a generator group G={G1,G2,…,G |H|}, where |H| represents the number of generated features. The generators in the generator group G are arranged in the topological order of the causal relationship graph. The causal relationship graph is a directed acyclic graph used to clarify the causal path and dependency relationship between each feature. Each node in the graph represents a feature in the sample set D. The directed edge in the graph represents the causal relationship between two features in the sample set D. For any directed edge e between the generated features in the graph, i →H j ), the corresponding generator arrangement satisfies G i In G j Before; create a discriminator Dis; use the sample set D to perform collaborative adversarial training on the variational autoencoder Enc, the generator group G and the discriminator Dis to obtain the optimal generator group G opt ={G 1,opt ,G 2,opt ,…,G i,opt ,…,G |H|,opt}、Optimal variational autoencoder Enc opt and the optimal discriminator Dis opt , where G i,opt represents the optimal generator of the i-th generated feature;

[0009] S3. Use the classifier to classify the sample set D, based on the classification loss J(θ,d) of sample d in the sample set D, and the j-th non-sensitive feature x of sample d. j ∈X, calculate the gradient Select the feature I∈X that needs intervention and the intervention value K I , using the optimal variational autoencoder Enc optExtract unobserved features U from d and use the optimal generator group G opt Replace the value of the intervened feature I with K I , and generate the values ​​of all generated features in the causal topological order to obtain the intervention sample; determine whether the intervention sample is a counterfactual discrimination sample, and if so, put it into the global counterfactual discrimination sample set G CDS In the process, samples are selected from the sample set D and the process is repeated multiple times to obtain the global counterfactual discrimination sample set G CDS ;

[0010] S4. From the global counterfactual discrimination sample set G CDS Select samples, calculate the contribution of non-sensitive features of samples to the prediction results, and select features I and intervention values ​​K that require causal intervention I , optimal variational autoencoder Enc opt Extract the unobserved feature U from the sample and replace the value of the intervention feature I with K I , using the optimal generator group G in causal topological order opt Generate the values ​​of all generated features to obtain intervention samples; determine whether the intervention samples are counterfactual discrimination samples, and if so, put them into the local counterfactual discrimination sample set L CDS Repeat this process multiple times to obtain the local counterfactual discrimination sample set L CDS ;

[0011] S5. Generate sample set A CDS =G CDS ∪L CDS The generated samples in are input to the optimal variational autoencoder Enc opt Extract unobserved features and use the optimal generator group G opt For each different value of the sensitive feature S, a corresponding counterfactual sample is generated, and the label feature of the counterfactual sample is replaced with the label feature of the generated sample to obtain a counterfactual fair dataset D that meets the fairness requirements. cf .

[0012] Furthermore, the process of step S1 is as follows:

[0013] The training dataset D train The non-sensitive feature X is represented as a numerical matrix of dimension n×m Where n is the number of samples, and m is the feature dimension of each sample;

[0014] The training dataset D train The sensitive feature S is represented as a numerical matrix of dimension n×q Where q is the dimension of the sensitive feature S; this step extracts and standardizes the sensitive information separately to facilitate subsequent processing;

[0015] The training dataset D train The label feature Y is represented as a vector of dimension n×1 The vector elements take values ​​of 0 or 1, with a value of 0 indicating disagreement with recruitment screening or preferential treatment, and a value of 1 indicating agreement with recruitment screening or preferential treatment. This labeling method can help the model identify potential unfairness risks in the data during subsequent processing, laying the foundation for generating fair data.

[0016] The non-sensitive feature X, sensitive feature S, and corresponding label feature Y are merged to form the sample set D. The non-sensitive feature X and label feature Y are merged to form the generated feature H. This step ensures the standardization, structuring, and integrity of the data, while clarifying the analysis objectives of unfair risks, laying the foundation for subsequent causal reasoning and generating counterfactual fair data sets.

[0017] Furthermore, the process of step S2 is as follows:

[0018] S21. Construct and regularize a variational autoencoder: Based on the given causal relationship graph, a variational autoencoder Enc is constructed. The variational autoencoder Enc contains only one encoder. This step uses the variational autoencoder to model unobserved features. It can approximate the unobserved features without explicitly determining the data distribution. This allows the model to work stably in the face of diverse and complex data and extract as many key elements in causal inference as possible.

[0019] The variational autoencoder takes the non-sensitive feature X, sensitive feature S and label feature Y in the sample set D as input, and maps the input to the mean μ and logarithmic variance logσ containing the unobserved feature U 2 In the space of , the unobserved feature U is constructed according to the following formula: U = μ + δ*∈, where δ = exp(0.5*logσ 2 ), ∈ is the random noise sampled from the standard normal distribution N(0,1);

[0020] By imposing a priori conditions on the distribution p(U), the above variational autoencoder Enc is regularized. In order to make U obey the standard normal distribution, that is, U~N(0,1), the prior loss L is introduced pri As follows: L pri =KL[q(U|X,S,Y)||p(U)]

[0021] Here, KL[·||·] represents the Kullback-Leibler divergence between the two distributions, which is used to measure the difference between the unobserved feature distribution q(U|X,S,Y) generated by the variational autoencoder and the prior distribution p(U) of the unobserved feature U. This step introduces the KL divergence term to ensure that the distribution of the unobserved feature U is smoother, has a certain regularization ability, reduces overfitting, and maintains good robustness when facing new data or incremental data sets.

[0022] The correlation coefficient HGR is introduced to evaluate the correlation between the sensitive feature S and the unobserved feature U, and the correlation loss L of the correlation coefficient HGR is defined hgr :

[0023] in, and Respectively represent the nonlinear transformation function after standardization of the unobserved feature U and the sensitive feature S, ω u and ω s are the corresponding optimizable parameters, which are used to adjust the mapping function to maximize the correlation loss L hgr , Represents the optimizable parameter ω u and ω s Taking the maximum value maximizes the expected product of the nonlinear transformation of the unobserved feature U and the sensitive feature S. This step successfully extracts the unobserved feature U required for causal fairness modeling. By optimizing the loss function, it ensures that the unobserved feature preserves the key information in the dataset while removing sensitive information. This step is directly related to the accuracy of subsequent causal relationship modeling and the fairness of generated data.

[0024] S22, construct the generator group and generate the reconstructed sample set and the synthetic sample set: According to the directed acyclic graph structure of the causal relationship graph, generate the feature H for each i Create an independent generator G i , i=1,…,|H|, and all generators are organized into a generator group G={G1,G2,…,G |H|}, where |H| represents the number of generated features, corresponding to the generated feature H i The generator G i The input is the generated value of the parent node of the generated feature and the unobserved feature U, and the output is the generated value of the generated feature The generation process is as follows:

[0025] Among them G i () represents the generator G i The generating operation function, Indicates Hi The generated values ​​of all parent nodes in the causal relationship graph; through this step, the generation process is decomposed into multiple sub-generator modules, so that each module only needs to focus on generating its own corresponding features and takes the parent node as a condition. This modular strategy is easier to debug and modify. When the distribution or generation method of a certain feature needs to be adjusted, only the corresponding generator needs to be modified separately, without making large-scale changes to the entire generation process;

[0026] The sensitive features S and the unobserved features U inferred by the variational autoencoder are input into the generator group G, and the values ​​of the generated features are obtained in sequence according to the topological order until the values ​​of all generated features are generated, and finally the reconstructed sample set is output. in and Represents the non-sensitive features and label features generated by the generator group based on S and U. In order to ensure that the reconstructed samples are highly similar to the original input samples in distribution, the reconstruction loss L is defined as follows: rec :

[0027]

[0028] Among them, p(X,Y|U,S)=P(Y|,X,U,S)*P(X|U,S), P(Y|,X,U,S) describes the probability that the label feature Y is generated by the generator group under the conditions of the non-sensitive feature X, the unobserved feature U and the sensitive feature S, reflecting that the label feature Y is affected by the non-sensitive feature X and the sensitive feature S. P(X|U,S) describes the probability that the non-sensitive feature X is generated by the generator group under the conditions of the unobserved feature U and the sensitive feature S. The negative value of the log likelihood is used to measure the non-sensitive feature X, the label feature Y, and the reconstructed non-sensitive feature generated by the decoder. and label features similarity;

[0029] Sampling from the prior distribution N(0,1) of the unobserved feature U Sampling from the distribution P(S) of sensitive features S Exploiting sensitive features of sampling and unobserved characteristics Input the generator group G, and get the values ​​of the generated features in turn according to the topological order until the values ​​of all generated features are generated, and finally output the synthetic sample set in and Indicates based on and Use non-sensitive features and label features generated by the generator group;

[0030] This step ensures that the generation process strictly follows the structure of the causal graph, avoiding the problem of ignoring causal relationships in traditional generation models. By simulating the generation process through the variational autoencoder and generator group, the complete causal structure of the dataset is accurately captured. This ensures that the generated data is not only authentic but also meets the causal constraints required for causal inference. When modifying the values ​​of sensitive features or intervening features, downstream features can be generated along the structure of the causal graph. This mechanism provides a reliable technical foundation for improving dataset fairness.

[0031] S23, build a discriminator: build a discriminator Dis, which is used to evaluate the generation quality of the generator group G and discriminate the generator G i Whether the generated data conforms to the characteristic distribution in the causal relationship graph and distinguishes real samples from false samples;

[0032] The sample set D = (S, X, Y), the reconstructed sample set and synthetic sample sets As the input of the discriminator Dis, the discriminant loss L is defined as follows GAN :

[0033]

[0034] in, It represents the expected logarithmic probability that the discriminator Dis judges the samples in the sample set D as "true", The discriminator Dis reconstructs the sample set The expected logarithmic probability that the sample in is judged to be "false", is the discriminator Dis for the synthetic sample set The expected logarithmic probability that the samples in are judged to be "false";

[0035] This step can measure whether the generated data meets the characteristic distribution in the original causal relationship graph, ensure that the generated samples are consistent with the real data in terms of statistical characteristics, effectively evaluate the performance of the generator, and guide the generator to optimize the output quality, thereby improving the authenticity and reliability of the generated data;

[0036] S24. Collaborative adversarial training: Perform end-to-end collaborative adversarial training on the variational autoencoder, generator group, and discriminator, and optimize them through the following overall objective function L:

[0037] The adversarial training process of the variational autoencoder, generator group, and discriminator is as follows:

[0038] Fixed variational autoencoder Enc and generator group G, update the discriminator Dis: update the discriminator parameters by gradient ascent to maximize the discriminant loss L GAN, improve the discriminator Dis for sample set D, reconstruct the sample set and synthetic sample sets ability to distinguish;

[0039] Fixed discriminator, update variational autoencoder Enc and generator group G: update parameters ω by gradient ascent u and ω s To maximize the correlation loss L hgr , update the parameters of the variational autoencoder and generator group by gradient descent to minimize the overall objective function L;

[0040] According to the adversarial training results, the optimal generator group G is obtained opt ={G 1,opt ,G 2,opt ,…,G i,opt ,…,G |H|,opt}、Optimal variational autoencoder Enc opt and the optimal discriminator Dis opt , where G i,opt represents the optimal generator of the i-th generated feature;

[0041] Through this step, the modeling capability of the generative adversarial network is extended to the field of causal constrained data generation. The collaborative training optimization mechanism enables the generated data to maintain both the true distribution characteristics and causal fairness requirements. The variational autoencoder and generator group are integrated to form a basic framework that supports causal intervention and counterfactual reasoning, providing support for causal intervention technology.

[0042] Furthermore, the process of step S3 is as follows:

[0043] S31. Sample d is obtained from the sample set D. The classification loss J(θ, d) on sample d is calculated using the classifier for the j-th non-sensitive feature x of sample d. j The gradient of ∈X The correlation between non-sensitive features and sensitive features is measured by determining whether the non-sensitive feature is a descendant node of the sensitive feature in the causal relationship graph. The following formula is defined to select intervention features:

[0044]

[0045] Where |X| represents the number of non-sensitive features, r(x j ,S) represents the jth non-sensitive feature x j The degree of association between the sensitive feature S and De(S) represents the set of descendant nodes of the sensitive feature S, and rank(x j ,De(S)) represents the non-sensitive feature x jThe ranking in the descendant node set of S, I represents the intervention feature, for the intervention feature I of sample d, the intervention value K I The calculation formula is as follows:

[0046]

[0047] where d I is the original observation value of intervention feature I in sample d, K I Represents the intervention value of the intervention feature I, that is, in the causal intervention process, the value of the intervention feature I will be changed from d I Replace with K I , g s It is a set hyperparameter used to adjust the feature intervention intensity when generating global counterfactual discrimination samples. Represents the gradient of the classification loss J(θ,d) to the intervention feature I of sample d, sign() is the sign function, when When is a positive number, Output +1, otherwise -1, used to determine the intervention direction;

[0048] Through this step, we can identify non-sensitive features that have a significant impact on the classification results and are causally related to sensitive features, ensuring that in the subsequent intervention process, the samples after intervention can effectively change the classification results while complying with causal constraints, thereby generating counterfactual discrimination samples with causal explanations.

[0049] S32, intervene in the intervention feature I in the sample d to obtain the intervention sample d′, the process is as follows: use the optimal variational autoencoder Enc opt Extract the unobserved feature U of sample d, and input the sensitive feature S and unobserved feature U in sample d into the optimal generator group G opt In the process of intervening feature I, the values ​​of the generated features are obtained in turn according to the topological order until the values ​​of all generated features are generated. Replaced by Among them G I,opt represents the optimal generator corresponding to the intervention feature I, Represents the generated value of the parent node of I in the causal relationship graph;

[0050] This step uses the optimal generator group and the optimal variational autoencoder to modify the selected intervention features while maintaining the causal generation process of other sample features, ensuring that the intervention operation is legal in the causal graph, thereby generating semantically reasonable intervention samples that conform to counterfactual logic.

[0051] S33, determine whether the intervention sample d′ is a counterfactual discrimination sample, that is, whether it satisfies the counterfactual discrimination condition, where the counterfactual discrimination condition is: input the intervention sample d′ into the optimal variational autoencoder Enc opt Extract the unobserved feature U and use the optimal generator group G opt Generate corresponding counterfactual samples for different values ​​of the sensitive feature S one by one. If the classification result of the classifier for the counterfactual sample is inconsistent with the classification result of d′, then the sample d′ is considered to meet the counterfactual discrimination condition;

[0052] If the intervention sample d′ is a counterfactual discrimination sample, then d′ is placed in the global counterfactual discrimination sample set G CDS Then, the next sample is selected from D to continue the above process; if the intervention sample d′ is not a counterfactual discrimination sample, the intervention feature of d′ is further calculated and the intervention operation is performed until one of the termination conditions is met: the preset maximum number of iterations is reached, and the sample generated by the current intervention is judged to be a counterfactual discrimination sample;

[0053] This step verifies whether the intervention sample meets the counterfactual discrimination condition, determines whether it reveals the model's potential discriminatory bias, and provides a basis for subsequent fairness optimization;

[0054] S34, repeat steps S31 to S33, and finally obtain the global counterfactual discrimination sample set G CDS ;

[0055] This step systematically obtains a global set of counterfactual discrimination samples by iteratively generating and screening counterfactual discrimination samples, which not only reveals the discriminatory decision-making patterns in the model, but also lays an important foundation for the subsequent expansion of the counterfactual discrimination sample dataset.

[0056] Furthermore, the process of step S4 is as follows:

[0057] S41. From the global counterfactual discrimination sample set G CDS Sample m is sampled from the dataset, and the jth non-sensitive feature x in m is calculated. i Contribution to the prediction results And calculate the correlation between non-sensitive features and sensitive features, and determine the probability that the j-th non-sensitive feature in m is selected as the intervention feature according to the following formula:

[0058]

[0059] where x t Represents all features in non-sensitive feature X;

[0060] This step establishes a probabilistic intervention feature selection mechanism based on causal relationships by quantitatively analyzing the contribution of each non-sensitive feature to the prediction result and its correlation with the sensitive feature, thereby ensuring that the selected intervention features ensure that the samples after intervention can maintain the classification results while meeting the constraints of causal relationships.

[0061] S42. According to probability Select the intervention feature I from the non-sensitive features, and select the intervention gradient direction ξ from {-1,1} with a probability of [0.5,0.5], that is, ξ satisfies P(ξ=-1)=0.5 and P(ξ=1)=0.5. Calculate the intervention value of the intervention feature I for sample m according to the following formula: K I =m I +ξ*l s

[0062] where l s It is a hyperparameter used to adjust the feature intervention strength when generating local counterfactual discrimination samples, and is used to adjust the feature intervention strength when generating local counterfactual discrimination samples;

[0063] This step uses a probabilistic selection mechanism to determine the intervention features and their directions, achieving fine-grained control over the generation of local counterfactual discrimination samples. By setting the feature intervention intensity hyperparameter, the intervention intensity is precisely controlled, allowing the generated local counterfactual discrimination samples to effectively expose model bias while maintaining reasonable semantic authenticity, providing a reliable methodological foundation for constructing a local counterfactual discrimination sample set.

[0064] S43. Intervene the intervention feature I of sample m to obtain the intervention sample m′, and determine whether m′ is a counterfactual discrimination sample. If m′ is a counterfactual discrimination sample, then put m′ into the local counterfactual discrimination sample set L CDS In the process, the intervention features and intervention values ​​of m′ are further calculated, and the intervention operation is performed until one of the termination conditions is met: the preset maximum number of iterations is reached, and the sample generated by the current intervention is not a counterfactual discrimination sample;

[0065] This step systematically generates counterfactual discrimination samples by intervening in selected features and conducting verification, effectively capturing the potential impact of sensitive features on model predictions under specific feature combinations;

[0066] S44, repeat steps S41 to S43, and finally obtain the local counterfactual discrimination sample set L CDS ;

[0067] This step systematically obtains a local set of counterfactual discrimination samples by iteratively generating and screening counterfactual discrimination samples, providing reliable data support for the subsequent generation of counterfactual fairness samples.

[0068] Furthermore, the process of step S5 is as follows:

[0069] The global counterfactual discrimination sample set G CDS and the local counterfactual discrimination sample set L CDS Merge to generate sample set A CDS =G CDS ∪L CDS , A CDS Generated sample input optimal variational autoencoder Enc opt Extract the unobserved feature U and use the optimal generator group G opt For each sensitive feature S, different value sets {s1,s2,…,s r ,…,s q}, generate corresponding counterfactual sample sets one by one: D c (s r )=G opt (U,s r )

[0070] Among them D c (s r ) indicates that the sensitive feature S takes the value of s r The sample set generated when s1,s2,…,s r ,…,s q is q different values ​​of the sensitive feature S. The label features of all counterfactual sample sets are replaced with the label features of the generated samples, and the correction preprocessing is performed according to the following formula:

[0071] where d r,y Indicates D c (s r ) in sample d r The label feature, y is A CDS Generate the label features of the samples in , merge all the counterfactual fair samples to obtain the counterfactual fair dataset D that meets the fairness requirements cf :

[0072] This step uses the optimal generator group and the optimal variational autoencoder to generate counterfactual samples covering all possible values ​​of sensitive features for counterfactual discrimination samples. By forcing the unified label features, it ensures that the generated counterfactual samples maintain the semantics of the original data while eliminating the discriminatory bias caused by different values ​​of sensitive features. The final synthesized D cf It does not sacrifice the quality and causal rationality of the data, and can also meet the counterfactual fairness constraints.

[0073] A second object of the present invention is to provide a device for enhancing fairness in data classification based on causal intervention, for executing the above-mentioned method for enhancing fairness in data classification based on causal intervention, the device comprising:

[0074] Dataset generation module, input recruitment screening or medical service training data D train , the training data D train Divided into non-sensitive features X, sensitive features S and label features Y, the non-sensitive features and label features are combined to represent H = (X, Y) and form the generated feature H, the non-sensitive features X, sensitive features S and label features Y are combined to represent the sample form D = (X, S, Y) and form the sample set D;

[0075] The data generation model establishment module creates a variational autoencoder Enc to extract unobserved features U from the sample set D. The unobserved features U represent unobserved potential factors that may affect the generated features; for each feature in the generated features, an independent generator G is created. i ,i=1,…,|H|, all generators are grouped into a generator group G={G1,G2,…,G |H|}, where |H| represents the number of generated features. The generators in the generator group G are arranged in the topological order of the causal relationship graph. The causal relationship graph is a directed acyclic graph used to clarify the causal path and dependency relationship between each feature. Each node in the graph represents a feature in the sample set D. The directed edge in the graph represents the causal relationship between two features in the sample set D. For any directed edge e between the generated features in the graph, i →H j ), the corresponding generator arrangement satisfies G i In G j Before; create a discriminator Dis; use the sample set D to perform collaborative adversarial training on the variational autoencoder Enc, the generator group G and the discriminator Dis to obtain the optimal generator group G opt ={G 1,opt ,G 2,opt ,…,G i,opt ,…,G |H|,opt}、Optimal variational autoencoder Enc opt and the optimal discriminator Dis opt , where G i,opt represents the optimal generator of the i-th generated feature;

[0076] The global counterfactual discrimination sample generation module uses a classifier to classify the sample set D, and classifies the j-th non-sensitive feature x of sample d based on the classification loss J(θ,d) of sample d in the sample set D. j ∈X, calculate the gradient Select the feature I∈X that needs intervention and the intervention value KI , using the optimal variational autoencoder Enc opt Extract unobserved features U from d and use the optimal generator group G opt Replace the value of the intervened feature I with K I , and generate the values ​​of all generated features in the causal topological order to obtain the intervention sample; determine whether the intervention sample is a counterfactual discrimination sample, and if so, put it into the global counterfactual discrimination sample set G CDS In the process, samples are selected from the sample set D and the process is repeated multiple times to obtain the global counterfactual discrimination sample set G CDS ;

[0077] The local counterfactual discrimination sample generation module is generated from the global counterfactual discrimination sample set G CDS Select samples, calculate the contribution of non-sensitive features of samples to the prediction results, and select features I and intervention values ​​K that require causal intervention I , optimal variational autoencoder Enc opt Extract the unobserved feature U from the sample and replace the value of the intervention feature I with K I , using the optimal generator group G in causal topological order opt Generate the values ​​of all generated features to obtain intervention samples; determine whether the intervention samples are counterfactual discrimination samples, and if so, put them into the local counterfactual discrimination sample set L CDS Repeat this process multiple times to obtain the local counterfactual discrimination sample set L CDS ;

[0078] The counterfactual fair sample generation module will generate a sample set A CDS =G CDS ∪L CDS The generated samples in are input to the optimal variational autoencoder Enc opt Extract unobserved features and use the optimal generator group G opt For each different value of the sensitive feature S, a corresponding counterfactual sample is generated, and the label feature of the counterfactual sample is replaced with the label feature of the generated sample to obtain a counterfactual fair dataset D that meets the fairness requirements. cf .

[0079] The third object of the present invention is to provide an electronic device, comprising a processor and a memory for storing a program executable by the processor, wherein when the processor executes the program stored in the memory, the above-mentioned data classification fairness enhancement method based on causal intervention is implemented.

[0080] A fourth object of the present invention is to provide a storage medium storing a program, which, when executed by a processor, implements the above-mentioned data classification fairness enhancement method based on causal intervention.

[0081] The present invention has the following advantages and effects compared to the prior art:

[0082] 1. Possess complete causal reasoning and counterfactual reasoning capabilities, and improve the level of causal consistency modeling. The present invention deeply integrates variational autoencoders (VAE) and generative adversarial networks (GANs) to construct a VAE-GAN joint model to fit the potential causal structure in the data. In the causal model framework, VAE and GAN are combined according to the topological order of the causal relationship graph, giving full play to the ability of VAE in extracting unobserved features and the ability of GAN to generate data according to causal paths, realizing the whole process from potential causal feature modeling to causal consistency data generation, and effectively achieving the causal reasoning goal. During the collaborative training process, by applying the HGR correlation loss L hgr Ensure that the unobserved features inferred by VAE are independent of each other and the sensitive features; by applying a priori loss L pri Ensure that the inferred unobserved features conform to the prior distribution assumptions; by applying the reconstruction loss L rec Ensure that the sample remains unchanged under the premise of fixing the unobserved features and sensitive features, thereby satisfying the principle of causal invariance; by applying the discriminant loss L GAN Ensure the authenticity of generated data. The causal generative model proposed in this paper achieves integrated modeling from inference of unobserved features to causal data generation, becoming a powerful framework for promoting counterfactual reasoning and counterfactual fairness enhancement. It not only has good interpretability and controllability, but also preserves the causal relationship between features while ensuring the generation of high-quality data.

[0083] 2. It has intuitive guidance for the generation of counterfactual fair samples. The present invention quantifies the probability of feature selection at the global and local stages by predicting the gradient of the loss with respect to the feature, the correlation between sensitive features and non-sensitive features, and the contribution of the feature to the prediction result, and intuitively guides the selection of intervention features. The above mechanism avoids the problem of random selection of intervention features in traditional methods, and realizes the intuitiveness and controllability of the counterfactual discrimination sample generation process. In addition, for the generated counterfactual discrimination samples, the present invention further introduces a bias correction preprocessing mechanism to correct the label features of its counterfactual samples to ensure the counterfactual fairness of the generated samples, thereby making the generation of counterfactual fair samples explainable. In the entire data classification fairness enhancement process, there is no need to impose unobservable fairness constraints in the training stage, which avoids the "black box" training method, making the counterfactual fairness enhancement process have good explainability and practical guidance significance.

[0084] 3. Possessing the ability of causal intervention and realizing structured causal generation of samples. The present invention realizes the ability of causal intervention on samples by fusing variational autoencoders (VAE) and generative adversarial networks (GAN). First, VAE is used to extract the corresponding unobserved features from the original samples; then, during the intervention process, the generator output corresponding to the specified intervention feature is replaced with the intervention value, and the characteristic values ​​corresponding to the causal descendant nodes of the intervention feature are generated in sequence according to the topological order of the causal relationship graph, and finally the sample after causal intervention is constructed. The above process strictly follows the causal reasoning principle in the structural causal model, can realize direct intervention on specific variables, and track the propagation path of the intervention effect in the causal chain, reflecting the deep modeling ability of the causal mechanism, and providing a solid foundation for the subsequent generation of counterfactual discrimination samples.

[0085] 4. It has the scalability to enhance the fairness of data classification. The present invention improves the fairness of data classification by generating counterfactual fair samples and retraining the classifier. In this process, the counterfactual fair samples are obtained after bias correction preprocessing of the counterfactual samples of the counterfactual discriminatory samples generated in the global stage and the local stage. In the global and local stages, the number of counterfactual discriminatory samples generated can be controlled by setting different numbers of iterations and sampling numbers, thereby affecting the scale of counterfactual fair samples ultimately used for classifier retraining. This mechanism gives the model flexibility and scalability in the fairness enhancement process, and can adjust the intensity of fairness enhancement according to specific application requirements, thereby taking into account both model performance and fairness goals, and is suitable for classification tasks of different scales and types.

[0086] 5. While maintaining robust classification performance, counterfactual fairness is significantly improved. The present invention demonstrates significant fairness improvements in experimental validation. On a deep neural network classifier (DNN), compared to methods without any fairness enhancement, the two fairness indicators are improved by an average of 94.1% and 82.0%, respectively, with the classification accuracy rate (ACC) decreasing by only 0.01, but the F1 score slightly improving. On a residual neural network classifier (ResNet), the fairness indicators are improved by an average of 97.1% and 87.2%, respectively, with the classification accuracy rate (ACC) decreasing by only 0.04, but the F1 score remains unchanged. Compared to the most advanced and best-performing existing algorithms, on the DNN classifier, the fairness indicators are improved by an average of 40.7% and 40.4%, respectively, with the classification accuracy rate (ACC) increasing by 0.028 and the F1 score increasing by 0.136. On the ResNet classifier, the fairness indicators are improved by an average of 56.7% and 56.1%, respectively, with the classification accuracy rate (ACC) increasing by 0.018 and the F1 score increasing by 0.097. Experimental results show that the counterfactual fairness enhancement method proposed in this paper can effectively generate high-quality counterfactual fairness samples, significantly reduce the impact of sensitive features on model output, and reduce the potential bias and discrimination risks of the model. At the same time, the generated samples maintain the authenticity and consistency of the data on the basis of satisfying causal constraints, and have good data quality. It has demonstrated excellent versatility and adaptability on multiple mainstream classifiers, not only significantly improving the counterfactual fairness of the model, but also optimizing the overall performance of the model to a certain extent, taking into account both fairness and accuracy, and has strong engineering implementation capabilities and broad application prospects. BRIEF DESCRIPTION OF THE DRAWINGS

[0087] The drawings described herein are used to provide a further understanding of the technical solution of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:

[0088] Figure 1 is a flow chart of data classification fairness enhancement based on causal intervention disclosed in the present invention;

[0089] Figure 2 This is a flow chart of generating a synthetic sample set and a reconstructed sample set by using causal topological data in the present invention;

[0090] Figure 3 It is a flowchart for generating a counterfactual fair dataset by generating counterfactual discrimination samples and then preprocessing them with bias correction;

[0091] Figure 4 Schematic diagram of the structure of the data classification fairness enhancement device based on causal intervention disclosed in Example 3 of the present invention;

[0092] Figure 5 This is a structural diagram of the electronic device disclosed in Example 4 of the present invention. DETAILED DESCRIPTION

[0093] To make the objectives, technical solutions, and advantages of the embodiments of the present invention more clear, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts shall fall within the scope of protection of the present invention.

[0094] References to "embodiments" in this application mean that a particular feature, structure, or characteristic described in connection with the embodiment may be included in at least one embodiment of the application. The appearance of this phrase in various places in the specification does not necessarily refer to the same embodiment, nor does it constitute an independent or alternative embodiment that is mutually exclusive of other embodiments. It is understood, both explicitly and implicitly, by those skilled in the art that the embodiments described in this application may be combined with other embodiments.

[0095] Example 1

[0096] This embodiment discloses a method and apparatus for enhancing fairness in data classification based on causal intervention, which specifically includes the following steps:

[0097] S1. Input recruitment screening training data D train· , the training data D train The dataset is divided into non-sensitive features X, sensitive features S, and label features Y. The training data for recruitment screening is the adult income dataset from the UCI public dataset, which includes sample data from the 1994 US Census and contains 32,561 cases and 15 features. Non-sensitive features X include age, country of birth, race, job type, education level, marital status, occupation type, family relationships, and weekly work hours. Sensitive feature S represents gender, with values ​​{0, 1}, where 0 represents male and 1 represents female. The dataset is designed for binary classification. Label feature Y represents annual income, with values ​​{0, 1}, where 0 represents annual income less than or equal to $50,000 and 1 represents annual income greater than $50,000. The non-sensitive features and label features are combined into H = (X, Y) to form the generated feature H. The non-sensitive features X, sensitive features S, and label features Y are combined into the sample form D = (X, S, Y) to form the sample set D. This dataset is used to simulate the automatic decision-making modeling task of enterprises in the recruitment screening process, that is, to predict whether the candidate has high income potential based on his or her personal information, and then assist in determining whether he or she meets the conditions for being hired.

[0098] S2. Create a variational autoencoder Enc to extract unobserved features U from the sample set D. The unobserved features U represent unobserved potential factors that may affect the generated features. Create an independent generator G for each feature in the generated features. i ,i=1,…,|H|, all generators are grouped into a generator group G={G1,G2,…,G |H|}, where |H| represents the number of generated features. The generators in the generator group G are arranged in the topological order of the causal relationship graph. The causal relationship graph is a directed acyclic graph used to clarify the causal path and dependency relationship between each feature. Each node in the graph represents a feature in the sample set D. The directed edge in the graph represents the causal relationship between two features in the sample set D. For any directed edge e between the generated features in the graph, i →H j ), the corresponding generator arrangement satisfies G i In G j Before; create a discriminator Dis; use the sample set D to perform collaborative adversarial training on the variational autoencoder Enc, the generator group G and the discriminator Dis to obtain the optimal generator group G opt ={G 1,opt ,G 2,opt ,…,G i,opt ,…,G |H|,opt}、Optimal variational autoencoder Enc opt and the optimal discriminator Dis opt , where G i,opt represents the optimal generator of the i-th generated feature;

[0099] S21. Construct and regularize a variational autoencoder: Based on the given causal relationship graph, a variational autoencoder Enc is constructed. The variational autoencoder Enc contains only one encoder, which takes the non-sensitive feature X, sensitive feature S and label feature Y in the sample set D as input, and maps the input to the mean μ and logarithmic variance logσ of the unobserved feature U. 2 In the space of , the unobserved feature U is constructed according to the following formula: U = μ + δ*∈, where δ = exp(0.5*logσ 2 ), ∈ is the random noise sampled from the standard normal distribution N(0,1). According to the above formula, we can get the unobserved feature U = [[-0.5708,-2.2155,0.1490,…,-1.2008,0.4826,-0.2410],[-0.8428,0.9331,-2.0939,…,0.9426,-0.2457,1.3438],…,[1.0648,1.2490,-1.0066,…,-2.9662,0.0631,0.1361]];

[0100] In this embodiment, the variational autoencoder Enc is regularized by applying a priori conditions to the distribution p(U). In order to make U obey the standard normal distribution, that is, U~N(0,1), a priori loss L is introduced. pri as follows:

[0101] L pri =KL[q(U|X,S,Y)||p(U)]

[0102] The correlation coefficient HGR is introduced to evaluate the correlation between the sensitive feature S and the unobserved feature U, and the correlation loss L of the correlation coefficient HGR is defined hgr :

[0103] S22, construct the generator group and generate the reconstructed sample set and the synthetic sample set: According to the directed acyclic graph structure of the causal relationship graph, generate the feature H for each i Create an independent generator G i , i=1,…,10, and all generators are organized into a generator group G={G1,G2,…,G 10};

[0104] The generator groups are ordered according to the causal topology, where the causal graph is:

[0105] Node definition: S: Gender is the root node and has no parent node; H1: Age is the root node and has no parent node; H2: Country of birth is the root node and has no parent node; H3: Race is the root node and has no parent node; H4: Marital status is a non-root node, and its parent nodes are gender, age, race, and country of birth; H5: Education level is a non-root node, and its parent nodes are gender, age, race, country of birth, and marital status; H6: Occupation type is a non-root node, and its parent nodes are gender, age, race, country of birth, and marital status; H7: Weekly working hours is a non-root node, and its parent nodes are gender, age, race, country of birth, marital status, and education level; H8: Job type is a non-root node, and its parent nodes are gender, age, country of birth, marital status, and education level; H9: Family relationship is a non-root node, and its parent nodes are gender, age, country of birth, marital status, and education level; H 10 : Income status is a non-root node, and its parent nodes are gender, age, race, country of birth, marital status, education level, occupation type, weekly work hours, job type, and family relationship;

[0106] Edges represent causal relationships:

[0107] Gender → income status,

[0108] Gender → marital status → income,

[0109] Gender → Education → Income,

[0110] Gender → Job Type → Income

[0111] Gender → Occupation type → Income situation,

[0112] Gender → Weekly working hours → Income,

[0113] Gender → Family Relationship → Income

[0114] Gender → marital status → education level → income,

[0115] Gender → marital status → job type → income,

[0116] Gender → marital status → occupation type → income situation,

[0117] Gender → marital status → weekly working hours → income,

[0118] Gender → marital status → family relationship → income situation,

[0119] Gender → Education level → Job type → Income,

[0120] Gender → Education level → Occupation type → Income,

[0121] Gender → Education level → Family relationship → Income,

[0122] Gender → Education level → Weekly working hours → Income,

[0123] Age → income,

[0124] Age → marital status → income,

[0125] Age → Education → Income,

[0126] Age → Job Type → Income

[0127] Age → Occupation type → Income,

[0128] Age → Weekly working hours → Income,

[0129] Age → Family Relationship → Income

[0130] Age → marital status → education level → income,

[0131] Age → marital status → job type → income,

[0132] Age → marital status → occupation type → income,

[0133] Age → marital status → weekly working hours → income,

[0134] Age → marital status → family relationship → income,

[0135] Age → Education → Job Type → Income

[0136] Age → Education → Occupation → Income

[0137] Age → Education → Family Relationship → Income,

[0138] Age → Education → Weekly working hours → Income,

[0139] Race → income,

[0140] Race → marital status → income,

[0141] Race → Education → Income,

[0142] Race → Occupation type → Income situation,

[0143] Race → Weekly work hours → Income

[0144] Race → marital status → education level → income,

[0145] Race → Marital status → Job type → Income,

[0146] Race → Marital status → Occupation type → Income,

[0147] Race → marital status → weekly work hours → income,

[0148] Race → marital status → family relationship → income,

[0149] Race → Education → Job Type → Income

[0150] Race → Education → Occupation → Income

[0151] Race → Education → Family Relationship → Income,

[0152] Race → Education → Weekly Work Hours → Income

[0153] Country of birth → income,

[0154] Country of birth → marital status → income,

[0155] Country of birth → education level → income,

[0156] Country of birth → Weekly working hours → Income

[0157] Country of birth → marital status → education level → income,

[0158] Country of birth → marital status → job type → income,

[0159] Country of birth → marital status → occupation type → income situation,

[0160] Country of birth → marital status → weekly working hours → income,

[0161] Country of birth → marital status → family relationship → income situation,

[0162] Country of birth → education level → job type → income,

[0163] Country of birth → education level → occupation type → income,

[0164] Country of birth → education level → family relationship → income,

[0165] Country of birth → education level → weekly working hours → income;

[0166] Corresponding generated feature H i The generator G i The input is the generated value of the parent node of the generated feature and the unobserved feature U, and the output is the generated value of the generated feature The generation process is as follows:

[0167] First, the root node is generated:

[0168] Age H1, country of birth H2, and race H3 are root nodes that do not depend on other nodes but only on unobserved features:

[0169]

[0170] Non-root node generation:

[0171] Generation of marital status H4:

[0172] Generation of education level H5:

[0173] Generation of occupation type H6:

[0174] Generation of weekly working hours H7:

[0175] Generation of work type H8:

[0176] Generation of family relationship H9:

[0177] Income situation 10 Generation of:

[0178] The sensitive features S and the unobserved features U inferred by the variational autoencoder are input into the generator group G, and the values ​​of the generated features are obtained in sequence according to the topological order until the values ​​of all generated features are generated, and finally the reconstructed sample set is output.

[0179] In order to ensure that the reconstructed samples are highly similar to the original input samples in distribution, the reconstruction loss L is defined as follows: rec :

[0180]

[0181] Among them, p(X,Y|U,S)=P(Y|,X,U,S)*P(X|U,S), P(Y|,X,U,S) describes the probability that the label feature Y is generated by the generator group under the conditions of the non-sensitive feature X, the unobserved feature U and the sensitive feature S, reflecting that the label feature Y is affected by the non-sensitive feature X and the sensitive feature S. P(X|U,S) describes the probability that the non-sensitive feature X is generated by the generator group under the conditions of the unobserved feature U and the sensitive feature S. The negative value of the log likelihood is used to measure the non-sensitive feature X, the label feature Y, and the reconstructed non-sensitive feature generated by the decoder. and label features similarity;

[0182] Sampling from the prior distribution N(0,1) of the unobserved feature U Sampling from the distribution P(S) of sensitive features S Exploiting sensitive features of sampling and unobserved characteristics Input the generator group G, and get the values ​​of the generated features in turn according to the topological order until the values ​​of all generated features are generated, and finally output the synthetic sample set

[0183] S23, build a discriminator: build a discriminator Dis, which is used to evaluate the generation quality of the generator group G and discriminate the generator G i Whether the generated data conforms to the characteristic distribution in the causal relationship graph and distinguishes real samples from false samples;

[0184] The sample set D = (S, X, Y), the reconstructed sample set and synthetic sample sets As the input of the discriminator Dis, the discriminant loss L is defined as follows GAN :

[0185]

[0186] in, It represents the expected logarithmic probability that the discriminator Dis judges the samples in the sample set D as "true", The discriminator Dis reconstructs the sample set The expected logarithmic probability that the sample in is judged to be "false", is the discriminator Dis for the synthetic sample set The expected logarithmic probability that the samples in are judged to be "false";

[0187] S24. Collaborative adversarial training: Perform end-to-end collaborative adversarial training on the variational autoencoder, generator group, and discriminator, and optimize them through the following overall objective function L:

[0188] The adversarial training process of the variational autoencoder, generator group, and discriminator is as follows:

[0189] Fixed variational autoencoder Enc and generator group G, update the discriminator Dis: update the discriminator parameters by gradient ascent to maximize the discriminant loss L GAN , improve the discriminator Dis for sample set D, reconstruct the sample set and synthetic sample sets ability to distinguish;

[0190] Fixed discriminator, update variational autoencoder Enc and generator group G: update parameters ω by gradient ascent u and ω s To maximize the correlation loss L hgr , update the parameters of the variational autoencoder and generator group by gradient descent to minimize the overall objective function L;

[0191] According to the adversarial training results, the optimal generator group G is obtained opt ={G 1,opt ,…,G 10,opt}、Optimal variational autoencoder Enc opt and the optimal discriminator Dis opt , where G i,opt represents the optimal generator for the i-th generated feature.

[0192] S3. Use the classifier to classify the sample set D, based on the classification loss J(θ,d) of sample d in the sample set D, and the j-th non-sensitive feature x of sample d. j ∈X, calculate the gradient Select the feature I∈X that needs intervention and the intervention value K I , using the optimal variational autoencoder Enc opt Extract unobserved features U from d and use the optimal generator group G opt Replace the value of the intervened feature I with K I , and generate the values ​​of all generated features in the causal topological order to obtain the intervention sample; determine whether the intervention sample is a counterfactual discrimination sample, and if so, put it into the global counterfactual discrimination sample set G CDS In the process, samples are selected from the sample set D and the process is repeated multiple times to obtain the global counterfactual discrimination sample set G CDS ;

[0193] S31. Sample d is obtained from the sample set D. The classification loss J(θ, d) on sample d is calculated using the classifier for the j-th non-sensitive feature x of sample d. j The gradient of ∈X The correlation between non-sensitive features and sensitive features is measured by determining whether the non-sensitive feature is a descendant node of the sensitive feature in the causal relationship graph. The following formula is defined to select intervention features:

[0194]

[0195] For the intervention feature I of sample d, the intervention value K I The calculation formula is as follows:

[0196] S32, intervene in the intervention feature I in the sample d to obtain the intervention sample d′, the process is as follows: use the optimal variational autoencoder Enc opt Extract the unobserved feature U of sample d, and input the sensitive feature S and unobserved feature U in sample d into the optimal generator group G opt ={G 1, o pt ,…,G 10,opt}, the values ​​of the generated features are obtained in sequence according to the topological order until the values ​​of all generated features are generated;

[0197] S33, determine whether the intervention sample d′ is a counterfactual discrimination sample, that is, whether it satisfies the counterfactual discrimination condition, where the counterfactual discrimination condition is: input the intervention sample d′ into the optimal variational autoencoder Enc opt Extract the unobserved feature U and use the optimal generator group G opt Generate corresponding counterfactual samples for different values ​​of the sensitive feature S one by one. If the classification result of the classifier for the counterfactual sample is inconsistent with the classification result of d′, then the sample d′ is considered to meet the counterfactual discrimination condition;

[0198] If the intervention sample d′ is a counterfactual discrimination sample, then d′ is placed in the global counterfactual discrimination sample set G CDS Then, the next sample is selected from D to continue the above process; if the intervention sample D′ is not a counterfactual discrimination sample, the intervention feature of d′ is further calculated and the intervention operation is performed until one of the termination conditions is met: the preset maximum number of iterations is reached, and the sample generated by the current intervention is judged to be a counterfactual discrimination sample;

[0199] S34, repeat steps S31 to S33, and finally obtain the global counterfactual discrimination sample set G CDS .

[0200] S4. From the global counterfactual discrimination sample set G CDS Select samples, calculate the contribution of non-sensitive features of samples to the prediction results, and select features I and intervention values ​​K that require causal intervention I , optimal variational autoencoder Enc opt Extract the unobserved feature U from the sample and replace the value of the intervention feature I with K I , using the optimal generator group G in causal topological order opt Generate the values ​​of all generated features to obtain intervention samples; determine whether the intervention samples are counterfactual discrimination samples, and if so, put them into the local counterfactual discrimination sample set L CDS Repeat this process multiple times to obtain the local counterfactual discrimination sample set L CDS ;

[0201] S41. From the global counterfactual discrimination sample set G CDS Select sample x from the sampling, and calculate the jth non-sensitive feature x in m j Contribution to the prediction results And calculate the correlation between non-sensitive features and sensitive features, and determine the probability that the j-th non-sensitive feature in m is selected as the intervention feature according to the following formula:

[0202]

[0203] S42. According to probability Select the intervention feature I from the non-sensitive features, and select the intervention gradient direction ξ from {-1,1} with a probability of [0.5,0.5], that is, ξ satisfies P(ξ=-1)=0.5 and P(ξ=1)=0.5. Calculate the intervention value of the intervention feature I for sample m according to the following formula: K I =m I +ξ*l s ;

[0204] S43. Intervene the intervention feature I of sample m to obtain the intervention sample m′, and determine whether m′ is a counterfactual discrimination sample. If m′ is a counterfactual discrimination sample, then put m′ into the local counterfactual discrimination sample set L CDS In the process, the intervention features and intervention values ​​of m′ are further calculated, and the intervention operation is performed until one of the termination conditions is met: the preset maximum number of iterations is reached, and the sample generated by the current intervention is not a counterfactual discrimination sample;

[0205] S44, repeat steps S41 to S43, and finally obtain the local counterfactual discrimination sample set L CDS .

[0206] S5. Generate sample set A CDS =G CDS ∪L CDS The generated samples in are input to the optimal variational autoencoder Enc opt Extract unobserved features and use the optimal generator group G opt ={G 1,opt ,…,G 10,opt Generate corresponding counterfactual samples for each different value of the sensitive feature S, replace the label features of the counterfactual samples with the label features of the generated samples, and obtain the counterfactual fair dataset D that meets the fairness requirements cf ;

[0207] The global counterfactual discrimination sample set G CDS and the local counterfactual discrimination sample set L CDS Merge to generate sample set A CDS =G CDS ∪L CDS After that, A CDS Input optimal variational autoencoder Enc opt Extract the unobserved feature U and use the optimal generator group G opt ={G 1,opt ,…,G 10,opt For each sensitive feature S with different value sets {0,1}, generate corresponding counterfactual sample sets one by one: D c (0) = G opt (U,0), D c (1) = G opt (U,1);

[0208] Replace the label features of all counterfactual sample sets with the label features of the generated samples to generate counterfactual fair samples:

[0209] Merge all counterfactual fairness samples to obtain the counterfactual fairness dataset D that meets the fairness requirements. cf:

[0210] D cf =D c (0)∪D c (1).

[0211] The present invention is compared with other algorithms, and the comparison indicators include classification performance indicators: classification accuracy ACC, F1 score F1-score; counterfactual fairness indicator: linear maximum mean difference MMD L , kernel maximum mean difference MMD K . The accuracy index ACC indicates whether the obtained classification result is consistent with the actual classification result. The higher the ACC, the better the classification effect. The F1 score F1-score is the harmonic mean of precision (Precision) and recall (Recall), which is used to comprehensively evaluate the performance of the classification model, especially in the case of class imbalance. It can better reflect the model's prediction performance for minority classes than the accuracy rate. The higher the F1-score, the better the classification effect. The maximum mean difference MMD is an indicator to measure the distribution difference between generated data and real data. It evaluates whether the generated data and the real data are similar in distribution by comparing different feature distributions. The smaller the MMD, the closer the generated data is to the real data in the overall feature distribution, thereby ensuring the authenticity of the data. Among them, the linear maximum mean difference MMD L The core idea is to calculate the mean difference between samples, the maximum mean difference (MMD) KMapping low-dimensional space to high-dimensional space allows for comparison of distribution differences in high-dimensional space. Table 1 examines the counterfactual fairness improvement and classification performance of the present invention's enhanced DNN classifier fairness on recruitment screening data. Table 2 examines the counterfactual fairness improvement and classification performance of the present invention's enhanced DNN classifier fairness on recruitment screening data. The second row, UF, is a method that uses all observable features to train a supervised model without counterfactual fairness processing; the third row, Unaware, is a method proposed in the paper "The case for process fairness in learning: Feature selection for fair decision making" based on the concept of achieving fairness through imperceptibility, using all features except sensitive features to predict labels; the fourth row, Counterfactual fairness, is a method proposed in the paper "Counterfactual fairness", which removes sensitive features and their descendants and relies only on the remaining features to predict labels; the fifth row, CR, is a method proposed in the paper "Counterfactual Fairness in Text Classification through Robustness", which generates counterfactual samples from the original dataset and adds counterfactual fairness constraints during training to minimize the prediction difference between the original and counterfactual samples; the sixth row, Counterfactually fair representation, is a method proposed in the paper "Counterfactually fair representation", which aggregates counterfactual samples and original samples to create counterfactual fair representations and then uses them to train the predictor; the seventh row, Learning for Counterfactual Fairness from Observational Data》proposed a method to learn fair representations by applying counterfactual fairness constraints, while using constant risk minimization losses to exclude non-causal variables with false and unstable correlations with the target; the last row is the method of the present invention. The comparison results are shown in Tables 1 and 2. It can be seen from the results in the tables that compared with other methods, the method of the present invention shows significant advantages in improving the counterfactual fairness of the classifier, and has a significant improvement over the suboptimal algorithm. At the same time, although the classification performance is slightly lower than that of the original model, the F1-score has a slight improvement on the DNN classifier. Compared with other counterfactual enhancement methods, the method of the present invention has a significant improvement in classification performance, which proves the effectiveness of the present invention.

[0212] Table 1. Comparison of the indicators of the disclosed method and the existing method for enhancing the DNN classifier on recruitment screening data

[0213]

[0214] Table 2. Comparison of the indicators of the disclosed method and the existing method for enhancing the ResNet classifier on recruitment screening data

[0215]

[0216] Example 2

[0217] This embodiment discloses a method and apparatus for enhancing fairness in data classification based on causal intervention, which specifically includes the following steps:

[0218] S1. Input medical service training data D train , the training data D train It is divided into non-sensitive features X, sensitive features S, and label features Y. The public health training data is the National Health and Nutrition Examination Survey (NHANES) dataset, a large-scale health survey conducted by the US Centers for Disease Control and Prevention (CDC), containing 9,932 cases and 18 features. Non-sensitive features X include race, age, gender, poverty index, red blood cell count, serum magnesium level, body mass index, serum cholesterol level, systolic blood pressure, diastolic blood pressure, erythrocyte sedimentation rate, white blood cell count, serum protein level, pulse pressure, iron binding capacity, transferrin saturation, serum ferritin level, and serum albumin level. Sensitive feature S is race, with values ​​{0, 1, 2}, where 0 represents white, 1 represents black, and 2 represents other races. The dataset is designed for a binary classification problem, and the label feature Y represents survival status, with values ​​{0, 1}, where 0 represents the inability to survive beyond 15 years and 1 represents the likelihood of survival beyond 15 years. The non-sensitive features and label features are combined into H = (X, Y) to form the generated feature H. The non-sensitive features X, sensitive features S, and label features Y are combined into a sample form D = (X, S, Y) to form the sample set D. This dataset is used to simulate the automated decision-making modeling task in the medical service field. That is, based on the patient's personal information (including non-sensitive features X and sensitive features S), the patient's long-term survival potential is predicted, thereby assisting in determining whether the patient meets the conditions for treatment plan or medical resource allocation.

[0219] S2. Create a variational autoencoder Enc to extract unobserved features U from the sample set D. The unobserved features U represent unobserved potential factors that may affect the generated features. For each feature in the generated features, create an independent generator Gi, i = 1, ..., |H|, and combine all generators into a generator group G = {G1, G2, ..., G |H|}, where |H| represents the number of generated features. The generators in the generator group G are arranged in the topological order of the causal relationship graph. The causal relationship graph is a directed acyclic graph used to clarify the causal path and dependency relationship between each feature. Each node in the graph represents a feature in the sample set D. The directed edge in the graph represents the causal relationship between two features in the sample set D. For any directed edge e between the generated features in the graph, i →H j ), the corresponding generator arrangement satisfies G i In G j Before; create a discriminator Dis; use the sample set D to perform collaborative adversarial training on the variational autoencoder Enc, the generator group G and the discriminator Dis to obtain the optimal generator group G opt ={G 1,opt ,G 2,opt ,…,G i,opt ,…,G |h|,opt}、Optimal variational autoencoder Enc opt and the optimal discriminator Dis opt , where G i,opt represents the optimal generator of the i-th generated feature;

[0220] S21. Construct and regularize a variational autoencoder: Based on the given causal relationship graph, a variational autoencoder Enc is constructed. The variational autoencoder Enc contains only one encoder, which takes the non-sensitive feature X, sensitive feature S and label feature Y in the sample set D as input, and maps the input to the mean μ and logarithmic variance logσ of the unobserved feature U. 2 In the space of , the unobserved feature U is constructed according to the following formula: U = μ + δ*∈, where δ = exp(0.5*logσ 2 ), ∈ is the random noise sampled from the standard normal distribution N(0,1). According to the above formula, we can get the unobserved feature U = [[-1.9769,1.1823,-0.6848,...,0.3507,1.4530,-0.1639],[-2.0354,0.5535,-1.2420,...,-0.1209,0.9400,2.5055],…,[0.4921,-1.8739,-0.0724,...,-0.6686,-0.3585,0.1084]];

[0221] In this embodiment, the variational autoencoder Enc is regularized by applying a priori conditions to the distribution p(U). In order to make U obey the standard normal distribution, that is, U~N(0,1), a priori loss L is introduced. pri As follows: L pri =KL[q(U|X,S,Y)||p(U)];

[0222] The correlation coefficient HGR is introduced to evaluate the correlation between the sensitive feature S and the unobserved feature U, and the correlation loss L of the correlation coefficient HGR is defined hgr :

[0223] S22, construct the generator group and generate the reconstructed sample set and the synthetic sample set: According to the directed acyclic graph structure of the causal relationship graph, generate the feature H for each i Create an independent generator G i , i=1,…,17, and all generators are organized into a generator group G={G1,G2,…,G 17};

[0224] The generator groups are ordered according to the causal topology, where the causal graph is:

[0225] Node definition: S: Race is the root node and has no parent node; H1: Age is the root node and has no parent node; H2: Gender is the root node and has no parent node; H3: Poverty index is a non-root node and its parent nodes are race, age, and gender; H4: Red blood cell count is a non-root node and its parent nodes are race, age, gender, and poverty index; H5: Serum magnesium level is a non-root node and its parent nodes are race, age, gender, and poverty index; H6: Body mass index is a non-root node and its parent nodes are race, age, gender, and poverty index; H7: Serum cholesterol level is a non-root node and its parent nodes are race, age, gender, and poverty index; H8: Systolic blood pressure is a non-root node and its parent nodes are race, age, gender, and poverty index; H9: Diastolic blood pressure is a non-root node and its parent nodes are race, age, gender, and poverty index; 10 : Erythrocyte sedimentation rate is a non-root node, and its parent nodes are race, age, gender, and poverty index; H 11 : The number of white blood cells is a non-root node, and its parent nodes are race, age, gender, and poverty index; H 12 : Serum protein level is a non-root node, and its parent nodes are race, age, gender, and poverty index; H 13 : Pulse pressure is a non-root node, and its parent nodes are systolic pressure and diastolic pressure; H 14 : Iron binding capacity is a non-root node, and its parent nodes are race, age, gender, and poverty index; H 15 : Transferrin saturation is a non-root node, and its parent nodes are race, age, gender, and poverty index; H 16 : Serum ferritin level is a non-root node, and its parent nodes are race, age, gender, and poverty index; H 17 : Serum albumin level is a non-root node, and its parent nodes are race, age, gender, and poverty index; H 18: Survival status is a non-root node, and its parent nodes are race, age, sex, poverty index, red blood cell count, serum magnesium level, body mass index, serum cholesterol level, systolic blood pressure, diastolic blood pressure, erythrocyte sedimentation rate, white blood cell count, serum protein level, pulse pressure, iron binding capacity, transferrin saturation, serum ferritin level, and serum albumin level;

[0226] Race → Survival status,

[0227] Race → Poverty Index → ​​Survival

[0228] Race → Poverty Index → ​​Red Blood Cell Count → Survival Status,

[0229] Race → Poverty Index → ​​Serum Magnesium Level → Survival

[0230] Race → Poverty Index → ​​Body Mass Index → ​​Survival Status,

[0231] Race → Poverty Index → ​​Serum Cholesterol Level → Survival

[0232] Race → Poverty Index → ​​Systolic Blood Pressure → Survival,

[0233] Race → Poverty Index → ​​Diastolic Blood Pressure → Survival,

[0234] Race → Poverty Index → ​​Erythrocyte Sedimentation Rate → Survival,

[0235] Race → Poverty Index → ​​White Blood Cell Count → Survival Status,

[0236] Race → Poverty Index → ​​Serum Protein Level → Survival

[0237] Race → Poverty Index → ​​Systolic Blood Pressure → Pulse Pressure → Survival,

[0238] Race → Poverty Index → ​​Diastolic Blood Pressure → Pulse Pressure → Survival,

[0239] Race → Poverty Index → ​​Iron Binding Capacity → Survival

[0240] Race → Poverty Index → ​​Transferrin Saturation → Survival,

[0241] Race → Poverty Index → ​​Serum Ferritin Level → Survival,

[0242] Race → Poverty Index → ​​Serum Albumin Level → Survival

[0243] Age → survival,

[0244] Age → Poverty Index → ​​Survival Status,

[0245] Age → Poverty Index → ​​Red Blood Cell Count → Survival Status,

[0246] Age → Poverty Index → ​​Serum Magnesium Level → Survival,

[0247] Age → Poverty Index → ​​Body Mass Index → ​​Survival Status,

[0248] Age → Poverty Index → ​​Serum Cholesterol Level → Survival Status,

[0249] Age → Poverty Index → ​​Systolic Blood Pressure → Survival Status,

[0250] Age → Poverty Index → ​​Diastolic Blood Pressure → Survival Status,

[0251] Age → Poverty Index → ​​Erythrocyte Sedimentation Rate → Survival Status,

[0252] Age → Poverty Index → ​​White Blood Cell Count → Survival Status,

[0253] Age → Poverty Index → ​​Serum Protein Level → Survival Status,

[0254] Age → Poverty Index → ​​Systolic Blood Pressure → Pulse Pressure → Survival Status,

[0255] Age → Poverty Index → ​​Diastolic Blood Pressure → Pulse Pressure → Survival Status,

[0256] Age → Poverty Index → ​​Iron Binding Capacity → Survival Status,

[0257] Age → Poverty Index → ​​Transferrin Saturation → Survival Status,

[0258] Age → Poverty Index → ​​Serum Ferritin Level → Survival,

[0259] Age → Poverty Index → ​​Serum Albumin Level → Survival Status,

[0260] Gender → survival status,

[0261] Gender → Poverty Index → ​​Survival Status,

[0262] Gender → Poverty Index → ​​Red Blood Cell Count → Survival Status,

[0263] Gender → Poverty Index → ​​Serum Magnesium Level → Survival

[0264] Gender → Poverty Index → ​​Body Mass Index → ​​Survival Status,

[0265] Gender → Poverty Index → ​​Serum Cholesterol Level → Survival Status,

[0266] Gender → Poverty Index → ​​Systolic Blood Pressure → Survival Status,

[0267] Gender→Poverty Index→Diastolic Blood Pressure→Survival Status,

[0268] Gender → Poverty Index → ​​Erythrocyte Sedimentation Rate → Survival Status,

[0269] Gender → Poverty Index → ​​White Blood Cell Count → Survival Status,

[0270] Gender → Poverty Index → ​​Serum Protein Level → Survival Status,

[0271] Gender → Poverty Index → ​​Systolic Blood Pressure → Pulse Pressure → Survival Status,

[0272] Gender→Poverty Index→Diastolic Blood Pressure→Pulse Pressure→Survival Status,

[0273] Gender → Poverty Index → ​​Iron Binding Capacity → Survival

[0274] Gender → Poverty Index → ​​Transferrin Saturation → Survival Status,

[0275] Gender → Poverty Index → ​​Serum Ferritin Level → Survival Status,

[0276] Gender → poverty index → ​​serum albumin level → survival;

[0277] Corresponding generated feature H i The generator G i The input is the generated value of the parent node of the generated feature and the unobserved feature U, and the output is the generated value of the generated feature The generation process is as follows:

[0278] First, the root node is generated:

[0279] Although gender is the root node, race is a sensitive feature, and sensitive features are not generated by unobserved features. Therefore, gender does not need to be simulated by a generator;

[0280] Age H1 and gender H2 do not depend on other nodes, but only on unobserved features:

[0281] Non-root node generation:

[0282] Generation of poverty index H3:

[0283] Production of red blood cell count H4:

[0284] Serum magnesium levels H5 production:

[0285] Generation of body mass index H6:

[0286] Serum cholesterol levels H7 production:

[0287] Generation of Systolic Blood Pressure H8:

[0288] Generation of diastolic blood pressure H9:

[0289] Erythrocyte sedimentation rate H 10 Generation of:

[0290] White blood cell count H 11 Generation of:

[0291] Serum protein level H 12 Generation of:

[0292] Pulse pressure H 13 Generation of:

[0293] Iron binding capacity H 14 Generation of:

[0294] Transferrin saturation H 15 Generation of:

[0295] Serum ferritin level 16 Generation of:

[0296] Serum albumin level H 17 Generation of:

[0297] Survival status 18 Generation of:

[0298]

[0299] The sensitive features S and the unobserved features U inferred by the variational autoencoder are input into the generator group G, and the values ​​of the generated features are obtained in sequence according to the topological order until the values ​​of all generated features are generated, and finally the reconstructed sample set is output.

[0300] In order to ensure that the reconstructed samples are highly similar to the original input samples in distribution, the reconstruction loss L is defined as follows: rec :

[0301]

[0302] Among them, p(X,Y|U,S)=P(Y|,X,U,S)*P(X|U,S), P(Y|,X,U,S) describes the probability that the label feature Y is generated by the generator group under the conditions of the non-sensitive feature X, the unobserved feature U and the sensitive feature S, reflecting that the label feature Y is affected by the non-sensitive feature X and the sensitive feature S. P(X|U,S) describes the probability that the non-sensitive feature X is generated by the generator group under the conditions of the unobserved feature U and the sensitive feature S. The negative value of the log likelihood is used to measure the non-sensitive feature X, the label feature Y, and the reconstructed non-sensitive feature generated by the decoder. and label features similarity;

[0303] Sampling from the prior distribution N(0,1) of the unobserved feature U Sampling from the distribution P(S) of sensitive features S Exploiting sensitive features of sampling and unobserved characteristics Input the generator group G, and get the values ​​of the generated features in turn according to the topological order until the values ​​of all generated features are generated, and finally output the synthetic sample set

[0304] S23, build a discriminator: build a discriminator Dis, which is used to evaluate the generation quality of the generator group G and discriminate the generator G i Whether the generated data conforms to the characteristic distribution in the causal relationship graph and distinguishes real samples from false samples;

[0305] The sample set D = (S, X, Y), the reconstructed sample set and synthetic sample sets As the input of the discriminator Dis, the discriminant loss L is defined as follows GAN :

[0306]

[0307] in, It represents the expected logarithmic probability that the discriminator Dis judges the samples in the sample set D as "true", The discriminator Dis reconstructs the sample set The expected logarithmic probability that the sample in is judged to be "false", is the discriminator Dis for the synthetic sample set The expected logarithmic probability that the samples in are judged to be "false";

[0308] S24. Collaborative adversarial training: Perform end-to-end collaborative adversarial training on the variational autoencoder, generator group, and discriminator, and optimize them through the following overall objective function L:

[0309] The adversarial training process of the variational autoencoder, generator group, and discriminator is as follows:

[0310] Fixed variational autoencoder Enc and generator group G, update the discriminator Dis: update the discriminator parameters by gradient ascent to maximize the discriminant loss L GAN , improve the discriminator Dis for sample set D, reconstruct the sample set and synthetic sample sets ability to distinguish;

[0311] Fixed discriminator, update variational autoencoder Enc and generator group G: update parameters ω by gradient ascent u and ω s To maximize the correlation loss L hgr , update the parameters of the variational autoencoder and generator group by gradient descent to minimize the overall objective function L;

[0312] According to the adversarial training results, the optimal generator group G is obtained opt ={G 1,opt ,…,G 18,opt}、Optimal variational autoencoder Enc opt and the optimal discriminator Dis opt , where G i,opt represents the optimal generator for the i-th generated feature.

[0313] S3. Use the classifier to classify the sample set D, based on the classification loss J(θ,d) of sample d in the sample set D, and the j-th non-sensitive feature x of sample d. j ∈X, calculate the gradient Select the feature I∈X that needs intervention and the intervention value K I , using the optimal variational autoencoder Enc opt Extract unobserved features U from d and use the optimal generator group G opt Replace the value of the intervened feature I with K I , and generate the values ​​of all generated features in the causal topological order to obtain the intervention sample; determine whether the intervention sample is a counterfactual discrimination sample, and if so, put it into the global counterfactual discrimination sample set G CDS In the process, samples are selected from the sample set D and the process is repeated multiple times to obtain the global counterfactual discrimination sample set G CDS ;

[0314] S31. Sample d is obtained from the sample set D. The classification loss J(θ, d) on sample d is calculated using the classifier for the j-th non-sensitive feature x of sample d. j The gradient of ∈X The correlation between non-sensitive features and sensitive features is measured by determining whether the non-sensitive feature is a descendant node of the sensitive feature in the causal relationship graph. The following formula is defined to select intervention features:

[0315]

[0316] For the intervention feature I of sample d, the intervention value K I The calculation formula is as follows:

[0317] S32, intervene in the intervention feature I in the sample d to obtain the intervention sample d′, the process is as follows: use the optimal variational autoencoder Enc opt Extract the unobserved feature U of sample d, and input the sensitive feature S and unobserved feature U in sample d into the optimal generator group G opt ={G 1,opt ,…,G 18,opt}, the values ​​of the generated features are obtained in sequence according to the topological order until the values ​​of all generated features are generated;

[0318] S33, determine whether the intervention sample d′ is a counterfactual discrimination sample, that is, whether it satisfies the counterfactual discrimination condition, where the counterfactual discrimination condition is: input the intervention sample d′ into the optimal variational autoencoder Enc opt Extract the unobserved feature U and use the optimal generator group G opt Generate corresponding counterfactual samples for different values ​​of the sensitive feature S one by one. If the classification result of the classifier for the counterfactual sample is inconsistent with the classification result of d′, then the sample d′ is considered to meet the counterfactual discrimination condition;

[0319] If the intervention sample d′ is a counterfactual discrimination sample, then d′ is placed in the global counterfactual discrimination sample set G CDS Then, the next sample is selected from D to continue the above process; if the intervention sample d′ is not a counterfactual discrimination sample, the intervention feature of d′ is further calculated and the intervention operation is performed until one of the termination conditions is met: the preset maximum number of iterations is reached, and the sample generated by the current intervention is judged to be a counterfactual discrimination sample;

[0320] S34, repeat steps S31 to S33, and finally obtain the global counterfactual discrimination sample set G CDS .

[0321] S4. From the global counterfactual discrimination sample set G CDS Select samples, calculate the contribution of non-sensitive features of samples to the prediction results, and select features I and intervention values ​​K that require causal intervention I , optimal variational autoencoder Enc optExtract the unobserved feature U from the sample and replace the value of the intervention feature I with K I , using the optimal generator group G in causal topological order opt Generate the values ​​of all generated features to obtain intervention samples; determine whether the intervention samples are counterfactual discrimination samples, and if so, put them into the local counterfactual discrimination sample set L CDS Repeat this process multiple times to obtain the local counterfactual discrimination sample set L CDS ;

[0322] S41. From the global counterfactual discrimination sample set G CDS Select sample x from the sampling, and calculate the jth non-sensitive feature x in m j Contribution to the prediction results And calculate the correlation between non-sensitive features and sensitive features, and determine the probability that the j-th non-sensitive feature in m is selected as the intervention feature according to the following formula:

[0323]

[0324] S42. According to probability Select the intervention feature I from the non-sensitive features, and select the intervention gradient direction ξ from {-1,1} with a probability of [0.5,0.5], that is, ξ satisfies P(ξ=-1)=0.5 and P(ξ=1)=0.5. Calculate the intervention value of the intervention feature I for sample m according to the following formula: K I =m I +ξ*l s ;

[0325] S43. Intervene the intervention feature I of sample m to obtain the intervention sample m′, and determine whether m′ is a counterfactual discrimination sample. If m′ is a counterfactual discrimination sample, then put m′ into the local counterfactual discrimination sample set L CDS In the process, the intervention features and intervention values ​​of m′ are further calculated, and the intervention operation is performed until one of the termination conditions is met: the preset maximum number of iterations is reached, and the sample generated by the current intervention is not a counterfactual discrimination sample;

[0326] S44, repeat steps S41 to S43, and finally obtain the local counterfactual discrimination sample set L CDS .

[0327] S5. Generate sample set A CDS =G CDS ∪L CDS The generated samples in are input to the optimal variational autoencoder Enc opt Extract unobserved features and use the optimal generator group G opt ={G 1,opt ,…,G18,opt Generate corresponding counterfactual samples for each different value of the sensitive feature S, replace the label features of the counterfactual samples with the label features of the generated samples, and obtain the counterfactual fair dataset D that meets the fairness requirements cf ;

[0328] The global counterfactual discrimination sample set G CDS and the local counterfactual discrimination sample set L CDS Merge to generate sample set A CDS =G CDS ∪L CDS After that, A CDS Input optimal variational autoencoder Enc opt Extract the unobserved feature U and use the optimal generator group G opt ={G 1,opt ,…,G 18,opt For each sensitive feature S with different value sets {0, 1, 2}, generate corresponding counterfactual sample sets one by one: D c (0) = G opt (U,0), D c (1) = G opt (U,1);

[0329] Replace the label features of all counterfactual sample sets with the label features of the generated samples to generate counterfactual fair samples:

[0330] Merge all counterfactual fairness samples to obtain the counterfactual fairness dataset D that meets the fairness requirements. cf :

[0331] D cf =D c (0)∪D c (1)∪D c (2).

[0332] The present invention is compared with other algorithms, and the comparison indicators include classification performance indicators: classification accuracy ACC, F1 score F1-score; counterfactual fairness indicator: linear maximum mean difference MMD L , kernel maximum mean difference MMD K. The accuracy index ACC indicates whether the obtained classification result is consistent with the actual classification result. The higher the ACC, the better the classification effect. The F1 score F1-score is the harmonic mean of precision (Precision) and recall (Recall), which is used to comprehensively evaluate the performance of the classification model, especially in the case of class imbalance. It can better reflect the model's prediction performance for minority classes than the accuracy rate. The higher the F1-score, the better the classification effect. The maximum mean difference MMD is an indicator to measure the distribution difference between generated data and real data. It evaluates whether the generated data and the real data are similar in distribution by comparing different feature distributions. The smaller the MMD, the closer the generated data is to the real data in the overall feature distribution, thereby ensuring the authenticity of the data. Among them, the linear maximum mean difference MMD L The core idea is to calculate the mean difference between samples, the maximum mean difference (MMD) KMapping low-dimensional space to high-dimensional space allows for comparison of distribution differences in high-dimensional space. Table 3 examines the counterfactual fairness improvement and classification performance of the present invention's enhanced fairness for DNN classifiers on medical service data. Table 4 examines the counterfactual fairness improvement and classification performance of the present invention's enhanced fairness for ResNet classifiers on medical service data. The second row, UF, is a method that uses all observable features to train a supervised model without counterfactual fairness processing; the third row, Unaware, is a method proposed in the paper "The case for process fairness in learning: Feature selection for fair decision making" based on the concept of achieving fairness through imperceptibility, using all features except sensitive features to predict labels; the fourth row, Counterfactual fairness, is a method proposed in the paper "Counterfactual fairness", which removes sensitive features and their descendants and relies only on the remaining features to predict labels; the fifth row, CR, is a method proposed in the paper "Counterfactual Fairness in Text Classification through Robustness", which generates counterfactual samples from the original dataset and adds counterfactual fairness constraints during training to minimize the prediction difference between the original and counterfactual samples; the sixth row, Counterfactually fair representation, is a method proposed in the paper "Counterfactually fair representation", which aggregates counterfactual samples and original samples to create counterfactual fair representations and then uses them to train the predictor; the seventh row, Learning for Counterfactual Fairness from Observational The first line is the method proposed in the paper "Data" to learn fair representations by applying counterfactual fairness constraints, while using constant risk minimization to exclude non-causal variables with spurious and unstable correlations with the target; the last line is the method of the present invention. The comparison results are shown in Tables 3 and 4. It can be seen from the results in the tables that compared with other methods, the present invention significantly outperforms other methods in enhancing data classification fairness, ranking first and leading by a large number of suboptimal algorithms. At the same time, compared with the original model, the classification performance has been improved, and the accuracy (ACC) and F1 score (F1-score) are better than all other algorithms, verifying the effectiveness of the present invention.

[0333] Table 3. Comparison of the indicators of the disclosed method and the existing method for enhancing the DNN classifier on medical service data

[0334]

[0335] Table 4. Comparison of the indicators of the disclosed method and the existing method for enhancing the ResNet classifier on medical service data

[0336]

[0337]

[0338] Example 3

[0339] like Figure 4 As shown, this embodiment provides a data classification fairness enhancement device based on causal intervention, which includes: a data set generation module 401, a data generation model establishment module 402, a global counterfactual discrimination sample generation module 403, a local counterfactual discrimination sample generation module 404, and a counterfactual fairness sample generation module 405. The specific functions of each module are as follows:

[0340] The data classification fairness enhancement device based on causal intervention includes:

[0341] Dataset generation module 401, inputs recruitment screening or medical service training data D train , the training data D train Divided into non-sensitive features X, sensitive features S and label features Y, the non-sensitive features and label features are combined to represent H = (X, Y) and form the generated feature H, the non-sensitive features X, sensitive features S and label features Y are combined to represent the sample form D = (X, S, Y) and form the sample set D;

[0342] The data generation model building module 402 creates a variational autoencoder Enc to extract unobserved features U from the sample set D. The unobserved features U represent unobserved potential factors that may affect the generated features. For each feature in the generated features, an independent generator G is created. i ,i=1,…,|H|, all generators are grouped into a generator group G={G1,G2,…,G |H|}, where |H| represents the number of generated features. The generators in the generator group G are arranged in the topological order of the causal relationship graph. The causal relationship graph is a directed acyclic graph used to clarify the causal path and dependency relationship between each feature. Each node in the graph represents a feature in the sample set D. The directed edge in the graph represents the causal relationship between two features in the sample set D. For any directed edge e between the generated features in the graph, i →H j ), the corresponding generator arrangement satisfies G i In G jBefore; create a discriminator Dis; use the sample set D to perform collaborative adversarial training on the variational autoencoder Enc, the generator group G and the discriminator Dis to obtain the optimal generator group G opt ={G 1,opt ,G 2,opt ,…,G i,opt ,…,G |H|,opt}、Optimal variational autoencoder Enc opt and the optimal discriminator Dis opt , where G i,opt represents the optimal generator of the i-th generated feature;

[0343] The global counterfactual discrimination sample generation module 403 uses a classifier to classify the sample set D, and classifies the j-th non-sensitive feature x of sample d based on the classification loss J(θ,d) of sample d in the sample set D. j ∈X, calculate the gradient Select the feature I∈X that needs intervention and the intervention value K I , using the optimal variational autoencoder Enc opt Extract unobserved features U from d and use the optimal generator group G opt Replace the value of the intervened feature I with K I , and generate the values ​​of all generated features in the causal topological order to obtain the intervention sample; determine whether the intervention sample is a counterfactual discrimination sample, and if so, put it into the global counterfactual discrimination sample set G CDS In the process, samples are selected from the sample set D and the process is repeated multiple times to obtain the global counterfactual discrimination sample set G CDS ;

[0344] The local counterfactual discrimination sample generation module 404 generates the global counterfactual discrimination sample set G CDS Select samples, calculate the contribution of non-sensitive features of samples to the prediction results, and select features I and intervention values ​​K that require causal intervention I , optimal variational autoencoder Enc opt Extract the unobserved feature U from the sample and replace the value of the intervention feature I with K I , using the optimal generator group G in causal topological order opt Generate the values ​​of all generated features to obtain intervention samples; determine whether the intervention samples are counterfactual discrimination samples, and if so, put them into the local counterfactual discrimination sample set L CDS Repeat this process multiple times to obtain the local counterfactual discrimination sample set L CDS ;

[0345] The counterfactual fair sample generation module 405 generates a sample set A CDS =G CDS ∪L CDSThe generated samples in are input to the optimal variational autoencoder Enc opt Extract unobserved features and use the optimal generator group G opt For each different value of the sensitive feature S, a corresponding counterfactual sample is generated, and the label feature of the counterfactual sample is replaced with the label feature of the generated sample to obtain a counterfactual fair dataset D that meets the fairness requirements. cf .

[0346] Example 4

[0347] This embodiment provides an electronic device, which may be a computer, such as Figure 5 As shown, a processor 502, a memory, an input device 503, a display 504, and a network interface 505 are connected via a system bus 501. The processor is used to provide computing and control capabilities. The memory includes a non-volatile storage medium 506 and an internal memory 507. The non-volatile storage medium 506 stores an operating system, a computer program, and a database. The internal memory 507 provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. When the processor 502 executes the computer program stored in the memory, a data classification fairness enhancement method based on causal intervention proposed in the above embodiment 1 is implemented. The data classification fairness enhancement method based on causal intervention includes the following steps:

[0348] S1. Input recruitment screening or medical service training data D train , the training data D train Divided into non-sensitive features X, sensitive features S and label features Y, forming generated features H and sample set D;

[0349] S2. Create a variational autoencoder Enc to extract unobserved features U from the sample set D; create an independent generator G for each feature in the generated features i , i=1,…,|H|, each generator in the generator group G is arranged in the topological order of the causal relationship graph. The causal relationship graph is a directed acyclic graph, which is used to clarify the causal path and dependency relationship between each feature. Each node in the graph represents a feature in the sample set D, and the directed edge in the graph represents the causal relationship between two features in the sample set D. For any directed edge e=(H i →H j ), the corresponding generator arrangement satisfies G i In G j Before; create a discriminator Dis; use the sample set D to perform collaborative adversarial training on the variational autoencoder Enc, the generator group G and the discriminator Dis to obtain the optimal generator group G opt , optimal variational autoencoder Enc opt and the optimal discriminator Disopt ;

[0350] S3. Use the classifier to classify the sample set D, based on the classification loss J(θ,d) of sample d in the sample set D, and the j-th non-sensitive feature x of sample d. j ∈X, calculate the gradient Select the feature I∈X that needs intervention and the intervention value K I , using the optimal variational autoencoder Enc opt Extract unobserved features U from d and use the optimal generator group G opt Replace the value of the intervened feature I with K I , and generate the values ​​of all generated features in the causal topological order to obtain the intervention sample; determine whether the intervention sample is a counterfactual discrimination sample, and if so, put it into the global counterfactual discrimination sample set G CDS In the process, samples are selected from the sample set D and the process is repeated multiple times to obtain the global counterfactual discrimination sample set G CDS ;

[0351] S4. From the global counterfactual discrimination sample set G CDS Select samples, calculate the contribution of non-sensitive features of samples to the prediction results, and select features I and intervention values ​​K that require causal intervention I , optimal variational autoencoder Enc opt Extract the unobserved feature U from the sample and replace the value of the intervention feature I with K I , using the optimal generator group G in causal topological order opt Generate the values ​​of all generated features to obtain intervention samples; determine whether the intervention samples are counterfactual discrimination samples, and if so, put them into the local counterfactual discrimination sample set L CDS Repeat this process multiple times to obtain the local counterfactual discrimination sample set L CDS ;

[0352] S5. Generate sample set A CDS =G CDS ∪L CDS The generated samples in are input to the optimal variational autoencoder Enc opt Extract unobserved features and use the optimal generator group G opt For each different value of the sensitive feature S, a corresponding counterfactual sample is generated, and the label feature of the counterfactual sample is replaced with the label feature of the generated sample to obtain a counterfactual fair dataset D that meets the fairness requirements. cf .

[0353] Example 5

[0354] This embodiment provides a storage medium, which is a computer-readable storage medium and stores a computer program. When the computer program is executed by a processor, the method for enhancing fairness in data classification based on causal intervention described in the first embodiment is implemented. The method for enhancing fairness in data classification based on causal intervention includes the following steps:

[0355] S1. Input recruitment screening or medical service training data D train , the training data D train Divided into non-sensitive features X, sensitive features S and label features Y, forming generated features H and sample set D;

[0356] S2. Create a variational autoencoder Enc to extract unobserved features U from the sample set D; create an independent generator G for each feature in the generated features i , i=1,…,|H|, each generator in the generator group G is arranged in the topological order of the causal relationship graph. The causal relationship graph is a directed acyclic graph, which is used to clarify the causal path and dependency relationship between each feature. Each node in the graph represents a feature in the sample set D, and the directed edge in the graph represents the causal relationship between two features in the sample set D. For any directed edge e=(H i →H j ), the corresponding generator arrangement satisfies G i In G j Before; create a discriminator Dis; use the sample set D to perform collaborative adversarial training on the variational autoencoder Enc, the generator group G and the discriminator Dis to obtain the optimal generator group G opt , optimal variational autoencoder Enc opt and the optimal discriminator Dis opt ;

[0357] S3. Use the classifier to classify the sample set D, based on the classification loss J(θ,d) of sample d in the sample set D, and the j-th non-sensitive feature x of sample d. j ∈X, calculate the gradient Select the feature I∈X that needs intervention and the intervention value K I , using the optimal variational autoencoder Enc opt Extract unobserved features U from d and use the optimal generator group G opt Replace the value of the intervened feature I with K I , and generate the values ​​of all generated features in the causal topological order to obtain the intervention sample; determine whether the intervention sample is a counterfactual discrimination sample, and if so, put it into the global counterfactual discrimination sample set G CDS In the process, samples are selected from the sample set D and the process is repeated multiple times to obtain the global counterfactual discrimination sample set G CDS ;

[0358] S4. From the global counterfactual discrimination sample set G CDS Select samples, calculate the contribution of non-sensitive features of samples to the prediction results, and select features I and intervention values ​​K that require causal intervention I , optimal variational autoencoder Enc opt Extract the unobserved feature U from the sample and replace the value of the intervention feature I with K I , using the optimal generator group G in causal topological order opt Generate the values ​​of all generated features to obtain intervention samples; determine whether the intervention samples are counterfactual discrimination samples, and if so, put them into the local counterfactual discrimination sample set L CDS Repeat this process multiple times to obtain the local counterfactual discrimination sample set L CDS ;

[0359] S5. Generate sample set A CDS =G CDS ∪L CDS The generated samples in are input to the optimal variational autoencoder Enc opt Extract unobserved features and use the optimal generator group G opt For each different value of the sensitive feature S, a corresponding counterfactual sample is generated, and the label feature of the counterfactual sample is replaced with the label feature of the generated sample to obtain a counterfactual fair dataset D that meets the fairness requirements. cf .

[0360] The technical features of the above embodiments can be combined arbitrarily. In order to make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0361] The above embodiments are preferred implementations of the present invention, but the implementations of the present invention are not limited to the above embodiments. Any other changes, modifications, substitutions, combinations, and simplifications that do not deviate from the spirit and principles of the present invention should be considered equivalent replacement methods and are included in the scope of protection of the present invention.

Claims

1. A data classification fairness enhancement method based on causal intervention, characterized in that: The data classification fairness enhancement method comprises the following steps: S1. Input recruitment screening or medical service training data D train , the training data D train Divided into non-sensitive features X, sensitive features S and label features Y, the non-sensitive features and label features are combined to represent H = (X, Y) and form the generated feature H, the non-sensitive features X, sensitive features S and label features Y are combined to represent the sample form D = (X, S, Y) and form the sample set D; S2. Create a variational autoencoder Enc to extract unobserved features U from the sample set D. The unobserved features U represent unobserved potential factors that may affect the generated features. Create an independent generator G for each feature in the generated features. i ,i=1,…,|H|, all generators are grouped into a generator group G={G1,G2,…,G |H| }, where |H| represents the number of generated features. The generators in the generator group G are arranged in the topological order of the causal relationship graph. The causal relationship graph is a directed acyclic graph used to clarify the causal path and dependency relationship between each feature. Each node in the graph represents a feature in the sample set D. The directed edge in the graph represents the causal relationship between two features in the sample set D. For any directed edge e between the generated features in the graph, i →H j ), the corresponding generator arrangement satisfies G i In G j Before; create a discriminator Dis; use the sample set D to perform collaborative adversarial training on the variational autoencoder Enc, the generator group G and the discriminator Dis to obtain the optimal generator group G opt ={G 1,opt ,G 2,opt ,…,G i,opt ,…,G |H|,opt }、Optimal variational autoencoder Enc opt and the optimal discriminator Dis opt , where G i,opt represents the optimal generator of the i-th generated feature; S3. Use the classifier to classify the sample set D, based on the classification loss J(θ,d) of sample d in the sample set D, and the j-th non-sensitive feature x of sample d. j ∈X, calculate the gradient Select the feature I∈X that needs intervention and the intervention value K I , using the optimal variational autoencoder Enc opt Extract unobserved features U from d and use the optimal generator group G opt Replace the value of the intervened feature I with K I , and generate the values ​​of all generated features in the causal topological order to obtain the intervention sample; determine whether the intervention sample is a counterfactual discrimination sample, and if so, put it into the global counterfactual discrimination sample set G CDS In the process, samples are selected from the sample set D and the process is repeated multiple times to obtain the global counterfactual discrimination sample set G CDS ; S4. From the global counterfactual discrimination sample set G CDS Select samples, calculate the contribution of non-sensitive features of samples to the prediction results, and select features I and intervention values ​​K that require causal intervention I , optimal variational autoencoder Enc opt Extract the unobserved feature U from the sample and replace the value of the intervention feature I with K I , using the optimal generator group G in causal topological order opt Generate the values ​​of all generated features to obtain intervention samples; determine whether the intervention samples are counterfactual discrimination samples, and if so, put them into the local counterfactual discrimination sample set L CDS Repeat this process multiple times to obtain the local counterfactual discrimination sample set L CDS ; S5. Generate sample set A CDS =G CDS ∪L CDS The generated samples in are input to the optimal variational autoencoder Enc opt Extract unobserved features and use the optimal generator group G opt For each different value of the sensitive feature S, a corresponding counterfactual sample is generated, and the label feature of the counterfactual sample is replaced with the label feature of the generated sample to obtain a counterfactual fair dataset D that meets the fairness requirements. cf .

2. The data classification fairness enhancement method based on causal intervention according to claim 1 is characterized in that: The process of step S1 is as follows: The training data set D train The non-sensitive feature X is represented as a numerical matrix of dimension n×m Where n is the number of samples, and m is the feature dimension of each sample; The training data set D train The sensitive feature S is represented as a numerical matrix of dimension n×q Where q is the dimension of the sensitive feature S; The training data set D train The label feature Y is represented as a vector of dimension n×1 The vector elements take values ​​of 0 or 1, where a value of 0 indicates disagreement with recruitment screening or disagreement with priority treatment, and a value of 1 indicates agreement with recruitment screening or agreement with priority treatment; The non-sensitive feature X, the sensitive feature S and the corresponding label feature Y are merged to form a sample set D, and the non-sensitive feature X and the label feature Y are merged to form a generated feature H.

3. The data classification fairness enhancement method based on causal intervention according to claim 1 is characterized in that: The process of step S2 is as follows: S21. Construct and regularize a variational autoencoder: Based on the given causal relationship graph, a variational autoencoder Enc is constructed. The variational autoencoder Enc contains only one encoder, which takes the non-sensitive feature X, sensitive feature S and label feature Y in the sample set D as input, and maps the input to the mean μ and logarithmic variance logσ of the unobserved feature U. 2 In the space of , the unobserved feature U is constructed according to the following formula: U = μ + δ*∈, where δ = exp(0.5*logσ 2 ), ∈ is the random noise sampled from the standard normal distribution N(0,1); By imposing a priori conditions on the distribution p(U), the above variational autoencoder ENc is regularized. In order to make U obey the standard normal distribution, that is, U~N(0,1), the prior loss L is introduced pri as follows: L pri =KL[q(U|X,S,Y)||p(U)] Among them, KL[·||·] represents the Kullback-Leibler divergence between the two distributions, which is used to measure the difference between the unobserved feature distribution q(U|X,S,Y) generated by the variational autoencoder and the prior distribution p(U) of the unobserved feature U. The correlation coefficient HGR is introduced to evaluate the correlation between the sensitive feature S and the unobserved feature U, and the correlation loss L of the correlation coefficient HGR is defined. hgr : in, and Respectively represent the nonlinear transformation function after standardization of the unobserved feature U and the sensitive feature S, ω u and ω s are the corresponding optimizable parameters, which are used to adjust the mapping function to maximize the correlation loss L hgr , Represents the optimizable parameter ω u and ω s Take the maximum value to maximize the expected product of the unobserved feature U and the sensitive feature S after nonlinear transformation; S22, construct the generator group and generate the reconstructed sample set and the synthetic sample set: According to the directed acyclic graph structure of the causal relationship graph, generate the feature H for each i Create an independent generator G i , i=1,…,|H|, and all generators are organized into a generator group G={G1,G2,…,G |H| }, where |H| represents the number of generated features, corresponding to the generated feature H i The generator G i The input is the generated value of the parent node of the generated feature and the unobserved feature U, and the output is the generated value of the generated feature The generation process is as follows: Among them G i () represents the generator G i The generating operation function, Indicates H i The generated values ​​of all parent nodes in the causal graph; The sensitive features S and the unobserved features U inferred by the variational autoencoder are input into the generator group G, and the values ​​of the generated features are obtained in sequence according to the topological order until the values ​​of all generated features are generated, and finally the reconstructed sample set is output. in and Represents the non-sensitive features and label features generated by the generator group based on S and U. In order to ensure that the reconstructed samples are highly similar to the original input samples in distribution, the reconstruction loss L is defined as follows: rec : Among them, p(X,Y|U,S)=P(Y|,X,U,S)*P(X|U,S), P(Y|,X,U,S) describes the probability that the label feature Y is generated by the generator group under the conditions of the non-sensitive feature X, the unobserved feature U and the sensitive feature S, reflecting that the label feature Y is affected by the non-sensitive feature X and the sensitive feature S. P(X|U,S) describes the probability that the non-sensitive feature X is generated by the generator group under the conditions of the unobserved feature U and the sensitive feature S. The negative value of the log likelihood is used to measure the non-sensitive feature X, the label feature Y, and the reconstructed non-sensitive feature generated by the decoder. and label features similarity; Sampling from the prior distribution N(0,1) of the unobserved feature U Sampling from the distribution P(S) of sensitive features S Exploiting sensitive features of sampling and unobserved characteristics Input the generator group G, and get the values ​​of the generated features in turn according to the topological order until the values ​​of all generated features are generated, and finally output the synthetic sample set in and Indicates based on and Use non-sensitive features and label features generated by the generator group; S23, build a discriminator: build a discriminator Dis, which is used to evaluate the generation quality of the generator group G and discriminate the generator G i Whether the generated data conforms to the characteristic distribution in the causal relationship graph and distinguishes real samples from false samples; The sample set D = (S, X, Y), the reconstructed sample set and synthetic sample sets As the input of the discriminator Dis, the discriminant loss L is defined as follows GAN : in, It represents the expected logarithmic probability that the discriminator Dis judges the samples in the sample set D as "true", The discriminator Dis reconstructs the sample set The expected logarithmic probability that the sample in is judged to be "false", is the discriminator Dis for the synthetic sample set The expected logarithmic probability that the samples in are judged to be "false"; S24. Collaborative adversarial training: Perform end-to-end collaborative adversarial training on the variational autoencoder, generator group, and discriminator, and optimize them through the following overall objective function L: The adversarial training process of the variational autoencoder, generator group, and discriminator is as follows: Fixed variational autoencoder Enc and generator group G, update the discriminator Dis: update the discriminator parameters by gradient ascent to maximize the discriminant loss L GAN , improve the discriminator Dis for sample set D, reconstruct the sample set and synthetic sample sets ability to distinguish; Fixed discriminator, update variational autoencoder Enc and generator group G: update parameters ω by gradient ascent u and ω s To maximize the correlation loss L hgr , update the parameters of the variational autoencoder and generator group by gradient descent to minimize the overall objective function L; According to the adversarial training results, the optimal generator group G is obtained opt ={G 1,opt ,G 2,opt ,…,G i,opt ,…,G |H|,opt }、Optimal variational autoencoder Enc opt and the optimal discriminator Dis opt , where G i,opt represents the optimal generator for the i-th generated feature.

4. The data classification fairness enhancement method based on causal intervention according to claim 1 is characterized in that: The process of step S3 is as follows: S31. Sample d is obtained from the sample set D. The classification loss J(θ, d) on sample d is calculated using the classifier for the j-th non-sensitive feature x of sample d. j The gradient of ∈X The correlation between non-sensitive features and sensitive features is measured by determining whether the non-sensitive feature is a descendant node of the sensitive feature in the causal relationship graph. The following formula is defined to select intervention features: Where |X| represents the number of non-sensitive features, r(x j ,S) represents the jth non-sensitive feature x j The degree of association between the sensitive feature S and De(S) represents the set of descendant nodes of the sensitive feature S, and rank(x j ,De(S)) represents the non-sensitive feature x j The ranking in the descendant node set of S, I represents the intervention feature, for the intervention feature I of sample d, the intervention value K I The calculation formula is as follows: where d I is the original observation value of intervention feature I in sample d, K I Represents the intervention value of the intervention feature I, that is, in the causal intervention process, the value of the intervention feature I will be changed from d I Replace with K I , g s It is a set hyperparameter used to adjust the feature intervention intensity when generating global counterfactual discrimination samples. Represents the gradient of the classification loss J(θ,d) to the intervention feature I of sample d, sign() is the sign function, when When is a positive number, Output +1, otherwise -1, used to determine the intervention direction; S32. Intervene the intervention feature I in sample d to obtain intervention sample d ′ , the process is as follows: Use the optimal variational autoencoder Enc opt Extract the unobserved feature U of sample d, and input the sensitive feature S and unobserved feature U in sample d into the optimal generator group G opt In the process of intervening feature I, the values ​​of the generated features are obtained in turn according to the topological order until the values ​​of all generated features are generated. Replaced by Among them G I,opt represents the optimal generator corresponding to the intervention feature I, Represents the generated value of the parent node of I in the causal relationship graph; S33, judge the intervention sample d ′ Is it a counterfactual discrimination sample, that is, whether it meets the counterfactual discrimination condition, where the counterfactual discrimination condition is: the intervention sample d ′ Input optimal variational autoencoder Enc opt Extract the unobserved feature U and use the optimal generator group G opt Generate corresponding counterfactual samples for different values ​​of sensitive feature S one by one. If the classification result of the classifier for the counterfactual sample is different from that for d ′ The classification results are inconsistent, then it is considered that sample d ′ satisfying the counterfactual discrimination condition; If the intervention sample d ′ For counterfactual discrimination samples, d ′ Put into the global counterfactual discrimination sample set G CDS Then select the next sample from D and continue the above process; if the intervention sample d ′ If it is not a counterfactual discrimination sample, then further calculate d ′ The intervention feature is set and the intervention operation is performed until one of the termination conditions is met: the preset maximum number of iterations is reached, and the sample generated by the current intervention is judged to be a counterfactual discrimination sample; S34, repeat steps S31 to S33, and finally obtain the global counterfactual discrimination sample set G CDS .

5. The data classification fairness enhancement method based on causal intervention according to claim 1 is characterized in that: The process of step S4 is as follows: S41. From the global counterfactual discrimination sample set G CDS Sample m is sampled from the dataset, and the jth non-sensitive feature x in m is calculated. j Contribution to the prediction results And calculate the correlation between non-sensitive features and sensitive features, and determine the probability that the j-th non-sensitive feature in m is selected as the intervention feature according to the following formula: where x t Represents all features in non-sensitive feature X; S42. According to probability Select the intervention feature I from the non-sensitive features, and select the intervention gradient direction ξ from {-1,1} with a probability of [0.5,0.5], that is, ξ satisfies P(ξ=-1)=0.5 and P(ξ=1)=0.

5. Calculate the intervention value of the intervention feature I for sample m according to the following formula: K I =m I +ξ*l s where l s It is a hyperparameter used to adjust the feature intervention strength when generating local counterfactual discrimination samples, and is used to adjust the feature intervention strength when generating local counterfactual discrimination samples; S43. Intervene the intervention feature I of sample m to obtain intervention sample m ′ , judge m ′ Is it a counterfactual discrimination sample? If m ′ is a counterfactual discrimination sample, then m ′ Put the local counterfactual discrimination sample set L CDS and further calculate m ′ The intervention operation is performed until one of the termination conditions is met: the preset maximum number of iterations is reached, and the sample generated by the current intervention is not a counterfactual discrimination sample; S44, repeat steps S41 to S43, and finally obtain the local counterfactual discrimination sample set L CDS .

6. The data classification fairness enhancement method based on causal intervention according to claim 1 is characterized in that: The process of step S5 is as follows: The global counterfactual discrimination sample set G CDS and the local counterfactual discrimination sample set L CDS Merge to generate sample set A CDS =G CDS ∪L CDS , A CDS Generated sample input optimal variational autoencoder Enc opt Extract the unobserved feature U and use the optimal generator group G opt For each sensitive feature S, different value sets {s1,s2,…,s r ,…,s q }, generate the corresponding counterfactual sample sets one by one: D c (s r )=G opt (U,s r ) Among them D c (s r ) indicates that the sensitive feature S takes the value of s r The sample set generated when s1,s2,…,s r ,…,s q is q different values ​​of the sensitive feature S. The label features of all counterfactual sample sets are replaced with the label features of the generated samples, and the correction preprocessing is performed according to the following formula: where d r,y Indicates D c (s r ) in sample d r The label feature, y is A CDS Generate the label features of the samples in , merge all the counterfactual fair samples to obtain the counterfactual fair dataset D that meets the fairness requirements cf :

7. A data classification fairness enhancement device based on causal intervention, used to implement the data classification fairness enhancement method based on causal intervention according to any one of claims 1 to 6, characterized in that: The data classification fairness enhancement device includes: Dataset generation module, input recruitment screening or medical service training data D train , the training data D train Divided into non-sensitive features X, sensitive features S and label features Y, the non-sensitive features and label features are combined to represent H = (X, Y) and form the generated feature H, the non-sensitive features X, sensitive features S and label features Y are combined to represent the sample form D = (X, S, Y) and form the sample set D; The data generation model establishment module creates a variational autoencoder Enc to extract unobserved features U from the sample set D. The unobserved features U represent unobserved potential factors that may affect the generated features; for each feature in the generated features, an independent generator G is created. i ,i=1,…,|H|, all generators are grouped into a generator group G={G1,G2,…,G |H| }, where |H| represents the number of generated features. The generators in the generator group G are arranged in the topological order of the causal relationship graph. The causal relationship graph is a directed acyclic graph used to clarify the causal path and dependency relationship between each feature. Each node in the graph represents a feature in the sample set D. The directed edge in the graph represents the causal relationship between two features in the sample set D. For any directed edge e between the generated features in the graph, i →H j ), the corresponding generator arrangement satisfies G i In G j Before; create a discriminator Dis; use the sample set D to perform collaborative adversarial training on the variational autoencoder Enc, the generator group G and the discriminator Dis to obtain the optimal generator group G opt ={G 1,opt ,G 2,opt ,…,G i,opt ,…,G |H|,opt }、Optimal variational autoencoder Enc opt and the optimal discriminator Dis opt , where G i,opt represents the optimal generator of the i-th generated feature; The global counterfactual discrimination sample generation module uses a classifier to classify the sample set D, and classifies the j-th non-sensitive feature x of sample d based on the classification loss J(θ,d) of sample d in the sample set D. j ∈X, calculate the gradient Select the feature I∈X that needs intervention and the intervention value K I , using the optimal variational autoencoder Enc opt Extract unobserved features U from d and use the optimal generator group G opt Replace the value of the intervened feature I with K I , and generate the values ​​of all generated features in the causal topological order to obtain the intervention sample; determine whether the intervention sample is a counterfactual discrimination sample, and if so, put it into the global counterfactual discrimination sample set G CDS In the process, samples are selected from the sample set D and the process is repeated multiple times to obtain the global counterfactual discrimination sample set G CDS ; The local counterfactual discrimination sample generation module is generated from the global counterfactual discrimination sample set G CDS Select samples, calculate the contribution of non-sensitive features of samples to the prediction results, and select features I and intervention values ​​K that require causal intervention I , optimal variational autoencoder Enc opt Extract the unobserved feature U from the sample and replace the value of the intervention feature I with K I , using the optimal generator group G in causal topological order opt Generate the values ​​of all generated features to obtain intervention samples; determine whether the intervention samples are counterfactual discrimination samples, and if so, put them into the local counterfactual discrimination sample set L CDS Repeat this process multiple times to obtain the local counterfactual discrimination sample set L CDS ; The counterfactual fair sample generation module will generate a sample set A CDS =G CDS ∪L CDS The generated samples in are input to the optimal variational autoencoder Enc opt Extract unobserved features and use the optimal generator group G opt For each different value of the sensitive feature S, a corresponding counterfactual sample is generated, and the label feature of the counterfactual sample is replaced with the label feature of the generated sample to obtain a counterfactual fair dataset D that meets the fairness requirements. cf .

8. An electronic device comprising a processor and a memory for storing a program executable by the processor, characterized in that: When the processor executes the program stored in the memory, it implements the data classification fairness enhancement method based on causal intervention described in any one of claims 1 to 6.

9. A storage medium storing a program, characterized in that: When the program is executed by a processor, the data classification fairness enhancement method based on causal intervention described in any one of claims 1 to 6 is implemented.

Citation Information

Cited By

  • Interaction quantity causal contribution prediction method and device, and storage medium

    CN121685017A

  • Landscape space environment quality evaluation method and system based on neural network

    CN122047513A