Linear Regression
Linear regression is a regression model to find a linear function or model that expresses relationship between dependent and independent variables. Modeling in the regression means showing various concepts by using mathematical function.
As we see in Image 1 , linear regression equation contains one independent variable , one constant and coefficient(also known as weight) and we are trying to predict dependent variable.
In linear regression equation we cannot ignore error also known as residual which is shown in Image 2. Error also known as loss is the penalty for a bad prediction. This error means difference between actual value and predicted value and we are trying to minimize this error as possible.
As we see in the graph above we have regression line in red and shows us the prediction. We have blue dot as a data and the blue line shows us the error. For example the distance between first blue dot and red line demonstrates us low loss, second blue dot and red line demonstrates us high loss.
You see that the regression line did not start at zero that means bias which is shown in the equation as a intercept.
To minimize these loss we have many mathematical function.
These are the mathematical function we will use when we want to minimize the errors in Image 4.
- Mean squared error is found the sum of square of differences between actual and predicted value divide by value numbers.
- Root mean squared error is found the sum of square of differences between actual and predicted value divide by value numbers and in additon we take square root of this.
Why we take square of the values because we do not want to cancel positive and negative values each other.
3.Mean absolute error is found the sum of differences between actual and predicted value by taking absolute value and divide by value numbers.
We are able to calculate these mathematical function using one of the Python libraries known as Numpy easily also there is a function in sklearn library known as mean_squared_error.
This blog was about linear regression in basic.
Thank you for reading.