# A Methodology for Controlling Bias and Fairness in Synthetic Data Generation
## 3 Methodology for Data Generation  
This section presents the methodology for the generation of datasets to be used in machine learning applications. The objective is to generate a dataset \(\mathcal{D}\) consisting of \(n\) records described by \(m\) categorical features, i.e., features with a finite set of values. In turn, each feature \(j\) is characterized by \(q_{j}\) values. The proposed methodology is based on the definition of a probabilistic network that accounts for the dependencies among data features, while appropriate samplings of this network will be used to generate the datasets. More precisely, a five-step approach was applied, consisting of:  
1. Defining the probabilistic network that characterizes the initial dependencies and their strength, among features;
2. Altering the bias on the dataset by tuning the direct influence among attribute pairs, as well as the overall amount of bias of a specific attribute;
3. Deriving the multivariate probabilistic distribution that summarizes this probabilistic network;
4. Sampling the multivariate normal distribution;
5. Converting the samplings into a dataset with categorical features. As already discussed in Section 2, most of the state-of-the-art, non-proprietary approaches for generating or enlarging datasets rely on both existing data and large conditional probability tables in order to address dependencies among the various data features. In contrast, the proposed methodology generates new datasets using only a limited number of parameters to describe the strength of ties among the various data features. More precisely, similarly to Bayesian networks, this probabilistic network is a weighted directed acyclic graph (DAG) whose nodes represent feature variables and whose edges describe the direct probabilistic influences. The weights of the edges summarize the strength of the corresponding influence. The proposed methodology is based on a structural equation modeling (SEM) framework--see, e.g., [18; 19]--to model the dependencies among features. More precisely, SEM representations are usually applied, in combination with factor and multiple regression analyses, to model datasets with sets of equations and structures. This approach also accounts for data variability, noise and discrepancy by using latent variables. In contrast with usual SEM applications, the methodology described in this work uses SEM representations as the starting point for data generation. Indeed, each feature is associated with a latent Gaussian random variable that, in turn, is represented by a node in the DAG. The values of the features are computed from sampling the joint distribution of all of the latent variables. As a running example, let \(\mathcal{D}\) be a dataset characterized by \(m=4\) features, namely \(A\), \(B\), \(C\) and \(Z\). Given \(A\), \(B\) and \(C\) as independent features, the purpose is to model their dependencies on the feature \(Z\), that is, to derive the conditional probability distribution \(P(Z|A,B,C)\). Figure 1 depicts the SEM representation of these features, where \(X_{A}\), \(X_{B}\), \(X_{C}\) and \(X_{Z}\) are the latent random variables associated with the considered features. Moreover, the edge weights \(\alpha_{A}\), \(\alpha_{B}\) and \(\alpha_{C}\), i.e., the regression coefficients in SEM terminology, summarize the strength of the dependencies among the corresponding pair of random variables. Figure 1: Example of a SEM representation describing a dependent feature \(Z\) as a function of three independent features, namely \(A\), \(B\) and \(C\). Rounded nodes represent the latent variables, whereas squared boxes denote their corresponding features. \(\mu=\bar{0}\) is the \(m\) dimensional null vector, since all \(m\) expected values are equal to zero, and \(z_{i}\) are independent samplings of a univariate standard normal distribution \(\mathcal{N}(0,1)\). The last step of the proposed methodology focuses on deriving the final dataset where, as previously introduced, each record is described by categorical features.