1.9 Machine Learning Overview | Linear regression model part 1 --[Machine Learning | Andrew Ng]
 In this video, we'll look at what the overall process of supervised learning is like. Specifically, you see the first model of this course, a linear regression model. That just means filling a straight line to your data. It's probably the most widely used learning algorithm in the world today. And as you get familiar with linear regression, many of the concepts you see here will also apply to other machine learning models, models that you'll see later in this specialization. Let's start with a problem that you can address using linear regression. Say you want to predict the price of a house based on the size of a house. This is example we see in earlier this week. We're going to use a data set on house sizes and prices from Portland, a city in the United States. Here with a graph where the horizontal axis is the size of the house in square feet and the vertical axis is the price of the house in thousands of dollars. Let's go ahead and plot the data points for various houses in the data set. Here each data point, each of these little crosses is a house with a size and a price that it most recently was sold for. Now let's say you're a real estate agent in Portland and you're helping a client sell her house. And she's asking you, how much do you think you're going to get for this house? This data set might help you estimate the price she could get for it. You start by measuring the size of the house and it turns out that her house is 1250 square feet. How much do you think this house could sell for? One thing you could do is you can build a linear regression model from this data set. Your model will fit a straight line to the data, which might look like this. And based on this straight line fit to the data, you can kind of see that if a house is 1250 square feet, it will intersect the best fit line over here. And if you trace that to the vertical axis on the left, you can see the prices may be around here, say about $220,000. So this is an example of what's called a supervised learning model. We call this supervised learning because you are first training your model by giving it data that has the right answers. Because you give the model examples of houses with both the size of the house as well as the price that the model should predict for each house. Where here are the prices, that is the right answers are given for every house in the data set. This linear regression model is a particular type of supervised learning model. It's called a regression model because it predicts numbers as the output, like prices and dollars. Any supervised learning model that predicts a number, such as 220,000 or 1.5 or negative 33.2 is addressing what's called a regression problem. So linear regression is one example of a regression model, but there are other models for addressing regression problems too. And we'll see some of those later in course two of this specialization. And just to remind you, in contrast with the regression model, the other most common type of supervised learning model is called a classification model. A classification model predicts categories or discrete categories, such as predicting if a picture is of a cat meow or a dog woof. Or if given a medical record, it has to predict if a patient has a particular disease. You see more about classification models later in this course as well. So as a reminder about the difference between classification and regression, in classification, there are only a small number of possible outputs. If your model is recognizing cats versus dogs, that's two possible outputs. Or maybe you're trying to recognize any of 10 possible medical conditions in a patient. So there's a discrete, finite set of possible outputs. We call it a classification problem. Whereas in regression, there are infinitely many possible numbers that the model could output. In addition to visualizing this data as a plot here on the left, there's one other way of looking at the data that would be useful. And that's a data table here on the right. The data comprises a set of inputs. This would be the size of the house, which is this column here. It also has outputs, you're trying to predict the price, which is this column here. Notice that the horizontal and vertical axes correspond to these two columns, the size and the price. And so if you have, say, 47 rows in this data table, then there are 47 of these little crosses on the plot of the left, each cross corresponding to one row of the table. For example, the first row of the table is a house with size 2104 square feet. So that's around here. And this house, so for $400,000, which is around here. So this first row of the table is plotted as this data point over here. Now let's look at some notation for describing the data. This is notation that you find useful throughout your journey in machine learning. As you increasingly get familiar with machine learning terminology, this would be terminology that you can use to talk about machine learning concepts with others as well, since a lot of this is quite standard across AI. You'll be seeing this notation multiple times in this specialization. So it's okay if you don't remember everything the first time through, it will naturally become more familiar over time. The data set that you just saw and that is used to train the model is called a training set. Note that your client's house is not in this data set because it's not yet sold. So no one knows what his price is. So to predict the price of your client's house, you first train your model to learn from the training set and that model can then predict your client's house's price. In machine learning, the standard notation to denote the input here is lowercase x and we call this the input variable. It's also called a feature or an input feature. For example, for the first house in your training set, x is the size of the house, so x equals 2104. The standard notation to denote the output variable, which you're trying to predict, which is also sometimes called the target variable, is lowercase y. And so here, y is the price of the house and for the first training example, this is equal to 400. So y equals 400. So the data set has one row for each house and in this particular training set, there are 47 rows with each row representing a different training example. We're going to use lowercase m to refer to the total number of training examples and so here, m is equal to 47. To indicate a single training example, we're going to use the notation parentheses x comma y. So for the first training example, x comma y, this pair of numbers is 2104 comma 400. Now we have a lot of different training examples. We have 47 of them in fact. So to refer to a specific training example, this will correspond to a specific row in this table on the left. I'm going to use the notation x superscript in parentheses i comma y superscript in parentheses i. The superscript tells us that this is the i-th training example, such as the first, second or third up to the 47th training example. i here refers to a specific row in the table. So for instance, here is the first example when i equals 1 in the training set. And so x superscript 1 is equal to 2104 and y superscript 1 is equal to 400. And let's add the superscript 1 here as well. Just a note, this superscript i in parentheses is not exponentiation. So when I write this, this is not x squared. This is not x to the power of 2. It just refers to the second training example. So this i is just an index in the training set and refers to row i in the table. In this video, you saw what a training set is like as well as standard notation for describing this training set. In the next video, let's look at what it'll take to take this training set that you just saw and feed it to a learning algorithm so that the algorithm can learn from this data. We'll see that in the next video.
