Counterfactual fairness prediction model training method, prediction method and device
By generating partial directed acyclic graphs and training tendency score models and causal effect models, and combining the minimum-maximum joint learning algorithm to alternately train the model, the problem that causal DAG cannot be obtained in the existing technology is solved, and a prediction model training that satisfies counterfactual fairness without reducing the prediction accuracy is achieved.
Patent Information
- Application Number
- CN202311236303.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-22
- Publication Date
- 2025-03-25
- Estimated Expiration
- 2043-09-22
AI Technical Summary
The prior art requires real causal directed acyclic graphs (DAGs) when achieving counterfactual fairness, but in practice it is usually impossible to obtain real causal DAGs directly, and the Fair and FairRelax algorithms prohibit all definite descendants when training prediction models, resulting in very limited attributes available for prediction, significantly reducing the accuracy of predictions.
By obtaining the training data set, a partially directed acyclic graph (PDAG) is generated, the properties that may affect sensitive attributes are found, multiple possible parent node sets of sensitive attributes are generated, the propensity score model and causal effect model are trained, and the causal effect model is alternately trained with the minimum-maximum joint learning algorithm to satisfy the predictive model of counterfactual fairness.
In the case where the real causal graph is unknown, counterfactual fairness can be achieved under the premise of ensuring prediction accuracy, and make full use of all attributes of the sample, including descendants with clear sensitive attributes, improving the accuracy and fairness of the prediction.
Smart Images

