# Linear regression (No loitering)

Let’s understand the linear regression without any elaboration and in a short manner, that won’t waste your time rather than it will deliver you just the needed information. That will help you to grasp the linear regression and would also make your way easy to know logistic regression.

## What you will learn

- An overview of the basics.
- Working
- Cost function
- Gradient Descent
- Assumptions
- Implementing in python from scratch
- Metrics in linear regression

## A Quick Helper

Let’s start with becoming familiar with some terminologies and concepts needed to understand the actual algorithm.

- If we split the word linear regression. Here “linear” word, just consider it as a line and regression can be defined as the linear relation between the dependent and independent variable. It can be represented by
*Y=mx+c* - Where Y is the dependent variable, which has to be predicted
**(also known as a response, observation)**. m is the slope i.e the steepness in the line also known as**gradient or a coefficient**. x is the independent variable**(also known as a predictor, exploratory variable)**that is the data, And c is the intercept i.e the starting end that crosses the y-axis. - The linear regression can be further classified as simple linear regression and multiple linear regression. Simple linear regression involves a single variable, whereas multiple linear regression involves multiple variables.
- The relation between the independent and dependent variables is observed using correlation.
- Residual is the error term that is obtained by subtracting the predicted values from the actual values.
- The predictions of linear regression are always continuous.
- If the Y-axis value is constant, then the slope formed will be negative
*( y = -mx + c )**.*

## How it Works.

Taking into consideration the above graph that is plotted using the coordinates *x = {3, 6, 4, 5, 2, 7, 9, 10}, y = {2, 4, 3, 7, 2, 6, 8, 9}*

By calculating the mean of x and y we get mean as **x_mean = 5.75 **&** y_mean = 5.12, **after plotting these mean values we get the below diagram.