[{"start": 0.0, "end": 8.0, "text": " In this video, we'll look at what the overall process of supervised learning is like."}, {"start": 8.0, "end": 14.24, "text": " Specifically, you see the first model of this course, a linear regression model."}, {"start": 14.24, "end": 17.52, "text": " That just means filling a straight line to your data."}, {"start": 17.52, "end": 21.92, "text": " It's probably the most widely used learning algorithm in the world today."}, {"start": 21.92, "end": 27.32, "text": " And as you get familiar with linear regression, many of the concepts you see here will also"}, {"start": 27.32, "end": 34.4, "text": " apply to other machine learning models, models that you'll see later in this specialization."}, {"start": 34.4, "end": 38.44, "text": " Let's start with a problem that you can address using linear regression."}, {"start": 38.44, "end": 42.28, "text": " Say you want to predict the price of a house based on the size of a house."}, {"start": 42.28, "end": 45.56, "text": " This is example we see in earlier this week."}, {"start": 45.56, "end": 51.72, "text": " We're going to use a data set on house sizes and prices from Portland, a city in the United"}, {"start": 51.72, "end": 53.120000000000005, "text": " States."}, {"start": 53.12, "end": 58.16, "text": " Here with a graph where the horizontal axis is the size of the house in square feet and"}, {"start": 58.16, "end": 63.76, "text": " the vertical axis is the price of the house in thousands of dollars."}, {"start": 63.76, "end": 68.36, "text": " Let's go ahead and plot the data points for various houses in the data set."}, {"start": 68.36, "end": 74.44, "text": " Here each data point, each of these little crosses is a house with a size and a price"}, {"start": 74.44, "end": 77.88, "text": " that it most recently was sold for."}, {"start": 77.88, "end": 83.39999999999999, "text": " Now let's say you're a real estate agent in Portland and you're helping a client sell"}, {"start": 83.39999999999999, "end": 84.39999999999999, "text": " her house."}, {"start": 84.39999999999999, "end": 87.8, "text": " And she's asking you, how much do you think you're going to get for this house?"}, {"start": 87.8, "end": 92.52, "text": " This data set might help you estimate the price she could get for it."}, {"start": 92.52, "end": 98.28, "text": " You start by measuring the size of the house and it turns out that her house is 1250 square"}, {"start": 98.28, "end": 99.39999999999999, "text": " feet."}, {"start": 99.39999999999999, "end": 102.52, "text": " How much do you think this house could sell for?"}, {"start": 102.52, "end": 108.0, "text": " One thing you could do is you can build a linear regression model from this data set."}, {"start": 108.0, "end": 113.36, "text": " Your model will fit a straight line to the data, which might look like this."}, {"start": 113.36, "end": 117.6, "text": " And based on this straight line fit to the data, you can kind of see that if a house"}, {"start": 117.6, "end": 124.64, "text": " is 1250 square feet, it will intersect the best fit line over here."}, {"start": 124.64, "end": 129.28, "text": " And if you trace that to the vertical axis on the left, you can see the prices may be"}, {"start": 129.28, "end": 133.16, "text": " around here, say about $220,000."}, {"start": 133.16, "end": 138.04, "text": " So this is an example of what's called a supervised learning model."}, {"start": 138.04, "end": 142.2, "text": " We call this supervised learning because you are first training your model by giving it"}, {"start": 142.2, "end": 144.72, "text": " data that has the right answers."}, {"start": 144.72, "end": 148.76, "text": " Because you give the model examples of houses with both the size of the house as well as"}, {"start": 148.76, "end": 152.36, "text": " the price that the model should predict for each house."}, {"start": 152.36, "end": 157.6, "text": " Where here are the prices, that is the right answers are given for every house in the data"}, {"start": 157.6, "end": 159.08, "text": " set."}, {"start": 159.08, "end": 163.56, "text": " This linear regression model is a particular type of supervised learning model."}, {"start": 163.56, "end": 168.16000000000003, "text": " It's called a regression model because it predicts numbers as the output, like prices"}, {"start": 168.16000000000003, "end": 169.88000000000002, "text": " and dollars."}, {"start": 169.88000000000002, "end": 177.96, "text": " Any supervised learning model that predicts a number, such as 220,000 or 1.5 or negative"}, {"start": 177.96, "end": 183.64000000000001, "text": " 33.2 is addressing what's called a regression problem."}, {"start": 183.64, "end": 190.0, "text": " So linear regression is one example of a regression model, but there are other models for addressing"}, {"start": 190.0, "end": 192.55999999999997, "text": " regression problems too."}, {"start": 192.55999999999997, "end": 198.2, "text": " And we'll see some of those later in course two of this specialization."}, {"start": 198.2, "end": 203.88, "text": " And just to remind you, in contrast with the regression model, the other most common type"}, {"start": 203.88, "end": 208.72, "text": " of supervised learning model is called a classification model."}, {"start": 208.72, "end": 214.68, "text": " A classification model predicts categories or discrete categories, such as predicting"}, {"start": 214.68, "end": 219.72, "text": " if a picture is of a cat meow or a dog woof."}, {"start": 219.72, "end": 225.52, "text": " Or if given a medical record, it has to predict if a patient has a particular disease."}, {"start": 225.52, "end": 230.24, "text": " You see more about classification models later in this course as well."}, {"start": 230.24, "end": 235.76, "text": " So as a reminder about the difference between classification and regression, in classification,"}, {"start": 235.76, "end": 239.23999999999998, "text": " there are only a small number of possible outputs."}, {"start": 239.23999999999998, "end": 245.48, "text": " If your model is recognizing cats versus dogs, that's two possible outputs."}, {"start": 245.48, "end": 252.82, "text": " Or maybe you're trying to recognize any of 10 possible medical conditions in a patient."}, {"start": 252.82, "end": 256.52, "text": " So there's a discrete, finite set of possible outputs."}, {"start": 256.52, "end": 259.03999999999996, "text": " We call it a classification problem."}, {"start": 259.03999999999996, "end": 263.12, "text": " Whereas in regression, there are infinitely many possible numbers that the model could"}, {"start": 263.12, "end": 264.62, "text": " output."}, {"start": 264.62, "end": 270.36, "text": " In addition to visualizing this data as a plot here on the left, there's one other way"}, {"start": 270.36, "end": 274.4, "text": " of looking at the data that would be useful."}, {"start": 274.4, "end": 278.88, "text": " And that's a data table here on the right."}, {"start": 278.88, "end": 282.16, "text": " The data comprises a set of inputs."}, {"start": 282.16, "end": 286.68, "text": " This would be the size of the house, which is this column here."}, {"start": 286.68, "end": 295.12, "text": " It also has outputs, you're trying to predict the price, which is this column here."}, {"start": 295.12, "end": 302.8, "text": " Notice that the horizontal and vertical axes correspond to these two columns, the size"}, {"start": 302.8, "end": 305.2, "text": " and the price."}, {"start": 305.2, "end": 315.08, "text": " And so if you have, say, 47 rows in this data table, then there are 47 of these little crosses"}, {"start": 315.08, "end": 322.84, "text": " on the plot of the left, each cross corresponding to one row of the table."}, {"start": 322.84, "end": 331.4, "text": " For example, the first row of the table is a house with size 2104 square feet."}, {"start": 331.4, "end": 335.36, "text": " So that's around here."}, {"start": 335.36, "end": 342.41999999999996, "text": " And this house, so for $400,000, which is around here."}, {"start": 342.42, "end": 349.56, "text": " So this first row of the table is plotted as this data point over here."}, {"start": 349.56, "end": 353.98, "text": " Now let's look at some notation for describing the data."}, {"start": 353.98, "end": 359.0, "text": " This is notation that you find useful throughout your journey in machine learning."}, {"start": 359.0, "end": 364.36, "text": " As you increasingly get familiar with machine learning terminology, this would be terminology"}, {"start": 364.36, "end": 369.44, "text": " that you can use to talk about machine learning concepts with others as well, since a lot"}, {"start": 369.44, "end": 373.2, "text": " of this is quite standard across AI."}, {"start": 373.2, "end": 377.04, "text": " You'll be seeing this notation multiple times in this specialization."}, {"start": 377.04, "end": 381.56, "text": " So it's okay if you don't remember everything the first time through, it will naturally"}, {"start": 381.56, "end": 385.08, "text": " become more familiar over time."}, {"start": 385.08, "end": 392.08, "text": " The data set that you just saw and that is used to train the model is called a training"}, {"start": 392.08, "end": 393.08, "text": " set."}, {"start": 393.08, "end": 398.76, "text": " Note that your client's house is not in this data set because it's not yet sold."}, {"start": 398.76, "end": 401.56, "text": " So no one knows what his price is."}, {"start": 401.56, "end": 406.88, "text": " So to predict the price of your client's house, you first train your model to learn from the"}, {"start": 406.88, "end": 414.03999999999996, "text": " training set and that model can then predict your client's house's price."}, {"start": 414.03999999999996, "end": 420.96, "text": " In machine learning, the standard notation to denote the input here is lowercase x and"}, {"start": 420.96, "end": 423.76, "text": " we call this the input variable."}, {"start": 423.76, "end": 429.59999999999997, "text": " It's also called a feature or an input feature."}, {"start": 429.59999999999997, "end": 436.52, "text": " For example, for the first house in your training set, x is the size of the house, so x equals"}, {"start": 436.52, "end": 440.28, "text": " 2104."}, {"start": 440.28, "end": 446.92, "text": " The standard notation to denote the output variable, which you're trying to predict,"}, {"start": 446.92, "end": 455.64000000000004, "text": " which is also sometimes called the target variable, is lowercase y."}, {"start": 455.64000000000004, "end": 462.6, "text": " And so here, y is the price of the house and for the first training example, this is equal"}, {"start": 462.6, "end": 464.5, "text": " to 400."}, {"start": 464.5, "end": 468.20000000000005, "text": " So y equals 400."}, {"start": 468.2, "end": 477.4, "text": " So the data set has one row for each house and in this particular training set, there"}, {"start": 477.4, "end": 484.2, "text": " are 47 rows with each row representing a different training example."}, {"start": 484.2, "end": 489.59999999999997, "text": " We're going to use lowercase m to refer to the total number of training examples and"}, {"start": 489.59999999999997, "end": 494.03999999999996, "text": " so here, m is equal to 47."}, {"start": 494.04, "end": 500.76000000000005, "text": " To indicate a single training example, we're going to use the notation parentheses x comma"}, {"start": 500.76000000000005, "end": 502.28000000000003, "text": " y."}, {"start": 502.28000000000003, "end": 514.28, "text": " So for the first training example, x comma y, this pair of numbers is 2104 comma 400."}, {"start": 514.28, "end": 517.44, "text": " Now we have a lot of different training examples."}, {"start": 517.44, "end": 519.46, "text": " We have 47 of them in fact."}, {"start": 519.46, "end": 526.0, "text": " So to refer to a specific training example, this will correspond to a specific row in"}, {"start": 526.0, "end": 527.72, "text": " this table on the left."}, {"start": 527.72, "end": 536.24, "text": " I'm going to use the notation x superscript in parentheses i comma y superscript in parentheses"}, {"start": 536.24, "end": 538.12, "text": " i."}, {"start": 538.12, "end": 545.6800000000001, "text": " The superscript tells us that this is the i-th training example, such as the first,"}, {"start": 545.68, "end": 549.52, "text": " second or third up to the 47th training example."}, {"start": 549.52, "end": 556.04, "text": " i here refers to a specific row in the table."}, {"start": 556.04, "end": 566.12, "text": " So for instance, here is the first example when i equals 1 in the training set."}, {"start": 566.12, "end": 577.32, "text": " And so x superscript 1 is equal to 2104 and y superscript 1 is equal to 400."}, {"start": 577.32, "end": 582.52, "text": " And let's add the superscript 1 here as well."}, {"start": 582.52, "end": 588.36, "text": " Just a note, this superscript i in parentheses is not exponentiation."}, {"start": 588.36, "end": 593.6800000000001, "text": " So when I write this, this is not x squared."}, {"start": 593.6800000000001, "end": 596.04, "text": " This is not x to the power of 2."}, {"start": 596.04, "end": 599.7199999999999, "text": " It just refers to the second training example."}, {"start": 599.7199999999999, "end": 606.8, "text": " So this i is just an index in the training set and refers to row i in the table."}, {"start": 606.8, "end": 612.48, "text": " In this video, you saw what a training set is like as well as standard notation for describing"}, {"start": 612.48, "end": 613.48, "text": " this training set."}, {"start": 613.48, "end": 617.64, "text": " In the next video, let's look at what it'll take to take this training set that you just"}, {"start": 617.64, "end": 624.1999999999999, "text": " saw and feed it to a learning algorithm so that the algorithm can learn from this data."}, {"start": 624.2, "end": 626.6, "text": " We'll see that in the next video."}]