ML-Linear Regression
Univariate Linear Regression -Andrew Ng
Introduction
What is Linear Regression? Linear Regression is a model that finds the most explanatory Regression Coefficient of the assumed linear relation between the real number input variable X and the continuous variable Y.
Get Jaehoon Jang’s stories in your inbox
Join Medium for free to get updates from this writer.
To keep it simple, it’s about finding the most representative line between the dots in the graph.
Hypothesis function
The red line is not just a line on the grid, but a function. It’s a linear function, so it can be represented as this:
In this case, there is only one variable x. Like this, linear regression using only one feature is called a univariate linear regression.
Cost function
In our hypothesis function, graphs differ according to the values of the thetas. These thetas are called “parameter”s. So, how can we find the right parameters for our hypothesis function?
The red lines in the picture above represents the distance of the dots and the line. This is the “Cost” of our hypothesis function. The cost function is as follows:
The error here can be positive or negative, so we can use squared values. You might wonder, why do we divide it in to 2m? Shouldn’t it be just m? It’s because this makes it easy to calculate.
So, the goal here is to minimize the cost to make the line as representative as possible.