Figure CN117610398B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of machine learning algorithms, and in particular to a prediction model training method, a prediction method and a device thereof for counterfactual fairness based on a partial directed acyclic graph. Background Art
[0002] Making machine learning algorithms fair is crucial for making safe and trustworthy decisions for subgroups or individuals with different sensitive attributes (e.g., gender, etc.). To achieve fair predictions, previous studies have proposed association-based and causality-based fairness concepts. Specifically, association-based fairness studies the statistical independence between sensitive attributes and prediction results, while causality-based subgroup fairness restricts the causal influence of sensitive attributes on prediction results.
[0003] Among the above fairness concepts, counterfactual fairness takes into account the causal effects within a specific individual or group, requiring that the predicted results should be the same in the counterfactual world without intervention in the real world and in the counterfactual world with intervention on sensitive attributes. Although many algorithms have been developed to achieve counterfactual fairness, most of them require that the true causal directed acyclic graph (DAG) is completely known. However, in practice, the true causal DAG and structural equations are usually not directly accessible. In addition, without strong assumptions (such as linearity and additive noise), it is usually impossible to recover the true causal DAG from only observed data.
[0004] To address the above problem of the unavailability of the true causal DAG, a recent study proposed a method that uses observational data to first classify observed variables into three categories: explicit non-descendants, possible descendants, and explicit descendants, which are for sensitive attributes. Next, by noting that if the prediction is a function of the non-descendants of the sensitive attribute, the prediction will be fair in the counterfactual case, two algorithms for achieving counterfactual fairness are proposed: Fair (prediction using explicit non-descendant nodes) and FairRelax (further combining possible descendants for prediction).
[0005] Although this is theoretically sound, both Fair and FairRelax prohibit all determined descendants when training the prediction model, resulting in very limited attributes that can be used to make predictions, which may significantly reduce the accuracy of predictions. In particular, sensitive attributes are often inherent to the data, so many attributes are their descendants. Overall, both Fair and FairRelax algorithms do not fully utilize these attributes, which hurts prediction performance and leads to inaccurate prediction results. The FairRelax algorithm uses possible descendants to predict the results without imposing any fairness constraints, and is unable to achieve counterfactual fairness by offsetting the impact of sensitive attributes on the results. Summary of the invention
[0006] In view of this, an embodiment of the present invention provides a prediction model training method, a prediction method and a device thereof for counterfactual fairness to eliminate or improve one or more defects existing in the prior art.
[0007] One aspect of the present invention provides a method for training a prediction model of counterfactual fairness, the method comprising the following steps:
[0008] Obtain a training data set, wherein the training data set includes a plurality of samples, each sample includes a plurality of attributes including a sensitive attribute and a corresponding observation result as a label;
[0009] Generate a partial directed acyclic graph based on the attributes as nodes and the observation results, search for attributes that may affect the sensitive attribute from the partial directed acyclic graph, and generate multiple possible parent node sets of the sensitive attribute based on the search results;
[0010] Based on each possible parent node set, a corresponding preset propensity score model is trained, wherein the propensity score model is used to output a propensity score estimate of the possible parent node set for a sensitive attribute value of a sample;
[0011] Training a corresponding preset causal effect model based on each propensity score estimate and the corresponding prediction result, wherein the causal effect model is used to output an estimate of the causal effect of the sensitive attribute on the prediction result;
[0012] A preset prediction model is trained based on all causal effect estimation values, and the causal effect model and the prediction model are alternately trained in combination with a minimum-maximum joint learning algorithm, so that a prediction model that satisfies counterfactual fairness is used as a trained fair prediction model.
[0013] In some embodiments of the present invention, the steps of generating a partial directed acyclic graph based on the attributes as nodes and the observation results, searching the partial directed acyclic graph for attributes that may affect the sensitive attribute, and generating a plurality of possible parent node sets of the sensitive attribute based on the search results include:
[0014] Using a causal discovery algorithm to learn the training data set to generate a complete partial directed acyclic graph;
[0015] Using a local learning algorithm to find the attribute in the complete partial directed acyclic graph that may affect the sensitive attribute;
[0016] The attributes that may affect the sensitive attribute are arranged and combined. If the arrangement and combination does not introduce a new collision structure or the induced subgraph is a complete graph, the arrangement and combination is determined to be a possible parent node set of the sensitive attribute.
[0017] In some embodiments of the present invention, in the step of training a corresponding preset propensity score model based on each possible parent node set, the sensitive attribute is fitted by the attributes in each of the possible parent node sets, and the corresponding propensity score model is trained by minimizing the cross entropy loss.
[0018] In some embodiments of the present invention, in the step of training a corresponding preset causal effect model based on each propensity score estimate and the corresponding prediction result, wherein the causal effect model is used to output the causal effect estimate of the sensitive attribute on the prediction result, an unbiased estimate of the causal effect of the corresponding sensitive attribute on the prediction result is obtained by performing inverse probability weighting on the propensity score estimate of the sensitive attribute value of the sample for each possible parent node set.
[0019] In some embodiments of the present invention, in the step of training a corresponding preset causal effect model based on each propensity score estimate and the corresponding prediction result, the corresponding causal effect model is trained by minimizing the target loss.
[0020] In some embodiments of the present invention, in the step of training a preset prediction model based on all causal effect estimates, alternately training the causal effect model and the prediction model in combination with a minimum-maximum joint learning algorithm to use a prediction model that satisfies counterfactual fairness as a trained fair prediction model, the prediction model is trained by minimizing the average prediction error based on the causal effect estimate of the prediction result of each sample, and taking the counterfactual fairness violation when the causal effect estimate is maximum as a penalty item, and obtaining a prediction model that satisfies counterfactual fairness through a continuous updating and iterative process.
[0021] In some embodiments of the present invention, the observation results include: the result of whether the job is hired or the grades are qualified when at least one of the attributes of the person's physical health, gender, age and education level is changed;
[0022] The sensitive attributes include: at least one of the attributes of a person's physical health, gender, age, and education level.
[0023] Another aspect of the present invention provides a method for predicting counterfactual fairness, the method comprising the following steps:
[0024] Acquire a test data set, where the test data set includes multiple samples, and each sample includes multiple attributes including sensitive attributes;
[0025] The test data set is input into a prediction model trained by the prediction model training method as described above, and the prediction model is used to output a prediction result that satisfies counterfactual fairness.
[0026] Another aspect of the present invention provides a prediction model training device for counterfactual fairness, which includes: a computer device, the computer device includes a processor and a memory, the memory stores computer instructions, the processor is used to execute the computer instructions stored in the memory, and when the computer instructions are executed by the processor, the device implements the steps of the prediction model training method as described above.
[0027] Another aspect of the present invention provides a device for predicting counterfactual fairness, which includes: a computer device, the computer device includes a processor and a memory, the memory stores computer instructions, the processor is used to execute the computer instructions stored in the memory, and when the computer instructions are executed by the processor, the device implements the steps of the prediction method described above.
[0028] Another aspect of the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the prediction model training method and prediction method for counterfactual fairness as described above.
[0029] The prediction model training method, prediction method and device of the counterfactual fairness of the present invention can achieve counterfactual fairness under the premise of ensuring prediction accuracy when the true causal graph is unknown, and can be applied to various scenarios where unfairness exists. Specifically, by making full use of all attributes of the sample, including descendants with clear sensitive attributes, all possible parent node sets of sensitive attributes are obtained, and all possible causal effects of sensitive attributes on the prediction results are obtained accordingly. By using the optimization framework of the maximum-minimum joint learning algorithm to continuously and alternately update the prediction model and the corresponding possible estimated counterfactual causal effects, and controlling the violation of fairness in the worst case, counterfactual fairness can be guaranteed by offsetting all possible counterfactual causal effects of sensitive attributes, and the accuracy of the prediction is further improved.
[0030] Additional advantages, purposes, and features of the present invention will be described in part in the following description, and will become apparent to those skilled in the art after studying the following, or may be learned from the practice of the present invention. The purposes and other advantages of the present invention may be achieved and obtained by the structures specifically indicated in the specification and the accompanying drawings.
[0031] Those skilled in the art will appreciate that the objectives and advantages that can be achieved with the present invention are not limited to the above specific description, and the above and other objectives that can be achieved by the present invention will be more clearly understood from the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] The drawings described herein are used to provide a further understanding of the present invention, constitute a part of this application, and do not constitute a limitation of the present invention.
[0033] Figure 1 A flowchart of an implementation method of a prediction model training method for counterfactual fairness according to one embodiment of the present invention;
[0034] Figure 2 This is a flow chart of step S120 in one implementation of the method for training a prediction model of counterfactual fairness of the present invention;
[0035] Figure 3 The figure is a flowchart of an implementation method of the counterfactual fairness prediction method of the present invention. DETAILED DESCRIPTION
[0036] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the embodiments and the accompanying drawings. Here, the illustrative embodiments of the present invention and their descriptions are used to explain the present invention, but are not intended to limit the present invention.
[0037] It should also be noted that, in order to avoid obscuring the present invention due to unnecessary details, only structures and / or processing steps closely related to the solutions according to the present invention are shown in the accompanying drawings, while other details that are not closely related to the present invention are omitted.
[0038] It should be emphasized that the term “include / comprises” when used herein refers to the presence of features, elements, steps or components, but does not exclude the presence or addition of one or more other features, elements, steps or components.
[0039] Hereinafter, embodiments of the present invention will be described with reference to the accompanying drawings. In the accompanying drawings, the same reference numerals represent the same or similar components, or the same or similar steps.
[0040] First, the following basic concepts and their definitions are introduced:
[0041] Partially directed acyclic graph (PDAG): To formalize the problem, assume that in the graph In which V and E represent The set of nodes and edges in ; A graph is a directed graph, an undirected graph, or a partially directed graph, if all edges in the graph are directed, undirected, or a mixture of directed and undirected edges, respectively. A partially directed acyclic graph (PDAG) may contain both directed and undirected edges, but no directed cycles.
[0042] Completely Partially Directed Acyclic Graph (CPDAG): In a directed acyclic graph (DAG), all edges are directed and there are no directed cycles. Two DAGs are Markov equivalent if they lead to the same set of conditional independence relations. A Markov equivalence class is denoted by Indicates that all Equivalent DAGs. Markov equivalence classes Can be uniquely represented by a partially directed graph, called a complete partially directed acyclic graph Two vertices are only is adjacent if it is adjacent in Directed edges only appear when they appear in all DAGs in .
[0043] Maximally directed partial directed acyclic graphs (MPDAGs): If there is explicit knowledge about some causal relationships between variables, access to intervention data, or some model restrictions, then a refinement of this class can be obtained, uniquely represented by maximally directed partial directed acyclic graphs (MPDAGs).
[0044] Parent node, child node, parent node set, complete graph: given graph If the vertex X i1 →X j1 In the figure In the i1 Yes X j1 The parent node, X j1 For X i1 The child nodes of express Medium X j1 If all distinct vertices in a graph are adjacent, then the graph is called a complete graph.
[0045] v-structure (collision structure), induced subgraph: for three different vertices X i , X j and X k , if X i →X j ←X k , and in Medium X i Not with X k adjacent, then the triple (X i , X j , X k ) is called in X j The v-structure or collision structure where i, j, k represent different vertex numbers. Definition Graph The induced subgraph on V′ is defined by restricting the edges E to the edges on the vertex set V′. Therefore, the induced subgraph The edge set E′ of y is defined as the subset of E that contains all edges whose two endpoints are in y′.
[0046] Combining counterfactual fairness, counterfactual inference and graphs: A structural causal model (SCM) is defined as a triple (U, V, F) to model the causal relationship between variables. Specifically, V is a set of observable endogenous variables, U is a set of potential independent background variables that are not the cause of any variable in V. F is a set of functions f1,...,f |V| , each V i ∈V corresponds to a function f i , satisfying V i =f i (pa i , U i ),in U i ∈U. Here, all i represent subscript numbers. It is worth noting that the set of equations F induces a directed graph between variables, which is assumed to be DAG, which leads to V i The cause of represents the set of its parent nodes in the causal graph. Given the distribution P(U) on the background variable U, for the variable V i The intervention is defined as the equation Vi =f i (pa i , U i ) is replaced by Equation V i =v, where v is some value.
[0047] Based on SCM, counterfactual inference aims to answer counterfactual questions in the counterfactual world. For example, in the context of fairness, suppose A, Y, and X represent sensitive attributes, outcomes of interest, and other observable attributes that may have some causal relationship with sensitive attributes, respectively. For individuals (samples) with background variables U = u and observable variables A = a, Y = y, and X = x, the counterfactual question can be stated as "If A takes another value a', what will be the value of Y". In order to solve the above counterfactual problem, counterfactual inference includes the following three steps: induction, intervention, and prediction. Counterfactual fairness is a fairness standard based on SCMs, which is checked by the above counterfactual inference. is a prediction of Y generated by a machine learning algorithm. When an individual is predicted to be the same in the actual world and in the counterfactual world (in which the individual belongs to a different population group), that is, the counterfactual causal effect (or causal effect) is zero, we can say that It is counterfactually fair to the individual. The specific definition is as follows:
[0048] Counterfactual fairness: For any feature attributes X = x and A = a,
[0049]
[0050] The above formula is valid for all predicted values y and any value a′ that can be obtained from the sensitive attribute A, where The value of the sensitive attribute is A=a, and the value of other attributes that may have a causal relationship with the sensitive attribute is X A←a , a predictor of counterfactual fairness when the value of the background attribute U remains unchanged Output prediction results.
[0051] Next, the existing technology is introduced:
[0052] To achieve counterfactual fairness when the true causal graph is unknown, the first known work is to obtain predictors of counterfactual fairness on graphs, which focuses on exploiting the properties of causal graphs - using explicit non-descendants (and possible descendants) of sensitive attributes for prediction. Assume that the structural equation is: A = U A , X1=A+U1, X2=A+U2, Y=2X1+X2+U Y , and in the CPDAG obtained through learning, A and X1, X2 are connected by undirected edges. In this case,
[0053] The existing Fair algorithm prevents all attributes that have a causal relationship with sensitive attributes, namely X1 and X2, from predicting the result Y. When the learned CPDAG is accurate, the Fair algorithm can ensure counterfactual fairness, but because too many nodes are discarded, the prediction performance is damaged, resulting in inaccurate prediction results.
[0054] The existing FairRelax algorithm uses attributes that may affect sensitive attributes, namely X1 and X2, to predict the result Y without imposing any fairness constraints. In addition, X1 and X2 are both possible descendants of A, so it is impossible to achieve counterfactual fairness by offsetting the impact of sensitive attributes on the result. At the same time, the FairRelax algorithm will also discard some nodes, thereby damaging the prediction performance. Moreover, the Fair algorithm and the FairRelax algorithm have no guarantee for fairness when the learned CPDAG is inaccurate.
[0055] Since in many practical scenarios, the real causal graph and the corresponding structural equation are unknown, this poses a huge challenge to estimating possible counterfactual causal effects. In order to simultaneously solve the problems existing in the above existing algorithms and improve the fairness and accuracy of the prediction results, the embodiment of the present invention proposes a prediction model training method, prediction method and device for counterfactual fairness, which are applicable to any specific application scenario where unfairness exists.
[0056] The technical solution provided by the embodiment of the present invention is further explained below with reference to an example of the impact of physical health status on the fairness of whether a student's final score is qualified.
[0057] Figure 1 FIG. 1 is a flow chart of a method for training a prediction model of counterfactual fairness provided by an embodiment of the present invention. Figure 1 As shown, the steps of a counterfactual fairness prediction model training method according to an embodiment of the present invention include:
[0058] Step S110, obtaining a training data set, wherein the training data set includes a plurality of samples, each sample includes a plurality of attributes including a sensitive attribute and a corresponding observation result as a label.
[0059] Exemplarily, the training data set may be an OULAD (OpenUniversity Learning Analytics Dataset) data set containing demographic information of students, the data set containing 32,593 students and 11 attributes, wherein the 32,593 students are samples in the training data set, and the 11 attributes are sample attributes, namely, a module identification code for student registration, a demonstration identification code for student registration on the module, the student's id, the student's gender, the geographic area where the student lives, the student's highest education level (highest_education), an economic index segment for the student's place of residence, the student's age group, the number of times the student has attempted to learn the course, the total credits currently taken by the student, and the student's physical health status; "student's physical health status" is regarded as a sensitive attribute; the final score observed for each student is the observation result, and the final score is binarized as the result of interest.
[0060] Step S120, generating a partial directed acyclic graph based on the attributes of the nodes and the observation results, searching the partial directed acyclic graph for attributes that may affect the sensitive attributes, and generating multiple possible parent node sets of the sensitive attributes based on the search results.
[0061] In the embodiment of the present invention, Figure 2 As shown, in step S120, a partial directed acyclic graph is generated based on the attributes as nodes and the observation results, and the attributes that may affect the sensitive attributes are searched from the partial directed acyclic graph. The steps of generating multiple possible parent node sets of the sensitive attributes based on the search results include:
[0062] Step S121, using a causal discovery algorithm to learn the training data set to generate a complete partial directed acyclic graph;
[0063] Step S122, using a local learning algorithm to search for attributes in the complete partial directed acyclic graph that may affect the sensitive attribute;
[0064] Step S123, the attributes that may affect the sensitive attribute are arranged and combined. If the arrangement and combination does not introduce a new collision structure or the induced subgraph is a complete graph, the arrangement and combination is determined to be a possible parent node set of the sensitive attribute.
[0065] Exemplarily, the PC algorithm in the causal-learn package is first used to learn the CPDAG from the raw data of the OULAD data set, and the reasons why other attributes other than gender are not gender attributes are controlled, and the attribute "student's physical health status" is taken as the only sensitive attribute. Secondly, a causal DAG is randomly generated from the learned CPDAG, and then the data is divided into 100 random batches. For each batch, the path coefficient is determined based on linear regression, and the residual of the regression is regarded as noise. Other attributes (except sensitive attributes) that may affect the sensitive attribute "student's physical health status" in the causal DAG include the student's gender, the geographical area where the student lives, the student's age group, etc., and finally all possible parent node sets corresponding to "student's physical health status" are obtained, including {gender}, {geographical area where they live}, {age group}, {gender, geographical area where they live}, {gender, age group}, {geographical area where they live, age group}, and {gender, age group, geographical area where they live} and other multiple sets.
[0066] Step S130 , training a corresponding preset propensity score model based on each possible parent node set, wherein the propensity score model is used to output a propensity score estimate of the possible parent node set for a sensitive attribute value of a sample.
[0067] In the embodiment of the present invention, the sensitive attribute is fitted by the attributes in each of the possible parent node sets, and the corresponding propensity score model is trained by minimizing the cross entropy loss.
[0068] Specifically, the corresponding propensity score model is trained by minimizing the cross entropy loss according to the following formula:
[0069]
[0070] Among them, argmin represents the minimization function, l(·) represents the cross entropy loss function, represents the propensity score model, represents the gender, age group, geographic area of residence and other attributes of the student in the mth possible parent node set, m = 1,…,|S(A)|, |S(A)| represents the total number of all possible parent node sets, φ (m) represents the weight parameter of the mth propensity score model, represents the estimated value of the weight parameter of the mth propensity score model, S (m) Represents the mth parent node set, A i represents the sensitive attribute of the i-th student sample - "student's physical health status", i = 1, ..., N, N represents the total number of student samples.
[0071] Output the estimated propensity score of each possible parent node set for the sensitive attribute value of the sample according to the following formula:
[0072]
[0073] in, It represents the estimated propensity score of the mth possible parent node set for the sensitive attribute value of the sample. The two value results of the sensitive attribute "student's physical health status" "student's body is in a healthy state" and "student's body is in an unhealthy state" are binarized to 1 and 0 respectively. Correspondingly, the estimated propensity scores output here are or
[0074] Step S140, based on each propensity score estimate and the corresponding prediction result, a corresponding preset causal effect model is trained, and the causal effect model is used to output the causal effect estimate of the sensitive attribute on the prediction result. The causal effect estimate is used to evaluate the counterfactual fairness of the prediction model's prediction of whether the final score of each student is qualified based on the attribute of the physical health condition.
[0075] In the embodiment of the present invention, by performing inverse probability weighting on the estimated propensity score of each possible parent node set for the sensitive attribute value of the sample, an unbiased estimate of the counterfactual causal effect of the corresponding sensitive attribute on the prediction result is obtained, thereby obtaining all possible counterfactual causal effects.
[0076] In the embodiment of the present invention, the corresponding causal effect model is trained by minimizing the target loss.
[0077] Specifically, according to the following formula, the estimated propensity score of each possible parent node set for the sensitive attribute value of the sample is weighted by inverse probability to obtain an unbiased estimate of the counterfactual causal effect of the corresponding sensitive attribute on the prediction result, and the preset causal effect model is trained by minimizing the target loss:
[0078]
[0079]
[0080] Where k(·) represents the target loss function, represents the mth causal effect model, m = 1, ..., |S(A)|, |S(A)| represents the total number of all possible parent node sets, i represents the sample number of the student, i = 1, ..., N, N represents the total number of student samples, x i represents other attributes of the student sample, such as gender, age group, and geographic area of residence, except for “physical health status”, ψ (m)represents the weight parameter of the mth causal effect model, represents the estimated value of the weight parameter of the mth causal effect model, θ represents the weight parameter of the prediction model, and f A←1 (x i ; θ) means that when the sensitive attribute value is "the student's body is in a healthy state", that is, A i = 1 and the values of other attributes "gender, age group, geographic area of residence, etc." are When using f(x i ; θ) predicts whether the final score of the i-th student sample is qualified, f A←0 (x i ; θ) means that when the sensitive attribute value is "the student's body is in an unhealthy state", that is, A i = 0 and the values of other attributes "gender, age group, geographical area of residence, etc." are When using f(x i ; θ) predict whether the final score of the i-th student sample is qualified.
[0081] Step S150, training a preset prediction model based on all causal effect estimation values, and alternately training the causal effect model and the prediction model in combination with a minimum-maximum joint learning algorithm, so as to use a prediction model that satisfies counterfactual fairness as a trained fair prediction model.
[0082] In the embodiment of the present invention, according to the estimated value of the causal effect of the sensitive attribute of each sample on the prediction result, the prediction model is trained by minimizing the average prediction error, taking the counterfactual fairness violation when the estimated value of the causal effect is maximum as a penalty term, and the prediction model that satisfies counterfactual fairness is obtained through a continuous updating and iterative process. In other words, counterfactual fairness is finally achieved by continuously updating the maximum estimated value of the counterfactual causal effect and combining the prediction results output by the prediction model each time during the training process.
[0083] Specifically, the prediction model is continuously trained by minimizing the average prediction error according to the following formula, using the counterfactual fairness violation when the causal effect estimate is the maximum as a penalty term:
[0084]
[0085]
[0086]
[0087]
[0088] Where q(·) represents the average prediction error, ψ (1)represents the weight parameter of the first causal effect model, ψ (|S(A)|) represents the weight parameter of the |S(A)|th causal effect model, γ represents the hyperparameter that weighs the prediction accuracy and counterfactual fairness. Since it is usually impractical to achieve strict counterfactual fairness for all samples, that is, the individual counterfactual causal effect of sensitive attributes on the prediction model is zero (that is, whether the student is healthy or not does not affect the result of obtaining a qualified grade), and it will come at the cost of greater prediction accuracy, a slack variable is introduced for each sample individual Specifically, it represents the tolerance of each student sample for the unfairness of whether physical health affects the final grade, and C represents the preset threshold standard of the tolerable unfairness of whether physical health affects the final grade. When the loss is punished, Y i represents the actual result of whether the final score of the i-th student sample is qualified or not, f(x i ; θ) represents the prediction result of whether the final score of the i-th student sample is qualified.
[0089] when When it is linear, it is transformed into a convex optimization problem, which is equivalent to minimizing the loss in the following formula and training the prediction model:
[0090]
[0091] Among them, λ represents a hyperparameter that trades off between prediction accuracy and counterfactual fairness, represents the penalty for excessive counterfactual causal effects, Indicates taking with a maximum value of 0.
[0092] It should be noted that since the parent node set of sensitive attributes in the real causal DAG is unknown, all parent node sets obtained in step S120 in the method of the embodiment of the present invention are all possible parent node sets of sensitive attributes. Therefore, the method uses the minimum-maximum joint learning algorithm to control the violation of counterfactual fairness in the worst case (when all possible counterfactual causal effects are maximum) of the prediction model. The optimization framework of the minimum-maximum joint learning algorithm can be extended to CPDAGs and maximum-guided PDAGs (MPDAGs) with background knowledge. The above process of alternately training possible causal effect models and controlling the prediction model for counterfactual fairness violations in the worst case combined with the algorithm can be regarded as an iterative process of counterfactual evaluation and strategy improvement of the prediction model.
[0093] Figure 3is a schematic diagram of a method for predicting counterfactual fairness provided by an embodiment of the present invention. Figure 3 As shown, the steps of a method for predicting counterfactual fairness in an embodiment of the present invention include:
[0094] Step S210: obtaining a test data set, wherein the test data set includes a plurality of samples, and each sample includes a plurality of attributes including sensitive attributes.
[0095] Exemplarily, the test data set may also be an OULAD data set containing demographic information of students, which contains data sets of different students and their 11 attributes, but the data set does not contain results, and the final grade obtained by each student is unknown. The student attributes are the module identification code registered by the student, the demonstration identification code registered by the student on the module, the student's id, the student's gender, the geographical area where the student lives, the student's highest education level (highest_education), the economic index segment of the student's residence, the student's age group, the number of times the student has attempted to learn the course, the total credits currently learned by the student, and the student's physical health status, where "student's physical health status" is considered a sensitive attribute.
[0096] Step S220: input the test data set into a prediction model trained using the prediction model training method for counterfactual fairness as described above, and the prediction model is used to output a prediction result that satisfies counterfactual fairness.
[0097] The prediction result output here may specifically be a prediction result of whether the student's corresponding final score is qualified, and the prediction result satisfies counterfactual fairness.
[0098] It should be noted that the counterfactual fairness prediction model training method and prediction method proposed in the embodiments of the present invention are not limited to the specific application scenario of the above example "the fairness impact of physical health on whether the student's final score is qualified", where there is only one sensitive attribute and only two values of the sensitive attribute and the result, but are applicable to various application scenarios where there are multiple sensitive attributes, multiple values of the sensitive attributes, and multiple values of the results.
[0099] Next, the following two experiments are conducted to verify the above counterfactual fairness prediction model training method and prediction method using the specific application scenario of the example "the fairness impact of physical health on whether a student's final grade is qualified" as follows.
[0100] In the experiment, by using Y and The root mean square error (RMSE) between and The RMSE between is used to measure the violation of counterfactual fairness, which is called unfairness. The smaller the two indicators, the better.
[0101] Experimental Example 1: Verification on the OULAD dataset (the true causal graph is unknown)
[0102] In the experiment, the experimental steps after generating data are the same as those in Experimental Example 2. The prediction model Ours trained by the prediction model training method in the embodiment of the present invention is compared with the following four baseline prediction models: 1) Full uses all attributes, 2) Unaware uses all attributes except sensitive attributes, 3) FairRelax uses all explicit non-descendant and possible descendant attributes in CPDAG, and 4) Fair uses all explicit non-descendant attributes in CPDAG. The results are shown in Table 1 below.
[0103] Table 1: RMSE and unfairness performance of the method of the embodiment of the present invention and the baseline on the OULAD data test set
[0104]
[0105]
[0106] It can be seen from Table 1 that based on the counterfactual fairness prediction on the real data set, compared with the baseline, the method of the embodiment of the present invention has advantages in both prediction performance and fairness.
[0107] Experimental Example 2: Verification on a synthetic dataset (the true causal graph is known)
[0108] In the experiment, the data in the synthetic dataset are generated based on the linear structural equation model of the real DAG. The Rényi (ER) model randomly generates a DAG with d nodes and 2d directed edges, d∈{10, 20, 30, 40}. j →X k The path coefficient β jk It is randomly drawn from the uniform distribution Uniform([-2, -0.5]U[0.5, 2]). The data is generated according to the following formula:
[0109]
[0110] Among them, pa(X k ) indicates X k The parent node set of noise ∈ i~N(0,γ),γ∈{1.5,2.5}, n is the sample size, which is 1,000 in the experiment. After generating data, the PC algorithm in the causal learning package is used to learn the CPDAG, and then two nodes are randomly selected as the counterfactual result Y and the sensitive attribute A. A is randomly drawn from the binomial distribution Binomial([0,1]) with probability Where σ(·) represents the sigmoid function. The ratios of training data and test data are set to 0.8 and 0.2, respectively.
[0111] The prediction model Ours trained by the prediction model training method in the embodiment of the present invention is compared with the following five baseline prediction models: 1) Full uses all attributes, 2) Unaware uses all attributes except sensitive attributes, 3) Oracle uses all non-descendant attributes that are sensitive attributes in the real DAG. 4) FairRelax uses all explicit non-descendant and possible descendant attributes in CPDAG, 5) Fair uses all explicit non-descendant attributes in CPDAG, and the results are shown in Table 2 below.
[0112] Table 2: RMSE and unfairness performance of the method of the embodiment of the present invention and the baseline on the synthetic data test set
[0113]
[0114]
[0115] As can be seen from Table 2, Full and Unaware perform better in RMSE, but Fair, FairRelax and the method of the embodiment of the present invention have obvious advantages in unfairness. It is worth noting that in all cases, the method proposed in the embodiment of the present invention outperforms Fair and FairRelax in both RMSE and unfairness indicators. This is because the present invention can use all attributes for prediction and control unfairness by offsetting the impact of sensitive attributes on the results. When the learned CPDAG is inaccurate, Fair and FairRelax can hardly find the true descendants of sensitive attributes.
[0116] Corresponding to the above method, a prediction model training device for counterfactual fairness in an embodiment of the present invention includes a computer device, wherein the computer device includes a processor and a memory, wherein the memory stores computer instructions, and the processor is used to execute the computer instructions stored in the memory. When the computer instructions are executed by the processor, the device implements the steps of the prediction model training method for counterfactual fairness as described above.
[0117] Corresponding to the above method, a device for predicting counterfactual fairness in an embodiment of the present invention includes a computer device, wherein the computer device includes a processor and a memory, wherein the memory stores computer instructions, and the processor is used to execute the computer instructions stored in the memory. When the computer instructions are executed by the processor, the device implements the steps of the method for predicting counterfactual fairness as described above.
[0118] The embodiment of the present invention also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the aforementioned counterfactual fairness prediction model training method and prediction method steps. The computer-readable storage medium may be a tangible storage medium, such as a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a floppy disk, a hard disk, a removable storage disk, a CD-ROM, or any other form of storage medium known in the technical field.
[0119] It should be understood by those skilled in the art that the exemplary components, systems and methods described in conjunction with the embodiments disclosed herein can be implemented in hardware, software or a combination of the two. Whether it is performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention. When implemented in hardware, it can be, for example, an electronic circuit, an application specific integrated circuit (ASIC), appropriate firmware, a plug-in, a function card, etc. When implemented in software, the elements of the present invention are programs or code segments used to perform the required tasks. The program or code segment can be stored in a machine-readable medium, or transmitted on a transmission medium or a communication link via a data signal carried in a carrier.
[0120] It should be clear that the present invention is not limited to the specific configuration and processing described above and shown in the figures. For the sake of simplicity, a detailed description of the known method is omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of the present invention is not limited to the specific steps described and shown, and those skilled in the art can make various changes, modifications and additions, or change the order between the steps after understanding the spirit of the present invention.
[0121] In the present invention, features described and / or illustrated for one embodiment may be used in the same or similar manner in one or more other embodiments, and / or combined with or replace features of other embodiments.
[0122] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the embodiments of the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A prediction model training method for counterfactual fairness prediction, characterized in that: The steps of the method include: A training data set is obtained, wherein the training data set includes a plurality of training samples, each of which includes a plurality of attributes including a sensitive attribute and a corresponding observation result as a label; the sensitive attribute includes: at least one of a person's physical health, gender, age, and education level; the observation result includes: a result of whether the person is hired for the job or whether the performance is qualified when at least one of the person's physical health, gender, age, and education level is changed; Generate a partial directed acyclic graph based on the attributes as nodes and the observation results, search for attributes that may affect the sensitive attribute from the partial directed acyclic graph, and generate multiple possible parent node sets of the sensitive attribute based on the search results; Based on each possible parent node set, a corresponding preset propensity score model is trained, wherein the propensity score model is used to output a propensity score estimate of the possible parent node set for a sensitive attribute value of a training sample; Training a corresponding preset causal effect model based on each propensity score estimate and the corresponding prediction result, the causal effect model is used to output an estimate of the causal effect of the sensitive attribute on the prediction result; and Based on all causal effect estimation values, a preset prediction model is trained, and the causal effect model and the prediction model are alternately trained in combination with a minimum-maximum joint learning algorithm, so that a prediction model that satisfies counterfactual fairness is used as a trained prediction model; In the step of training a preset prediction model based on all causal effect estimates and alternately training the causal effect model and the prediction model in combination with a minimum-maximum joint learning algorithm, the prediction model is trained by minimizing the average prediction error according to the causal effect estimate of the sensitive attribute of each training sample on the prediction result, and taking the counterfactual fairness violation when the causal effect estimate is maximum as a penalty item.
2. The method according to claim 1, characterized in that The steps of generating a partial directed acyclic graph based on the attributes as nodes and the observation results, searching the partial directed acyclic graph for attributes that may affect the sensitive attribute, and generating multiple possible parent node sets of the sensitive attribute based on the search results include: Using a causal discovery algorithm to learn the training data set to generate a complete partial directed acyclic graph; Using a local learning algorithm to find the attribute in the complete partial directed acyclic graph that may affect the sensitive attribute; The attributes that may affect the sensitive attribute are arranged and combined. If the arrangement and combination does not introduce a new collision structure or the induced subgraph is a complete graph, the arrangement and combination is determined to be a possible parent node set of the sensitive attribute.
3. The method according to claim 1, characterized in that In the step of training a corresponding preset propensity score model based on each possible parent node set, the sensitive attribute is fitted by the attributes in each of the possible parent node sets, and the corresponding propensity score model is trained by minimizing the cross entropy loss.
4. The method according to claim 1, characterized in that: In the step of training a corresponding preset causal effect model based on each propensity score estimate and the corresponding prediction result, wherein the causal effect model is used to output the causal effect estimate of the sensitive attribute on the prediction result, an unbiased estimate of the causal effect of the corresponding sensitive attribute on the prediction result is obtained by performing inverse probability weighting on the propensity score estimate of the sensitive attribute value of the training sample for each possible parent node set.
5. The method according to claim 4, characterized in that In the step of training a corresponding preset causal effect model based on each propensity score estimate and the corresponding prediction result, the corresponding causal effect model is trained by minimizing the target loss.
6. The method according to claim 1, characterized in that In the step of training a preset prediction model based on all causal effect estimation values, alternately training the causal effect model and the prediction model in combination with the minimum-maximum joint learning algorithm, and taking the prediction model that satisfies counterfactual fairness as the trained prediction model, a prediction model that satisfies counterfactual fairness is obtained through a continuous updating and iterative process.
7. A prediction method for counterfactual fairness prediction, characterized in that: The steps of the method include: Acquire a test data set, the test data set comprising a plurality of test samples, each test sample comprising a plurality of attributes including a sensitive attribute; and The test data set is input into a prediction model trained by the method according to any one of claims 1 to 6, so that the prediction model outputs a prediction result that satisfies counterfactual fairness.
8. A prediction model training device for counterfactual fairness prediction, comprising a computer device, the computer device comprising a processor and a memory, characterized in that: The memory stores computer instructions, and the processor is used to execute the computer instructions stored in the memory. When the computer instructions are executed by the processor, the device implements the steps of the method as claimed in any one of claims 1 to 6.
9. A prediction device for counterfactual fairness prediction, comprising a computer device, wherein the computer device comprises a processor and a memory, wherein: The memory stores computer instructions, and the processor is used to execute the computer instructions stored in the memory. When the computer instructions are executed by the processor, the device implements the steps of the method as claimed in claim 7.
Citation Information
Patent Citations
Fair prediction system based on structural causal model
CN115240843A
Learner emotional evolution analysis method and system based on causal graph neural network
CN115374790A