Sitemap
Hariom Gautam

Hariom Gautam

Data Scientist with 10 years’ experience, specializing in Deep Learning, NLP, GenAI, and Computer Vision; postgraduate from IISc Bangalore

Press enter or click to view image in full size

Linear Regression: Basics

3 min readFeb 8, 2020

--

Content

  1. 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)
Press enter or click to view image in full size

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)

Press enter or click to view image in full size

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.

Press enter or click to view image in full size

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.

Press enter or click to view image in full size

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)

Press enter or click to view image in full size
At each iteration the value of m and c is get update
  • alpha is called learning rate. smaller/larger value of alpha affect the equation.
Press enter or click to view image in full size
Press enter or click to view image in full size

Use-cases of Linear Regression:

  1. Linear regression analysis can help a builder to predict how much houses it would sell in the coming months and at what price.
  2. Linear Regression can be used to predict the sale of products in the future based on past buying behaviour.
  3. Linear Regression can be used to predict the economic growth of a country or state.
  4. An organisation can use linear regression to figure out how much they would pay to a new joinee based on the years of experience.

--

--

Hariom Gautam
Hariom Gautam

Data Scientist with 10 years’ experience, specializing in Deep Learning, NLP, GenAI, and Computer Vision; postgraduate from IISc Bangalore