Linear Regression: Basics
Content
- 1. Introduction to Linear Regression
2. Assumptions in Linear Regression
3. Linear Regression Model
4. Linear Regression with one variable intuition
5. Cost function
6. Learning Parameter
7. Gradient Descent
8. Use-cases of Linear Regression
Introduction to Linear Regression:
- Linear Regression is a supervised learning mechanism that are used to predict the value/score based on some independent variable.
- Linear regression consists of finding the best-fitting straight line through the data points.
- The best fitting line is called Regression line
- In the figure below, our objective is to train a Linear Regression model on data set(in red) and find a regression line(in green)
Assumptions in Linear Regression:
There are mainly 5 assumptions in linear regression:
1. Linearity
2 Multivariate Normality
3. No Multicollinearity
4. No Autocorrelation
5. Homoscedasticity
Linear Regression Model:
The goal of linear regression is to find the best linear function that minimizes SSE(Sum of Squared Errors)
Linear regression is defined by this equation:
y = mx + c
Get Hariom Gautam’s stories in your inbox
Join Medium for free to get updates from this writer.
x — Independent or explanatory or predictor variable.
y — Dependent or target or outcome variable.
c — y intercept.
m — slope of a regression line or coefficient of (independent variable)
Linear Regression with one variable:
Below figure implies the Linear Regression with only one variable.
If x is the independent variable then we will try to find out the value of theta which gives minimum error.
Theta_0 is the intercept.
With the above parameter we want to find out the cost function and our objective is to minimize the cost function.
Graphical intuition:
In the figure below, we describe the house price prediction with the graphs that indicates the relationship between “Size(in square foot) and Price”, Relationship between “theta and J(theta)” means at what value of theta the cost will be minimum.
Gradient Descent and Learning Parameters:
Gradient descent is an algorithm that is used to minimize the function.
We try to find out the optimal value of m(slope) and c(intercept)
- alpha is called learning rate. smaller/larger value of alpha affect the equation.
Use-cases of Linear Regression:
- Linear regression analysis can help a builder to predict how much houses it would sell in the coming months and at what price.
- Linear Regression can be used to predict the sale of products in the future based on past buying behaviour.
- Linear Regression can be used to predict the economic growth of a country or state.
- An organisation can use linear regression to figure out how much they would pay to a new joinee based on the years of experience.









