Fairness: Identifying bias

As you prepare your data for model training and evaluation, it's important to keep issues of fairness in mind and audit for potential sources of bias, so you can proactively mitigate its effects before releasing your model into production.

Where might bias lurk? Here are some red flags to look out for in your dataset.

Missing feature values

If your dataset has one or more features that have missing values for a large number of examples, that could be an indicator that certain key characteristics of your dataset are under-represented.

Exercise: Check your understanding

You're training a model to predict adoptability of rescue dogs based on a variety of features, including breed, age, weight, temperament, and quantity of fur shed each day. Your goal is to ensure the model performs equally well on all types of dogs, irrespective of their physical or behavioral characteristics

You discover that 1,500 of the 5,000 examples in the training set are missing temperament values. Which of the following are potential sources of bias you should investigate?

Temperament data is more likely to be missing for certain breeds of dogs.
If the availability of temperament data correlates with dog breed, then this might result in less accurate adoptability predictions for certain dog breeds.
Temperament data is more likely to be missing for dogs under 12 months in age
If the availability of temperament data correlates with age, then this might result in less accurate adoptability predictions for puppies versus adult dogs.
Temperament data is missing for all dogs rescued from big cities.
At first glance, it might not appear that this is a potential source of bias, since the missing data would affect all dogs from big cities equally, irrespective of their breed, age, weight, etc. However, we still need to consider that the location a dog is from might effectively serve as a proxy for these physical characteristics. For example, if dogs from big cities are significantly more likely to be smaller than dogs from more rural areas, that could result in less accurate adoptability predictions for lower-weight dogs or certain small-dog breeds.
Temperament data is missing from the dataset at random.
If temperament data is truly missing at random, then that would not be a potential source of bias. However, it's possible temperament data might appear to be missing at random, but further investigation might reveal an explanation for the discrepancy. So it's important to do a thorough review to rule out other possibilities, rather than assume data gaps are random.

Unexpected feature values

When exploring data, you should also look for examples that contain feature values that stand out as especially uncharacteristic or unusual. These unexpected feature values could indicate problems that occurred during data collection or other inaccuracies that could introduce bias.

Exercise: Check your understanding

Review the following hypothetical set of examples for training a rescue-dog adoptability model.

breed age (yrs) weight (lbs) temperament shedding_level
toy poodle 2 12 excitable low
golden retriever 7 65 calm high
labrador retriever 35 73 calm high
french bulldog 0.5 11 calm medium
unknown mixed breed 4 45 excitable high
basset hound 9 48 calm medium
Can you identify any problems with the feature data?
Click here to see the answer

Data skew

Any sort of skew in your data, where certain groups or characteristics may be under- or over-represented relative to their real-world prevalence, can introduce bias into your model.

When auditing model performance, it's important not only to look at results in aggregate, but to break out results by subgroup. For example, in the case of our rescue-dog adoptability model, to ensure fairness, it's not sufficient to simply look at overall accuracy. We should also audit performance by subgroup to ensure the model performs equally well for each dog breed, age group, and size group.

Later in this module, in Evaluating for Bias, we'll take a closer look at different methods for evaluating models by subgroup.