Linear Regression is defined as an algorithm that provides a linear relationship between an independent variable and a dependent variable to predict the outcome of future events. It’s a basic algorithm of supervised learning.
For example, from the price dataset of more than 4000 houses, we will build a model to predict the house price that based on 3 attributes: bedrooms, bathrooms & floors. The input values are defined as a column vector:
So we have the output model that depends on the input values:
Our expectation is that the prediction error
We have to use the square of
1. Loss function
When we have
In machine learning, the loss function is the average of the error at each point that why we have the
2. Solution
The next step, we need to find the solution for that loss function by solving the derivative equation.
We have this transformation by using the equation
From (2.1) we have
You can read this post to understand about (2.2)
– If
– If
Where
In fact, solving derivative equations is an expensive calculation. So we need to use another way (Gradient Descent) to find the minimum of a function. It should be cheaper (faster) to find the solution using the gradient descent.
