# Easy Linear Regression concept

**Linear Regression model:**

This model is useful to predict the relationship between two variables. The two variables are known as **independent **and **dependent **variable.

**Regression **is a technique to find an equation that describes the best-fitting line for a set of data. When data is plotted on a graph, this model gives us a **straight-line relationship**.

Basically, the core idea is to obtain a line that best fits the data. The best fit line is the one for which total **prediction error **of all data points are **as small as possible**.

**Error **is the distance between the points to the regression line.

Real-time example:

Here, I have taken an example of relationship between **“working hours” **and **“productivity”**.

Below, we can see the dataset which contains

working hours **(independent variable** **plotted on X-axis)** and

productivity **(dependent variable plotted on** **Y-axis)**.

On X-axis, I have plotted the **no. of hours** I spent on working on a project.

On Y-axis, I have plotted the **no. of lines** I wrote for coding.

Data points plotted on Y-axis: 10,25,40,80,95,120,200

Data points plotted on X-axis: 1,1.5,2,2.5,3,3.5,4

The Linear Regression equation is as follows:

**y = a + bx + e**

where

a = intercept

b = slope

e = error

Thanks for reading!