00:01In machine learning, one can make a distinction between what's called generative approaches versus discriminative [Music] discriminative approaches
00:21And uh to talk about these, let's let's think about a a classification setting
00:27So say we are in we've got data points in R2
00:30So we've got R2
00:33Our X's are in R2
00:39Maybe that's one axis
00:39So that's like the X1
00:42It's like the X2
00:42And we've got some points
00:47Maybe I'll draw them as red for one class
00:52Something like this
00:58one class and maybe I'll do blue another class
01:03Something like this
01:07So, we got these points
01:11Maybe this is a little sparer over here
01:15Got some points here
01:15And there's not a clear, you know, they they kind of overlap here
01:24So in a so now if we had a new point right classification you would say you know what's so maybe an easy one would be like over here
01:34So what's that? Well looks like it ought to be a blue and in a generative approach
01:40So we'll talk about actually let's talk about discriminative first
01:46So discriminative approach you model
01:48So the let's say the the x is so we get this data x1 y1 let me use superscripts here x1 y1 first data point labeled and then we get some more data points up to say n xn yn and a discriminative approach would be to model the probability of the y's of a y given its x
02:24So I'm taking x and y as a prototypical as a prototypical um point here
02:30So x and y or maybe you could think about x and y as a new new point that we need to classify and we're going to model in a discriminative approach
02:44So let me say this is discriminative We're going to model the probability of Y given X
02:55So given this new X here has some coordinate X1 and X2 and we want to predict its class
03:02So if we had a model, so say we had a simple model where we only paid attention to in this class in this case it looks like X2 isn't doing very much
03:14So maybe our discriminative model only pays attention to say x1 and we say that the probability of y given that given say this is the first coordinate x1 maybe it only depends on that or we can let's make it clear let's so let's just keep it as x and then this is there might be an x2 axis but maybe the probability is uh doesn't Well, it can't be constant, but it would be um Oh, yeah
03:49I guess it could be constant
03:51Could be constant in the x2 direction
03:54So, the probability of y given x is uh say it looks something like this
04:03So, so if we call these reds, call that one class one and we'll call the blues class two or rather zero
04:14Then the probability that y equals 1
04:18So let's say that
04:18So let's say probability that y = 1 given x say this is one
04:27So maybe when it's over, you know, when we're in here, we're we're quite certain
04:32So this is going to be close to one
04:34And then it drops off very quickly
04:37And then when we're over here, we say, you know, for these x1 values, we're pretty sure that it's it's a the class is zero
04:46So the probability that y is one is is very small
04:51So maybe we have a discriminative model like this
05:00Now a generative model on the other hand would model both it would model the joint distribution X and Y
05:12So in this case the X's might have some so we could factor this as the the density let's write it as F
05:22So the density of X given Y times the probability of Y and these densities
05:35Uh so for example here you know we might have a density for the zero class that looks something like well you know maybe a Gaussian something like this right that might be Gaussian for that guy and maybe a density for this guy that's sort of concentrates in this region And in a generative model since we're paying attention to the distribution on X
06:08So we could also instead we could write this as the probability of Y given X times the marginal density of X
06:24And uh in a generative model you model the the densities as well as so you could you could view it two ways
06:33You could view it as the the class marginal probabilities and then the conditional density of X given the class or you could view it as just some marginal density on X and then the probability of the class given the X
06:46So the discriminative part shows up here and in this example which I I chose to illustrate this suppose we now had a point over here
07:00Suppose you're you were asked you were given a new X over here and you wanted to predict its value its its class its Y
07:09Well, in this uh discriminative type of model, you might you would you would probably say that that's class one
07:23And but in a generative model, if you are m modeling these class conditional densities, then you would you would probably you you would be more inclined to say that that belongs to class zero
07:41So in this perhaps contrived example at least it and and and more generally I mean a generative model is is more powerful in some sense than a discriminative model because well you're just accounting for more things but there are good reasons to use discriminative models very good reasons actually
08:01It's not just the fact that you're you know being lazy and sort of ignoring this other part
08:05It's so the the reasons well one reason is that uh in a generative model you have to estimate the these these densities well one of these at least if you take this approach you have to m mark you have to model these and estimating a density takes a lot of data and statistically speaking it's very difficult to do so you're uh you're inclined to make mistakes you know your estimates will have high variance especially if you don't have much data
08:41That was a sort of uh statistical um argument there
08:46But generally, you know, and you you can probably see that that uh it's going to be difficult to model this this density if unless you have lots of data
08:57And as a result, a generative model can be uh can have can have worse performance than a discriminative model
09:07So that's what people mean when they talk about generative versus discriminative models
09:14And let me explain this terminology why these are called generative at least
09:19So generative models well often they have a very natural so one sort of appealing thing about generative models is that they also often have a very natural sort of interpretation and uh it's in terms of a generative process
09:36So this this formula suggests it here
09:39So the generative process which we might describe this this data by would be first we're going to choose a class y zero or one in this case just zero or one since these are our only two classes
09:52So so we choose y according to this its marginal distribution and then given the class we're going to choose a point
10:00So first we choose zeros maybe and then we pick some point that's the gener that's what's called the generative process and then maybe if we run the generative process again maybe we pick one this time and then we we choose I don't know say this point you know we we choose it from the the mar from the conditional distribution on x given y equals one
10:33So that's why it's called a generative process versus a discriminative
10:38And a discriminative you don't have any distribution over the x's
10:42So you can't generate the x's
10:44All you can do is sort of discriminate between the classes given x.