1.10 Machine Learning Overview | Linear regression model part 2 --[Machine Learning | Andrew Ng]
 Let's look in this video at the process of how supervised learning works. Supervised learning algorithm will input a data set and then what exactly does it do and what does it output? Let's find out in this video. Recall that a training set in supervised learning includes both the input features, such as the size of the hulls, and also the output targets, such as the price of the hulls. The output targets are the right answers that the model will learn from. To train the model, you feed the training set, both the input features and the output targets, to your learning algorithm. Then your supervised learning algorithm will produce some function. We'll write this function as lowercase f, where f stands for function. Historically, this function used to be called a hypothesis, but I'm just going to call it a function f in this class. The job of f is to take a new input x and output an estimate or prediction, which I'm going to call y hat, and it's written like the variable y with this little hat symbol on top. In machine learning, the convention is that y hat is the estimate or the prediction for y. The function f is called the model. X is called the input or the input feature, and the output of the model is the prediction y hat. The model's prediction is the estimated value of y. When the symbol is just a letter y, then that refers to the target, which is the actual true value in the training set. In contrast, y hat is an estimate. It may or may not be the actual true value. Well, if you're helping your client to sell their hulls, well, the true price of the hulls is unknown until they sell it. So your model f, given the size, outputs a price which is the estimated, that is the prediction of what the true price will be. Now, when we design a learning algorithm, a key question is, how are we going to represent the function f? Or in other words, what is the math formula we're going to use to compute f? For now, let's stick with f being a straight line. So your function can be written as f subscript w comma b of x equals, I'm going to use w times x plus b. I'll define w and b soon, but for now, just know that w and b are numbers, and the values chosen for w and b will determine the prediction y hat based on the input feature x. So this f w b of x means f is a function that takes x's input, and depending on the values of w and b, f will output some value of a prediction y hat. As an alternative to writing this f w comma b of x, I'll sometimes just write f of x without explicitly including w and b in the subscript. It's just a simple notation, but means exactly the same thing as f w b of x. Let's plot the training set on the graph where the input feature x is on the horizontal axis, and the output target y is on the vertical axis. Remember, the algorithm learns from this data and generates a best fit line like maybe this one here. This straight line is the linear function f w b of x equals w times x plus b. Or more simply, we can drop w and b and just write f of x equals w x plus b. Here's what this function is doing, it's making predictions for the value of y using a straight line function of x. So you may ask, why are we choosing a linear function where linear function is just a fancy term for a straight line, instead of some nonlinear function like a curve or a parabola? Well, sometimes you want to fit more complex nonlinear functions as well, like a curve like this, but since this linear function is relatively simple and easy to work with, let's use a line as a foundation that will eventually help you to get to more complex models that are nonlinear. This particular model has a name, it's called linear regression. More specifically, this is linear regression with one variable, where the phrase one variable means that there's a single input variable or feature x, namely the size of the house. Another name for a linear model with one input variable is univariate linear regression, where uni means one in Latin and where variate means variable. So univariate is just a fancy way of saying one variable. In a later video, you'll also see a variation of regression where you want to make a prediction based not just on the size of a house, but on a bunch of other things that you may know about the house, such as number of bedrooms and other features. And by the way, when you're done with this video, there is another optional lab. You don't need to write any code, just review it, run the code and see what it does. That will show you how to define in Python a straight line function. And the lab will let you choose the values of W and B to try to fit the training data. You don't have to do the lab if you don't want to, but I hope you play of it when you're done watching this video. So that's linear regression. In order for you to make this work, one of the most important things you have to do is construct a cost function. The idea of a cost function is one of the most universal and important ideas in machine learning and is used in both linear regression and in training many of the most advanced AI models in the world. So let's go on to the next video and take a look at how you can construct a cost function.
