Low Level API
More complex scans, such as bias_sources, have underneath longer pipelines with multiple steps. This section describes these pipelines' structure.
These can currently be used in the IDE and customized, but they will not be displayed in the dashboard. As this API evolves we will surface methods that allow you to add these pipelines to the dashboard as well.
DataPipeline
To follow the example analysis below, download the Adult dataset from https://archive.ics.uci.edu/ml/datasets/adult or load it in the notebook as a Pandas dataframe from the samples included in the library. A demo notebook is available at https://github.com/ETIQ-AI/demo/blob/main/DemoAdultLibrary03.ipynb
data = load_sample('adultdata')The DataPipeline object has the model we'd like to evaluate, the dataset used to train it and associated fairness metrics.
Below, we define the parameters for the debiasing process using the BiasParams structure. This allows us to specify the protected category (often a demographic feature you'd like to mitigate bias for) using the protected parameter; specify who is in the privileged and unprivileged groups (these are set using the privileged and unprivileged parameters respectively); specify what is the positive outcome and the negative outcome in this dataset (these are set using the positive_outcome_label and negative_outcome_label parameters respectively).
debias_param = BiasParams(protected='gender',
privileged='Male',
unprivileged='Female',
positive_outcome_label='>50K',
negative_outcome_label='<=50K')Specify transforms like Dropna or EncodeLabels to make sure data are numeric and without missing values. Preferably use your own transform functions.
The DatasetLoader reads in the data, applies any transformations, splits the data into training, validation and test datasets and sets aside the test dataset to avoid data leakage in your analysis. The training and validation datasets are loaded into the Dataset class.
Choose the metrics you want computed for this project.
Each of these metrics measure how well our model is performing when classifying the data. For more details please see Definitions.
Load the model you'd like to evaluate with the dataset or choose one of the classifiers that are already available. For this test release these DefaultXGBoostClassifier (a wrapper around XGBoost classifier), DefaultRandomForestClassifier (a wrapper around the random forest classifier from sklearn) and DefaultLogisticRegression (a wrapper around the logistic regression classifier from sklearn).
Now you can create the DataPipeline. The DatasetLoader class will take the data, transform it, split it into training/validation/testing data and load it in. The DataPipeline computes your metrics of interest on the Dataset, using the model you provided.
DebiasPipeline
DebiasPipeline takes as inputs a data pipeline, an identify and/or repair method and metrics you want to use to evaluate your model. Identify methods are as the name suggests are intended to help you identify bias issues. Repair methods are designed to help fix or mitigate the issues identified and include implemented algorithms from the fairness literature.
The current repair pipeline we provide is at the pre-processing level, i.e. changes the dataset with the objective that some of the sources of bias in it will be mitigated. Other methods at in-processing or post-processing stages will be more effective from an optimization point of view, but they might not address some of the issues in the data, which is why this is a good starting area. In our full solution we have additional pipelines.
An example debiasing pipeline is given below
As with the data pipeline, when running the pipeline, we get the logs of how the pipeline has run:
Output methods
Now that you've checked the logs and the etiq pipeline ran, to retrieve the outputs, use the following methods:
Metrics
Example output:
Issues found by the pipeline
Our library is intended for you to test your models and see if there are any issues. The pipeline surfaces potential issues, and then it's up to you whether you consider them to be issues for your specific model or not. For more details on definitions please see Definitions tab
Example output

To help make sense of the segments, we also have a profiler method which gives you an idea about the rows found to have specific issues.

To understand more about the types of errors this pipeline finds, please use the following method; it will give you definitions and thresholds used. Also, please see a discussion of different bias sources at this link.
Last updated