Episode 99: [Value Boost] Preventing ML Bias Before it Becomes a Problem

Download MP3

[00:00:00] Dr Genevieve Hayes: Hello and welcome to Your Value Boost from Value-Driven Data Science, the podcast that helps data scientists transform from technical implementers to strategic experts by contributing to the decisions that really matter. I'm Dr. Genevieve Hayes, and I'm here again with Serg Masis, author of Interpretable Machine Learning with Python to boost your strategic impact in less time than it takes to grab a coffee.
[00:00:29] In today's episode, you'll learn practical techniques for detecting and mitigating bias in your machine learning models before they damage your reputation or derail your projects. Welcome back, Serg.
[00:00:42] Serg Masis: Thank you. Thank you for having me.
[00:00:44] Dr Genevieve Hayes: One of the key concepts underpinning interpretable machine learning is model fairness. That is ensuring predictions are made without discernible bias.
[00:00:57] This is something you covered in interpretable machine learning with Python, but my understanding is that you are diving even deeper into this topic in your upcoming book, building Responsible AI with Python. So today I'd like to get your practical advice on how data scientists can actually identify and mitigate bias in their machine learning models.
[00:01:23] There are many different types of bias that can creep into machine learning models. What are the most common that you've encountered in practice?
[00:01:32] Serg Masis: The biggest would have to do with false negatives or positives affecting one group more than another? It might not be something nefarious. It might have to do with it having less representation data wise,
[00:01:47] for instance, you have data from a hospital. Of course, if you're using data from a hospital, people. Are more likely to be sick you're gonna have less. Healthy people, in that group so depending on what you're trying to do with that data, it's of course gonna be biased towards a certain kind of outcome.
[00:02:06] Certain kind of circumstances going on with that data. So it's not gonna have a fair representation for other kinds of. Things we wanna do with it. It could also happen that if you segmented by age, you're gonna have less old people.
[00:02:20] Or, you could have an area that you don't have a lot. So those areas in prediction, they're not gonna be as good because they're not gonna have enough data to support it. So that could be a form of bias.
[00:02:32] Even though typically when we think of bias, we think of fairness. So with fairness, if we're talking about mitigating bias, usually that's what we're discussing. But I would argue you could apply the same techniques to actually enhance, your model in areas where it's weak,
[00:02:48] and so it's not necessarily a question of, okay, I'm just applying bias mitigation techniques just to fairness problems. I'm applying them to other kinds of problems that we wouldn't necessarily put under the umbrella of fairness.
[00:02:59] Dr Genevieve Hayes: Using that medical example. So a model that's designed to predict a heart condition is probably gonna be biased in favor of older people and against younger heart patients because just there are more older people with heart conditions than younger people.
[00:03:17] Serg Masis: Yeah, but if you talk to medical professionals, say, okay, that's perfectly normal. What I would question is if your model was trained entirely on hospital data, there might be people that are missing. You're missing all the healthy, older people. 'cause all the sick, older people end up in the hospital.
[00:03:35] Especially if they haven't been having preventative medicine performed at that. So there might be other things that are missed and that's just something that comes from the way the data was collected.
[00:03:46] So you could definitely do things to adjust. Data statistically so it meets the general population, if you were to use it outside of the hospital, for instance.
[00:03:57] Dr Genevieve Hayes: And if you don't make these corrections, what sort of impact could this have on the quality of your model and your model outputs?
[00:04:05] Serg Masis: Big because even we take this hospital example, if the intention is to make a general purpose model to assess the certain kind of risk to the general population, and you're training it on only data that was collected in the hospital it's not necessarily gonna be a good model.
[00:04:23] So you're gonna have to calibrate it to the realities outside in the general population
[00:04:28] Dr Genevieve Hayes: Suppose a data scientist suspects their model might have a bias issue, or even if they don't suspect this might be the case, they just want to check to make sure it doesn't. What practical steps can they take to diagnose whether an issue exists?
[00:04:44] Serg Masis: Look at the cross tabs. Generally you wanna look at how it's performing across different subsets. This might not be people, bias could happen in a number of different ways, your machinery data could be biased, for whatever reason. But you definitely wanna subset the data and the predictions you wanna say,
[00:05:06] how does it perform with this group? And also dissect it in terms of what kind of errors it has. Because if you have a model that has a proportion of false positives and negatives, throughout the model, but then you dissect it into different cross tabs and you figure for this population it's completely skewed in this direction.
[00:05:25] It's more false positives than false negatives. And then if you put a financial value to what it means to have false positive, false negative, you realize that's the worst outcome for this group.
[00:05:36] So you have to see it that way. And that varies from case to case. There's situations where one is preferred over another. So that's something definitely to look for, you're typically not just looking at the accuracy, you're also looking at
[00:05:52] where do the errors tend to go? .
[00:05:54] Dr Genevieve Hayes: If we discovered that our model causes much higher errors for our healthier non-hospital bound, elderly heart patients, then that would suggest that there's a. Ice problem with the model and would need to take further steps.
[00:06:10] Serg Masis: Yeah. Yeah. Depending on the problem. If you have high risk patients and you're erring on false positives for them, that could be a good thing. It might be performing preventative medicine on people that, we're high risk anyway, but not having eminent failure, happening tomorrow.
[00:06:29] That be okay. But if you're going on the other direction, if you have some high risk patients that happen to be from a more marginalized group and you're having more false negatives, then you might be actually causing deaths,
[00:06:43] by having those predictions. And the thing is, none of these models are perfect. You're gonna have errors in any case, but what you don't want is to have one population have. Way more kind of errors in one direction, another in the other, because in this scenario, the one that's getting the most false negatives, is the one that's gonna, possibly not get the treatment they should get.
[00:07:07] Dr Genevieve Hayes: If this bias is found to be present, what steps can the data scientists take to remove it?
[00:07:13] Serg Masis: Yeah there's many techniques. Bias mitigation can be formed on the data, which is considered pre-processing. Or in the model, which is called in processing or upon the predictions, which is more like a calibration technique. And that's post-processing. So you can do it on any level,
[00:07:34] I would suggest that it's good to explore everything. I'm more biased towards doing pre-processing. I think it's better to tackle things from the source. Because what happens with bias is that on every step it gets worse. Models magnify bias just simply by the way they are
[00:07:51] It's like when you make a caricature of someone, , you're gonna enhance some features that are not necessarily flattering, it's the same thing with models.
[00:07:59] Since it's gonna magnifying something that's already bad, you're probably gonna want to tackle it from the source first. And then if it's not enough, then you do the in processing. And even then that's not enough.
[00:08:11] You do the post-processing.
[00:08:12] Dr Genevieve Hayes: And what's one technique our listeners could implement today to make their models fairer?
[00:08:17] Serg Masis: The best way, if you have control over the data, this is even before the data becomes beta. If you have control over the data collection process, you can do a lot more to mitigate bias because the sad thing about data is that once you get it,
[00:08:34] it's already happened. If we go back to the hospital.
[00:08:37] Idea. There's a reason why a lot of hospitals will collect demographic data about their patients so they can precisely evaluate these things so they can keep tags of them and make sure they're not biased. And then on other levels they could be talking to the nurses and the doctors and saying, make sure , you fill in these things.
[00:08:56] Make sure you don't do this and that and give them all, because it's not necessarily doing bias things out of, we're talking about a different scenario, not necessarily what I was saying about the hospital data and then the general population, but let's say there's a source of bias inside that particular hospital.
[00:09:13] You could definitely think things from a data collection point of view whatever that may be. Maybe it's the people, maybe it's the processes, maybe it's the technology that's causing things to be biased. It could happen on so many different levels. Maybe it's a vendor, it's not even the hospital itself,
[00:09:30] it's a particular machine that happens to bias things in one direction or another. But it's a question of investigating what's going on and going to the source in addressing it. And so that to me is the best way of addressing bias. But if you don't have any control over that, then the data, and then after the data of the model and then after the model, the post processing.
[00:09:52] Dr Genevieve Hayes: Okay, so do it as early as possible in the pipeline.
[00:09:55] Serg Masis: Exactly. Exactly.
[00:09:57] Dr Genevieve Hayes: And that's a wrap for today's value boost. But if you want more insights from Surge, you're in luck. We've got a longer episode where you'll discover practical insights for building interpretable machine learning models, and it's packed with practical advice for moving from technical execution to real strategic impact.
[00:10:18] You can find it now wherever you found this episode, or at your favorite podcast platform. Thanks for joining me again, Serg,
[00:10:25] Serg Masis: My pleasure.
[00:10:27] Dr Genevieve Hayes: and for those in the audience. Thanks for listening. I'm Dr. Genevieve Hayes, and this has been Value Driven Data Science.

Episode 99: [Value Boost] Preventing ML Bias Before it Becomes a Problem
Broadcast by