[{"start": 0.0, "end": 7.38, "text": " Let's look in this video at the process of how supervised learning works."}, {"start": 7.38, "end": 11.3, "text": " Supervised learning algorithm will input a data set and then what exactly does it do"}, {"start": 11.3, "end": 12.84, "text": " and what does it output?"}, {"start": 12.84, "end": 15.68, "text": " Let's find out in this video."}, {"start": 15.68, "end": 21.0, "text": " Recall that a training set in supervised learning includes both the input features, such as"}, {"start": 21.0, "end": 26.16, "text": " the size of the hulls, and also the output targets, such as the price of the hulls."}, {"start": 26.16, "end": 31.08, "text": " The output targets are the right answers that the model will learn from."}, {"start": 31.08, "end": 35.8, "text": " To train the model, you feed the training set, both the input features and the output"}, {"start": 35.8, "end": 40.24, "text": " targets, to your learning algorithm."}, {"start": 40.24, "end": 45.28, "text": " Then your supervised learning algorithm will produce some function."}, {"start": 45.28, "end": 50.08, "text": " We'll write this function as lowercase f, where f stands for function."}, {"start": 50.08, "end": 55.6, "text": " Historically, this function used to be called a hypothesis, but I'm just going to call"}, {"start": 55.6, "end": 58.800000000000004, "text": " it a function f in this class."}, {"start": 58.800000000000004, "end": 69.36, "text": " The job of f is to take a new input x and output an estimate or prediction, which I'm"}, {"start": 69.36, "end": 76.44, "text": " going to call y hat, and it's written like the variable y with this little hat symbol"}, {"start": 76.44, "end": 78.52000000000001, "text": " on top."}, {"start": 78.52, "end": 85.84, "text": " In machine learning, the convention is that y hat is the estimate or the prediction for"}, {"start": 85.84, "end": 88.0, "text": " y."}, {"start": 88.0, "end": 92.0, "text": " The function f is called the model."}, {"start": 92.0, "end": 99.12, "text": " X is called the input or the input feature, and the output of the model is the prediction"}, {"start": 99.12, "end": 101.12, "text": " y hat."}, {"start": 101.12, "end": 105.88, "text": " The model's prediction is the estimated value of y."}, {"start": 105.88, "end": 112.6, "text": " When the symbol is just a letter y, then that refers to the target, which is the actual"}, {"start": 112.6, "end": 115.75999999999999, "text": " true value in the training set."}, {"start": 115.75999999999999, "end": 118.56, "text": " In contrast, y hat is an estimate."}, {"start": 118.56, "end": 120.96, "text": " It may or may not be the actual true value."}, {"start": 120.96, "end": 126.6, "text": " Well, if you're helping your client to sell their hulls, well, the true price of the hulls"}, {"start": 126.6, "end": 129.2, "text": " is unknown until they sell it."}, {"start": 129.2, "end": 135.2, "text": " So your model f, given the size, outputs a price which is the estimated, that is the"}, {"start": 135.2, "end": 138.79999999999998, "text": " prediction of what the true price will be."}, {"start": 138.79999999999998, "end": 146.67999999999998, "text": " Now, when we design a learning algorithm, a key question is, how are we going to represent"}, {"start": 146.67999999999998, "end": 148.44, "text": " the function f?"}, {"start": 148.44, "end": 155.56, "text": " Or in other words, what is the math formula we're going to use to compute f?"}, {"start": 155.56, "end": 159.82, "text": " For now, let's stick with f being a straight line."}, {"start": 159.82, "end": 168.88, "text": " So your function can be written as f subscript w comma b of x equals, I'm going to use w"}, {"start": 168.88, "end": 172.35999999999999, "text": " times x plus b."}, {"start": 172.35999999999999, "end": 179.92, "text": " I'll define w and b soon, but for now, just know that w and b are numbers, and the values"}, {"start": 179.92, "end": 188.44, "text": " chosen for w and b will determine the prediction y hat based on the input feature x."}, {"start": 188.44, "end": 196.92, "text": " So this f w b of x means f is a function that takes x's input, and depending on the values"}, {"start": 196.92, "end": 204.26, "text": " of w and b, f will output some value of a prediction y hat."}, {"start": 204.26, "end": 212.4, "text": " As an alternative to writing this f w comma b of x, I'll sometimes just write f of x without"}, {"start": 212.4, "end": 215.68, "text": " explicitly including w and b in the subscript."}, {"start": 215.68, "end": 223.24, "text": " It's just a simple notation, but means exactly the same thing as f w b of x."}, {"start": 223.24, "end": 229.32, "text": " Let's plot the training set on the graph where the input feature x is on the horizontal axis,"}, {"start": 229.32, "end": 233.84, "text": " and the output target y is on the vertical axis."}, {"start": 233.84, "end": 240.84, "text": " Remember, the algorithm learns from this data and generates a best fit line like maybe this"}, {"start": 240.84, "end": 242.54000000000002, "text": " one here."}, {"start": 242.54, "end": 252.16, "text": " This straight line is the linear function f w b of x equals w times x plus b."}, {"start": 252.16, "end": 260.84, "text": " Or more simply, we can drop w and b and just write f of x equals w x plus b."}, {"start": 260.84, "end": 266.76, "text": " Here's what this function is doing, it's making predictions for the value of y using a straight"}, {"start": 266.76, "end": 268.68, "text": " line function of x."}, {"start": 268.68, "end": 274.54, "text": " So you may ask, why are we choosing a linear function where linear function is just a fancy"}, {"start": 274.54, "end": 280.84000000000003, "text": " term for a straight line, instead of some nonlinear function like a curve or a parabola?"}, {"start": 280.84000000000003, "end": 286.52, "text": " Well, sometimes you want to fit more complex nonlinear functions as well, like a curve"}, {"start": 286.52, "end": 292.16, "text": " like this, but since this linear function is relatively simple and easy to work with,"}, {"start": 292.16, "end": 297.18, "text": " let's use a line as a foundation that will eventually help you to get to more complex"}, {"start": 297.18, "end": 300.44, "text": " models that are nonlinear."}, {"start": 300.44, "end": 304.76, "text": " This particular model has a name, it's called linear regression."}, {"start": 304.76, "end": 310.72, "text": " More specifically, this is linear regression with one variable, where the phrase one variable"}, {"start": 310.72, "end": 317.72, "text": " means that there's a single input variable or feature x, namely the size of the house."}, {"start": 317.72, "end": 324.16, "text": " Another name for a linear model with one input variable is univariate linear regression,"}, {"start": 324.16, "end": 329.8, "text": " where uni means one in Latin and where variate means variable."}, {"start": 329.8, "end": 334.8, "text": " So univariate is just a fancy way of saying one variable."}, {"start": 334.8, "end": 340.56, "text": " In a later video, you'll also see a variation of regression where you want to make a prediction"}, {"start": 340.56, "end": 345.52000000000004, "text": " based not just on the size of a house, but on a bunch of other things that you may know"}, {"start": 345.52000000000004, "end": 349.20000000000005, "text": " about the house, such as number of bedrooms and other features."}, {"start": 349.20000000000005, "end": 353.92, "text": " And by the way, when you're done with this video, there is another optional lab."}, {"start": 353.92, "end": 358.92, "text": " You don't need to write any code, just review it, run the code and see what it does."}, {"start": 358.92, "end": 363.6, "text": " That will show you how to define in Python a straight line function."}, {"start": 363.6, "end": 370.56, "text": " And the lab will let you choose the values of W and B to try to fit the training data."}, {"start": 370.56, "end": 374.52000000000004, "text": " You don't have to do the lab if you don't want to, but I hope you play of it when you're"}, {"start": 374.52000000000004, "end": 377.20000000000005, "text": " done watching this video."}, {"start": 377.20000000000005, "end": 379.34000000000003, "text": " So that's linear regression."}, {"start": 379.34000000000003, "end": 382.96000000000004, "text": " In order for you to make this work, one of the most important things you have to do is"}, {"start": 382.96, "end": 385.47999999999996, "text": " construct a cost function."}, {"start": 385.47999999999996, "end": 390.28, "text": " The idea of a cost function is one of the most universal and important ideas in machine"}, {"start": 390.28, "end": 395.91999999999996, "text": " learning and is used in both linear regression and in training many of the most advanced"}, {"start": 395.91999999999996, "end": 397.79999999999995, "text": " AI models in the world."}, {"start": 397.8, "end": 414.6, "text": " So let's go on to the next video and take a look at how you can construct a cost function."}]