
Lecture 1 Part II Fall 2025: Introduction Continued transcript
Rebecca Willett · @rebeccawillett9305
Words
4,308
Runtime
38:45
Speaking pace
111wpm
Reading time
18min
111 words per minute, below the 160 25th percentile of 349 measured videos. That distribution comes from the 349-video hook study.
Opening (first 30 seconds)
All right. So with that, let's get started. And to start today, I want to talk about just the core elements of machine learning. [Music] And as we talk about these elements, I want to consider a motivating example throughout just to make all of the different concepts I present concrete. So in particular imagine that
56 words, the words spoken in the first 30 seconds at 111 words per minute.
Sentence shape
| Measure | This transcript |
|---|---|
| Sentences | 214 |
| Average words per sentence | 20.1 |
| Longest sentence | 105 words |
| Questions asked | 8 |
| Sentences containing a number | 14 |
Most used terms
- um53
- music44
- data34
- different32
- learning25
- feature23
- model22
- training21
- features20
- talk19
- images17
- sample17
Filler phrases
84 in total: um 53 · like 10 · uh 10 · actually 4 · sort of 3 · I mean 2 · kind of 1 · right? 1.
A literal whole-word count of the same phrase list the Prepublish browser extension uses, so a phrase inside another word is not counted and a phrase used in its ordinary sense still is. It is a count and not a judgement.
What this transcript is
Every word below is the caption track YouTube publishes for this video, pulled from the video itself and reproduced unchanged. It is not Prepublish's writing, not a summary, and not a re-transcription: it is the video's own published captions. English captions, generated automatically by YouTube, in the video’s original language. Source: the video on YouTube. A channel that would rather this page did not exist can ask for its removal through the contact page, and it is removed.
Transcript
All right. So with that, let's get started. And to start today, I want to talk about just the core elements of machine learning. [Music] And as we talk about these elements, I want to consider a motivating example throughout just to make all of the different concepts I present concrete. So in particular imagine that we want to take an image of a face [Music] and predict whether that face is smiling or not. [Music] Now I know predict sounds a little bit odd in this context.
What we really mean is what would happen if a human were to look at this face? Would they say that it is smiling or not? And we want the machine to predict what that human response would be. So to approach this problem, the key idea in machine learning is to represent this this label whether they're smiling or not using a model, a mathematical description of the data. [Music] a model. [Music] A mathematical description of the data.
And so the first step in this process is to collect raw data. [Music] So, what we need are a whole bunch of images representing different faces with different facial expressions, some smiling and some not smiling. So, this would be a G photos of faces. [Music] Our second step is going to take this data and do pre-processing. [Music] And so in here what we're doing is we are performing simple operations on the data that's not going to affect our end task but will make the task easier.
So we are going to change the data to make [Music] learning easier. And so, for example, in our facial recognition context, this could correspond to cropping the images. We might want to center the faces. We want might want to make sure that each image um has the same number of pixels. Perhaps there's some graininess to the images and we want to clean them up a bit. So, you can see how these things, these operations are not really going to affect um whether or not the face is smiling or not, but they can make it easier to perform learning.
So, for instance, if the mouth is in the same part of the image in every single image, then that's just one less source of variation for us to worry about. So this is a very common task um for most data sets. The third is feature extraction. This is an task that's central but which has evolved quite a bit over the history of machine learning. So what we mean by this is now we are going to reduce the raw data by representing it in terms of features or properties relevant to the task.
[Music] So for instance, in our facial recognition example, we have these images of faces that have eyes, eyebrows, uh, a nose and a mouth. And we want to make a prediction about whether this is smiling or not. In its raw form, this image is a list of pixel values. How much red and green and blue light is there at every single location in this image? Feature extraction might say, well, rather than dealing with raw pixel values, I'm going to measure certain things.
Let's say the distance between the um left eye corner and the left mouth corner and the right eye corner and the right mouth corner or maybe how wide the mouth is or the distance between um uh the the ear and the mouth corner. So we might have a variety of different facial features that we can extract and then instead of representing the image in terms of its pixel values, we represent it in terms of say these different distances between different facial features.
This can be extremely helpful in settings where you might not have a whole lot of training images. Um, so if I wanted to perform machine learning and all of my images have millions and millions of pixels, you could imagine that many aspects of that image are irrelevant to my task. The color of the background, the color of the hair, um, a variety of whether or not they have earrings, all of that's irrelevant to whether or not they're smiling.
And if you have a small amount of training data, you run the risk of your model or your mathematical algorithm focusing on features that are just spurious correlations to that have spurious correlations to the label or to the task that you have at hand. Um and so reducing the number of features from say millions of pixels to on the order of 10 or 20 different facial features can make you much more robust to those sorts of spurious correlations.
Now I said that this is something that's actually evolved in recent years. So there's a few different variants of this. What I've just described is um I guess I would say manual feature selection where an expert decides which feature which features are uh relevant. [Music] I'm using the word expert loosely here. Um when we look at some modern tasks um such or modern methods like using neural networks, what we saw in the intro slides is that those models can actually perform well even when we don't have um feature extraction steps and we're just feeding in raw pixel values into the neural network.
Um and we also saw that different layers in the neural network can be attuned to different feature images. And so in that context we would say that in the process of learning to assign labels to the different images we are also learning good features features that are relevant to the task. So there is feature learning which would happen for instance with a neural network. [Music] Now to be clear in order for this to happen in order for us to have good future learning typically we need very large quantities of data.
And in fact, that's one of the things that really was key to neural networks taking off is the building of enormous data sets that these models could be trained on. Um, so if you don't have enormous data sets, sometimes it is important to do this manual feature selection. But a third uh category that we see commonly is to have um a foundation model. And this is something that we aren't going to talk about in any great depth um in this class um but I just wanted to mention it in case you just hear it and people discussing it.
And this refers to um settings where people have taken enormous data sets and trained neural networks to do a variety of different kinds of tasks and along the way perform feature learning and then taking those learned features and using them with as sort of in this context of manual feature selection. So instead of an expert coming along and saying, "Oh, you should look at the distance between the left eye corner and the left mouth corner," we would instead say, "Oh, my foundation model says here is an important feature.
So you should extract that feature from your images." And so these foundation models lead to somewhat generic features that can be used for a variety of tasks without expert knowledge but also without requiring us to have so much data for our specific task that we are able to do feature learning on our own. Okay. So the next element is to generate training samples. [Music] And this is number four. [Music] So we've collected all of these images.
Um we've done our pre-processing and we've done our um uh feature extraction. And so now we are going to form training samples and we are going to write this as pairs x i and y i for i = 1 to n. So in this setting and with this notation, n is equal to the number of training samples. Yi is equal to the label of the E sample. So for instance, this could be plus one if the image has a smile in it and negative one otherwise.
[Music] Next we have our feature vector xi. So I'm writing it like this with the underline on it under it. um in the typed notes this is going to have a bold font and we do that to correspond to or to to indicate that this is a vector. It's going to be a list of different feature values. So this could contain for instance the distance from the left eye to the mouth corner, the distance from the right eye to the mouth corner and the width of the mouth.
There we've got three different features and we're putting them all together in this one vector x i and we use this underlying to indicate that there could be more than one feature in this in this vector. So this is equal to the features of the i sample. Um and in general we are go usually going to use the letter P to be the number of features per sample. [Music] Okay. So and then a little bit more specifically if I wanted to talk about the J feature one specific feature in this entire vector I would write that as XI J.
So this is the J feature of the E sample. Now I want to pause for a moment and mention that in this class for the most part we are going to assume that we are just handed data like I've written out here um and that somebody has already done the feature extraction done whatever pre-processing selected what photographs to include and labeled them. Now, in real life, all of these steps re involve a number of different decisions that are extremely important.
Um and so just as an example, if you were to um from the outset only have images from one ethnic or racial group, then you run the risk of developing a machine learning model that really is only accurate at predicting smiling for that racial or ethnic group. or as we talked about earlier, decisions about how we actually assign labels to images, what human expertise we get or what kinds of algorithms we use to assign labels.
Um, those also can have downstream ramifications. So again, we're not going to be covering those decisions in part because they really depend very much on the context in this class, but I just want to take a moment to emphasize how important it is to think through that. And if you have a job where someone hands you a data set, it's completely valid and often extremely important to ask where did this data come from? What were the decisions that went into it?
How was it originally intended to be used? how is that related to the task that you're being asked to use it in etc. Okay. Now I also want to emphasize that we have um I I'm kind of focusing on one aspect or one form of machine learning here um called supervised machine learning and that is going to be our initial focus in this class. So when we talk about supervised [Music] machine learning, we mean that each sample has a label and that could and so when we talk about classification, [Music] what we mean is that the label is equal to a class indicator.
[Music] So that could be um whether or not someone is smiling, for instance. Or we could have more than one class. So we might have whether or not there's a dog in the image, whether or not there's a cat in the image, whether or not there's a face in the image. So we might have multiple different classes um that we're considering. We might also have regression. And when we talk about regression, what we mean is that the label is a real number.
[Music] So maybe what we want to do is predict someone's say height based on their shoe size. So that's not a category we're trying to predict. Rather, it's just a raw number indicating something um that we care about. When we talk about unsupervised machine learning, we have unlabeled samples. [Music] So for instance, when you think about generative models, those are trained um with huge quantities of data samples, say images, and those images aren't necessarily labeled with anything indicating their content.
They're just images. And so what we're trying to do is to learn how to generate new images based on the images we've already seen. And we can do that without labels. We also see things like semi-supervised learning or there's self-supervised and these are important concepts but beyond the scope of what we'll cover in this class. But once you have the foundations that you learn in this class, you'll be able to take subsequent classes where you can learn about these things in more detail.
But in this class, for the first part, we're going to focus on supervised machine learning. And then later in the quarter, we are going to move to unsupervised machine learning, we'll talk about dimensionality, reduction, clustering, and a variety of other problems within this space. And just to be clear, when we talk about supervised versus unsupervised, the idea is that the label is somehow supervising how we perform learning.
Okay? So with that in mind, we can now move on to the next step. We finally have our training data all set and we actually want to do a little bit of learning. So to learn a model, [Music] we first have to choose a loss function. [Music] What the loss function is going to do is tell us how good or bad a model is. [Music] So to be um so for instance let's just do a concrete example quickly in our case of people smiling or not smiling this could be the loss could be the number of people [Music] mclassified.
So it could be the number of people we say are smiling when they're not or the number of people who we say are not smiling when they are. It turns out that this particular loss function is very hard to work with. And so in the coming weeks we're going to talk about why that is and alternative loss functions that that we can use. But this is just a a quick example. And then finally we are going to learn the model. So in general what this means is that we search over a collection of candidate models [Music] and choose the one that has the smallest loss.
[Music] And so in particular uh and when I say loss, we're going to be looking at the loss on the training data. [Music] Okay, so let's make all of this very concrete. um with an example here. [Music] So, I'm going to imagine that I have training data that corresponds to a variety of different um samples with two features each. So I'm going to have X and this I'm going to write colon comma one. So this means that it could be any of the samples I from 1 to N.
But I'm looking at the first feature. And then over here I'm going to have X uh colon, 2. So in our um running example of classifying the features or classifying um whether someone is smiling or not based on facial features. This could be distance um eye to mouth and this one could be um mouth width. Okay. And then we have we can plot our training samples. And so we might have a whole bunch of examples where the person is not smiling.
And so this each one of these corresponds to a different eye. So this might be I is equal to one. That might be our first training sample. And so we're saying for the first training sample, it has this particular distance from the eye to the mouth, this particular mouth width, and the label associated with it. Y1 is equal to -1. And then we also have our positive examples. [Music] And so what we're talking about here would be for instance a different one maybe I is equal to 10 and Y 10 is equal to positive 1.
Now when we talk about families of models we're thinking about in this in this classification context different ways we could draw a dividing line within this data. So let's imagine for the for initially that we're going to constrain ourselves to only having straight lines that are that tell us how to classify like this. Okay, so this is one particular model. We could draw another model for instance like this. It's also a straight line.
But if we were to measure our loss for these two different models and we look and see how many errors are made by each model, we see they have very different values. Right? This solid line is making three mistakes on this sample, this sample and this sample. Whereas the dashed line is making far more mistakes. So when we draw these lines what we mean is that in the future if we get a new sample and it lies below this line then we are going to predict for that new sample that the label y hat is positive one and for any new sample that lies above this line we are going to predict that the label y hat is equal to -1 And so in these samples, oops, this one was not a mistake.
We ran two, uh, for these two samples here, um, this solid line is yielding a prediction that is different than the actual label that we had in our training data. And so our loss function is telling us how bad of a model this solid line is. And when we are doing our learning of the model, it means we're searching over all these candidate models. So in this case say all different lines of different slopes and different intercepts and choosing the one that minimizes our loss in this case perhaps minimizing the number of errors we make on the training data.
Another thing I want to quickly mention is that by controlling the complexity of the models um we can avoid problems like overfitting. So an alternative might have been that we have much more complicated models and end up with a decision boundary that gets zero errors on the training data. Something like this. And so when you look at this, you might think, oh yeah, that looks better because this orange decision boundary has not made any mistakes.
But what you run the risk of here is overfitting that somehow perhaps there's a few different errors in the training set. And so later on you get a new sample here which really should be I mean at test time after you've deployed your learn system um where it really is a photo of somebody not smiling but because you were so carefully attuned to this one positive sample here and overfitit to it you're no longer to make able to make as good of predictions on new samples.
And so we're going to talk more about this, how to prevent overfitting um later in the course. But before we get to that, I want to highlight sort of the final key element um that we will be considering here. [Music] which is to characterize the generalization error. [Music] Okay. So when we talk about characterizing the generalization error we are talking about the average error of our predicure predictor say of our decision boundary on new data.
So estimate [Music] average error of the learned model on new data [Music] not used in training. [Music] Um, so for instance, we could have a whole bunch of test samples and the test data are generally assumed to be from the same distribution uh as our training data. So they would also have the form Xi and Yi. Maybe I'll just put a little superscript t here for test. So these are different samples, but they've got the same features.
The labels mean the same things. And so what we can do is we can learn a model on our training data and then after the fact take our test data and evaluate how many times we make a mistake with our learned predictor on this test data. And this is telling us our generalization error. Okay. So now I want to dive in a little bit more to this classification example. Talk more about a concept I introduced a little bit earlier the notion of a vector and also how we can start mathematically representing this notion of linear classifiers.
Okay. So, [Music] so in our classification problem we are going to again get samples X I Yi to train on from i = 1 to n and the yis are going to correspond in this case to binary labels. So we write this as yi is in1 or + one. So that means every single yi is either a plus or a minus one. It's in that set. Or sometimes you see people use yi is equal to zero or one uh just because it can be mathematically more convenient in certain settings.
Our goal is to learn a model um that accurately predicts the label for a new sample. [Music] So we're going to use y hat to correspond to the predicted label um and for a new um feature vector and I'm going to write this as x knot just to be very clear that it is not one of our training samples. It's a new sample that we're going to get after training for which we want to make a prediction. Okay. So now when we do this let's consider this notion of a linear model.
[Music] And in particular [Music] the idea is that our label y hat is going to be a weighted sum of the features. So we are going to have x01, x02, x03, all the way out to x0 p, where p is the number of different features. And like I said, we're going to use a weighted sum. So, we're going to have W1 * X01 plus W2 * X02 + W3 * X03 all the way out to WP * X0P. So, with this linear model, we know that we are going to get these kinds of straight line decision boundaries or linear decision boundaries. um and in particular the weights are going to be what we learn from training data.
So when I talk about over here trying to choose between the dashed line and the solid line, what I mean is we are going to try to choose the best set of weights within the context of this linear model. Now when we write out this weighted sum, it can be a little bit cumbersome. And so we're going to introduce some notation that's going to simplify a lot of things for us a little bit when we first start talking about linear models, but a huge amount as we progress further and further into the course.
So in particular, we are going to let W or maybe I'll just use my orange again here. [Music] W with the underline um be our weight vector. So we have in this vector w1 w2 w3 all the way down to wp and I'm going to write this as in and then sort of a bold blackboard r to the p and what this means is that this weight vector w has p different entries and each one of them is a real number and we are going to call this um a weight vector [Music] and similarly [Music] we are going to have xnot vector be written as x1 x2 all the way to xnot p and it also is in rp it is a vector of P different real numbers.
And so now armed with this notation, we can express this linear model with some shorthand. And in particular, we can write this as an inner product. [Music] So we can write the inner product in a few different ways. We could write it as x knot comma w inside these angle brackets. And that's the same as w inner product with x knot. So in this inner product, the order doesn't matter at all. And we can also write it as xnot transpose w um or w transpose x knot.
And this notion of transpose is very simple. I'll just map it out over here. [Music] So when we talk about a vector let's say w transpose we indicate it with this superscript that looks like a little t and it means that we are going to have w1 w2 all the way to wp all in a row. Um and so when we talk about W transpose x knot then this means w1 w2 all the way to wp time x1 x2 all the way down to xp. And so what's happening here with this notation is we're saying you're going to multiply the first elements of the two vectors, the second elements of the two vectors all the way to the pith elements of the two vectors and then add up all those products which gives you exactly the weighted sum of our linear model.
Okay, so now we've set the stage and next time we're going to talk more about how we can use this notion of a vector and additional notions related to matrices to formulate our learning problem and start learning weights from data. Thanks very much.
The words are the caption track's own and nothing is reworded or re-transcribed. Paragraph breaks are placed between sentences so the text reads as prose.
Use this transcript
Three free tools that work on the material around a video like this one. No signup, no login.
Hook Analyzer
Paste the first 30 seconds of your own draft for a hook score and rewrites.
Policy Pre-Flight
Check your draft against YouTube's advertiser-friendly guidelines before you record it.
Channel Skill Generator
Read this channel's public videos and transcripts, and download a writing brief for it.