# Linear Regression

### Linear Regression

Before starting with linear regression, let us try to understand the machine learning concepts.

As of today, machine learning is one of the trending technologies as the applications are started to consume real-time data and deliver machine learning services.

As part of machine learning, we have three different types of machine learning models available.

1. Supervised Learning
2. Unsupervised Learning
3. Reinforcement learning

In Supervised Learning, the system tries to learn from the previous examples that are given.

Under supervised learning, we have classification and regression models.

One of the common and simple techniques for predicting a continuous variable is called linear regression.

It assumes a linear relationship between the outcome and the predictor variables.

The linear regression equation can be written as y = b0 + b*x + e, where:

1. b0 is the intercept,
2. b is the regression weight or coefficient associated with the predictor variable x.
3. e is the residual error

This post covers the linear regression on excel and R studio.

Linear Regression on Excel

Follow the below steps to perform the linear regression in excel

Step 1: Consider you have year wise sales amount. You are in the situation to predict the sales amount for the year 2011. Step 2: Create a scatter plot like below with Year and Sales Amount Step 3: Right-click on the line and choose trendline. Step 4: Display the equation on the trendline by selecting the checkbox on the Format trendline properties.  Step 5: Predict the value using the generated formula for existing values. Step 6: Predict for the year 2011. As you can see the values are not 100% correct, we need to adjust the con-efficient and reduce the r2 values to get the perfect result.