Philosophical Perspectives on Machine Learning
Transcript
[MUSIC] What I'm going to do in this pair of sessions is I'm going to start out by giving some sort of big picture philosophical perspectives about machine learning. Hoping that that will help you take some perspectives into your own learning. It's actually pretty easy to learn about specific machine learning methods. There's tons of open source software, there's blogs, there's tutorials, there's YouTube videos. So I try to avoid just repeating what somebody else might do
better at one particular topic of the other. And instead try to give you some perspective that will help you synthesize what you might learn directly from machine learning with what you might learn from economics and econometrics, or other kinds of social science research. So that you can better interpret what you're being taught and why people are approaching problems the way they are in these different areas. So that's my goal for the big picture part. And then I'll give some specific examples of some machine learning methods in the second part, that can be particularly relevant for financial applications. So I'll leave this when the slides are posted and so on. I did want to just advertise that there's actually a lot more material out there if you're interested. A couple years ago, I gave a two day course at the AEA. And I recorded those lectures that was together with Guido Imben's. Actually I realized that my site isn't updated.
I have a series on YouTube from my course this year. And then I have tutorials that you can download and run. So it's like a book but when you download them, you can also run the scripts and modify them and change them. And those are really focused more on the causal inference side of things. And I have some other references here as well, if you're interested. So first of all, big picture, there are two kinds of machine learning, really actually, there's more but I think the ones
you're most likely to first encounter fall into these two buckets. And I'm going to focus mostly today on supervised machine learning. And so supervised machine learning is set up to solve the problem where you have independent observations and a stable environment. And then you're trying to do usually one of two tasks. One is to do some kind of regression or prediction problem. And the other is to do classification. And the main difference being that the outcome is either continuous or binary or discreet. And so supervised is going to look closer to what you would learn about in a normal econometrics class, and so that's where I think I'll have more insights in terms of trying to draw connections between how we think about what looks like the same problem in the different fields. Another part of machine learning that can be very relevant in some parts of macro and finance is unsupervised machine learning.
In unsupervised machine learning, you are trying to take objects and put them into groups without necessarily specifying prior information about what's important or what you want those groups to look like. So for unsupervised learning, it might be that you just take a bunch of text and a bunch of different documents and I say tell the algorithm, put them into groups. Then after you put them into groups, you can go back and read the documents and
say, these are new stories about earnings announcements. Or these are new stories about macro events. And you can label them afterwards as a human. But you didn't tell the algorithm to go and look for a specific kind of story. You just told it to find things that were similar. So, and then there are kind of hybrid models where you are trying to kind of reduce the dimensionality or kind of find common themes, but find the themes that are important for prediction or
classification that would really fall into supervised. So I think a lot of times it actually can be better to use something supervised if you can. So if your goal in the end is to figure out how news articles relate to stock prices, then you might find something about, you find some kind of outcome that relates to stock prices. And then when you try to kind of reduce the dimensionality of the text you're reading, you want to find those aspects that are important for solving a problem,
like predicting stock prices or whatever it is you're trying to predict. And the challenge with doing unsupervised learning just on its own is that we don't have a great way to know when you've done a good job. And it could be that things are very similar. You can find a group of articles that are similar to each other, but maybe in some dimension, that's not really important for the problem you're solving. People sometimes go off and do unsupervised learning without touching any prediction problem because they want it to be sort of clean and separate. So they want to say, I don't want to worry that somehow the way I put articles into groups is contaminated by some kind of macro variable or something. So that's one reason you might do the unsupervised learning. One reason I don't go a lot further with unsupervised learning in my own teaching is that actually the reasons that economists would use unsupervised learning
are pretty similar to the reasons other people would use unsupervised learning. So there's no real special economist version of it, other than the things that I just said. So if you want to do it, you should go read about it and whichever discipline that is, will probably teach you what you want to know. While the approaches that we take to classification or regression are a little bit more often different in the social sciences. Okay, so classification. So what was the big hot stuff about machine learning and classification? The problem of predicting, say, a 01 variable, 1 if it's a cat, and 0 if it's a dog, that kind of problem, we've done forever like we. It's called logistic regression and you learned it in your econometrics class, you know how to predict the 01 variable. So what is it? What did machine learning bring to the table in this problem and what was different about it? Well, one of the biggest advances was trying to solve
these kinds of prediction problems. Predicting a 0,1 variable or dichotomous variable or which category something fits in. In an environment where you had complex right-hand side variables. And so images are this great example and they're one of the big examples where there really has been quite a bit of advance in the last 10 to 15 years. So when I first started going to machine learning conferences, I learned that there's lots of pictures of cats and dogs on the screen.
So ten years ago, you go to a machine learning conference and and I was like, what is this all about? And that was a time when people were getting really excited about the neural nets. So a typical presentation would be like, I found this better way to train my neural nets. And look, I've gotten, just a tiny bit better at telling cats and dogs apart. There's actually an interesting sociological phenomenon that happened here. And one of my colleagues here at Stanford, Fei Fei Li, helped create this big data set that everybody could apply their methods too. So it was kind of like a horse race. Academics are pretty competitive bunch. So you say here's a bunch of images, it's really big set of images. And who's the coolest AI scientist? It's that person who can, Come up with the very best classification of cats and dogs on this big, big public image data set. And they all went down on that they did a really good job with that.
And it's kind of an interesting phenomenon where, like having every kind of, let's say, let's all go to the moon. If you put up a common problem and you can all agree on what success is, then you get a very rapid progress towards that goal. So how exactly does this work? Well, how do you go from a picture to a prediction? You can take this image and first of all, just reduce it to zeros and ones basically. But if you think about you're looking at me on a monitor, that monitor has RGB. The way you're seeing my image is that each pixel on your little monitor has a certain degree of brightness in different colors. So you can take that, take the image, decompose it into its colors, and then describe the image by how bright each pixel is at each point.
And so that's how you translate a picture into X's which are on the right-hand side of this regression. And then the question would be given those this digitization of the image. Now, is it a cat? And so when we've traditionally done this in economics, we would build a model that says, you probability Y equals CAT given X And once we estimated the model, the output would be a probability. So that's what we've typically done in the past. Now, if you were attacking this problem 15 years ago as an economist, you never saw anything before, you might think, how would I attack this problem? Well, I'd think about the structure of cats,
I would think about the shapes of their ears, the shapes of their paws, and then I would try to find some way to take those pixels and first recognize a paw or an ear and then I would try to classify by pointy ears or round ears whether it's a cat or a dog. And so you might spend a whole lot of your time, first figuring out what those elements were that were different. And then second, trying to figure out how you would recognize them in an image, right? Because you just have these pixels like how do you even know that it's in a year at all? And how do you think about describing the shape of these nearby pixels? So it would be a big picture engineering problem, that's what you call it when you're trying to drive variables. In the real advance within the neural networks was that the algorithm itself figured out the features. So you would just literally put in the pixels, and you would even have to tell it
it was a picture, although it matters a little bit but you just put in the x's without saying anything else about cats, dogs, ears, nose, whiskers, anything and the neural net just figures out what's important and pops out predictions. So that kind of sounds like magic and I spent a lot of time asking people why it worked and how it worked. And if you check out my videos, I actually have some videos trying to explain neural nets, my YouTube videos about neural nets and how they work although other people's YouTube videos are frankly prettier than mine, but you can see mine because I'm talking to economists.
But I think one of the, what and there's no answer, it's just like it's a very, very flexible functional form and it happens to be a family of flexible, functional forms that works well for things like images and some things that may not work as well for other Data generating processes, but it works well for some. But the key thing here was that it's like you're outsourcing the feature generation to a robot, that's the way I think about it. So the old thing is, I would think about ears, eyes, and nose and I would try lots of different things. But in the end, there's like, if there's a, however many pixels there are imagine there's, whole bunch of 01 variables or something or continuous variables about brightness.
There is a limited number of ways you can combine that data into a smaller number of features to build a prediction model. What you do with their neural net is you just let a robotic research assistant try like a billion different ways to do it. And then it just sees what works and picks the best one. And so then I think thinking about it that way helps you understand what is a really good application for AI or machine learning type of methods, it's a case where there's a clear answer. So, I can hold out a test set where there are pictures and there's a label CAT DOG.
And then I can let my robotic research assistant, try a billion different ways, a billion different functional forms. And then I pick whichever one does the best on my little held-out test set, that's the winner. And imagine if you were supervising that research assistant, you wouldn't necessarily care how they got there. But if they have a method that if you give it another set of pictures and it does a great job telling cats and dogs apart. You're all set, that's all you really need to know. So great applications of machine learning and AI are ones where you can hold out a test set and just assess whether it worked.
And so when you think about it that way then, you'd be like, where are all the assumptions, where are these statistical assumptions, econometrics, they made me do all this math. [LAUGH] Why don't machine learning people worried about all this math? Well, you don't need the math if you can just test if something works. I mean, it's helpful to have some intuition about why it works but frankly, who cares? You can do machine learning without any math, you can just say, neural net why x and if it works, it works. That's why you can teach ten-year-olds to train neural nets, it's not hard. Now there's a lot of twiddling But it's not like conceptually hard.
Okay, but it does, so that's makes it sound like there's nothing to it but when you actually go to use machine learning in practice there's you often have additional considerations like maybe you need the model to not be changed every day. Maybe you want a model that's going to work for a long period of time. So that's where you start to get into the problems of Blackburn ox models. They work great on the problem you have, but you haven't actually, you haven't given it any other constraints. So it's going to pick up everything in the data set you have even things that might not really hold true tomorrow. So in this particular image, I've showed you I've got an image of a cat wearing a t-shirt, playing a piano. So if this particular week that I gathered my images from had a lot of pear
playing cats, because that was the new meme, I guess already, back in the day that might have been the thing on YouTube now it's the thing on TikTok if suddenly everybody was sharing their piano playing cat on TikTok. Then, the image corpus would have lots of this. And so your model would figure out the black and white rectangles are good predictions of cats. But if the next week, I started a YouTube, a TikTok trend with my piano playing dog, then the model might do a bad job. So this is a limitation, the model doesn't prioritize pointy ears over T shirts and pianos, it just says whatever is correlated with being a cat is going to be predictive of a cat. And in fact, you know it's going to pay attention to that stuff because the model that ignores pianos would get beaten by a model that included pianos
in a dataset where there were more piano-playing cats. So you're going to use everything, that's what's going to happen. You're going to use everything that's predictive. So that's a strength and a weakness, it works well at a moment in time. It's worth everything possible, but it doesn't have any kind of common sense about what might be important or generalizable or stable. So here's another example. This is from a McKinsey marketing brochure where the idea was to try to use data to classify whether customers are going to churn or not whether they're going to quit. And so here this shows the old version is like a classic logistic regression, is the green curve. And so, it's basically saying that drivers A and drivers B are the X variables. And in the simple model, things above the curve would be predicted to churn and
things below the curve would be predicted not to churn. Then they're showing this kind of topographical map is the example of what you would get from a fancy machine learning method. So this might be a really good predictor, but if you actually tried to generalize or use this to gain insight, you would realize it doesn't necessarily work as well. Because if you hold drivers A constant, say at 80, and increase drivers B, it's saying the probability of churn goes up and down and up and down and up and down. I don't know what the heck drivers B is, but there's probably isn't any variable like that where that's truly the partial relationship with respect to B. So why do you get this funky complicated picture? Well, it's because there's lots of covariates, and they all have this very complicated joint correlation structure. And so, in the background as drivers B changes,
a whole bunch of other stuff is changing, and you have this complicated nonlinear model that's exploiting very fine details of the joint distribution of all the axis. And that works well in the data that we have, but if anything changes about the joint distribution of the axis, then the whole thing could break. So this is a potential weakness of these models. And I actually have a line of research in machine learning published in AI journals, about trying to reduce the dependence on these high dimensional joint correlations. So then just to kind of pull this together, prediction in a stable environment is the problem that's solved by supervised machine learning. The goal is just to build a model that comes up with a good prediction and you want to minimize mean squared error in a test set. And you can just tell whether it works by checking what happens in a test set.
A few observations is that minimizing mean squared error actually entails a bias-variance tradeoff, and you're actually always going to want to accept some bias. In econometrics class, they often taught you that OLS is blue, unbiased, that was a you in blue, if you forgot it already. And you had to spend a lot of time memorizing the proof that OLS was the best linear unbiased estimator. But they didn't tell you in class, unless you took a very modern class, they didn't tell you that actually having an unbiased estimator comes at a cost and actually it potentially would give you a worst predictor in a test set. Now it turns out that being unbiased is kind of free if you have a small number of parameters you're estimating and a very large data set. But the difference with machine learning is that we actually try lots of very rich models. And so we push the limits, we make the models richer and richer and richer.
And so in that world, being unbiased does come at a cost, because if you have a really rich model, you're always going to over fit. If I tried to predict everybody in the class whether they had coffee or not, if I literally, there were 40 people in the class and I use the 40-dimensional model, I could predict perfectly whether you had coffee or not in the break, right? But if I went to the next class tomorrow, my model would be terrible. So when you have very rich models, there's a tradeoff between predicting well in the data you have and generalizing elsewhere, and the optimal model is somewhere in between. So the models are very rich, over fitting is a real concern, and a big part of the machinery or machine learning is figuring out the right way to optimize that. And the most generic machine learning models are optimized for MSE. But one of the things that I've done in my work is modify the objectives of machine
learning models, to try to make them more optimized for other objectives, things like causal inference. So the idea of machine learning algorithms is you consider a family of models, you use the data to select among the models, which is called choosing the tuning parameters. So the family includes simple models or rich models, like in OLS it might be three variables or 100 variables, would be all in the family of OLS regression. You use cross validation to choose, for example, you might break the data into ten folds, you estimate a model on nine-tenths of the data, look at their mean squared error on the last tenth. And then you see how rich a model actually gets the best mean squared error. And the machine learning works well because you can accurately evaluate the performance without additional assumptions. Your robotic research assistant tests many models to see what performs the best.
To contrast that with traditional econometrics, in traditional econometrics, economists focus on the case where you had many more observations than parameters. In that case, the in-sample mean squared error is a good approximation to the out-of-sample mean squared error. In contrast, economists typically imagine, at least, that they have a fairly simple model and they worry about things like estimating causal effects or identification. So we want to know what was the effect of having more immigrants come into Miami? What was the effect of changing the minimum wage? What were the effect of COVID lockdowns? These are all different kinds of policy questions you might answer. And then we're often interested in counterfactual predictions, like what would happen if we had another lockdown? What would happen if we had gotten vaccinations earlier? Things like that.
And then the empirical problems we worry a lot more about are separating correlation from causality. We also worry a lot about standard errors. Even if we run an experiment, we're worried that our result might just be due to sampling variation and might not generalize very well. We also try to incorporate behavioral assumptions or for like looking at some more complicated macro model, we may not have enough data to really pin everything down. So we're going to have some combination of behavioral assumptions, and calibrated parameters, and functional forms that help us, guide us to have sort of a data driven theoretical model. So a few observations on that just to kind of close the loop here, identification problems which cannot be evaluated using a holdout set. So identification is the question, if I had infinite data, would I even be able to answer my question? And we put a lot of emphasis on that in economics, especially in micro.
That's not something that you can figure out in a test set. So a simple example would be like, suppose that you were looking at the impact of price on sales. Well, if people typically raise their price in peak times, then prices and quantities would be positively correlated. Because when there's a big demand shock, the firms raise their prices, so you'd see lots of sales at a time with high prices. That positive correlation between prices and quantities will be true in a training set, it's true in a test set. Splitting your data or having held out data doesn't fix that problem at all. Instead we learn that you need something like a natural experiment, or some kind of exogenous variation, or some kind of supply shocks to be able to understand the relationship between prices and quantities. That type of logic was not there in traditional machine learning at all, wasn't really part of the textbooks or the framework.
So the traditional supervised machine learning kind of classes you would take. So causal methods typically sacrifice goodness-of-fit in order to focus only on variation of the data that identifies parameters of interest, and it's just a very different way to think about it. So let me actually skip ahead to, Kind of a little bit of a kind of summary of how we've brought together machine learning and econometrics and the causal inference literature. These are kind of six sort of takeaways. We first have said that machine learning is actually more about solving estimation problems in good functional forms. So as an economist using them, you might first consider identification. What would you do with infinite data, and then machine learning is going to be more about figuring out what the best functional form is.
A second point, this is more for the econometricians, is it actually we have a huge literature already, that says what you should do with semi-parametric models or when you want to be flexible functional forms. We had great theory, we just have bad practice. Like the models didn't work. So the machine learning can come in and have sort of better performing computational methods and functional forms and so on. But actually the theory is helpful and we actually collectively have pushed forward machine learning theory by bringing in ideas from semi-parametric efficiency theory. Once we change the question away from just prediction and make it towards estimation. A couple of other points, regularization can introduce emitted variable bias. That means when we do this model selection, sometimes we can throw away variables that might be important to control for, if we have a more causal approach.
So that's another reason we just don't throw the kitchen sink at a causal model. Instead what we do is, we break the problem apart, give some problems submit parts of the problem to machine learning. But change the objectives and the way that we optimize the problem to solve causal problems. Machine learning hadn't done much about sample splitting or cross fitting, there were some techniques that we've introduced, coming from the statistical theory perspective. And we've also tried to show how you can exploit a structure of a problem carefully to have better counterfactual predictions. So bringing in some ideas from either structural economics or aspects of a problem that are, were in economics, we had already put a lot of effort into finding the very best way to estimate a parameter. Now we just throw machine learning into kind of the nonparametric parts of that problem. And finally, it's actually pretty hard to test whether your approach works with
causal inference because people don't have causal effects stamped on their forehead. So I don't know whether Matteo would be paying more attention if he hadn't had that cup of coffee in the break or not. He had a cup of coffee. So he's bright eyed and bushy tailed. But what if he hadn't, so I can't just look at his outcome and know the causal effect of coffee. So we've had to be creative in figuring out how do we evaluate performance? If my goal is to predict how well, how alert Matteo is. [MUSIC]

Ask anything
We've read this whole study set, so questions about it get the best answers.