linear regression machine learning

Linear regression machine learning establishes a relationship between two variable, is the way to find the changes dependent variable with respect to the explanatory variable. The dependent variable is a variable whose value we want to forecast. linear regression predicts well if data is linearly separated. It will use to predict the unobserved value.

Linear regression machine learning is a line of best fit which tries to cover independent values of data point and provide an optimal model for seen and unseen data.

Look my Article for Linear Regression Application

Type of Machine Learning Regression models:

  1. Simple Linear Regression
  2. Multiple Linear Regression
  3. Polynomial Regression

In this article, we cover Simple linear regression who has one dependent variable X and one independent variable Y.

A simple regression is basically the formula of slop line formula.

Simple linear formula

M is a Coefficient of an independent variable and the slop of the line.

C is the y-intercept of the line.

And you might recognize this formula from back in high school or college it’s just a formal of slop line on X and Y axis.


Mathematically we can represent above formula in simple linear relationship Statistics.

Simple linear formula

b1 is representing as M and b0 represent as C.

Y is dependent variable the dependent variable something you’re trying to explain for instance Suppose how does a person’s salary change with respect to years of experience that he has. So here salary is dependent variable and something that you’re trying to understand how it depends on something else is your dependent variable and X is your independent variable which causing a dependent variable to change


It’s very straightforward you can visualize it easily.

Let’s look at that above example where we have experience and salary.

So experience is going to be our horizontal axis X- axis.

linear regression machine learning


Salary is all vertical axis  Y – axis and we want to understand how people’s salary depends on their experience

So as per the graph, we can convert simple regression formula according to our X and Y data points.

Simple linear formula

Based on the value we can get best-fit regression line which tries to cover all the data points because it’s difficult to draw a line which fit all the data point. So, based on above graph b0 is the point which intersects X and Y axis at the same time.  So, if b0 = 0 which mean the experience is zero and b1 point indicate the point at Y axis where a person with zero experience salary would be 30K.

linear regression machine learning

So according to our data point, we can see a person who has 1 more year of experience is eligible for extra $1000, So the salary hike depends on the slop if slop is a high person may get more then $1000 salary or if slop is less salary increment ratio will effect accordingly

So to draw the line regression model try to plot lots of lines and find which one is the best fit line according to the given data points. It will find the best fit line by calculating the distance between the actual value and the model predicted value. And that line will be the best fitting line and that is called the ordinary least squares method.

Linear Regression Formula :-

Simple linear formula

Linear regression Cost Function :-

Simple linear formula

Linear regression gradient descent :-

Simple linear formula

WrapingUP: A Simple Linear regression machine learning will use if you have one independent variable and want to predict dependent variable values.

You May Also Like