Podcast Lookup

Bayesian Thinking

Programming Throwdown

  • June 22, 2020
  • 1 h 34 min
  • Episode 102
Episode page
About this episodeMany people have asked us for more content on machine learning and artificial intelligence. This episode covers probability and Bayesian…

Many people have asked us for more content on machine learning and artificial intelligence. This episode covers probability and Bayesian math. Understanding random numbers is key to so many different technologies and solutions. Max and I dive deep and try to give as many pointers as possible. Give it a listen and let us know what you think! Max also has an awesome podcast, The Local Maximum. Check out his show on any podcast app or using the link in the show notes! Show notes: https://www.programmingthrowdown.com/episodes/102-bayesian-thinking-with-max

★ Support this podcast on Patreon ★

Transcript

From the publisher

This transcript comes from the podcast’s own feed, shown as the publisher wrote it.

Bayesian Thinking

00:00—
  1. A

    Programming Throwdown Episode 102: Bayesian Thinking with Max Sklar. Take it away, Jason.

  2. B

    Hey everybody! So this is gonna be an awesome episode. I know so many people have asked for more content on AI and on Machine Learning, and today we have Max Sklar, who's the engineer at FourSquare's Innovation Lab. He's going to talk to us about Bayesian Thinking, Bayesian Inference, and this whole universe. So thanks so much for coming on the show, thank.

  3. C

    You so much for having me. I love talking about this stuff. So let's get into it. I'm excited.

  4. B

    Cool, awesome. How are you doing? How are you handling the COVID situation?

  5. C

    Situation? Well, as reasonably as one can expect, I guess. You know every week on the podcast people can hear my mood going up and down and have commented as such, but I also experience.

  6. B

    Mood swings? There's something about being in the same place for everything that causes you to have these ups and downs because yeah, it seems to be a universal thing. I.

  7. C

    I feel like I was mentioning this to someone yesterday. Like do you ever go through your Apple Photos or Google Photos or whatever and just go through your past? Like the last five years, ten years, and just scroll? I'm like, what's it going to be like scrolling through these months? It's like all of a sudden I'm living my life. And then oh, it's a bunch of pictures in my room, and then a bunch of pictures of sirens going by, and then more pictures of my room, then a bunch of wires, and I said, I'm like, 'Oh, let's skip this. Let's skip this part.' Yeah.

  8. B

    It's so true. Yeah, what I heard the other day which really resonated was that 2020 is kind of like when you get bored at SimCity and you just turn on all the disasters at once. You know, kind of like what things have degenerated to. It's.

  9. C

    It's funny. I read like a full review of one of the things that I wasted my time on during this pandemic, which unfortunately I feel like I'm not alone when I feel like I could be getting so much done but I wasted so much time watching like a review of the original SimCity on YouTube. So okay, I found.

  10. B

    Out. I was reading an article that there's a game called Sim Refinery that Maxis made, I think, for Chevron and further employees, and someone was able to get a copy of it, and you can actually download it and play it in an emulator. I haven't tried it yet. Cool. So the topic is something that we need to really attack kind of from the surface because there are sort of a lot of layers to it. And so I feel like maybe one good way to get started on it is just to talk a little bit about uncertainty. I mean, there are a lot of challenges. Everyone knows software—at least most software is deterministic. You say one plus one and you expect it to be two every time. But when you're doing anything from trying to make some kind of prediction or you're getting data from some analog device or some sensor in the world around you, or even just behaviors of people, is full of uncertainty. And just in general, like how do people deal with that kind of stuff when they're writing code in this very rigid way? Yeah.

  11. C

    Well, one thing that I've learned even over the past couple of years as I've been doing this for many years is how deep the rabbit hole goes in terms of the different kinds of uncertainty and risk and probability, and the different definitions around it. Like people don't even agree on what uncertainty means or what probability means. I kind of tend to take the subjective view that it's sort of your degree of belief that something is true. But then there are the cases where you know, hey, we're at a casino, and or we're flipping a coin, and I know reasonably well what the probability is. Everybody agrees that like a coin flip is 50 percent, and the die roll is a six, a six, a six, etc. , but in the real world it's not like that. You often have cases where you don't even know what—you don't even know it's sort of subjective on what the probability is of certain events, and the best you could do is try to estimate it or try to figure out, 'Okay, what are the different possibilities that I want to consider here?' And that's where Bayesian Inference really shines. So I think the first step is to just—it's a dive into a problem, and maybe it'll help to go over some examples and try to figure out what type of uncertainty am I dealing with exactly, and kind of having that discussion with your team is usually very fruitful. Yeah.

  12. B

    Totally makes sense. I mean, I think one of the ways that sort of has both of those—your probability and uncertainty—is the classic multi-armed bandit, which is this idea where you know imagine you go to Las Vegas, and imagine now, in the real world, slot machines are highly regulated, so you could go to any casino, and I think you could even look up the probabilities; they're all posted publicly. But let's suspend belief on that for a moment, and just assume that every hotel had their own rules. Maybe some hotels are brand new, and so they make the slot machines really generous. Some of them are very strict, but you don't know what any of those probabilities are. And so you have maybe a thousand dollars worth of quarters in your pocket, or in a bucket or something, and you want to basically make as much money as possible. And so you're kind of torn because you don't—you don't know any of the information, but you don't want to waste a lot of money finding out either. You want to quickly dial that in and then choose the best slot machine for the rest of the day, and so you could see how you're sort of balancing reducing uncertainty and becoming more certain about your world with—in this case, I guess.

  13. C

    Profit. Yeah, exactly. Another one of the things that I like to talk about is what you know sometimes talk about—okay, what's the implications in terms of building a machine learning model, you know, at work? But sometimes there's also the question of what does this mean for my everyday life? And the multi-armed bandit example is the question of what is the cost of getting information? And oftentimes we don't consider what the cost of getting information to get the right answer is because it's not zero. And so people often either go into rabbit holes and try to get as much information as possible, when it kind of freezes them in place, or people will throw up their hands and just make a decision because they don't know. But taking a second to think about, you know, what's the cost of getting information and what does that get me is another way to kind of dig into a problem.

  14. B

    Yeah, yeah, totally makes sense. Yeah, and so you know, imagine if you're writing—if you're writing something that's going to do any kind of forecasting, you're invariably going to have some type of probability and then some type of uncertainty around that. So I mean, this is something that I think really gets neglected in a lot of these kind of coding bootcamps or these tutorials online, like if you've seen the show Silicon Valley, where—where...

  15. C

    I have not seen the last season, but you can spoil me if you want. Oh.

  16. B

    You know, I haven't either. So we're both in the same—okay, we're both in the same. So Patrick, try not to spoil it for us. But basically, the person I think Jian makes a hot dog, not Hot Dog app, right? Right. And so just taking that example, you know, if you build a model to do that, it's not going to say thumbs up or thumbs down; it's going to give you a probability. And if you build a Bayesian model, it's also going to give you a distribution which we can—which we can talk about. But but you have to then, you know, turn that into an action. So that really is context-dependent. For example, you know, maybe the Hot Dog, not Hot Dog app, you should only say hot dog if it's really confident because you're going to notify someone or send an email, and you really don't want to be wrong. But then on flip side, imagine something a little more serious like you're doing cancer screening. Well, maybe if you're 10 sure, you should say yes because yes means running an additional test, right? And so, so you really can't—you can't do anything in Machine Learning without, you know, dealing with probability and the sort of philosophy or economics of whatever you're trying to build and trying to marry those two together.

  17. C

    Yeah, oftentimes you're ultimately after making a decision, but you don't want to just go right away to the yes or no. You want to come up with the—with the probability or the distribution and then use that to help make the decision. So kind of breaking it up into two parts. If I could give an example from my work that—this is we'll probably bring this up again, but this is sort of a example. It might not be the most fun example, but it's definitely one of my favorites because it is just one of the projects that I've done that just brought so much value, which was in ad attribution. That was a product I worked on for Foursquare a few years ago. A lot of people, you know, in data science are going to run into attribution at some point in your life trying to figure out whether ads work or not—a big data problem. You know, lots of people trying to solve it. And Foursquare was kind of we were trying to figure out whether people whether ads were driving people into stores. And we had some visit data and we had some data on who saw the ads, and it was really hard to untangle what the—what the clients were asking for because they wanted to know lift. They wanted to know, you know, okay, what how what percent more likely is someone to visit one of my stores if I give them the ad? And an ad is it 10%? Is it 20%? Is it 5%? Um and no one asked for a probability distribution over that. They just wanted a number, an exact number. And then they wanted to tell us either an exact number or we don't have enough information to say. And originally the team was kind of just taking that at face value, being like, okay, let's try to—let's try to just calculate this number. But it led to so many problems with how accurate do we know? How accurate is this number? You know, when can we report it? When can we not report it? And then to untangle that, we took a step back and said, wait a minute, wait a minute, we don't know what the lift value... is for an ad. But let's try to turn this into a Bayesian model. And we could talk about like—I don't know if we want to kind of go back and dive into like the intro to Bayesian theory maybe after this, but we said instead of talking about what is the lift of an ad, let's say hey, we don't know what the lift of that is, but there's some uncertainty around it. There's it could be anything. And then as and we have some probability distribution there, and then as we gather more and more data, we update our probability distribution, and it gets taller and skinnier over time. And then we could come up with like a confidence range or sort of a Bayesian confidence range which is—you know, hey, your lift is somewhere in there. And then we could use that to help the clients make decisions. And it's sort of even though some clients didn't understand what we were doing, it's sort of made it a lot easier on the engineering and stats side where we could be like, okay, we now all agree on what we're doing, and what we're doing makes sense. And it was just amazing to see how it just detangled a lot of our issues. Yeah, yeah.

  18. B

    Totally. Yeah, I think you touch on a lot of things there, so we'll try and unpack that. I mean, one is, you know, I think probability distributions have to be one of the most foreign things—let's say foreign entry-level things in mathematics, right? Because I mean, there's a lot of things that, you know, string theory, there's a lot of things that are very complicated. But but I would say PDFs are probably one of the things that they're fundamental foundational, but they're also like really abstract and complicated. Um yeah, can you take a crack at sort of explaining what a Probability Density Function is to folks out?

  19. C

    There. Yeah, yeah. I mean, I guess one thing you could start with is if a PDF is blowing your mind, why not just start with the discrete case? Because—and I find this too sometimes when I'm dealing with continuous data, if I think about it in a discrete way, it's a lot easier to start. So just think of what a regular probability distribution is. You have a number of you have a number of potential events. In the case of Bayesian inference, you're usually talking about several hypotheses that you're trying to decide—okay, which one of these is the true one? Sometimes you're trying to figure out, you know, trying to make a prediction, which one of these 10 things is going to happen. And so when you have a kind of discrete probability space or a finite probability space, you can kind of say, okay, this is what it is—just going to be a bunch of numbers that add up to one, right? So each thing has a probability, and then you know you could update those values as more data comes in. A PDF is a little more complicated because it's continuous data. So instead of having it on let's say 10 possibilities or 30 possibilities or—or two possibilities, actually a lot of times it's two possibilities. You're dealing with a space that it's like okay, this is a number, this is like a real number. In the case of attribution, we're trying to find the ad lift. This is a positive number greater than zero. It's where usually it's greater than one because one means that the ad was not effective. So although there are exceptions to that, so it's—it's now you don't have you don't have some a bunch of numbers that like a bunch of values that add to one. You have a continuous space that if you know calculus, it integrates to one. Um you can kind of break up the continuous space in different ways. You could break it up into two sections like, hey, I could bucket it: what's the chance it's, you know, greater... ...than five or less than five? Well, both of those have to add to one. But you know essentially you're just searching a space of numbers, and you could even make it more complicated than numbers still. You could make it into, you know, R2, R3—a space of vectors. But then that gets even more abstract. So depending on I—I'm pretty sure you probably have listeners who are comfortable with levels of abstraction on a high level and not so much. But you know essentially you're just trying to figure out the relative probability of different possibilities. That's all of this stuff is trying to answer that one question. And I—and yeah, you know, it's your hypothesis. Yeah, it's your depending on how complicated you want your hypothesis space to be. Yeah.

  20. B

    It totally makes sense. You basically have this function, and when the function is high—like you could imagine, your mind just any type of function you'd graph on your graphing calculator or something, right? And when that function is high, you know has a high Y value, then for those values of X they're just more likely. And when the function is low, those values are really unlikely. So if you imagine like a coin toss and you're getting the PDF of this—of this coin, you know it could be you toss the coin three times to get three heads. It's possible, but it's much it's much more likely that you're going to get at least one tails. And so you could imagine, you know, the Y at 1/3 being higher than the Y at 0. But yeah, the thing that's really weird is as you said, you know, if you pick a single point it actually doesn't really mean anything. It's really just when you integrate over a range because for example, yeah, like you never in the continuous phase like you never have exactly 3/3, you know, 0.333. It's always going to be there's always going to be some uncertainty there. And so you have to deal in terms of these—of these ranges. And yeah, and so it's kind of more like a pie chart that's been kind of unrolled, in a sense. Yeah.

  21. C

    There are a number of different ways of looking at it. Another one I think of is relative probabilities. Like let's suppose you have just a standard Gaussian function that peaks at zero, right? So the zero value is the highest probability. But any single number has a probability of zero of landing on exactly that number. But you can actually compare, hey, what's the chance of me landing on zero versus the chance of me landing on one, and you can kind of compare relatively what those two are even though they're both zero, which is kind of mind-blowing until you're comfortable with calculus and differentials and all that. Um yeah, but sometimes you could just understand what the graph means like hey, I'm going to be somewhere under this graph, and so I'm much more likely to be in the high sections than the low sections. And that's sort of where my mind goes when I read a simple PDF. And then every once in a while I want to get into like really abstract like what's going on here. And you know sometimes I do read into this stuff. I read into like topology and and Measure Theory, and you could really get into—yeah, you could get into like some really abstract. I was reading the other day about—I can't believe I'm bringing this up. I was reading the other day about something called Point-set Topology, and it's this idea that in a space like real numbers, the point is not the fundamental unit. You actually can only talk about, you know, places of finite extent. So you have to be able to move a little bit to the right and a little bit to the left. And yeah.

  22. B

    Mean think about it in terms of like electricity. Like if you're doing—if you're an electrician, like you never say, okay, exactly 120.0000 volts is coming out of this socket. Like, no house has that kind of tolerance. Yeah, and so you're always thinking about things in terms of tolerance and so you're always thinking about things in terms of hopefully small ranges of numbers.

  23. C

    Yeah, and the scary thing is that oftentimes the infinite precision number really has no meaning. You know, because what does it mean to if I said there was 120 volts, but it was, you know, zeros all the way down exactly? Like, is that even possible if you go deep down into like quantum physics? Oftentimes the numbers that you're talking about stop having meaning anymore. It's one example that I give is like how many water molecules are in the Atlantic Ocean. I could probably come up with a reasonable estimate to that, but is there an exact integer that represents that value? Probably not.

  24. B

    No, and I mean with evaporation and everything, you'd never be able to count it. So another thing that I think, you know, talking about Bayesian and statistics really helps people is with generative, let's say models, but even more generically, generative systems, right? I mean, I think when people write, for example, when I write unit tests—I typically, you know, ideally, I want to make a unit test that's generative. So, for example, let's say I write my own sort—maybe, you know, I could have a unit test where I take some canonical inputs. I know what the sorted outputs are, and you know, I run my sort, and then I make sure it matches. But, you know, another way to do that would be to have a validation function, right? So, I have let's say the STL QuickSort, which I can't use for whatever reason, but I have it, and my unit test could be, you know, generate some data, run the STL sort, run my new sort, and maybe my new one's faster. You know, that could be part of the test. And then compare the results, right? So, that's this example of this sort of generative unit test. Some people hate that idea or they tell you you need to fix the random seed, and there's kind of a whole rabbit hole there. But, but, you know, you can imagine a lot of testing as being sort of generative. And I think to really understand Bayesian inference and how to build these Bayesian models, you have to think in terms of, you know, you have some phenomena that generated that phenomena, and can I artificially, you know, how much of that phenomena can I generate artificially? And so, you know, people who want to do, let's say game design, you will have to deal with this kind of thing. And so in general, it's really good for really any engineer to know how to build sort of a generative system to model some problem. Yeah.

  25. C

    A couple points on that. First of all, the idea that the first step in kind of a Bayesian inference is—once you've defined the problem, I guess I would say that's the first step is then you have to figure out what your hypothesis space is. You know, what are what is what are the possible mechanisms that I'm going to consider that could have generated the data that I'm seeing or that I'm about to see. And one of the well—I guess you could say it's like a pitfall of Bayesian thinking or Bayesian analysis is that there is no guarantee that, you know, one of the hypotheses that you come up with is true or that works particularly well. And so that's why you often need to throw in like a dummy hypothesis and say, 'Oh, this is actually just random data,' or something like that. And then if that beats everything, then, you know, okay, I either it either is random or I don't understand the mechanism.' And so, and I know we're talking kind of abstractly here, but if we can go back to—I'm not trying to get trying to figure out where we were in the conversation. If we go back to the unit test, like that's always very interesting. Like I remember writing a unit test for the sort is one thing. Like I've written some to check if a logistic regression is coming up with the right answer. And it's often you often have to kind of tell the rest of the organization, 'If my unit tests run differently,' I either have to set the random number generator in stone, in which case I don't know if I'm necessarily getting what I want. My unit test passed 95 of the time, but the other five percent it doesn't pass.' So every once in a while when you're doing this stuff, you run into problems with the organization with unit tests where I don't know necessarily know the answer other than in some cases I just have unit tests that I run offline. That aren't part of our automated testing whenever I change something that's probabilistic. aren't part of our automated testing uh in whenever i change something that's probabilistic yeah

  26. B

    Yeah, totally makes sense. Yeah, I mean, and this is true in general—is what you know, you have a generative system, especially one that's let's say generating data for a test, there's always going to be that one chance that it generates like really degenerate data, like maybe all the X's are the same. I mean, that could happen one out of, you know, a billion times or a million times. And there are unit test systems that are going to run your test a million times—maybe even a million times a day. So, so that could.

  27. C

    Happen? Yeah, yeah, exactly. Happens all the time. One in a million, one in a million. I'm not surprised by one in a million things anymore.

  28. B

    Yeah, yeah, yeah. I saw something—this is a pretty old quote, but it was from the lady who is the head of security at Twitter many years ago, and she basically said something to the effect of, 'Yeah, if there's a if there's a one in a million chance, then it happens.' You know, 20 times an hour on Twitter or something like that. Yeah, hey guys, gonna take a little break to talk about University of California Irvine's Division of Continuing Education. So this is a pretty cool program they have a variety of different kind of certificates that you could acquire. They have things like Python, they have Data Science, they have Machine Learning. And these are things where, you know, if you didn't necessarily get, let's say, a degree in Machine Learning or you haven't worked in a in a as a Machine Learning Engineer for a bunch of years, this is a way to sort of get a lot of that knowledge, a lot of that expertise. And you know, I know Patrick and I we've both done a bunch of courses online. Um, and so it's it's a really good way to sort of boost your knowledge and your skills in a particular.

  29. A

    Area. Yeah, I mean, I did tons of online classes when I first started working, and you know, for me being part of a class—I mean, it's always interesting, but the curriculum, the self-paced stuff, it works great sometimes, but sometimes having a 'Here's what we're doing each week,' marching through their curriculum and going through it, it's very similar to how you know just a normal university class works. In fact, you know, feeling like it's almost exactly the same is just a comfortable thing, a good way to learn and learning from professors who, you know, that's their thing—that they teach, they help others to learn. And having access to it doing the assignments, it really helped me go from where my undergraduate left off to just kind of bootstrapping into more specifics, higher-level things, things that were more pertinent to my job at the time. I hardly recommend people taking classes continuing education from a college.

  30. B

    Yep, yep, yeah. I think getting it through a university is actually a really stellar. I mean, it's really awesome that universities are starting to get into this. And you know, you know that there's going to be sort of quality lectures and professors there. There's a very strong brand behind any major university, and usually reminds one of the top universities for CS. So they they, you know, they've been around since about 1962, I think, and they, you know, they have, you know, they've been around a long time. They've been doing, you know, they've been teaching a long time. They've been teaching online a long time, and so it's a good place to go and get this kind of education. Yeah.

  31. A

    If you're interested, I think they're still doing enrollment for some late classes for Spring, but Summer's upcoming. And as we've been talking about this whole episode, I mean, I think everyone has extra time at home these days. Oh my gosh, if you're interested, you can check it out at ce.uci.edu/programmingthrowdown, and we'll put the link in the show notes of course. But once again, that's ce.uci.edu/programmingthrowdown. Yeah, and if.

  32. B

    You do sign up and take any courses, we'd love to get feedback. You know, please write us in, tell us what you think of it. We could pass it on to them. But also for us, it's really good to know what you thought about that. Folks out there who are listening. So all right, back to the show. So so yeah, so what makes something Bayesian or one of the ways to explain it is, you know, when you're building—when you're building that generative system, if you build it on top of random numbers, right? Now you have kind of a generative model. So for example, um, so for example, if we go to our sort example, so we're generating some random numbers to sort and to compare the outputs of them. If we know the function that's generating those numbers—so for example, the numbers that we're sorting, we're generating them from a Gaussian distribution, right? If we have the getting back to our earlier topic, if we have the probability density function for this generator, now we have instead of needing when we do analysis, instead of needing the list of numbers, we could just think about it in terms of, 'Okay, this is the distribution that I'm sorting,' and then all of the models and the math afterwards could be done on the distributions, and your output could also be another probability density.

  33. C

    function. Yeah, so I'm not sure I'm following exactly. So you're generating a bunch of random numbers from let's say a Gaussian, and you still want to sort it? Are you saying—oh yeah, yeah, sorting algorithm or change? Yeah, well.

  34. B

    I'm saying let's say we just want to do some analysis on the sort. So yeah, the actual sort is going is not going to be a Bayesian, you know, system because it's it's kind of a deterministic thing, but in general I think if you start with sort of random numbers and then you instead of applying things on each of those elements that we've drawn from the distribution, you could also imagine doing functions on the distribution itself. So let's take this Gaussian distribution and let's maybe multiply it by a constant and add it to this other Gaussian distribution. And if you do that enough times, you get some kind of linear regression, and so that output then of that process also becomes a distribution. Yeah.

  35. C

    Mean, I think the main point is you can actually recapture the distribution from the random numbers, and that's always very interesting. I was reading like a lot—well, a few months ago I was reading a whole bunch of the COVID papers, you know, the coronavirus papers. And the one that I was really interested in on March, you know, March 10th, was how long does it take for someone to get it? Because I walked into the Four Square office on March 6th and no one was there, and I was like, 'What's going on? Is it a weekend? Did I screw up?' And like, haven't you heard somebody got COVID, and we all have to quarantine for two weeks? And that was back then nobody was quarantining. So I was like, it was kind of like I felt like I was personally being punished. But after five days, you know, I was like, 'Okay, I'm not sick. None of my co-workers are sick.' And what's the probability that that we got it or any of us got it? And as I looked into the number, I found one paper that was really good which took the discrete data of okay, these are example of people who know when they were exposed, know when they started exhibiting symptoms. And so they construct the probability distribution on you know when you start exhibiting symptoms from when you were exposed. And I noticed in the paper, which I liked—which gave me confidence in the paper, which a lot of the papers that I've read over the last three months in this topic did not inspire as much confidence—but one of the things that they did was they checked a lot of forms for the distribution. So they checked—they checked to see if it was a Gaussian, but they also checked many other forms including distribution functions with fat tails and things like that, and they got similar answers. Each time when they reconstructed the distribution, which was you know, hey, you have a median of getting this thing in like five days and set 97% chance it'll come at you in 14 days. So that sort of inspired confidence from the data they got. And yeah, not nobody at work at least got sick from work, so that was good. I was pretty confident after five days, but my co-workers were still not so confident.

  36. B

    Yeah, I mean the statistics, especially when it's rather early and there hasn't been enough time, it's just very hard to get that right. I think a lot of people learned the hard way that fractions have denominators, right? And so yeah, you might have a thousand cases, but if you tested a hundred times as many people as at the next place, then that obviously has a huge impact.

  37. C

    Yeah, I mean one thing that I like about Bayesian inference is it sort of tells me what my certainty is as I go. So if I'm allowed to draw an inference early on, I'll know that, and because you know there'll be less uncertainty around my data if I already have enough data. If I don't have enough data and my probability is still spread all over the place, then I'll know I still have to.

  38. B

    Wait, yeah, and one thing you touched on is this idea that you have to fit a distribution. So we talked about the probability density function, but there's a variety of different functions that have really nice properties, right? So for example, as we talked about, there's the Gaussian distribution or the Normal distribution, and that is this symmetric distribution that has a whole bunch of really nice properties. Now, as we talked about the electricity example, you know, the real world will never give you exactly 120 volts. It's also not going to give you exactly a Gaussian distribution either, right? And so it could give you a distribution that is and it probably will give you a distribution that is unlike any of the mathematical distributions. So you know, a lot of work usually does. Yeah, a lot of work has to go into sort of how do we sort of fit the data that we have to—you know one or more or some composition of distribution so that actually is itself a really difficult problem.

  39. C

    Yeah, one of the topics that I like talking about on this is conjugate priors. I don't know if you've run into that, but an example of a conjugate prior is a Beta distribution. A Beta distribution is an uncertainty over a probability. So let's let me say it in a way that might make sense, might make more sense intuitively: like you have a coin, a weighted coin, and you don't know if the coin is weighted zero percent on heads or a hundred percent on heads—it's somewhere in between or equal to those two things. It's somewhere on a value from zero to one, and we don't know exactly where.

  40. B

    It is, and weighted means it's cheated? It's right, it's cheating in some way, but you don't know.

  41. C

    Right. Right. So I mean you could think of it as a coin or you could think of it as any event that's repeated where I don't really know what the probability of this event—like I don't know what the probability of this event is. All I know is that it's repeated over and over, and it's somewhere between zero and one. And so a Beta distribution represents an uncertainty over that. And a Beta distribution, like a Gaussian distribution, it has you know it has two parameters, and you know you can say it has a mean and it has a variance and all that. But the really cool thing about the Beta distribution is that if you have a Beta distribution to represent the uncertainty over the weight of the coin, if you flip the coin a bunch of times and then run through Bayes' rule and then calculate the updated distribution, the updated distribution is also a Beta distribution just with updated parameters. It's actually very easy. You just add the number of heads to one parameter and number of tails to the other parameter. So the math all works out, and you don't even need any complicated calculations. You don't need to—you don't even need to use a computer. You can just figure out what. And so sometimes those are really good to look at. There's Beta Dirichlet which I've written a bunch about, and Gamma, and then like you said oftentimes you want to in some cases you want to check, you know, hey, could this be some pathological distribution? And she should often throw that into the mix to check because some of the biggest mistakes—not mistakes but like errors that people can make is like trying to fit your data into a certain distribution when it doesn't fit. And sometimes you have to for simplicity, so you have to kind of get like an intuition for when. This is going to be a problem, but it's usually a problem in instances where you have data where one day it could blow up and everything is affected. I'm trying to think of an exact answer, and you know you could sort of like you get an intuition for which is which. For example, like the attribution, I'm not worried about one ad all of a sudden—well, I don't know there could be an ad that could be extremely effective, but I'm sort of I don't expect it to be out of a range of like an order of magnitude.

  42. B

    Yeah, exactly. And the other thing is is you know these distributions are shaped by what we call hyperparameters. So for example, looking at the Normal distribution, it's symmetric, so that's you can't vary. But you can still vary basically how much you want to say stretch it, and so we call that the variance of the distribution. And you can also vary where the top of it is, right? Then we call that—I guess the basis or the base. So there's different words for that, but the center of the distribution, yeah, the mean of the distribution works. And so those are hyperparameters, right? So let's say you have some data and you can fit a Normal distribution. Let's say the data is bimodal, which means you actually see two normal distributions in your data. So imagine it has sort of these two humps, right? So now you can say well there's a Gaussian distribution that generated this data, but sometimes the mean is this or sometimes the mean is that. And so you can have another distribution which tells you when you should use one mean or the other, right? So you could have let's say a Bernoulli distribution and when it's heads use the one mean and when it's tails use the other mean. And so then in this way it becomes kind of this chain or this—this you could look at it as a graph where distributions are informing other distributions, and so you can even introduce external data. So for example, yeah, when it's sunny outside, it's much more likely to be this distribution, this Normal distribution; when it's raining outside, it's more likely to be this other one. And it's just that the data you have was a combination of sunny and rainy, and so that's why you have this bimodal distribution. But it turns out if you add this extra feature, now you can explain it in a much better way. That's predictive. Yeah, yeah.

  43. C

    And that's how these things kind of chain together. You can have, hey, you know which group am I in? I'm in Group A or Group B. And that's the first distribution between A and B. And then within A, okay, we have a Gaussian; within B, we have a Gaussian. There's a whole field called Hierarchical Models that's kind of based on that. And it's sort of like, okay, I'm in a subgroup, and then I'm in a larger group. And there are certain—there's certain properties that the larger group has, and there's certain graph properties that each subgroup has. And as I get data, how do I figure out, you know, what those properties are? And a good example of that is in election forecasting. I interviewed Jon Local Max Anderson. I think that was episode 99, if I remember correctly. Yeah. So basically, he does election forecasting. He's in France. He's kind of like the 538 blog for France. Oh yeah. And so what I tried to go to localmaxradio slash 99 to make sure, but I don't know it's not responding right now. But we talked about Hierarchical Models, and the question is, okay, let's say I do a poll from a single town, and I get a crazy outlier on that poll. The way I talk about there are three things that could be going on: one, you could have just gotten a bad sample, or you could have just gotten like a random—just it just happened to be that the random people you hit just fell in a weird way. That's like one in a million, or maybe not even one in a million shot, where it's just it just randomly was an outlier and that does not reflect the data. Two, it could be that that town—something is going on in that town, and people are really changing their minds. And three, it could be that this is a broader national trend. And so when you get that data, how do you tell which case it is? Or maybe it's a combination of those cases? And a Hierarchical Model—Hierarchical Bayesian Model—does a very good job of kind of disambiguating between these and trying to figure out, okay, where does this fit?

  44. B

    Yeah, totally makes sense. Yeah. I mean, so you could actually have a distribution over all three of those hypotheses, like I guess in this case a derivative distribution and over time and with more surveys and more samples, you would become more and more confident about some mixture of those hypotheses. Yeah. Yeah. This

  45. C

    episode 98, by the way, but not 99. But it's—it's yeah, it's oftentimes I mean one of the things that I might think of is, okay, let's say each town has a and again you could break it up by town. You could break it up by age and gender and demographics and all these things. But to simplify, let's say each town—let's say it's a two-candidate election, and you just have a Beta distribution over what the probability for each person is in those towns. Then the county, you say, okay, each town in that county we're going to have a different Beta distribution, and the hyperparameters for the data Beta distribution are drawn from another distribution for that county, and then so on and so forth, and you go up to the state level. And so that's yeah, and that's that—that sort of disambiguates. And oftentimes in these cases it can be very intractable because like do I want to break it up by geography? Do I want to pick it up by demographics? Do I want some combination? And that's where a lot of kind of trial—that's where you're getting into, you know, the machine learning curve dimensionality. I'm just trying to, you know, trying to include, trying to figure out which variables are best to include. Yeah.

  46. B

    I mean, it's kind of—it kind of ties into the multi-armed bandit stuff again where you know just to give an example, if you flip a coin once and you get heads, there's just a lot of uncertainty there. If you flip it 10,000 times and it is roughly 50/50, then you're much more certain. And so you have what's called tighter bounds, right? And so as you try to come up with more and more features to explain some phenomena—so you know the phenomena is the survey results—and as you come up with more and more features to better explain that phenomena, you also are adding more and more uncertainty because you know maybe you've only surveyed one 18-year-old from, you know, the Leon province from Nice. And so now you've gotten so specific that you've blown up the variance. And so you're constantly kind of struggling with this—we'll call it bias-variance trade-off, right? And so that's one of the reasons why acquisition functions are really important. And so we could kind of dive into that. I mean, a lot of these—a lot of these systems and one really cool thing about Bayesian in general is it's because it comes from kind of the signal processing world. You know, a lot of it is designed to be iterative. So it's not like collaborative filtering and some of these other methods where they're just concerned about this one shot, like you generate this probability of hot dog and then that's it, you're done. But in this case, you can actually have an acquisition function which says, 'You know, who should I survey next to get the most possible signal?' And going back to the casino example, right? Like which casino should I visit to either learn more about it or make the most money. Um and so actually you know Bayesian—a lot of Bayesian methods directly address the acquisition function, which is another thing that isn't covered really well, but it's also really

  47. C

    important. Yeah. And to expand on that a little bit, a real-world example from Foursquare attribution. Well, in this case it wasn't so much an acquisition function where we're trying to decide who to survey because we have our panel of data, but it was more like trying to decide which data to throw out because we had too much. It was very expensive to put all of it in our model, and we were trying to figure out, let's use Starbucks as an example. I don't think Starbucks is a—is a is a client, but let's use Starbucks as an example. We're trying to figure out, okay, what is the probability that any given user or for every user and their data and information about them, or what is the probability that they're going to visit Starbucks on this particular day? And we have that probability set up for every person in our system. And so that was a pretty big model to train, and we had examples of days where people did visit Starbucks and days where people didn't visit Starbucks. And as you can imagine, there are a lot of examples of a person days where Starbucks was not visited. There are a lot of examples where Starbucks was visited, but there—there's a huge multiple of days where Starbucks wasn't visited. And so we did a bunch of stuff where we threw away some of that data so that we got less, you know, that we—that we can then calculate our probability function, which was kind of a logistic regression on on a smaller data size. And we again use Bayesian inference to say, 'Okay, how do I get these original parameters from the original data set given that we probabilistically threw away a bunch of this data?' And we were able to calculate that as like a bias-corrected logistic regression is a very interesting problem to tackle. And yeah, again save a lot of money, save a lot. of calculation time and programming cycles and AWS costs and all.

  48. B

    That. Yeah. True. It's true. And even if you had infinite of those, you run into this other issue where the model will spend energy based on the loss. So for example, the example you gave is great. You know, the odds that someone goes to Starbucks specifically—you know, if you look at everyone on Foursquare including all the folks who have never been to a Starbucks, the odds that that someone goes to Starbucks is probably way less than one percent. Yeah. And so if the model let's say doesn't isn't a very very large model, it doesn't have a lot of free parameters, then the model is just going to say no one goes to Starbucks ever, and it's going to be 99% accurate, right? And so—and so typically, you know, that's that's one of the big challenges on the modeling side is how do we respect the sort of economics of the problem, right? Like why is saying no one ever goes to Starbucks bad? The reason is because it's a lot more valuable to predict when someone's going to Starbucks and get it right than it is to predict that this person is not going to Starbucks, right? Because if you know someone's going to Starbucks, you could send them let's say a coupon, and you could get maybe three dollars worth of value out of that. If you know that someone's not going to Starbucks, that's kind of useless, right? Yeah. And so, and more importantly,

  49. C

    it was which people are going to be swayed by the ads too because we wanted to know who was going no matter what.

  50. B

    Yeah, that's right. Yeah, you need the uplift, right? So yeah, so the—so you do all this, all these various tricks to make sure the model is as useful as possible. But because you've done that, now it's uncalibrated. So now the model thinks that an average person goes to Starbucks, you know, every other day, because it's been given data that's skewed, right? And so then you have to do this calibration step where you build another kind of simpler model on top of that model which is given unbiased data and you freeze that first model so that you know the first model is biased on purpose, and you freeze that. But now you train this unbiased one afterwards. And you know, I think a lot of this, you know, between sort of this bias-variance trade-off and all the things downstream of that and this question of like how do you subdivide the data and how do you gather new features—that's probably 90% of what a data scientist will do in their day job.

  51. C

    Yeah. Yeah, I agree. It's some of this stuff can get quite involved, and oftentimes you have to take a deep breath and say, 'Okay, let's start at the beginning,' and let's do this step by step because well in my case, and I think a lot of cases, you often have sort of, you know, a problem of explaining to the organization all of these issues which can be intractable as well. You know, management.

  52. B

    Yep. So what is that? How do you deploy, you know, something like this reliably? Um, you know, and how do you know if you've deployed a bad apple? I mean, let's say that—let's say there's a data corruption. Um, how do you kind of keep that from getting to people? And how do you build sort of protection in case it does get out?

  53. C

    People? Hmm. Well, uh, that's—I'm trying to think if I have some good examples of that. Uh, you know, we definitely have a bunch of like, uh, you know, data sanity checks in all of our pipelines to make sure things don't shrink or grow considerably between runs. But honestly, sometimes they're more—sometimes they cause us more problems than they help. And other times, other times things have blown up. Anyway, um, but in terms of models, um, you know, I think you just look there's nothing that you can do if the data coming in is just horrible, just completely like zeroed out or something unless you sort of just have a check that the new—that the new model is completely, um, you know, completely 180 degrees different from the old model. Uh, you know, that's a really good point. Yeah, but so, sanity smoke checks help a lot. Um, one thing that I talk about a lot that's been running on Foursquare for the last like six years in its current form—but really eight years—is the rating system. So if you go to Foursquare City Guide, you can search for venues and restaurants and bars and stuff. Remember we used to go to bars? Yeah, movie theaters and things like that. Yeah. Um, so they had a one-to-ten rating, and the algorithm on that is one of the biggest signals is sentiment analysis on the Foursquare tips, which are like these mini reviews that people write. And I built this in 2012, and they kind of revamped it in 2014 with Stephanie Yang, who I had on my show in Episode Three. And um basically the sentiment analysis algorithm is based on people who have liked and disliked a venue explicitly but also left a tip. And so we trained language models on that. And the reason why this is my favorite example is that this thing gets has been getting retrained every week for the last six years. And it probably—I don't know Foursquare isn't growing by a big percentage now, but back in the day like it used to get better over time. Like it would be better at doing new languages because a certain language maybe didn't have enough data, but then when more people that language started using Foursquare, it got better and better at figuring out whether something was positive or negative in that language. And so sometimes you can deploy something where it actually gets better over time instead of drifting. Um, yeah, which is really interesting. It's—you have to a certain number of things have to align. You have to be training on your own data, and sometimes like, you know, it has to be something that doesn't change that fast. I don't think—I don't think language does change, but in terms of what we were looking for, it doesn't change that much, or if it does change, it's the introduction of new terms that it could easily learn and not, you know, completely going opposite. But um, yeah, it's always an interesting—I don't know if I have a clear answer for you, but it's always an interesting architecture problem like how do I build this thing to last? Yeah.

  54. B

    I mean, I think it's—it's definitely an open problem, I think. Um, as you said though, you know, comparing to yesterday's model having some expectation about drift and sort of a A/B testing or I guess an A/A testing, you know, this version versus the previous one, is really the best you can do. I mean, there are some sort of counterfactual evaluation techniques, but it's very, very hard to dial those in. Yeah.

  55. C

    Yeah, especially something like venue ratings where how good they are is very subjective. Um, and then if you want to die—yes, there's no ground truth there. Uh, and then there I guess we were using our own data for ground, and even though it seems like they've worked pretty well and they've held up over the years, uh, you know people still say oh we enjoy these, you know, better than some of the other services that rate places. Um, but it—I was trying to think out what like if you go um if you go to the sentiment analysis, like yes, we have uh we have training data that we have kind of ground truth there with people self-reporting, but it's not really always truth. So and you know there's spam and all that, so uh there's a whole bunch of things that could.

  56. B

    Go wrong? Yeah, totally makes sense. What do you think about um, you know, I used to do Patrick, and I both used to do a lot of image processing. This is probably like a decade ago. Um, you know, and back then as before Deep Learning was a thing, and so it was a lot of kind of, you know, SVM or sorry SVD, and these other sort of unsupervised like these decompositional models. A whole bunch of human engineering. And um then Deep Learning came and just ate all of it, right? And so um I remember when.

  57. C

    I was at NYU. I took a class in machine learning, and the professor was Jan LeCun. I didn't know who he was, but now he's at Facebook and all that. And uh he showed us—I think it was the first day—he showed us like a camera that like a little eyeball-shaped camera that he pointed at things, and then on the screen it said what he was pointing at, like it would be like keys, phone, desk, you know. And I'd be like, and it was just—it was just amazing. And now that technology is everywhere. Yeah. Yeah. Yeah.

  58. B

    And so and so Deep Learning kind of just ate all that. Feel like no one has to know about Gabor filters or um these Gaussian pyramid models or a lot of these color contrast models. I mean, they just take the raw pixels, throw it into this deep net, and so you're starting to see this emergence, and and and it's been going on for a few years now of sort of these deep Bayesian models where we're basically, uh, you know, it'll be some Deep Learning where the last layer is a Gaussian process that has just priors that nobody knows. Um or you start to see um like another example is um, you know, just you start to see Variational Inference pop up everywhere, um like this reparameterization trick pop up everywhere. And so they're—they're all these sort of black box models where nobody really knows what these distributions are in the same way that nobody really knows what's going on in the Deep Learning system, but it can handle, you know, enormous amounts of data. And so do you think that that sort of Deep Learning is going to eat a lot of the kind of Bayesian math and it's just going to become Deep Learning?

  59. C

    Well, so first of all, I think some parts of Deep Learning are based on Bayesian math. So you—you have um to to some degree or another. So it's not necessarily that's going to eat it, but I think that there is always going to be a market for the simpler models. You're never going to reach a point where people are like oh linear regression and logistic regression don't even learn about those—those are um those are obsolete. Uh no, I think the I think those types of things are always going to be kind of the bread and butter, you know, first first step uh to try to wrap your head around the problem and figure out uh and to be interpretable and try to figure out, you know, what what is really going on, what the—what the um what the causal mechanisms are that a deep model can't necessarily tell you. And Deep Learning is really good at something like um image recognition or speech recognition where think it's just you just have so such complicated levels of abstraction that it could do really well. Uh but I—I don't think it eats everything. Um I think I think these complex models are very important and they're going to do a lot of things, but eats everything? No. Yeah. I.

  60. B

    Totally agree with you. Yeah, I think—I think um yeah, I mean if you think about it actually, I mean imagine you have let's say a click probability model that's a deep model. It's it's still a logistic regression at the last layer. It just has this sort of this embedding, this composition that that that sort of transforms the data into something that can be learned in a linear space, right? And so it might just be that you know we do this composition and and we have to just cross our fingers there, but but what comes out of that—that embedding that comes out of that, it could still be we could still do some interpretable ML on top of.

  61. C

    That, right? And sometimes sometimes these click models or this marketing data is not as deeply complex with layers of abstraction as is image recognition. So sometimes you can throw Deep Learning at it and you can get small small wins, but not always—there's they're often small wins and not big wins. Um but uh for for for lots of effort. But hey, I'm sure Google will use it to kind of squeeze extra 0.1 percent efficiency out of their out of their clicks and you know get translates to some huge amount of money. But yeah, might not might might not be practical on the scale of like a small business. Yeah. I.

  62. B

    Mean, I think it's probably worth mentioning the reparameterization tricks. It's that's something that most people could do with really any data without having to fit distributions. And the idea is is um you know as we talked about, the distributions are defined by these hyperparameters. Um and so you could imagine like if you imagine just let's take the logistic regression example. You have a set of labels, so you have a set of, you know, coin tosses, and you want to have some function that takes in I don't know the wind and some other parameters and decides whether the coin tosses will be biased in one way or the other. Um And that's—but that's going to give you a single probability, or the hot dog? Not a hot dog. For example, it's going to give you a single probability like 0.9 or something. Um if you want a distribution, um one way to do it is to say okay instead of uh trying to get the actual answer—so so the way that 0.9 comes about is when we train the model, you know, we give it a picture of a hot dog and we say this is one. We give it a picture that doesn't have a hot dog and we say this is zero, right? And so over time it it trains on that. But you could also—you could give it, you know, a batch of pictures and say, you know, in this batch of pictures 90 of them are hot dogs, and not necessarily tell them uh tell the model, um, you know which which uh which ones are which. You know, you could do that, and it will still learn. It will take longer because it will have to sort of, you know, tease apart from these batches which ones are actual hot dogs, but it would.

  63. C

    Work does it have uh does it have multiple such batches? Like to say in this batch 90 are hot dogs, and in this batch 10 are hot dogs exactly.

  64. B

    Yeah. Oh, okay. Yeah. So if we give it enough of these batches and let's say we shuffle in between the batches, it'll still learn even though we only have one loss or one, you know, bit of feedback for the entire batch, right? Um, and so, and so if you can follow that, then you could imagine saying this batch has this distribution, and our model, I want you to match this distribution. So instead of saying this batch has a 0.9, you could say this batch has this Gaussian distribution, you know, match it. And the next batch will have a different Gaussian distribution, and over time, you know, it will start to fit all of these different distributions over all these batches. And so this is a nice little trick you can use. Um, it's called the reparameterization trick, and so you can actually get a distribution out of pretty much any model. Um, and that's—I feel like that's a kind of, you know, lesson 101. You know, we could do much better than that, but that's one way where anyone can get into models that output distributions. Yeah.

  65. C

    I haven't heard of the reparameterization trick. I'll have to look into it, but I think what's been so the way I always break it down with Bayesian inference is however the data comes in—even if the data has been mixed and matched and filtered and all that—and so long as I know how it was done or I have, you know, some hypothesis as to how it was done, you could always come up with a Bayesian model on that and learn.

  66. B

    Something. Yep, yeah, totally. Yeah. I think—um, yeah, I think, you know, having the uncertainty lets you do some really cool things. Like imagine, yeah, against problems depending like Foursquare is actually a good example. Let's say let's say we're recommending restaurants to somebody. Um, and let's say we don't know whether they like Thai food or not. Well, maybe we should do what's called the upper confidence bounds, which is just a fancy way of saying, you know, if the distribution is really wide, we want to be more likely to choose this item. So Foursquare doesn't know if I like Thai food; they show me an advertisement or they suggest a Thai food restaurant that's nearby. And if I cancel it or if I tell them don't show me this again, well, that tightens the bounds. Now they know something. And so next time maybe they'll try, you know, Chinese food, right? On the flip side, it could be that I really love Thai food but I always go to the same place and so I haven't looked for Thai food on Foursquare. And so by taking that chance, Foursquare, you know, if I do maybe I click on it and I go to that restaurant, that really opens up this huge array of possibilities that didn't exist before, right? And so that's where, you know, showing the upper confidence bound of something can give you this nice mix of learning but at the same time using the information you learned at the same time.

  67. C

    Yeah, lots of ways to slice and dice the data.

  68. B

    Yeah, totally. I.

  69. C

    Could put it one.

  70. B

    Way. Yeah, exactly. I mean, I think and having the probability and the uncertainty, yeah, opens up tons of opportunities. I feel like this is something that a lot of even big companies like Google, you know, and Facebook and these other large companies are just starting to get their hands around. They have these very very complicated models, but then they all output a single number, and you're kind of limited in what you can do with.

  71. C

    That. Yeah, yeah, that's—that's a constant struggle of, you know, the data scientists often have more information than the product managers or the customers want to use. Um, and yeah, I get it. Maybe like in a consumer app, you don't necessarily want to start teaching people probability, but you want to be ready with all of the probabilities so that you can then make the changes to the—you know, you could then make product decisions as you go. I guess. Yeah, that makes sense. Like I want an increase or like maybe I want an indication that we're uncertain, or maybe I want an indication that maybe you'll like this place because of this, or, you know, all the different possibilities that we've been over a lot over the last many years at Foursquare for.

  72. B

    Sure. So in Foursquare, do you have, you know, like these let's say clear box or these like very interpretable models and you have sort of the heavy-hitting deep learning model that squeezes the extra one percent? Do you do both of that, or do you just focus on the clear box, or like how do you sort of—

  73. C

    Strike that balance. So let's try to figure out which product do we want to talk about: the consumer product or attribution? Um, so let's we can talk about attribution for a bit. Attribution was, you know, we had a bias-corrected logistic regression, like I said, which sort of tried to figure out what the likelihood of someone visiting a place given what day it is and given information about them and when they visited before, and all that. And then we compared what happens when they didn't see the ads versus when they did see the ad, and then we used a Bayesian model to come up with ad lift that was a few years ago. More recently, last year Foursquare bought a company called Placed, um, which only did location-based attribution. And so, you know, we found that we kind of did it the same way, but now the Foursquare Attribution team is like I don't know 20 data scientists, and I—when I was doing it, it was like me and two other people, and now we're like okay, well, we've got this group in Seattle who are very good doing it. So I don't have as much insight into it, but I assume it's—I assume it's similar. Um, but some of the models we had a logistic regression model on the top layer, but some of the bottom layers were actually a bit more complicated. So for example, one of the things that might affect whether you visit a place or not is your age and gender, wouldn't you agree? But we didn't have everyone's age and gender, and what we did was for the people who we did have their age and gender, we built a model to predict what it was given the places that we visited. And I did this fun thing where I revealed to the company like everyone's—everyone's gender probabilistic gender, and I was nice. I had to be very careful, like you know, it's just a model; this is not telling you which gender you actually are. It turned out that most of the people who are misgendered by the model Were, you know, married people who were doing things with their spouse. Oh, that makes sense. Yeah, and I found out like it was 99 male, but I also found out interesting things, like it wouldn't be so much if I didn't go to Best Buy, which is like across the street all the time, then it would be more like 70. Does going into a Best Buy make you more male? Of course not; it's just a model; it's not causation. Yeah, yeah, exactly. But no, then we were able to use the output of this model as an input to the attribution model. We didn't just say which gender are you; we actually used the percentage output from the model into and plugged it into the new model directly. So we have these layers, and the age and gender model was a little more complicated. I don't think it was deep learning, but it was like it was Gradient Boosted Trees, so something a little bit—a lot more non-linear than just, you know, logistic regression. Yeah, totally makes sense.

  74. B

    Yeah, I mean, I think you know from what I've seen it's always this struggle. You know, you have the super complicated model squeezes out the extra percent, but no one can interpret it. And so you build all these simple models, but then you know if there's any skew or bias at all, then you're kind of you're informing your Product Managers based on one model, but then your actual system is using a different one, and that's always difficult.

  75. C

    Right. Sometimes it's sort of evens itself out. So for example, the gender model, we're using the output of that to predict whether you're going to visit a place. And so the visit prediction algorithm is just using this input; it doesn't know that it's a gender prediction. It just knows that it's a feature, and so it could use it however it wants. And even if the gender prediction is off, the layer on top of it—the visit prediction—kind of takes what it can from that, and so we don't have to worry about whether it's entirely accurate predicting gender or not. Yeah.

  76. B

    Yeah, totally. And if you have the uncertainty of the gender, that could also go into the model, so it could say, if yeah, if the gender isn't certain, then doesn't matter what number it is; we'll just throw it out or something.

  77. C

    Yeah, that's exactly what we did. Or in our case, if it was like 50/50, I think we have a few—I don't know what there's a number of things you could do. You could just input a 0.5 as a real number that's the feature, or you could just say, pick if it's whatever the probability is, sample from that and give me the sample value either one or zero, and do that a few times—a lot of.

  78. B

    Things you could do. So what are you doing now? You've worked on so many different parts of Foursquare. I mean, we've talked about several of them just in the show alone, and now you're at the Innovation Lab. What do you do there?

  79. C

    Right. So I every once in a while I get to do a statistical model, but right now I'm really just working with our founder, Dennis Crowley, and we're trying to use Foursquare's core tech to put out new apps that sort of inspire, show off the company's technology. And so it's a nice change of pace to be able to essentially work on the fun stuff. We had a really great product ready to go for, and it was called Marsbot Audio, where you would walk around the city, and one of the things that Foursquare can do is it can tell whether you're walking past a store, like when you walk right past a place, and so we can trigger an audio file to play when you walk past something. So we have like sound effects, we have text speech, and we have you could even upload your own audio, and then whenever someone with the app walks by the place you set it at, they'll hear it. And so that was really cool. It was ready to go for March 11th, and we were like, are we going to be finished? Are we going to be finished? And on March 10th, we were like, it looks like we're going to finish for tomorrow, and then the country shut down. So we kind of pushed that back six months or so. I really hope to get this out though as soon as we can because the tech is ready and it's really cool.

  80. B

    One of the things I've been thinking a lot about is—I think what you're working on falls right into this. Is how to sort of reboot people's habits. So imagine someone has is in the habit of going to the movie theater once a week. You know, there has to be some way to sort of reboot that habit when things open back up, and I think something like this could be pretty cool where you know if it could kind of encourage—almost like a like a fitness tracker but for fun, you know, like just to help people kind of recover their social life.

  81. C

    I know. I know it's been a little—I'm not happy with the way the industry has gone. I feel like a lot of these consumer apps, one of the things that attracted me to Foursquare was how positive it was as a social network and as a tool to be present and do things in the real world. You know, Foursquare is not one of the big tech companies right now, and I feel like a lot of consumer technology has gone in a darker direction that maybe we don't like. And now over the next three months, I feel like I want people to get out again. I want people to have a good life again, and I feel like people are saying, 'Oh no, no, that's evil. We have to work on contact tracing apps. We have to work on apps to tell you which friends are out to kill you.' And I'm not too happy with that. I'm really hoping—I feel like my thinking is against the grain here, but well, I think it's a great place.

  82. B

    It's a great thing for an Innovation Lab to be working on because it's sort of the next frontier. Right? I mean, getting through COVID is one frontier, but trying to rebuild the social infrastructure—I mean, that's going to have to happen, and so thinking about that now is really.

  83. C

    Good. Yeah. So over the last few months, we've been working more on data sets for coronavirus—essentially not for the virus itself, but to see which places are coming online and offline at different times. You know, there's a Foursquare Recovery Index at visitdata.org, but yeah, pretty soon we'll return to these, I hope.

  84. B

    Cool. And so working at Foursquare, can you kind of walk us through—we have a lot of folks who are let's say in college right now; they are looking for internships, they're looking for jobs, but even more than that, they want to know what it's like to work at a company like Foursquare. Could you kind of walk us through kind of what a day in your life is like? Yeah.

  85. C

    Well, one of the things that I've learned over the last 10 years is don't get too comfortable because once you are, things are going to shift under your feet pretty quickly. And so whatever the day in my life is now is—well, it sure is; it certainly isn't the same as what the day in my life was four months ago back in February. Right? Yeah, it certainly wasn't what it was two years ago. I'd say the best case for Foursquare was when we were working on these Labs projects and it's just three or four people talking every day, working on the whiteboard, trying something out, making progress, building something into the app, and then returning and then trying to go out and use it, and then returning and then trying it again. The thing that I enjoyed was actually coming out with these models and selling these models to the company and even going on some sales calls and trying to explain how they work and why certain ads are seeing lifts and certain aren't. There was a lot of issues, but sometimes there are issues on those teams when certain companies wanted custom things done that we as engineers didn't really think made a lot of sense, and you're kind of kind of pressured by the sales team into that. That stuff happens as well sometimes. You know, you run into cases where the companies kind of reach—you're excited about a product, but the company kind of reaches a dead end or deprioritizes your product for someone, even for someone who's been in the industry for a long time, and but also for someone new. Like that's always a very disappointing point part of working in this field. I don't know if you agree? Yeah, totally.

  86. B

    Yeah, yeah. That is the number one complaint. You know, I'm on a research team, like an applied research team, and the number one source of frustration is when you know we have something that all of the math looks great and it's headed in all the right direction, but the product changes and the demand disappears.

  87. C

    Yeah, yeah. Sometimes that happens. Sometimes, sometimes the leadership doesn't see it—doesn't, you know? Sometimes it is very valuable, but the leadership in the company either doesn't see it or is focused elsewhere. And then sometimes, but you know, there's a plus side to that too, is when you do ship something and you get something out, and either it's, you know, either it's on the back end business-to-business that, you know, is bringing a lot of value, or it's on the consumer side and people are loving it and telling you about it. Like there's nothing better.

  88. B

    Than that. Yeah, yeah. Totally agree. So is Foursquare hiring like full-time? Are they doing internships with the whole Covet thing? Are they going to?

  89. C

    Do fall internships things are a little bit up in the air at Foursquare because again, you know, we bought—we, we bought Placed last year and this year we bought or merged another company called Factual. So there's a lot of integrating these companies. Very, you know, it's a there's a lot of moving pieces at Foursquare right now. So I don't exactly know what the internship situation at Foursquare is like, but foursquare.com/jobs. You can go to. If I were looking for a job, I'd also like Union Square Ventures. It is one of the VC funds, one of the VC companies that funds Foursquare, and they have a job board for like all of their companies, and they invest in a lot of cool companies. So I often go to their job or I often sometimes I first show people this is the Foursquare job board. Let's see if your job is here. If it's not there, then I jump to the USV job board because there's a lot of cool—there's a lot of cool companies in there as well that are kind of a similar size, similar philosophy. So.

  90. B

    Is Foursquare on this remote work bandwagon or are most of the?

  91. C

    Folks in New York? Um we are remote right now, and I don't know where we're going. Yeah, that's personally, I really hope to get back into the office. I just feel like some of the creative work that we do has to be face-to-face. I don't need the open office with 300 people, but having like a small group of, you know, three to seven to ten people get together and solve problems is way more efficient than everyone in their apartment with either, you know, with delivery people come in or their kids screaming at them or whatever their dog—whatever's happening in the background. Yeah, it doesn't, in my opinion, it's not working as well, or at least in order for it to work as well, we'd have to like none of us have our apartments particularly in New York City like optimized for this. So it's yeah, it's not. I really hope to get back. I don't know what the situation is going to be. There are people who are saying let's never go back. I don't know who's gonna win.

  92. B

    Uh yeah, honestly it's—it's—I don't think anyone does. I think I mean, I mean, honestly when Twitter Jack Dorsey from Twitter said no one has to come back, that was absolutely shocking to the entire industry. I mean, that was seismic. I mean, that probably like Zillow stock price probably tanked when he tweeted that, right? I mean, it's just unbelievable. And and I totally agree with you that at least for now there hasn't been the right mechanism for a while actually. This is way before COVID when most of us were in the office. You know, we do have another team that's in Seattle, and what we did is we set up a television, and they did the same where when you look at the television you see their desks. It's kind of weird, you know? It's it's kind of like a literally like some kind of portal. I don't—I.

  93. C

    Don't know if we need to see in everybody's homes either. I mean, there's a lot of personal things in people's homes. Yeah, and it's not—and it's—I don't see how people don't recognize that. Yeah, exactly.

  94. B

    I think there needs to be um yeah, there needs to be a new modality. I mean, like one way to do it is maybe you know we have some on the clock time where everyone's there, and—and—you know that is a time where the mic is always on or something. I honestly don't know. It's a totally uncharted territory, but we'll have to see, have to see how that all goes. But yeah, I think if folks out there listening are interested, is foursquare.com/jobs or what was the other one? Union—Union?

  95. C

    Something. Oh, usv.com/jobs. Oh.

  96. B

    usv.com/jobs. I think that's what it is. Let me check. And so yeah, we'll put it in the show notes and we'll correct it either way. Cool. This was this was awesome. Is there oh, we should talk about your podcast. Yes. So your podcast is called The Local Maximum every week, which is—which is awesome for.

  97. C

    Every week we reach a new local maximum. Hopefully higher, exactly, hopefully higher than the previous local maximum, but not always.

  98. B

    Yeah, I think the name is great. Yeah, I think hopefully there's some kind of mini-batch going on or something where you can eventually reach the global maximum; you don't just get stuck at that.

  99. C

    Be the last—the last. If there is a last episode, it will be called...

  100. B

    The Global Maximum. Yeah, that's right. Exactly. Very cool. And so what do you...

  101. C

    Talk about? There. So I generally talk about things that are interesting to me. I'd say about 50 percent of my episodes are guest interviews, and so a lot of the guests are technology related, but I do branch out a little bit. I branch out to professors, probability and statisticians, of course. Then pull more on like the data engineering side, but then I've also talked to historians and other podcasters and comedians and things like that. So I am kind of all over the place there. One of the things that I like to do is take concepts in sort of Machine Learning and Bayesian Analysis and just sort of apply them to either the news or to your everyday life. And so, by the way, if you've made it this far but you kind of are interested in Bayesian Inference and you want to look at it from—you want the 101, the more basic ones, I have a lot of really good episodes for you to listen to. Like, I think in the hundreds, I've got—let me check my archive for a second—but I know episode 105, I talked to mathematician Sophie Carr. Talks a lot about Bayes' Rule. And then I had a few episodes after that about like what is probability. So we do go into the philosophical side of things, but also I try to make it relevant to someone who is not a data scientist and not in tech. Like, I can explain what overfitting and underfitting is, and then I ask, 'Okay, who in your life do you know who is always overfitting?' And people tend to have an answer for that. So yeah, everyone's got that one uncle, right? Yeah, yeah, exactly. And well, I think the example we have is often like you know toddlers can overfit—not always, yeah—but sometimes older people tend to underfit. But we can their example is interesting to just have these prompts and come up with these examples. Or sometimes I just kind of take a bunch of news stories that day and try to distill it down into a theme, like what's Occam's Razor or what is expected value or something like.

  102. B

    That what inspired you to—I mean, it's a huge undertaking to do a podcast. I mean, you do one show a week, which is just it takes an extraordinary amount of time. And so what inspired you to really start it and what kind of keeps you...

  103. C

    Motivated? Well, I was trying to do—well, I had a radio show in college. This was back in like 2004 to 2006, and that was like the best part of my week when I was doing that radio show. So I knew I would enjoy it. I was trying to put more content out there, and at the same time you know, I had spent a summer kind of at NYU Future Lab talking to entrepreneurs, and I was like, 'Well, you know what? I think I would enjoy this.' And I think no matter what project I do, I'm gonna want to have like an audience to discuss it with and kind of a forum to learn about—you know, learn about new concepts and learn about issues and talk to people who I'm interested in, like authors. So I tried it. I did like a 10-episode challenge: let's put on 10 episodes and see how it goes. And then after that, I just kept going. It was just a lot of fun. Every week is—you know, some weeks are easy, some weeks it's a little bit challenging where I have to do a solo show, where the solo shows always take the most research and thought even though it should be simple, right? I could just edit whatever I want. No one will ever know. But it's—I feel like the solo shows are the hardest for me because when I'm interviewing someone, at least I could ask for their content, their information. But it's one week seems to be the sweet spot where if it's two weeks and I had something to say, it would take too long for me to get the time to say it, but if it was more than a one week, it would just be completely overwhelming. Yeah.

  104. B

    Totally makes sense. Yeah, totally makes sense. I think—yeah, Patrick and I originally were doing it bi-weekly, and we switched to monthly, but yeah, I totally agree that you know if you find a piece of news early in the month sometimes, you have to kind of throw it out because so you know two weeks go by, things become irrelevant really quickly. I mean, especially in 2020 where your entire lifestyle changes—it seems almost week to week, yeah.

  105. C

    Yeah, I mean, I'm almost going to go back to some of these episodes and relive it. It's like, do I want to do that? I don't know. But no, but it did generate a lot of interesting episodes. Like I did one episode 115 all about the coronavirus models—you know what was right, what was wrong, what are they actually trying to do? And I had a lot of—I talked to my friend who works in a hospital recently about you know what his experiences have been like over the last three weeks. So you know we have been talking a lot about what's going on. Some episodes, I feel like I just want to talk about a concept and ignore what's going on in the outside world. I've completely thrown that away, I think.

  106. B

    Yep, yep, yeah. I think you know it's interesting we have this sort of this bipolar or bimodal response to our current events. There's some folks who say, 'You know, I just want to know about the topic,' and there's other folks who say, 'I'm so glad you add color to the show, and it's not just about tech all the time.' And so I think the compromise we finally struck was to put the timestamp of when the show topic starts. That seemed to satisfy most people, but I totally agree with you that the idea of just ignoring the outside world—you know, like the entire world is burning down—and you say, 'Okay, today we're going to talk about the Beta Distribution.' Right. Kind of odd, but...

  107. C

    Yeah, I feel like I know we wrap it up, but I feel like the purpose of the podcast is not to be a course that you take that's going to be evergreen. It's more like let's sit back, let's have a conversation about issues that are important to us and let's talk it out, let's talk about concepts that we know, and then we'll get interested in things, we'll discover things. Then if we want to learn more, maybe we'll do like look at a more formal course or something like.

  108. B

    that yeah yeah totally so it's it's the local maximum is the podcast are you on you're probably on uh like like a google podcasts and stitcher

  109. C

    and all these things stitcher apple spotify oh great yeah if you

  110. B

    if you don't have any of those or if you want more information you can go to local max radio dot com and uh you know max it was it was it was really awesome um to have you is i just realized your name is max and it's local max radio is that on purpose or is

  111. C

    that well yes i realize it's a triple entendre right yeah that's right so there's the local maximum which is the the probabilistic well it's the local maximum is a is both a optimization concept machine learning concept and design concept too so that's one meaning there's also my name in it and also the local maximum well it's you know location data i'm all about that too so two meetings two meanings is is is one thing but three meetings that's when you know that's that's very rare three

  112. B

    yeah you hit the jackpot it's very clever cool this is awesome i'm definitely going to listen to some episodes uh actually right when we get off this i'm going to check this out because this is super exciting and uh you know i really appreciate you coming on uh folks are just dying chomping at the bit to know about anything ai machine learning and so um you know i feel like we covered a lot of really really important ground here that that that any engineer can can apply uh you know even in their day-to-day work which is which is ultimately i think really you know useful and has high impact

  113. C

    cool it's great to be on the show and uh to have this really fascinating discussion with you we covered a lot of ground there's things that i have to look more into

  114. B

    now all right cool awesome it was really great talking to you and then for folks out there um you know thank you for uh you know supporting us on patreon uh you obviously you know tough times for a lot of folks out there uh you know we don't demand anything all the content's totally free uh but we do really appreciate all the donations that goes to uh you know our equipment and and we have some some uh hosting costs and all of that um so thank you again for your support uh thank you for your emails a lot of really good ideas keep coming in and and you know our hope is to i don't think we'll ever end the fifo queue but our hope is to go through it and try to answer as many questions as as you folks have and we'll see you all next month the intro music is axo by binar pilot programming throwdown is distributed under a creative commons attribution share alike 2.0 license you're free to share copy distribute transmit the work to remix adapt the work but you must provide attribution uh to uh patrick and i and uh share alike in kind reaction you're free to be reaction