Source-linked AI summary
Fair Preprocessing: Towards Understanding Compositional Fairness of Data Transformers in Machine Learning Pipeline
Sumon Biswas, Hridesh Rajan
TL;DR
Fairness research has focused mainly on classifiers, leaving the fairness effects of individual preprocessing transformations in ML pipelines undermeasured. The paper uses causal reasoning and existing fairness metrics to evaluate preprocessing stages across pipelines, finding that many stages induce bias and that fairness composition can guide transformer choices that mitigate it.
Problem
Most fairness research evaluates single classifiers, while the fairness of preprocessing stages and their contribution to overall pipeline fairness has not been measured systematically.
Method
The paper applies causal reasoning and existing fairness metrics to measure stage-level fairness, then studies how local fairness composes in ML pipelines.
Results
Many preprocessing stages induce bias; the study identifies fairness patterns and uses fairness composition to select downstream transformers that mitigate pipeline unfairness.
Takeaways & Limitations
Measuring preprocessing-stage fairness can support fairer ML pipelines, fairness monitoring, automated unfairness detection, and transformer recommendations.
Takeaways & Limitations
The findings’ generalizability is bounded by the evaluated pipeline variations, sources, alternative transformers, classifiers, and fairness metrics, despite efforts to broaden coverage.
Abstract
from arXiv · showhide
In recent years, many incidents have been reported where machine learning models exhibited discrimination among people based on race, sex, age, etc. Research has been conducted to measure and mitigate unfairness in machine learning models. For a machine learning task, it is a common practice to build a pipeline that includes an ordered set of data preprocessing stages followed by a classifier. However, most of the research on fairness has considered a single classifier based prediction task. What are the fairness impacts of the preprocessing stages in machine learning pipeline? Furthermore, studies showed that often the root cause of unfairness is ingrained in the data itself, rather than the model. But no research has been conducted to measure the unfairness caused by a specific transformation made in the data preprocessing stage. In this paper, we introduced the causal method of fairness to reason about the fairness impact of data preprocessing stages in ML pipeline. We leveraged existing metrics to define the fairness measures of the stages. Then we conducted a detailed fairness evaluation of the preprocessing stages in 37 pipelines collected from three different sources. Our results show that certain data transformers are causing the model to exhibit unfairness. We identified a number of fairness patterns in several categories of data transformers. Finally, we showed how the local fairness of a preprocessing stage composes in the global fairness of the pipeline. We used the fairness composition to choose appropriate downstream transformer that mitigates unfairness in the machine learning pipeline.
1 INTRODUCTION
Fairness research has largely evaluated standalone classifiers, leaving the fairness effects of preprocessing stages in complex ML pipelines insufficiently measured. This paper introduces a causal, stage-level analysis and shows how local fairness composes into pipeline-level fairness to guide transformer selection.
- Research gap: Most ML fairness research studies single classifiers, although real-world predictions pass through multiple preprocessing stages.This omission can miss fairness impacts introduced before classification.
- Research gap: Bias can be encoded in data, but no prior study measured the fairness of individual preprocessing stages or their impact on overall pipeline fairness.The paper addresses this gap using causal reasoning and existing fairness metrics.
- Research questions: The study evaluates fairness measures for preprocessing stages and identifies fair and biased data transformers.These questions correspond to the paper’s first two research questions.
- Contributions: The paper introduces a fairness benchmark of ML pipelines and a causal notion for reasoning about stage-level fairness.The benchmark, code, and results are released for further research.
- Contributions: Fairness composition connects stage-specific fairness to overall pipeline fairness and supports selecting downstream transformers that mitigate bias.The paper also reports that fairness monitoring and automated detection tools could be built around preprocessing stages.
2 MOTIVATION
The motivating examples show that preprocessing can affect fairness before classification. The paper illustrates this with pipelines involving filtering, imputation, encoding, PCA, and feature selection, including a SelectKBest transformation associated with unequal prediction changes.
- Motivation: Preprocessing stages can affect model fairness, making bias induced by individual data transformers important to study.The motivating examples are used to demonstrate this issue before the classifier stage.
- Motivating example 1: In a recidivism pipeline, SPD is -0.102 and EOD is -0.027, indicating predictions biased toward Caucasian defendants.The pipeline includes cleaning, categorical encoding, and missing-value imputation before logistic regression.
- Motivating example 1: The recidivism pipeline is asymmetric across gender groups because male defendants are filtered more than female defendants.The example motivates measuring each transformation’s contribution to unfairness.
- Motivating example 2: The German Credit pipeline uses PCA and SelectKBest before a random forest, with SPD 0.005 indicating slight bias toward female candidates.The example concerns predicting good or bad credit risk from personal data.
- Motivating example 2: Removing SelectKBest shows that the stage changes 1.1% of female and 3.6% of male participants from favorable to unfavorable predictions.The unequal change rates illustrate how a specific transformer can affect prediction fairness.
3 METHODOLOGY
The methodology models an ML pipeline as ordered preprocessing stages followed by a classifier, then measures each stage’s fairness by comparing predictions with and without that stage. It adapts established group-fairness metrics to quantify stage-specific disparities caused by preprocessing.
- 3.1 ML Pipeline: An ML pipeline is an ordered sequence of preprocessing stages followed by a final classifier, with each stage operating on data transformed by earlier stages.Stages may be standard data transformers or custom operations such as filtering instances.
- 3.2 Fairness Metrics: The study adapts statistical parity, equal opportunity, average odds, and error rate differences to measure fairness.These metrics compare group-specific classification rates or errors.
- 3.3.1 Causal Method to Measure Fairness of Preprocessing Stage: For a stage S_k, causal fairness compares predictions from the original pipeline P with an alternative P* that removes S_k or replaces it with a reference stage.The comparison isolates prediction changes associated with intervening on that preprocessing stage.
- 3.3.1 Causal Method to Measure Fairness of Preprocessing Stage: The impact set I contains instances whose predictions differ between P and P*, and fairness metrics are computed over those changes.Unchanged predictions receive I_i = 0; changed predictions receive I_i = 1.
- 3.3.2 Fairness Metrics for Preprocessing Stage: Stage-specific metrics reuse SPD, EOD, AOD, and ERD definitions to quantify whether a preprocessing stage favors one group over another.The resulting rates range from -2 to 2; values near 0 indicate a fair preprocessing stage.
- 3.3.2 Fairness Metrics for Preprocessing Stage: The stage-specific SPD counts favorable and unfavorable prediction changes by group, then compares the resulting change rates.Its sign preserves the direction of changes, while the fairness comparison captures disparities between groups.
- 3.3.2 Fairness Metrics for Preprocessing Stage: EOD uses true-positive changes, AOD averages true-positive and false-positive changes, and ERD uses false-positive and false-negative changes.Each metric applies the corresponding original fairness criterion to prediction changes caused by preprocessing.
4 EVALUATION
The evaluation benchmarks preprocessing fairness across 37 pipelines drawn from three prior sources and operating on five datasets. It identifies pipeline stages, substitutes a reference encoder when removal is impossible, and compares predictions from original and altered pipelines.
- 4.1 Benchmark: The benchmark contains 37 machine-learning pipelines collected from three sources and operating on five datasets.The sources include Kaggle models, pipelines from Yang et al., and pipelines studied by Zelaya.
- 4.1 Benchmark: The benchmark covers German Credit, Adult Census, Bank Marketing, Titanic, and Compas classification tasks.The tasks involve credit risk, income, term-deposit subscription, survival, and recidivism prediction.
- 4.1 Benchmark: Each benchmark pipeline contains one or more preprocessing stages followed by a classifier, with performance reported using accuracy and F1 score.The study evaluates fairness of the preprocessing stages using the metrics defined earlier.
- 4.2 Experiment Design: To evaluate a stage, the researchers remove it from the pipeline or replace it with a reference stage when removal is impossible.Encoders were replaced with OneHotEncoder because encoders could not be removed and OneHotEncoder showed no bias in preliminary experiments.
- 4.2 Experiment Design: The original dataset is split into 70% training and 30% test data, and predictions from the original and altered pipelines are compared on the same test instances.The prediction comparisons provide the data needed to compute the four stage-specific fairness metrics.
5 FAIRNESS OF PREPROCESSING STAGES
The evaluation measures fairness across 69 preprocessing stages in 37 pipelines and identifies recurring transformer-specific bias patterns. Fairness can vary by metric, dataset, classifier, and performance effect.
- Fairness measurement: Four metrics—SFSPD, SFEOD, SFAOD, and SFERD—measure fairness of preprocessing stages using different fairness criteria.Metrics can disagree; in AC4, SFERD indicates positive fairness for PCA and StandardScaler while the other metrics indicate negative fairness.
- Fairness patterns: Stages that substantially change data distributions or modify minority data are associated with increased pipeline bias.The paper highlights data filtering, missing-value removal, feature generation, feature transformation, and encoding as important categories.
- Fairness patterns: Custom feature transformations can create high bias, such as extracting passenger titles from Titanic names to represent social status.Adult Census transformations that group education values or discretize age also modify original data values and cause unfairness in reported pipelines.
- Fairness patterns: LabelEncoder introduces bias in German Credit and Titanic, whereas OneHotEncoder does not change fairness in the reported evaluation.LabelEncoder imposes a sequential order on categories, which may create a linear relation with the target value.
- Fairness variability: Fairness variability depends on dataset size and overall prediction rate, and stage unfairness can be dominated by the dataset or classifier.German Credit and Titanic show more unstable metrics, while StandardScaler exhibits opposite fairness measures in pipelines using RandomForest and K-Neighbors.
- Fairness-performance tradeoff: 19 of 63 stages change accuracy and f1 score by no more than 0.05%, while 17 stages improve accuracy or f1 score by more than 0.05% and show moderate to high bias.The most biased performance-improving stages include TT7(LE), TT8(CT), TT4(CT), TT1(MV), and GC8(SS).
6 FAIR DATA TRANSFORMERS
The transformer study evaluates alternative preprocessing methods across datasets and classifiers to identify fairer choices. Sampling and feature selection often show the greatest unfairness, while standardization is usually fair but context-dependent.
- Evaluation design: The study evaluates commonly used and alternative transformers by applying them to vanilla classifier pipelines and measuring four fairness metrics.Transformers are grouped into categories such as scaling, sampling, and feature selection, with alternatives collected from corresponding libraries.
- Transformer fairness: Sampling techniques exhibit the most unfairness among the evaluated transformer categories.The overall dataset trend identifies sampling as the most biased category, followed by feature selection in its impact on fairness.
- Transformer fairness: In three of four datasets, balancing data with sampling increases bias despite prior evidence that balancing can improve fairness.SMOTE creates minority instances, while undersampling removes majority instances; both can produce unfair predictions depending on the classifier and dataset.
- Transformer fairness: Selecting a subset of features often increases unfairness because selected features can encode and dominate discriminatory information.SelectFpr shows little or no bias compared with other feature-selection methods in the reported evaluation.
- Transformer fairness: Feature standardization and non-linear transformers are fair in most pipelines, especially StandardScaler and RobustScaler, because they generally preserve feature importance.Outliers, particular classifiers, and data properties can nevertheless make standardizing transformers biased.
- Fairness composition: Local and global fairness follow the same trend in most Adult Census pipelines, indicating that local fairness contributes directly to global fairness.The trends can diverge when global fairness reflects all prediction changes but local fairness considers only instances altered by a transformer.
7 FAIRNESS COMPOSITION OF STAGES
The evaluation finds that local fairness generally tracks global pipeline fairness, while downstream transformers can mitigate bias introduced upstream. Selecting a downstream transformer with opposing fairness impact reduces overall unfairness.
- Fairness composition: The study evaluates global and stage-specific fairness before and after preprocessing on Adult Census pipelines using four existing metrics.These local and global measures are plotted together to compare stage-level and pipeline-level effects.
- Fairness composition: Local and global fairness follow the same trend in most pipelines, indicating that preprocessing-stage fairness contributes directly to pipeline fairness.Global fairness considers all prediction changes, whereas local fairness considers only instances altered by the transformer.
- Bias mitigation: Choosing a downstream transformer with an opposing fairness impact can mitigate bias introduced by an upstream transformer.The paper tests whether fairness composition can guide downstream-transformer selection.
- Bias mitigation: The paper uses Figure 7 to compare global fairness after the upstream transformer alone with fairness after adding one downstream transformer.The figure specifically illustrates undersampling as the upstream transformer.
- Bias mitigation: For XGB, Normalizer most successfully mitigates undersampling bias, while MinMaxScaler most reduces the opposite-direction bias for KNC.Both examples use undersampling upstream and standardizing transformers downstream.
8 DISCUSSION
The discussion presents causal fairness analysis as an initial way to understand preprocessing components and connect their fairness measures to pipeline optimization. It also identifies opportunities for monitoring, automated diagnosis, and bias mitigation.
- Implications: The method is presented as a first step toward understanding fairness in ML-pipeline components and reasoning about component effects on outcomes.The authors suggest extending it to other software modules and fault localization.
- Implications: Fairness measures for pipeline components can support fairness-aware optimization under constraints such as a selection-rate difference below 20%.The discussion mentions TPOT and Lara as potential pipeline-optimization techniques.
- Implications: The study reports fairness patterns in missing-value processing, custom feature generation, and feature selection that can induce pipeline bias.These patterns complement the paper’s broader analysis of preprocessing-stage fairness.
- Implications: Instrumentation and fairness monitoring of transformers could help identify fairness bugs, recommend fixes, and augment existing fairness tools.The discussion proposes API support for observing and mitigating transformer bias.
9 THREATS TO VALIDITY
The paper addresses internal validity by grounding its measures in existing causal and fairness concepts, and external validity by evaluating varied pipelines, transformers, datasets, classifiers, and metrics.
- Internal validity: Internal validity concerns whether the proposed fairness measures actually capture fairness in preprocessing stages.The authors use existing concepts and metrics and compare local with global fairness to address this concern.
- Internal validity: The fairness measures use causal reasoning and prediction equivalences to quantify intervention impacts without requiring an oracle.The paper connects this design to prior work on causality in software and fairness.
- External validity: External validity concerns how broadly the findings generalize beyond the evaluated settings.The study collects pipelines from three sources and evaluates alternative transformers, classifiers, datasets, and fairness metrics.
10 RELATED WORKS
Prior fairness research largely studies single classification tasks, while composition research shows that fair components can produce unfair combined outcomes. This paper extends the composition perspective to preprocessing stages in ML pipelines.
- Fairness in ML classification: Most ML-fairness work defines metrics and mitigation techniques for single classification tasks, with emphasis on theoretical fairness analysis.The related work describes this literature as concentrated on individual classification settings.
- Fairness in composition: Research on fairness in composition shows that combining components can yield an unfair overall system even when components are fair in isolation.This motivates examining fairness beyond individual classifiers.
11 CONCLUSION
The paper shows that preprocessing stages can affect fairness in classification pipelines, and that measuring and composing their fairness supports mitigation through transformer selection.
- The authors use a causal method and existing metrics to measure fairness at individual data preprocessing stages.
- Many preprocessing stages induce bias in predictions, demonstrating that fairness must be considered beyond the classifier.
- Selecting appropriate downstream transformers can mitigate existing bias and support fairer machine learning pipelines.
- The released benchmark, code, and results support further research on automated detection and instrumentation of unfair pipeline stages.