Linear Regression - Explained easy.

Regression models describe the relationship between variables by fitting a line to the observed data. Linear regression models use a straight line, while logistic and nonlinear regression models use a curved line. Regression allows you to estimate how a dependent variable changes as the independent variable(s) change.

Linear regression attempts to model the relationship between two variables by fitting a linear equation to observed data. One variable is considered to be an explanatory variable, and the other is considered to be a dependent variable.


Dependent Variable – Variable who’s values we want to explain or forecast

Independent or explanatory Variable - Variable that explains the other variable. Values are independent.


Dependent variable can be easily remembered as a child Y who always asks why questions and dependent on parents.

Independent variable can be easily remembered as Ex Boyfriend/Girlfriend X who is independent or doesn't depend or need you.


Lets look at an example to better understand Linear Regression.


A waiter's tip at a nice restaurant is mostly dependent on the amount of the total bill.

So this will be a good example for simple linear regression.


So, imagine the waiter wanted to develop a model to predict what amount of tip to expect for any given bill amount. So, He starts collecting data for say, 10 meals.


He wants to predict the tip which will be the dependent variable Y.

Data for Y - 17,18,10,18,16,18,25,30,12

The tip depends upon the Bill amount , which will be the independent variable X.

Data for X - 168,175,100,180,160,175,250,300,125


It"ll be helpful to include a graph so that we can understand better. We can simply plot the observations on the x and y axis and then include the regression line and regression function:

The formula that was used to calculate the Regression is

Y= mX + b +error term.

I will describe the Math involved in this graph in my next blog in detail.



To Conclude,

Simple linear regression is a regression model that estimates the relationship between one independent variable and one dependent variable using a straight line. Both variables should be quantitative.


Thank you for stopping by !










25 views0 comments

Recent Posts

See All

Headless Browser in Python

What is a headless browser? A headless browser can access any website but unlike normal browsers (which you currently use) nothing will appear on the screen. Everything is done on the backend side inv