Latest / Talk Python To Me / #261: Monitoring and auditing machine learning
Transcript
- 0:00Traditionally, when we've depended upon software to make a decision with real-world implications,
- 0:04that software was deterministic.
- 0:06It had some inputs, a few if statements, and we could point to the exact line of code where
- 0:10the decision was made, and the same inputs would lead to the same decisions.
- 0:14Nowadays, with the rise of machine learning and neural networks, this is much more blurry.
- 0:19How did the model decide?
- 0:20Has the model inputs drifted apart so the decisions are outside what it was designed for?
- 0:24These are just some of the questions discussed with our guest, Andrew Clark, on this,
- 0:29episode 261 of Talk Python To Me, recorded April 17th, 2020.
- 0:34Welcome to Talk Python To Me, a weekly podcast on Python, the language, the libraries, the
- 0:52ecosystem, and the personalities.
- 0:53This is your host, Michael Kennedy.
- 0:55Follow me on Twitter, where I'm @mkennedy.
- 0:57Keep up with the show and listen to past episodes at talkpython.fm, and follow the show on Twitter
- 1:02via at Talk Python.
- 1:03This episode is sponsored by Linode and Reuven Lerner.
- 1:07Please check out what they're both offering during their segments.
- 1:09It really helps support the show.
- 1:11Andrew Clark, welcome to Talk Python To Me.
- 1:13Hi, Michael.
- 1:14Glad to be here.
- 1:15It's always a pleasure listening to your podcast.
- 1:17I'm really excited to get to talk to you today.
- 1:19Well, thank you so much.
- 1:20And I'm excited to talk to you as well.
- 1:22It's going to be really fun to talk about machine learning.
- 1:24And I think of all of the programming type of stuff out there, more than most, machine
- 1:31learning is truly a black box for a lot of people.
- 1:35The decisions it makes is sort of unclear.
- 1:40It's sort of statistical.
- 1:42To me, it feels a little bit like quantum mechanics over Newtonian physics or whatever.
- 1:47It's like, well, I know there's rules that guide it, but it's kind of just it does its
- 1:53thing and you can't really know for sure.
- 1:55But at the same time, the world is beginning to rely more and more on machine learning, right?
- 1:59Yes, definitely.
- 2:01And there's definitely different levels of the complexity of it on how much is deterministic
- 2:05and how much of it really is quantum mechanics.
- 2:07Nice.
- 2:09All right.
- 2:10Now, before we get into that, though, of course, let's start with your story.
- 2:12How did you get into programming and into Python?
- 2:14Yeah, definitely.
- 2:15In my undergrad, I was actually an accounting major.
- 2:17And then about halfway through, I realized accounting is a great career, but it's really boring for
- 2:22me.
- 2:23So I started trying to just get into programming and stuff.
- 2:26Big data was like the craze when I was in college.
- 2:27Everybody was talking about big data and Hadoop and all that kind of thing.
- 2:31So I really started wanting to learn more about it and work through Code Academy and learn
- 2:35Python the hard way and some of those other books that are around.
- 2:38Tried a bunch of different things to see what worked for me and learn Python the hard way
- 2:42is what really seemed to stick.
- 2:43And then really started just trying to find little side projects of little things to do
- 2:47to actually build the programming.
- 2:49So I tried doing the top down, like here's the theory, more computer science-y approach.
- 2:53Didn't really work for me.
- 2:54It's more the bottom up of like, I'm trying to solve a problem.
- 2:56I want to move this file to this location.
- 2:58And I want to like orient this image in my Excel file.
- 3:01There's like different things like that to help learning how to program.
- 3:04Do you think that programming is often taught in like in reverse in the wrong way?
- 3:08Right.
- 3:09It's like very high level.
- 3:10And then we're going to work our way down and down.
- 3:11And like, here's the concepts.
- 3:13And then here's the theory.
- 3:14And instead of just like, here's a couple of problems and a few things you need to know
- 3:18and a whole bunch of stuff that we're not going to even tell you exists about.
- 3:21Right.
- 3:21Like you don't even know what a heap is.
- 3:23I don't care.
- 3:23We're going to just make this work until you like eventually care what like, you know,
- 3:27memory allocation is.
- 3:28Right.
- 3:28At least I found, especially in the academic world, I felt sort of flipped on its head.
- 3:34I definitely think so.
- 3:35A lot of careers are built that way.
- 3:37It's like you need to have some sort of a concrete of why does this matter?
- 3:39Why do I care?
- 3:40And like being able to do get your hands dirty and then go into the theory.
- 3:43So you really want to do both in tandem.
- 3:45But really starting with the hands on is really helped me with that approach.
- 3:48I know some people can do it the top down theory way, but I definitely think computer science
- 3:53could have a lot better programmers faster if they did it from the bottom up.
- 3:56Yeah, I agree.
- 3:57And computer science or programming in general is nice in that it has that possibility.
- 4:02Right.
- 4:02Like it's harder.
- 4:03You know, we joked about quantum mechanics.
- 4:05It's harder to just like, well, let's get your hands dirty with some quantum mechanics.
- 4:09And then we'll talk about like wave particle duality, like whatever.
- 4:13Like it just doesn't lend itself to that kind of presentation or that kind of like analysis,
- 4:18I don't think.
- 4:20But programming does, right?
- 4:21You could say, we're going to take this little API.
- 4:23I'm going to build a graph.
- 4:24And how cool is that?
- 4:25Now let's figure out what the heck we did.
- 4:27Exactly.
- 4:27Exactly.
- 4:28So that's one of the beauties about programming, especially Python with its ease of starting
- 4:33up and just getting something running on your computer.
- 4:35You can really start dealing with problems you wouldn't be able to do in some of these fields
- 4:38until you had a postdoc.
- 4:39You can't even start talking about quantum.
- 4:41Exactly.
- 4:42So back to your story, you were talking about like, this was the way that you found worked
- 4:47for you to get rolling.
- 4:48Yeah.
- 4:49And it really worked well with the different internships I was doing at the time.
- 4:52So I was working in financial audit.
- 4:54And during that time was really when auditors were starting to think about using data and
- 5:00using more than just normally in auditing, you do random sampling.
- 5:03So you'll look at a bunch of transactions from like accounts payable for like, these are bills
- 5:08the company paid.
- 5:09And being able to find that there's a lot of times there's duplicates.
- 5:11Some people are paying invoices twice and things like that.
- 5:14So being able to use programming to start solving just audit problems to speed up the process for
- 5:18my company and just make my life easier, honestly.
- 5:20It was really how I started getting very excited about Python besides just like very small little
- 5:25utils on my computer.
- 5:26So like seeing what can we really do with this and how can we make solve business problems
- 5:29with it?
- 5:30So I really came out of that pragmatic way.
- 5:32That's cool.
- 5:33Did you find that your co-workers, other people trying to solve the same problems, were trying
- 5:38to solve it with Excel and you just had like this power that they didn't have?
- 5:41Definitely.
- 5:42Definitely.
- 5:43Excel and some like specific analytics tools.
- 5:46Like there's a couple out there for auditors that like Caseware Idea and ACL and things.
- 5:51And they're just not as easy to use.
- 5:53They trump Excel, but they have a massive learning curve themselves.
- 5:56So it's like being able to do something like Python.
- 5:58I can both camps of different types of auditors, either Excel or ACL auditors were able to
- 6:03just run circles around them with testing.
- 6:05That's pretty cool.
- 6:07Well, that's a really interesting and practical way to get into it.
- 6:10I've recently realized or come to learn that so many people seem to be coming into Python
- 6:17and especially the data science side of Python from economics.
- 6:20Yeah, there's a big move these days from people traditionally in economics would be using
- 6:25like Matplotlib and no, sorry, Matlab.
- 6:28Python's on the brain here.
- 6:29Matlab and moving in to do more quantitative analysis.
- 6:32And now really Python has kind of taken over in economics.
- 6:35And there's like this a ton of people that are just coming over to the data science from
- 6:38you do those types of modeling for econometrics and stuff.
- 6:41So there's definitely a big surge of economists turned data scientists these days.
- 6:45Yeah, cool.
- 6:45What are you doing day to day now?
- 6:47Like you started out doing auditing and getting into Python that way.
- 6:51Now what?
- 6:52Well, it's been a really crazy ride, but I'm now doing a startup called Monitor that works on
- 6:57machine learning assurance.
- 6:58Like how do we provide assurance around machine learning models?
- 7:00So I'm the co-founder and CTO with them.
- 7:02So my day to day right now, we're currently in the midst of Techstars Boston's is very much
- 7:07just like meeting with different investors, meeting with their startup founders, meeting with
- 7:12client potential clients and running as different parts of business.
- 7:16So wearing a lot of hats right now.
- 7:18And then I run all the R&Ds type side and figuring out like, what are the things we want to build?
- 7:22And then I can start working with the engineering team to execute.
- 7:24Do you find that you're doing all these things that sort of a tech background wholly unprepared
- 7:30you for?
- 7:30There's definitely some of that.
- 7:32Some of it, like my accounting degree is definitely coming in handy.
- 7:35Yeah.
- 7:35A lot of the business side things, but there's definitely a lot of moving pieces.
- 7:39And it's more than just strictly like being a good Python programmer.
- 7:43So it's a little more than I was expecting on that side.
- 7:46Well, I do feel like a lot of people, and this is like my former self included, is like,
- 7:51if you build it, they will come.
- 7:53All we need is like really good tech and like a compelling project or technology or product.
- 7:59And then we'll figure out the rest of the stuff.
- 8:01We'll figure out the accounting, the marketing, the user growth, like all that stuff.
- 8:06And it's like, no, no, no, no.
- 8:07Like the product and the programming is table stakes.
- 8:11All this other stuff is what it actually takes to make it work, right?
- 8:14Definitely.
- 8:14Definitely.
- 8:15You need to have innovative tech, but that's only a component of it.
- 8:19Like that's like one fourth of the problem.
- 8:21And, you know, for I think a lot of myself and I think a lot of first time startup individuals
- 8:27as well, you come into that thinking like, hey, tech is going to be king when there's
- 8:30actually so many other moving pieces like you're mentioning.
- 8:33So it's actually an eye opening experience, but I really respect founders more.
- 8:36Yeah, same.
- 8:38Well, I do find it really interesting and almost disheartening when you realize like I have
- 8:44all this amazing programming skill and I know I can build this.
- 8:47If I had two months and I'm really focused, we can build this thing.
- 8:51And you realize like, actually, that's just a small part of like having to build it.
- 8:55Like this is where it starts.
- 8:56This is not like basically it's ready to roll.
- 8:58So I don't know.
- 8:59It's something I've been thinking about over the last few years.
- 9:02And it's not the way I think a lot of people perceive it starting something like this.
- 9:08If you have like, we're going to get a cool programming team together.
- 9:10We're going to build this thing and it'd be great.
- 9:12It's like, okay, well, that gets you started.
- 9:13But then what?
- 9:14Right?
- 9:14Exactly.
- 9:15And the other problem you have with a startup is like you can't even do, okay, we'll give
- 9:19me two months and we'll can build it.
- 9:20Like with all the other competing business things and stuff, you can't even get that straight
- 9:24two months of just building because you have all the investor obligations and things.
- 9:27So it's definitely a lot of things to juggle.
- 9:29So you get really good at time management and priority juggling.
- 9:32But it's exciting, right?
- 9:34It's a lot of fun.
- 9:34Yeah.
- 9:35Oh, it's fantastic.
- 9:36And being part of Techstars is really wonderful.
- 9:38It's wouldn't trade it for anything.
- 9:39It's just definitely eye opening and a great learning experience.
- 9:42Yeah, I've had some people on the show a while back who had gone through Techstars, but maybe
- 9:47folks haven't listened to that show or whatever.
- 9:49So probably the most popular, well-known something like that is probably Y Combinator, though I
- 9:57don't know that it's exactly the same thing.
- 9:59But tell folks about what Techstar is a little bit just so they have a sense of what you're
- 10:04working on or what you're doing.
- 10:05So Techstars is an accelerator.
- 10:08There's like accelerators and incubators.
- 10:09I didn't really know there was much of a difference, but being part of Techstars, the
- 10:13accelerators are really very mentor heavy.
- 10:15Like the first couple of weeks of Techstars, you have a ton of different mentors that you
- 10:18meet with, like five a day or more, and trying to find who's going to help guide the vision
- 10:23of your company.
- 10:23How do you get to write people around the table?
- 10:25What's your company vision?
- 10:27Your mission statement?
- 10:28How are you going to do fundraising?
- 10:29What's your marketing strategy?
- 10:30What's your go-to-market?
- 10:31How do you get your first few customers?
- 10:32How do you keep those customers?
- 10:33It's very focused on the execution and how do you make a successful business that will last?
- 10:39So it's a lot of very business-y things.
- 10:41For a tech-run startup company thing, it's very, very focused on the non-tech aspects,
- 10:47the business aspects, the how do we differentiate ourselves from the crowd and things.
- 10:51So there's seminars, mentor meetings, there's just lots of moving pieces with that.
- 10:55But it's a very, very good thing.
- 10:57And it helps in about three months to take your company from a cool idea and you have a product
- 11:02to really being able to execute your vision and have better staying power.
- 11:06Yeah, well, it sounds like it's a lot of the stuff to sort of build that structure and support
- 11:11of what we were just talking about, of like what you don't get if you know how to write
- 11:14code and create a product.
- 11:15Right.
- 11:16It's exactly right.
- 11:17Because like Techstars, 10 companies are accepted out of over 2,000 applicants.
- 11:21So it's like you already have a product.
- 11:22You already have good tech to make it across the bar.
- 11:24They're like, okay, everybody knows what they're doing, how to build tech.
- 11:27Now we've got to teach you guys how to actually run a company.
- 11:30So it's a very good way of approaching it.
- 11:33It's not like you all sit in a room with a bunch of group think and programmers making
- 11:36it more geeky.
- 11:37You think like, okay, you might even need to scale back the complexity of this a little
- 11:40bit so we can actually market this to the user.
- 11:42It's very, very good program for small companies to go through.
- 11:48This portion of Talk Python To Me is brought to you by Linode.
- 11:50Whether you're working on a personal project or managing your enterprise's infrastructure,
- 11:55Linode has the pricing, support, and scale that you need to take your project to the next
- 11:59level.
- 11:59With 11 data centers worldwide, including their newest data center in Sydney, Australia, enterprise
- 12:05grade hardware, S3 compatible storage, and the next generation network, Linode delivers
- 12:11the performance that you expect at a price that you don't.
- 12:14Get started on Linode today with a $20 credit and you get access to the next generation
- 12:18to native SSD storage, a 40 gigabit network, industry leading processors, their revamped
- 12:23cloud manager, cloud.linode.com, root access to your server, along with their newest API and
- 12:29a Python CLI.
- 12:30Just visit talkpython.fm/Linode when creating a new Linode account and you'll automatically
- 12:36get $20 credit for your next project.
- 12:38Oh, and one last thing, they're hiring.
- 12:40Go to linode.com slash careers to find out more.
- 12:43Let them know that we sent you.
- 12:47Well, I want to talk a little bit more about that at the end and how it's probably changed
- 12:51as the world has changed with COVID-19 and all that.
- 12:53But let's talk about machine learning and stuff like that first.
- 12:57Yeah, definitely.
- 12:57We talked a little bit about machine learning and I joke that like, at least to my very limited
- 13:04experience, it feels a little bit quantum mechanics-y in that same sense.
- 13:09But let's tell people, I guess, what is machine learning?
- 13:14Obviously, we have a bit of a sense, but like, let's try to make it a little bit more concrete
- 13:18for people who maybe it's still like a buzzword and what makes up machine learning, I guess.
- 13:23Definitely.
- 13:25So I'll start by saying there's a lot of terminology where people kind of interchange
- 13:29together, like AI, machine learning, deep learning.
- 13:31So if you think of three big circles, AI is just a broad range of trying to make machines
- 13:37to copy human tasks.
- 13:39So AI doesn't have to exactly be modeling.
- 13:42It can also be rule-based systems and things that try and mimic human intelligence.
- 13:46So it's like a broad field of trying to do something that copies human behavior.
- 13:50Right.
- 13:50Computers making decisions, kind of.
- 13:53Right.
- 13:54Exactly.
- 13:54Trying to make decisions like a human.
- 13:56So there's a lot of different components in that.
- 13:58And it's been a field that people have been talking about for a long time and you've had
- 14:02movies about it for a long time.
- 14:03So it's just a broad field.
- 14:05There's very many components, a part of it, because you have some things like expert systems
- 14:08and some sort of rule-based engines that actually do a pretty good job of mimicking that when
- 14:12there's not actually any modeling.
- 14:13So they have a limited use because like self-driving cars, if you think about that, you can't build
- 14:18enough rules to specify every time a car should turn, there's too much going on.
- 14:22You have to use something more complex than that.
- 14:24By itself doesn't mean modeling.
- 14:25Machine learning is types of statistical models that learn from data to make decisions.
- 14:31So that is just a broad field of modeling that is what most people think about when you
- 14:36think about machine learning.
- 14:37And it's just the modeling aspect.
- 14:38And we can go into the classes of models you have, like class supervised, which is basically
- 14:44you can have a model, look at a bunch of data that has a decision.
- 14:48So like if you look at a bunch of pictures of cake and it says it will be cake, and then
- 14:52you look at another picture that's a bunch of raw ingredients and it'll say it's not cake.
- 14:56You know, you can train an algorithm to look at those two pictures and make the correct
- 14:59decision by optimizing a function.
- 15:01Right.
- 15:02Where you have, you already know the answer and you kind of tell it like a kid.
- 15:06That's right.
- 15:07No, that's wrong.
- 15:08Right.
- 15:08Oh, good job.
- 15:09That was right.
- 15:10You know, and so on.
- 15:10Yeah.
- 15:11And it takes that feedback sort of iteratively and like evolves itself.
- 15:14Exactly.
- 15:15And it's extremely, extremely dumb.
- 15:17So you have to just have a lot of training data that is balanced and meaning you have
- 15:21the same amount of pi not pi type scenarios.
- 15:24So it knows how to learn from that and have very catered data sets that don't generalize
- 15:29very well.
- 15:29On the far other extreme side of things, you have completely unsupervised learning, which
- 15:34is basically let's throw some data at this algorithm and see what patterns emerge, see
- 15:38what groups happen.
- 15:39So it's very good to use like for very early on exploratory analysis of like I have a bunch
- 15:44of data.
- 15:45I have no idea what to do with this.
- 15:46Let's see if there's anything interesting here.
- 15:47But in between the supervised and unsupervised, you'll have like supervised learning or semi
- 15:52supervised learning and reinforcement learning, which basically what they do is it's a combination
- 15:58of those two where you have not quite explicit labels on everything, but it's not completely
- 16:02just sending an algorithm out in the unknown to figure out what's happening.
- 16:05And that's where you've seen like a lot of AlphaGo and a lot of really cool problems
- 16:10have been done with reinforcement learning and semi supervised.
- 16:13Okay.
- 16:13And there's a lot going on in that space as well.
- 16:15Yeah.
- 16:15Well, I think that's a pretty good overview and unsupervised side.
- 16:20That's probably the realm of where people start to think, you know, computers are just learning
- 16:26on their own.
- 16:27And what if they get too smart and they just, you know, take over or whatever.
- 16:32But that's kind of, I would say that's probably the almost the science fiction side of things,
- 16:38but it's also real.
- 16:39Obviously people are doing it, but that's probably what people think of when they think
- 16:43of AI is like there's data, the computer looked at it and then it understood it and learned
- 16:48it and found things that humans maybe wouldn't have known about.
- 16:50Definitely.
- 16:51Some of the continuous learning stuff, which is a part of subset of that.
- 16:54Yeah.
- 16:54And then the very minor part of deep learning was basically as a subset of machine learning,
- 16:58which is looking at trying to copy how your brain synapses work.
- 17:01And it's just a type of machine learning where you think of the convolutional neural networks
- 17:04and things like that.
- 17:05So there's like the three big tiers and the different parts that fit in between those.
- 17:08Yeah.
- 17:09And when I was talking about quantum mechanics analogies, I was thinking of deep learning.
- 17:13Exactly.
- 17:14Exactly.
- 17:15And like deep learning is extremely valuable.
- 17:16A lot of the really cool research problems you're seeing people develop, OpenAI and all
- 17:20of these people are using that for doing reinforcement learning with deep learning and things
- 17:24like that is not what a lot of companies are using today in regulated industries or even
- 17:29in most of most of America.
- 17:30You know, a lot of companies are using more traditional supervised and just even getting
- 17:35past linear regression in a lot of instances.
- 17:37The deep learning stuff that science fiction people are using, but it's not very widely deployed
- 17:41yet because there's a lot of problems with the deployments.
- 17:44Yeah.
- 17:44And probably even just knowing with certainty that it's right and that it's reproducible.
- 17:49Completely.
- 17:50Yeah.
- 17:50Yeah.
- 17:51I think that the, you know, it's such a buzzword machine learning and AI that, right.
- 17:56If a lot of people seem to think, well, even if just an if statement is in there, like,
- 18:01well, the computer decided, so that's AI.
- 18:03It's like, well, that's not really what that term means, but that's okay.
- 18:07I guess the computer decided, yes, you're right.
- 18:10But that's just code.
- 18:11I mean, code's been having if statements for a super long time.
- 18:14I was thinking back to something in the British parliament where they were upset that there
- 18:19was some airline, which is bad, that some airline was looking when people would book tickets.
- 18:25If the people had the same last name, they would put them in different seats away from
- 18:30each other and then charge them a fee to put them back next to each other.
- 18:33And they were saying that this, this AI system that is causing this, that they're abused.
- 18:39This is not AI.
- 18:40This is just an if statement.
- 18:41If the names are the same.
- 18:43Exactly.
- 18:43They're going to come apart and offer them the upgrade to get it back together.
- 18:46Exactly.
- 18:46Yeah.
- 18:46So I think it's interesting to think about how companies can apply machine learning and maybe
- 18:52the hesitancy to do so.
- 18:55Right.
- 18:55Like if if I'm applying for a mortgage and the company is using, you know, some deep learning
- 19:02algorithm to decide whether I'm a good fit to provide a mortgage to.
- 19:07Right.
- 19:07Some states in the United States have like walkaway laws, right?
- 19:10You just decide like, I don't want to pay anymore.
- 19:12And you can have the house even if it's like in crappy condition and not worth what it was.
- 19:16Right.
- 19:16So it's a big risk.
- 19:17So they want to get that answer right.
- 19:20Yeah.
- 19:21Exactly.
- 19:21But at the same time, I'm sure there's regulations and stuff saying you can't just randomly assign
- 19:28or not assign or have some super biased algorithm just making this decision and say, well,
- 19:34it's not our fault the computer did this, you know, unjust thing or whatever.
- 19:38Right.
- 19:38Exactly.
- 19:39And that's what a lot of insurance companies, for instance, are struggling with right now
- 19:41is there are laws in the US on like fairness and you can't do gender discrimination or those
- 19:49sorts of different protected classes discrimination.
- 19:51But there's not a very hierarchical full regulation around machine learning right now.
- 19:57So a lot of companies are kind of in the dark on like regulators don't really like machine
- 20:01learning.
- 20:01They don't understand it.
- 20:03They don't like the non deterministic aspects or like it's a they like rule sets.
- 20:07Right.
- 20:07So if this happens, we'll do this.
- 20:08They're very comfortable with having those sorts of rules, but having this kind of nebulous
- 20:12modeling.
- 20:13Exactly.
- 20:14It's easy to do a code audit and say, OK, this is the part where they tested like their income
- 20:22to credit card debt ratio.
- 20:25And it was above the threshold you all have said.
- 20:28And so you said no.
- 20:29And so it's because they have too much debt.
- 20:31And in fact, I can set a break point and I can step down and look at the code, like making
- 20:37those decisions and comparing those values.
- 20:40And then here's what it does.
- 20:41Right.
- 20:41And as far as I know, like break points and deep learning don't really mean a lot.
- 20:46Yeah.
- 20:47Because a lot of times if you use like a support vector machine algorithm, you won't have a
- 20:52linear decision boundary, meaning that sometimes if you have income over this amount and this
- 20:56other thing will give you a loan.
- 20:57And other times we won't.
- 20:58It depends on what some of the other inputs are.
- 21:01So that's where regulators get very nervous because you can't have that strict rule based
- 21:05system.
- 21:05Yeah.
- 21:06But at the same time, this is an amazing technology that could make, you know, make those decisions
- 21:11more accurate.
- 21:12And it could be better.
- 21:14Right.
- 21:15It could actually understand like, yeah, OK, so you do have a lot of credit card debt, but
- 21:18you're doing this other thing that's really shows that you are a good borrower.
- 21:22Right.
- 21:23Exactly.
- 21:23Their code would have completely ignored.
- 21:25But the machine learning is like, no, no, that actually those type of people are good.
- 21:29You want to loan to them.
- 21:31Right.
- 21:31You want to lend to them.
- 21:32Exactly.
- 21:33Because it could be good to have this.
- 21:35Right.
- 21:35It's not just a negative.
- 21:36It's just you just don't know.
- 21:37That's a part of the challenge.
- 21:39Exactly.
- 21:39Because you could have be able to do more targeted rates for consumers so then they can
- 21:44have lower rates.
- 21:45The custom, the insurance company will have lower default rates.
- 21:48Basically, everybody wins.
- 21:49The problem is for for executives and regulators is how do you know that this how do you have assurance
- 21:55and trust the system is doing what you want to do and you're not going to end up
- 21:58on the front page soon like the Apple credit card thing a few months ago with, oh, you were
- 22:02really discriminatory or you messed this up.
- 22:05So the problem is we're being able to provide that assurance and trust over algorithms to allow
- 22:10them to be deployed.
- 22:11And that's kind of where the industry is struggling with right now because no one really knows quite
- 22:15how to have that with these deterministic qualities.
- 22:17Like how do you get that assurance around the model doing what it's supposed to be doing?
- 22:20So that's where there's a lot of work right now on the different machine learning monitoring
- 22:22you can doing.
- 22:23Do you need a third party to monitor those sorts of things so you can provide that trust
- 22:27and risk mitigation to be able to deploy the algorithms that are beneficial for both the
- 22:31company and the consumer?
- 22:32Sure.
- 22:32And, you know, we're talking about America because we both live here and whatnot.
- 22:38But I think actually Europe probably has even stricter rules around accountability and traceability.
- 22:44Definitely.
- 22:45That's a good stuff for my cursory experience of both.
- 22:47Definitely.
- 22:48And Europe's actually doing a better job of first regulating it right now and also providing
- 22:52guidance around the regulations.
- 22:54So GDPR has several, that's the General Data Privacy Act in Europe, has some regulations
- 23:00around like if a consumer's decision has been made fully automated, such as the example you
- 23:04just gave, the consumer needs to know and they can request the logic on how that decision
- 23:09was made.
- 23:09So there's a lot of user consumer protections around machine learning algorithm use in Europe.
- 23:14And there's also a lot more guidance.
- 23:16Europe is now a little behind on, they're creating now a white paper on guidance around how would
- 23:20you make sure the algorithms are doing what they should be doing to help the companies.
- 23:24But Britain, the UK has, Information Commissioner's Office has released two different white paper
- 23:30drafts on how you do explainable AI.
- 23:33How do you make sure you have the assurance around your algorithms and actually doing some prescriptive
- 23:37recommendations on how to do that correctly.
- 23:39So like Europe is really ahead of the US right now on first regulating AI and then also helping
- 23:44companies and consumers understand it and find ways so they can still use it.
- 23:48US hasn't really addressed those yet.
- 23:50Yeah.
- 23:50Yeah.
- 23:51And it was exactly that situation that you were talking about.
- 23:54If a computer has made a completely automated decision, the consumer can request why, right?
- 24:02Exactly.
- 24:03And that was like thinking around this entire conversation, like that is the core thing that I think is at
- 24:07the crux of the problem here that made me like interested in this because the deep learning stuff
- 24:12and the ability to get a computer to understand the nuances that we don't even know exist out there and make
- 24:20better decisions.
- 24:21I think that that's, that's really powerful.
- 24:24And as a company, you would definitely want to employ that.
- 24:27If it's required that you say, well, it's because your credit to debt ratio was too far out of bounds.
- 24:34Like, how are you going to get a deep learning, like poorest sort of thing going on and go, well, it said this.
- 24:42It's like, well, the weights of the nodes were this.
- 24:45And so it said, no, that's not satisfying or even meaningful.
- 24:48Right.
- 24:48Like, I don't even know how, how do we get there?
- 24:51Maybe we get, maybe ultimately people would be willing to accept, like, I don't even know.
- 24:57Maybe there's something like, okay, it, it's made these decisions and it, we had these false positives and we had these false negatives.
- 25:03Like, almost like an AB testing or clinical trial type of thing.
- 25:07Like, we're going to let 10% of the people through on our old analysis anyway.
- 25:12And then compared to how the machine learning did on both like the positive and negative.
- 25:17I don't know.
- 25:17But like, how do you see that there's a possible way to get that answer?
- 25:21Yeah.
- 25:22There's a couple approaches.
- 25:23One of the main ones has been a lot of my research the past couple of years, which is you can provide assurance around the implementations because like a lot of the points that you just mentioned, we don't have that ability with a human.
- 25:32And you usually understand why did a loan officer give that loan either?
- 25:35Like, there's the type of understanding some people are asking from algorithms doesn't really exist with humans either.
- 25:40If you ask a human two weeks later why you made that exact decision, they're not going to say the same thing that they were thinking at that time.
- 25:45So you want to provide a trust and an audit trail and then transparency around an algorithm.
- 25:50Basically give it a history and show that it's been making reliable decisions and it's operating within the acceptable bounds for the inputs and the outputs.
- 25:58So being able to provide this holistic business understanding and process understanding is very huge.
- 26:02It's very it's not really as much of a tech problem as it is a business problem and a process problem.
- 26:07But also be able to provide the ability of this is what the algorithm saw when it made this decision.
- 26:13So for even a deep learning algorithm, say you are taking in FICO score and you're taking an age and you're taking in zip code and things like that to make this decision.
- 26:21Some of those are protected glasses, but you're taking in information by a consumer to understand.
- 26:26You don't need to see like what neural network layer said something.
- 26:28It's like based on these features, because your your FICO score is above 600 and because your zip code was in this high income area, we're going to approve this loan or not approve this loan.
- 26:38So that you can see with some research.
- 26:41Anchors is a great library that was open sourced a few years ago.
- 26:44It's a there's Python implementation and Selden Alibi has a library that's really, really good that has a production grade implementation.
- 26:51Can help you see what did the algorithm see when it made this decision?
- 26:54So you can start addressing that inside the whole bigger process of providing business and process understanding.
- 27:00I see.
- 27:01So there's all these different facets or features that come in and you can say you can't exactly say, you know, here's how the flow went through the code and here's the if statement.
- 27:12But you can say it keyed off of these three things.
- 27:17It keyed off the fact that you have three cars leased and you have this credit card or whatever.
- 27:24Right.
- 27:24Like it said, those are the things that like sort of helped it decide.
- 27:28Made a decision.
- 27:29Exactly.
- 27:29Exactly.
- 27:30So when you put that in tandem with understanding the whole process, providing the ability to go back and verify, you can start getting more assurance around the implementation and start getting comfortable with it.
- 27:39Because that's the other problem.
- 27:40A lot of times with these algorithms is like it makes a decision.
- 27:43And as a company, like how in the world if a customer asks, why did you make this decision about me six months ago?
- 27:47How are they going to go back and get the exact log file, make sure you have the exact model version, be able to rerun that specific model version and see all these types of information?
- 27:55It's not strictly just a tech problem of let me see which neural network layer was activated and which neuron.
- 28:03Like it's more process based and there's a lot of components to it.
- 28:07So that's where a lot of times we see right now in the data science community, people trying to solve this problem by building better explainability, by understanding that neural network better.
- 28:15But that's not really addressing the consumers ask on like, why did this make decision happen?
- 28:19How do I know that you just didn't arbitrarily make this?
- 28:21How do we know it's not biased?
- 28:22Those sorts of more fundamental issues aren't something you can just address by better neural network explainability tool.
- 28:29Yeah. Do you think there's somewhere out in the future, the possibility of like a meta network in the sense that like there is a neural network that looks at how the neural network is working and then tries to explain how it works?
- 28:42Like use AI to like get it, get it to sort of answer what the other AI did.
- 28:46There's definitely some things like that currently in research.
- 28:49There's a whole bunch of different good explainability libraries out there and people that are addressing specifically those types of problems.
- 28:54And that's Monotar is doing that as well, except for more of the business process side and the basic understanding about the model.
- 29:00It's really to get the consumers comfortable.
- 29:03It's going to be understanding and being able to prove why something was done, which is more than just specific deep learning interpretability.
- 29:10Because a lot of times these loan models and stuff are still like we're moving from a loan officer to trying to do a very basic machine learning model.
- 29:17Like they haven't even gotten to complexity of deep learning.
- 29:20So it's like incremental improvements.
- 29:21Right.
- 29:22You talked about your origins being in the big data era and all that.
- 29:27Is there some sort of statistical way that people might become, you think, comfortable with things like deep learning, making these decisions?
- 29:34Like, so for example, you've got all of the records of the mortgages in the US.
- 29:42If you were able to take your algorithm and run it across those as if it was trying to make the decision and then you have the actual data, kind of like the supervised learning you talked about going through and saying, OK, we're going to apply it to all of this.
- 29:57Maybe we don't share that data back with the company, but they give us the model.
- 30:01We run it through all of it.
- 30:03And it's within bounds of what we've deemed to be fair to the community or to the country.
- 30:09Definitely.
- 30:09So that's those are some definitely tests we can do.
- 30:12And ideally, if you're building a loan algorithm, you're going to want to see what those historical statistics are to make sure that our our model is doing, say, classification percentages to be in line with what's expected for the general population.
- 30:25So, for instance, if you're you're doing an algorithm, if you have basically this at certain FICO bands, FICO score bands, you're going to have X amount of acceptance.
- 30:34So if you start seeing your model starts really not accepting people that are in a certain range, like we can definitely start raising a flag.
- 30:40There's concept drift going on.
- 30:42So there's definitely tests you can do around there.
- 30:44There's a Fisher exact test that lets you check.
- 30:46Say if you have age, you don't really want to be using age as a indication or gender, for instance.
- 30:52But in some instances, you have to.
- 30:53So you can run a test to see if it's ever statistically significant that that one variable is negatively influencing the outcome.
- 30:59There are definitely ways you can make sure that the algorithm, based on the example you said with the loans, this is the amount of normally acceptance, not acceptance that we've had over the past X amount of years in America for loans.
- 31:10And that's kind of what we think is OK.
- 31:12There are definitely tests you can do, such as the Fisher exact test.
- 31:15It's a statistical test and others that you can do around making sure an algorithm isn't biased and it's going within the percentage that you're wanting it to do for acceptance.
- 31:22So there's a lot of tests that companies can do there, some that we're implementing, some that other people are implementing and a lot of things that people can do.
- 31:29But really, for the public to really start accepting that machine learning is OK, I think there really needs to be some sort of more government regulation that's at least even like rubber stamping that this is OK.
- 31:39And that we've looked at this algorithm.
- 31:40There needs to be like third party assurance and third party audits of algorithms or not even you don't have to share your code if it's like it's a proprietary thing.
- 31:48But just the understanding that this is doing what it should be doing and it's not discriminatory can be very important for people to be able to trust AI systems.
- 31:56I think it's going to be super important.
- 31:57And when I threw that idea out there, what I was thinking of was the XPRIZE stuff done around health care and breast cancer, where instead of you getting all the data, you submitted a Docker image with your algorithm that was then run and it couldn't communicate out.
- 32:14It was run against the data and then you got just the trained model out of it and then you could basically go from there.
- 32:22So like there was this sort of arbitrage of your model meets the data, but you don't ever see the data and no one else sees your model kind of thing.
- 32:29Definitely.
- 32:31It's just somebody needs to facilitate that.
- 32:33That's a trusted party.
- 32:34So like some sort of government regulation to enable that kind of thing.
- 32:38But those sorts of processes will definitely start allowing people to trust the system and allow state regulators and things to be able to be signing off on systems and being comfortable to let the public enjoy better insurance policies.
- 32:48Right.
- 32:49But we need to have some sort of assurance to get there.
- 32:54This episode of Talk Python To Me is brought to you by me, Reuven Lerner, and Weekly Python Exercise.
- 33:00You want to do more with less code or just write more idiomatic Python?
- 33:04It won't happen on its own or even from a course.
- 33:06Practice is the only way.
- 33:08Now in its fourth year, Weekly Python Exercise makes you a more fluent developer.
- 33:13Between pytest tests, our private forum, and live office hours, your Python will improve one week at a time.
- 33:21Developers of all levels rave about Weekly Python Exercise.
- 33:23Get free samples and see our schedule at talkpython.fm/exercise.
- 33:29So you talked a little bit about some of the Python libraries that are out there to help people understand how these models are making decisions and understand a little bit better.
- 33:40Some other things that are probably, like we could talk about some of the other things you're doing and, you know, some things that might matter.
- 33:48It's like you talked about the company that if I asked them six months later, why did you decide this thing, right?
- 33:57They probably still have all of my form fields I filled out.
- 34:00Like my credit history is X.
- 34:02My average income is whatever.
- 34:05I've been in the job for this long.
- 34:08But how would they go back and run that against the same code, right?
- 34:13So maybe what they would do is they would go and say, well, let me just ask the system again.
- 34:16What would the answer be now and why?
- 34:18But they may have completely rolled out a new version of code, right?
- 34:21It might not even do the same thing.
- 34:23And I'm sure they don't have like retroactive versions of like the entire infrastructure of the insurance company around to go back and run it exactly.
- 34:33Maybe they do, but probably not in a lot of companies.
- 34:35Like the ability to almost a version control, but like production, right?
- 34:40So knowing how the model changes over time, like what else do you guys need to look at or keep track of to be able to like give that kind of, you know, why did this happen?
- 34:51Answer.
- 34:51Definitely.
- 34:52And that's the key part is summarizing all information and being able to replay that exact algorithm with the decision.
- 34:57So to be able to do that, you really have to have exact feature inputs.
- 35:02Like what exactly did the user say, the exact model version, you need to know the, so like the model object file, the pickle file, something like that, the exact production Python code.
- 35:11Then you have to have the actual version of the library used in the same environment.
- 35:16So there's a lot of things going on there and the amount of logging and that you have to have in place there and have it very easily to be accessible and non tampered with and be able to recreate that environment.
- 35:25That's a hard technical problem.
- 35:26A lot of companies don't have in addition to just having like the, how do I understand that the exact, some sort of interpretability for the decision and then the metrics and monitoring around it.
- 35:35That's a big ask.
- 35:36And that's where a lot of companies are struggling when they start hitting these regulatory audits.
- 35:39Sure.
- 35:40Well, I can imagine it's really tricky to say, all right, well, when our app started up back then and we went back and we looked in the logs and it said this version and this version, this version of the library, but maybe somebody forgot the log.
- 35:52Oh yeah, there's a dependency library that actually matters.
- 35:54And it was that version where we were running on this version of Python and its implementation of, you know, floating points slightly, slightly changed.
- 36:04And it had some effect or I, you know, I don't know.
- 36:06Right.
- 36:06Like there's just all these things.
- 36:08And it seems like there's probably some analogies here to the reproducibility challenges and solutions that science even has.
- 36:17Exactly.
- 36:18It's along the exact same lines, but it's even more exacerbated and more difficult to solve.
- 36:23Because if you think about science, it's like you're trying to reproduce the results of one paper.
- 36:27You know, if it's a biological experiment, it might be a little harder to recreate those conditions.
- 36:30But in computer science, like you should be able to save the seed, send a Docker file with everything and rerun your algorithm results.
- 36:36Right.
- 36:37But people are even having a hard time to do that because the amount of process and forethought into how you're going to be packaging things, how you're going to be setting things up, it's a lot to deal with.
- 36:45But like reproducibility is just a major crisis in science right now, too.
- 36:48But it's really hitting the corporate environment really hard to be able to provide that kind of ability around the algorithms to be able to answer questions.
- 36:56Because if like you want to implement these things, people are going to want to have audits and they're going to want to understand why something was done.
- 37:00So exactly what's happening in the scientific community, except even on a larger scale.
- 37:04Now, two things you talk about when you look at Monitar's website, talking about what you all do there.
- 37:10One is counterfactuals.
- 37:13And the other is detecting when model and feature drift occur.
- 37:19Do you want to address those problems a little?
- 37:20Yeah, definitely.
- 37:21So counterfactuals is basically what we've just described is the re-performance of an exact transaction.
- 37:27So we record all those things, the versioning of all the files.
- 37:30So when you go back six months from now, six years from now, and go and select on a specific transaction, if it's a tabular transaction, we can actually hit a button and we will pull all that stuff up in a Docker container and rerun it.
- 37:43So that's what we're calling counterfactuals is the ability to go back and re-perform a transaction and then perform what-if analysis.
- 37:48Say like one of the variables said your income was $200,000.
- 37:53And if you want to change it to $150,000, you can go do that and rerun the transaction as well off of that old version.
- 37:59So it allows you to do the sensitivity analysis if a consumer is like, well, what if my income was slightly different?
- 38:03But also re-perform for audit tracing that it's doing exactly what it said it was going to do.
- 38:08Sure.
- 38:09Okay.
- 38:09And then model drift.
- 38:11Yeah.
- 38:11Model drift is exactly like what we were talking about a few minutes ago with you have loans.
- 38:15Normally 60% of loans are rejected, 40% are accepted.
- 38:18And that's kind of the average for this risk class.
- 38:21Model drift will allow to see in a monitor platform when your model has started to drift out of those bounds.
- 38:27If you say, I'm okay if the model's in between 75% classification and 50% classification of you don't get a loan of rejection.
- 38:34And if we start slipping to 80% of loans are now being rejected, we're going to throw you alerts and say, hey, your model has drifted.
- 38:40Something is wrong here.
- 38:41I see.
- 38:41Yeah.
- 38:42So it's not necessarily detecting that the model is making some variation in its predictions, but it's saying you've set these bounds.
- 38:52And if it's outside of these bounds, like something is wrong.
- 38:54Let us know.
- 38:56Exactly.
- 38:56And that will be saying that the algorithm is making kind of a drift in what it's supposed to be predicting.
- 39:01Same with features.
- 39:02There's a lot of times, there's a great paper a couple of years ago by Google called the high debt or high credit card debt or something in machine learning implementations.
- 39:10The name's not quite right there, but it's a very popular paper on technical debt, whereas basically a lot of times when you have an algorithm, a lot of the code around it is where your issues are going to happen.
- 39:20So if you have a model that's used to having features between 1 and 10, and you start having a drift with a mean of 5, and you start having a drift up, that can be affecting the model's outputs, but you can't really detect it until it's too late.
- 39:33So what Monotar does is we allow you to look at the feature drift and see, like, if I'm expecting this feature between 1 to 2 standard deviations of 5, a mean of 5, and you start getting higher numbers out of there, we'll know, like, hey, there's feature drift, which means your model is not performing in the same environment that it was built for.
- 39:50So we'll be able to know that, hey, you need to go look at this, the situation your model's built for has changed.
- 39:55Because a lot of times when these models start misbehaving, it's not because the model code has changed, quote unquote, it's because the environment that it was built for has changed.
- 40:03You're no longer in that same environment.
- 40:04I see. And that's one of the real challenges of the whole ML story, right?
- 40:09Is the model's good at answering the question the model was intended to answer, but it may be completely inappropriate for something else, right?
- 40:18Like, self-driving cars work great in Arizona, but you put them in the snow and they can't see the road anymore because they don't know to look at snowy roads or whatever, right?
- 40:27Exactly. Because algorithms are extremely, extremely dumb.
- 40:30Like, people are trying to make them better with this transfer learning and some of the semi-supervised learning and things.
- 40:36But when it comes down to the root of it, there is no thinking going on here.
- 40:39It doesn't matter how accurate it is at detecting cancer and radiology images.
- 40:42There is no thinking. It's a dumb algorithm that's made for a specific set of circumstances.
- 40:46It can be fantastic as long as those circumstances change.
- 40:50But that's where the key problem happens in production is those circumstances no longer hold true, so your model starts performing badly.
- 40:55Your model is doing the exact same thing it was trained to do, just the inputs are different.
- 40:59I see. So one of the things that might be important is to keep track of the input range and document that in the early days and then keep checking in production that it still holds true.
- 41:13Exactly.
- 41:14Exactly.
- 41:15And that's where we can start testing for bias and things like that as well.
- 41:19Seeing with one specific variable, such as we mentioned, gender variable, if that starts being a key influencer for a decision, we also know something is up there.
- 41:28So you can start doing proactive bias monitoring.
- 41:30Interesting. So maybe you don't actually want to take gender into account, but it's somewhere in the algorithm or somewhere in the data.
- 41:39And you can test whether or not it actually seems to be influencing.
- 41:44Like you can detect bias in a sense.
- 41:46Exactly. You choose whatever feature.
- 41:48Like if you're building an algorithm, you should try and never have gender or something like that in there.
- 41:52But occasionally, such as you think of cancer screening, you're going to have to include that because that's a key component.
- 41:57I would argue you should never include gender if you're doing a credit card application.
- 42:00But if you're doing something more fundamental, like cancer screening or something, you still need to be able to have those sorts of things.
- 42:05Or like if it's a image recognition algorithm, you're going to have to include race just because it may may different skin tones may affect the results of the algorithm.
- 42:13Doesn't mean we're trying to be any sort of bias.
- 42:16But that's why you want to have these controls to make sure bias doesn't occur.
- 42:18We've had a lot of radiology implementations that won't work as well on certain individuals.
- 42:23So like there's all these things that machine learning can improve everybody's lives.
- 42:27We just need to have the right safeguards in place because almost every single company is deployed machine learning.
- 42:32None of them are trying to be discriminatory.
- 42:33That's not the purpose.
- 42:35They just there's these things that will happen and they're not aware of.
- 42:37So it's just making sure you have a controlled environment to make sure that doesn't happen or being able to catch it when it does happen so you can fix it.
- 42:43Yeah, that's pretty awesome.
- 42:44What else should people be thinking about that they either need to be doing, logging, trying to use libraries to help with, especially in production with their models?
- 42:56Definitely like the structure of how you do your models is very important.
- 43:01I'm a huge advocate of using microservices and Docker containers and trying to do, especially for these complicated deployments, make as many of the services possible.
- 43:11So it's just like sometimes you want to have your algorithm is strictly in a container and then it will interact with your logic in a different container.
- 43:17Because when sometimes you have everything combined into one area is when you can start having like that technical debt and things build up.
- 43:23And it's very hard to figure out what's broken and where is it broken.
- 43:26So being able to keep things as separate as possible in complex deployments really helps to figure out the root cause.
- 43:32Yeah, that's interesting.
- 43:33Because if you have it kind of mixed in to your app, you probably deployed 10 versions of your app.
- 43:40Did any of them actually affect the model or was that just like to change some other aspect of an API or some aspect of the website or something like that that is just,
- 43:50well, we changed how users log in.
- 43:51They can now log in with Google.
- 43:53But that didn't affect the machine learning model that we're deploying.
- 43:56But if you have it as a separate API endpoint that's its own thing, then you know.
- 44:01Exactly.
- 44:02It's the same thing from like science is how do you get rid of the confounding variables and do as much of a control test as possible.
- 44:08So the more you can have those things that you know what's changing, you'll know what to fix when something breaks.
- 44:13So having those sorts of architectures and really coming in with document, document, document and auditing because I'm an ex-auditor.
- 44:19If it wasn't documented, it doesn't exist.
- 44:21Not really true, but that's how auditors look at things.
- 44:24But that's extremely important to do when you're working in regulated industries or you're working in areas when you're building these models.
- 44:30You need to document all your assumptions.
- 44:31Where's your data coming from?
- 44:32All of this, the plain businessy things that, frankly, data scientists hate to do.
- 44:36I hate to do it as well.
- 44:38But you need to have that kind of thing for being able to show other people, different stakeholders, and also, frankly, even cover yourself if something comes back later.
- 44:47Like, here's why we did something and helping you remember if you look at this code six months ago.
- 44:51So just the documentation, having these sorts of planned way that you're building an algorithm instead of just agileing.
- 44:57Agile is great, but you have to have an overarching plan for some of these things instead of just MVP it until it hits production.
- 45:03Sure.
- 45:03And while it also sounds like a little bit of the guidance is also just good computer science.
- 45:09Right, exactly.
- 45:10It's a very big problem in this space is data scientists are not normally good software engineers.
- 45:17So a lot of the great software engineering practices haven't really translated into machine learning code.
- 45:21There's becoming a big trend towards that with machine learning engineers and things.
- 45:25So we're definitely trending in the right direction.
- 45:27But still, there's a lot of models that get deployed that don't have the engineering rigor that is common in the Python community.
- 45:33Like, there's certain ways we do things with CI/CD, with unit tests and stuff, and a lot of machine learning code doesn't have those things.
- 45:39Sometimes you can't really, in a non-deterministic outcome, it's hard to unit test.
- 45:43But there's a lot of the processes of good engineering that we can apply to help make everybody's lives easier and better AI deployments.
- 45:49Sure.
- 45:49I was thinking about that as well in testing.
- 45:51And it just seems like that's one of the areas that is tricky to test.
- 45:55Because it's not like, well, if I set the user to none, and then I ask to access this page, I want to make sure it does a redirect over to the login page.
- 46:05If I set the user to be logged in, and I ask the same thing, I want them to go to their account page.
- 46:09And so it's super easy to write that test.
- 46:11User's none, call the test, check the outcome.
- 46:14User's this, call the test.
- 46:15What about testing these ML models?
- 46:18It's definitely a challenge, and it's a developing art.
- 46:21And it's more of a science at the moment than, more of an art than a science.
- 46:26But one of the ways you could do it is kind of like how we talk about ranges, is you'll say, like, to unit test a machine learning algorithm, like, hey, we're expecting a range between this and this, and we're acceptable.
- 46:35These are acceptable ranges.
- 46:36And you just use it there.
- 46:38You won't know if 100% is working, because you would have to look at over time to see if there's drift.
- 46:42But you'll be able to say, like, hey, if it's a regression problem, meaning I have an output between 1 and 10, and it's supposed to be a 5, if I'm hitting an 8 or a 2, that means something's probably not quite right.
- 46:53You can put some sort of ranges for your unit test.
- 46:55So it can't be quite the deterministic, like, I know exactly this test is failing or not, but at least can give you some assurance and some heads up for your curve.
- 47:02Sure.
- 47:03So maybe it feels a lot like testing scientific things as well, right?
- 47:08You can't say, if I call the, you know, estimate, whatever, right?
- 47:13And I give it these inputs, all floating point numbers, I can't say it's going to be equal to 2, or it's going to be false.
- 47:20It's probably some number that comes out.
- 47:22And you're willing to allow a slight variation, because, like, the algorithm might evolve, and it might actually be more accurate if it's a little, you know, if it's slightly better.
- 47:31But it's got to basically be within a hundredth of this other number, right?
- 47:35So you've got to do, like, range.
- 47:37Like, it's in this range, and it's not too far out.
- 47:40I guess it's probably similar.
- 47:42What do you think about, like, a hypothesis or other sort of, like, automatic property-based testing where you could say, give me some integers here in this range and give me one of these values and sort of give me a whole bunch of examples and let's test those.
- 47:57That's definitely a very good, sensitivity analysis is a very good way to do that.
- 48:02So, like, ideally, you'd want to do that kind of testing.
- 48:04So it's better.
- 48:05You can't really unit test as well.
- 48:06Like, we talked about that.
- 48:07But sensitivity analysis testing is fantastic to do, which is, like, here are the different scenarios, here are the different users we would get, and run a bunch of them with slight variations through your model and see if it performs as it should.
- 48:17So that is definitely a very good way to test a model, and you should never deploy a model without doing that.
- 48:22The other test you can kind of do is you can't really unit test machine learning code too accurately, but you can unit test data.
- 48:29So there's a couple good libraries out there that will help you unit test data right now.
- 48:33I think marbles might be one in Python, and I think there's great expectations that you see, like, is the schema right?
- 48:39So that's really huge because, like, this is supposed to be an int, or is this supposed to be a float, or, like, a float between these numbers and things.
- 48:45So you can really check the input data too.
- 48:47So there are some tests you can do a little more accurately around your data in addition to the sensitivity analysis.
- 48:52Yeah.
- 48:53Great expectations.
- 48:54It's cool.
- 48:54It's got things like expect column values to be not null, or expect column values to be unique, or expect them to be, you know,
- 49:03between such and such values.
- 49:04That's pretty cool.
- 49:05Yeah.
- 49:06So it's a very cool library.
- 49:07Very good to do that kind of testing.
- 49:08Yeah.
- 49:09I suppose if you have some sort of, you talked about unexpected situations as, like, it's, you know,
- 49:15my analogy was it's built for dry, sunny roads, not snowy roads, and automatic car driving or automated driving.
- 49:22But similarly, it's probably not built to take a null or none in a spot where it expected a number, right?
- 49:30What's it going to do with that, right?
- 49:32And that's, it's great to do the looking for the, using a Taleb example, black swans.
- 49:37Like, it's good to test your model for when something bad is going to happen.
- 49:40Like, even just to do the correct try accepts type statements around it.
- 49:43For like, here is something crazy that should never happen, but let's see what happens anyway.
- 49:47So we can handle that.
- 49:48So we don't become the next news story with this company really screwed up type scenario.
- 49:53So it's good to do those types of tests that are just like, we hopefully never have this, but what happens if?
- 49:58So we can build the type of exceptions and logic around those sorts of crazy scenarios.
- 50:02Sounds good.
- 50:03Sounds like a lot of things that people can go figure out, you know, find some of these libraries, try to add some of these techniques.
- 50:10I mean, you guys over at Monitor are doing this.
- 50:13You're not quite out of Techstars yet.
- 50:15You know, people can check you out.
- 50:16What else would you recommend that folks maybe look into to make this practical in their environments?
- 50:23So definitely those two great expectations is great for like unit testing your data.
- 50:27Alibi is a library that has anchors implementation.
- 50:30I was talking about anchors at explainability library.
- 50:32It basically gives you if statements on why a transaction was done.
- 50:35It's kind of a 2.0 from Lime, which is a very popular data explanation.
- 50:39Those are some good ones.
- 50:40Shapp is a great library as well.
- 50:42It gives you, it's game theory based for giving you values of what's, how your algorithm is interpreting a decision.
- 50:47That's cool.
- 50:48Yeah.
- 50:48So it's a very, very cool, cool library.
- 50:51And then it's just really starting to apply.
- 50:53So that's all of the like explainability type scenarios.
- 50:56Py Metrics has a very cool library that does some bias detection.
- 51:00That's something that's really cool to check out.
- 51:02Quintus is as a bias and fairness audit toolkit that is really cool.
- 51:06And that's out of the University of Chicago.
- 51:07So those are some good ways to get started on how to provide more assurance around your models.
- 51:12And then just really, you want to be doing Docker, you want to be doing best practices on your engineering.
- 51:16Yeah.
- 51:17So some of the good places to start.
- 51:18Yeah, absolutely.
- 51:19You know, something that came to mind while you're talking, there's this thing called missing no, missing N O, which is a Python library for visualizing missing numbers and data.
- 51:30And so you can give it interesting.
- 51:32I think Panda data frames or something like that.
- 51:35And it gives you these graphs with like continuous lines if it's everything's good or like little marks where there's like bad data stuff.
- 51:42It's a pretty cool library for like trying to just like throw your data set at it and visually quickly identify if something's busted.
- 51:49Well, that's very cool.
- 51:50I have not heard that one.
- 51:51I'm going to go check that out.
- 51:52Yeah, absolutely.
- 51:53Yeah, absolutely.
- 51:54Absolutely.
- 51:55Okay.
- 51:55One final machine learning question, I guess.
- 51:57Keep it positive.
- 51:58Like what are the opportunities for this?
- 52:01You talked about how many companies are kind of at the rudimentary stage of this modeling and predictability.
- 52:09And there's obviously a lot more way to go with the challenges that the whole episode basically has been about.
- 52:14But what do you see as the big opportunities?
- 52:16You get this.
- 52:17You get these key components, right?
- 52:19You're going to be able to start having companies providing cheaper insurance, better medical screening.
- 52:25I mean, self-driving cars.
- 52:27These are all the types of things that are really going to help society and humanity when we get right.
- 52:30There's just a few things like when we talked about to get ironed out.
- 52:33But really, like the future is very bright.
- 52:35Machine learning can do some great things.
- 52:38And like together as a community, we'll be able to make that happen.
- 52:40Yeah, awesome.
- 52:41And, you know, so you talked also at the beginning about your Techstars experience and you guys are going through and launching Monotar through Techstars.
- 52:50And that's awesome.
- 52:51But I suspect that a bit of a change has happened.
- 52:55Like Techstar, to me, these incubators and accelerators are all about like coming together.
- 53:00It's almost like a hackathon, but for a company.
- 53:02You come together with all these people and it's just like this intense period where you're all together and working with mentors.
- 53:07And co-founders and creating.
- 53:09And we've all been told to not do that.
- 53:12So how's that work?
- 53:14Well, Techstars did a very good job of switching to online.
- 53:18So still all the same things happen.
- 53:19They even started setting up some like water cooler sessions and stuff for people to kind of just chat informally.
- 53:24And so they moved to online to Zoom very, very early on and did a very smooth transition.
- 53:28So that was very good.
- 53:29They did a great job of handling it.
- 53:31We're having a virtual demo day in two weeks, end of April, which is not ideal.
- 53:37But we're going to also have a live one in September as well, I believe.
- 53:40So they're really going above and beyond to help with the transition for companies and doing a bunch of extra like extra classes around fundraising during COVID and things like that.
- 53:48So Techstars has done a great job transitioning and they had all the technology in place to make it a pretty smooth transition.
- 53:54So even though it's not the same, like the quality is still very much there and we're still getting a lot out of it.
- 53:59Yeah, that's good.
- 54:00I'm glad that it's still going.
- 54:01I mean, it won't be rough.
- 54:03How did you get into it?
- 54:04You talked about, I don't remember the exact numbers, but it sounded like 101 applicant to acceptance ratio or something like that.
- 54:11Like if people out there are listening, they're like, I would love to go through something like Techstars, maybe ideally in a year when it's back to its in-person one.
- 54:19But even not, right?
- 54:21I'm sure it'd be super helpful.
- 54:22What was that experience like?
- 54:23How do you decide to get going and how'd you get in there?
- 54:27So we did some networking around from the Boston area, kind of like meeting some of the founders in the area, different VC firms, kind of like early socializing.
- 54:34Like who we are, what we're about.
- 54:36So we kind of got our name around.
- 54:37So starting like the socialization with the, there's Techstars in different cities, kind of like getting kind of the community of founders and startups, kind of get yourself known.
- 54:46And then it's the application process.
- 54:48You just need to really rock that.
- 54:49And then just being part of the community and doing a good application and have a compelling story.
- 54:54But definitely the pre-networking before the application to kind of like start showing who you are, do as many meetups as you can, like get your name out there.
- 55:02So if someone has heard of you when they, when the application comes across, it's definitely helpful.
- 55:06Yeah, I'm sure they, oh, I've heard of them.
- 55:08They actually were doing something pretty cool.
- 55:09I talked to Andrew or something like that kind of stuff goes really far, farther than it seems like it should necessarily just like on the surface.
- 55:16But yeah, absolutely.
- 55:17There are definitely companies that got into this year's Techstars program that had, that were completely cold.
- 55:22So it's not like, it's just based on the merit.
- 55:25We happen to be in the area and had the ability to network with people before.
- 55:28But honestly, like if you're in Techstars or not in Techstars, you should be doing what we were doing anyway, socializing your company.
- 55:34So like they are very, very sure they're a fair company.
- 55:38Several of our companies are female only led.
- 55:40So it's like they're doing a great job of being a fair and inclusive place that's trying to be as non-biased as possible with acceptance.
- 55:47Yeah, that's excellent.
- 55:48I suspect that machine learning in particular and data science type of companies in general are probably pretty hot commodities at the moment.
- 55:57And you have an above average chance of getting into these type of things, just looking in from the outside.
- 56:04So even a lot of listeners who particularly care about this episode, maybe they've got a good chance.
- 56:09Definitely.
- 56:09And let me know.
- 56:10I'd love to hear your idea as well.
- 56:11Awesome.
- 56:12Feel free to reach out.
- 56:12I'm still connected in the space.
- 56:14So let me know.
- 56:15But definitely innovative AI ML companies are definitely big right now.
- 56:19It's just making sure you have something fully baked and are solving a real business problem and not just a tech problem.
- 56:24Yeah.
- 56:25Very cool.
- 56:25All right.
- 56:26Well, I think we're just about out of time there, Andrew.
- 56:29So I'll hit you with the final two questions.
- 56:31Sounds good.
- 56:32Yeah.
- 56:32If you're going to write some Python code these days or editors, do you use?
- 56:35Ah, yes.
- 56:36The famous question.
- 56:37When I'm writing real Python code, I'm using Visual Studio.
- 56:40When I'm doing exploratory data analysis stuff, I can't be Jupyter.
- 56:44Yeah.
- 56:44Those are my two go-tos.
- 56:45I used to be an Atom with Vim for my real coding stuff.
- 56:50But the newer versions of Visual Studio are just so good, I can't pass it up anymore.
- 56:54Even though I liked being a rebel and doing completely open source, like Vim type stuff.
- 56:59Yeah.
- 57:00Well, and then Atom and Visual Studio Code have such similar origins, right?
- 57:06They're both Electron.
- 57:07Atom came from GitHub.
- 57:08Microsoft now overseeing GitHub.
- 57:11I think there's a lot of zen between Visual Studio Code and Atom these days.
- 57:18So it's not that wild, right?
- 57:20It's not that different.
- 57:21That's cool.
- 57:22And then you already mentioned some really good Python packages and libraries out there.
- 57:26But other notable ones maybe worth throwing out there?
- 57:28Yeah.
- 57:28NetworkX.
- 57:29I really love NetworkX for doing graph theory and things like that.
- 57:33And it's a very good connection with like Pandas and the Python dictionaries to be able to have different nodes and edges and things.
- 57:39So if you're doing any type of network-based work, which I've done at some previous companies and PhD program, it's a very good library to have.
- 57:46My favorite machine learning library has to be SkyKit Learn.
- 57:49It's just so easy to use, intuitive.
- 57:51The documentation, like I've never seen a Python library with such good documentation and so many good examples.
- 57:57Yeah.
- 57:57And then for Alibi, I really like as well for like that Anchors implementation I was talking about.
- 58:02So those are probably my three at the moment.
- 58:04But the change is weekly.
- 58:05Yeah.
- 58:07Those are great.
- 58:08Awesome.
- 58:08And then final call to action.
- 58:10People want to put their machine learning models into production or they have them and they want them to be better.
- 58:15Maybe what can they do in general?
- 58:17And then also how do they learn about what you guys are up to?
- 58:20Definitely.
- 58:20Monitor.ai.
- 58:22Come check us out.
- 58:23If you're in a regulated industry and you're wanting to deploy a machine learning model, we offer services to help you do that.
- 58:28And also the machine learning record platform that will allow you to have that audit trail and the counterfactuals and all the things we talked about in this episode to allow you to get past the auditors and regulators and being able to move those models to protection.
- 58:41Yeah.
- 58:41Cool.
- 58:42All right.
- 58:42Well, it's been really fun to talk about machine learning and watching how it goes, verifying what it does.
- 58:48And, you know, I think these, like you said, these are the things that are going to need to be in place before it can really sort of serve the greater public or the greater companies out there that need to make use of it.
- 59:00Right.
- 59:00So great topic to cover.
- 59:02Thanks.
- 59:02Thank you so much.
- 59:03Been great talking to you.
- 59:04Yeah, you bet.
- 59:04Bye bye.
- 59:05Bye.
- 59:05This has been another episode of Talk Python To Me.
- 59:09Our guest on this episode was Andrew Clark, and it's been brought to you by Linode and Reuven Lerner's weekly Python exercise.
- 59:17Start your next Python project on Linode's state-of-the-art cloud service.
- 59:21Just visit talkpython.fm/Linode, L-I-N-O-D-E.
- 59:25You'll automatically get a $20 credit when you create a new account.
- 59:28Learn Python using deliberate practice every week with Reuven Lerner's weekly Python exercise.
- 59:35Just visit talkpython.fm/exercise.
- 59:39Want to level up your Python?
- 59:41If you're just getting started, try my Python Jumpstart by Building 10 Apps course.
- 59:45Or if you're looking for something more advanced, check out our new async course that digs into all the different types of async programming you can do in Python.
- 59:54And of course, if you're interested in more than one of these, be sure to check out our Everything Bundle.
- 59:58It's like a subscription that never expires.
- 1:00:00Be sure to subscribe to the show.
- 1:00:02Open your favorite podcatcher and search for Python.
- 1:00:05We should be right at the top.
- 1:00:06You can also find the iTunes feed at /itunes, the Google Play feed at /play, and the direct RSS feed at /rss on talkpython.fm.
- 1:00:15This is your host, Michael Kennedy.
- 1:00:17Thanks so much for listening.
- 1:00:18I really appreciate it.
- 1:00:20Now get out there and write some Python code.
- 1:00:21Thank you.
- 1:00:21Thank you.
- 1:00:41Thank you.