What is Linear Regression?

General July 31, 2019
About linear regression

What is Linear Regression?

In this topic we actually learn how do we make Machines learn from data and what particular Mathematics is used behind that and how to the particular algorithm is built.

Linear Regression is a part of Supervised Learning Technique which is first most basic part of Machine Learning. So, Linear Regression can be called as first most Machine Learning algorithm.

Linear Regression


Linear Regression is a Supervised Learning Algorithm that learns from a set of training samples. It estimates the relationship between a dependent variable (target/label) and one or more independent variable (predictors).

Linear Regression

Regression Equation:

y = mx + c


Y is Output variable,

X is Input variable

m and c are the parameters

Machine Learning Certification Training

Types of Linear Regression:

There are three types of Linear Regression. They are:

  1. Univariate Linear Regression
  2. Multivariate Linear Regression
  3. Polynomial Linear Regression

Linear Regression Type

So, clearly from the equation we can make out that the Regression equation depends on the values of m and c. Let’s see that in the below examples.

Linear Regression Equations

is the predicted value

When m=0 and c=40; Line is parallel to the X-axis.

When m=0.8 and c=0; Line passes across center.

When m=0.8 and c>0; Line is shifted above the x-axis for the value equal to c.

Error function:

e =  – y

Where is Predicted value and

Y is Actual value.

Error depends on the values of m and c.

Linear Regression Error Functions

Our aim here is to build an algorithm which can minimize the error of the problem.

Machine Learning Interview Questions and Answers

Cost function:

For that we use the cost function of Linear Regression. Which is,

Linear Regression Cost Functions

Here goal is to minimize the cost function J by changing m and c. This is called optimization and in order to perform this we need particular optimizers. The most important optimizer we use here in Linear Regression among all is Gradient Descent Algorithm.

Gradient Descent Algorithm


w is the parameter(m or c) and

lr is the Learning rate

What is Learning Rate?

Learning Rate is the value which the developer (person building the model) gives which decides how fast the algorithm learns from data.

Learning Rate should range between 0 to 1.

Simple Python code for Linear Regression:

# Importing Libraries
import numpy
import matplotlibas plt
Import pandas
# Importing data set
dataset=pandas.read_csv(‘salary_data.csv’) X=dataset.iloc[:,:-1].values Y=dataset.iloc[:,1].values
# Train Test Spilt
from sklearn.model_selectionimport train_test_split
# Linear Regression method
from sklearnimport linear_model
alg= linear_model.LinearRegression(),ytrain)
# Predicting the test results

Machine Learning Batch Shedule

Besant Technologies – Chennai & Bangalore Branch Locations

Besant Technologies - Velachery Branch

Plot No. 119, No.8, 11th Main road, Vijaya nagar,

Velachery, Chennai - 600 042

Tamil Nadu, India

Landmark - Reliance Digital Opposite Street

  +91-8099 770 770

Besant Technologies - Tambaram Branch

No.2A, 1st Floor, Duraisami Reddy Street,

West Tambaram, Chennai - 600 045

Tamil Nadu, India

Landmark - Near By Passport Seva

  +91-8099 770 770

Besant Technologies - OMR Branch

No. 5/318, 2nd Floor, Sri Sowdeswari Nagar,

OMR, Okkiyam Thoraipakkam, Chennai - 600 097

Tamil Nadu, India

Landmark - Behind Okkiyampet Bus Stop,

  +91-8099 770 770

Besant Technologies - Porur Branch

No. 180/84, 1st Floor, Karnataka Bank Building,

Trunk Road, Porur, Chennai - 600 116

Tamil Nadu, India

Landmark - Opposite to Gopalakrishna Theatre

  +91-8099 770 770

Besant Technologies - Anna Nagar Branch

Plot No:1371, 28th street kambar colony,

I Block, Anna Nagar, Chennai - 600 040

Tamil Nadu, India

Landmark - Behind Reliance Fresh

  +91-8099 770 770

Besant Technologies - T.Nagar Branch

Old No:146/2- New No: 48,

Habibullah Road,T.Nagar, Chennai - 600 017

Tamil Nadu, India

Landmark - Opposite to SGS Sabha

  +91-8099 770 770

Besant Technologies - Thiruvanmiyur Branch

22/67, 1st Floor, North mada street, Kamaraj Nagar

Thiruvanmiyur, Chennai 600041

Tamil Nadu, India

Landmark - Above Thiruvanmiyur ICICI Bank

  +91-8099 770 770

Besant Technologies - Siruseri Branch

No. 4/76, Ambedkar Street, OMR Road, Egatoor, Navallur,

Siruseri, Chennai 600130

Tamil Nadu, India

Landmark - Near Navallur Toll Gate, Next to Yamaha Showroom

  +91-8099 770 770

Besant Technologies - Maraimalai Nagar Branch

No.37, Ground Floor, Thiruvalluvar Salai,

Maraimalai Nagar,Chennai 603209

Tamil Nadu, India

Landmark - Near to Maraimalai Nagar Arch

  +91-8099 770 770

Besant Technologies - BTM Layout Branch

No 2, Ground floor, 29th Main Road,

Kuvempu Nagar,BTM Layout 2nd Coming from Silkboard,

AXA company signal, Stage, Bangalore - 560 076

Karnataka, India

Landmark - Next to OI Play School

  +91-8767 260 270

Besant Technologies - Marathahalli Branch

No. 43/2, 2nd Floor, VMR Arcade,

Varthur Main Road, Silver Springs Layout,

Munnekollal, Marathahalli, Bengaluru - 560037

Karnataka, India

Landmark - Near Kundalahalli Gate Signal

  +91-8767 260 270

Besant Technologies - Rajaji Nagar Branch

No. 309/43, JRS Ecstasy, First Floor,

59th Cross, 3rd Block, Bashyam Circle,

Rajaji Nagar, Bangalore - 560 010

Karnataka, India

Landmark - Near Bashyam Circle

  +91-8767 260 270

Besant Technologies - Jaya Nagar Branch

No. 2nd Floor,1575,11th Main Road,

4th T-Block, Pattabhirama Nagar,

Jaya Nagar, Bangalore - 560 041

Karnataka, India

Landmark - Opposite to Shanthi Nursing Home

  +91-8767 260 270

Besant Technologies - Kalyan Nagar Branch

No.513, 4th Cross Rd

2nd Block, HRBR Layout,

Kalyan Nagar, Bangalore - 560 043

Karnataka, India

Landmark - Opposite to kalayan nagar Axis Bank

  +91-8767 260 270

Besant Technologies - Electronic City Branch

No. 7, 3rd Floor, Ganga Enclave,

Neeladri Road, Karuna Nagar, Doddathoguru Village,

Electronics City Phase 1, Electronic City,

Bangalore - 560100, karnataka, India

Landmark - Adjacent to HDFC Bank and State Bank Of India

  +91-8767 260 270

Besant Technologies - Indira Nagar Branch

No.54, 1st Floor,

5th Main kodihalli,

Bengaluru, Karnataka 560008, India

Landmark - Behind Leela Palace Hotel,

  +91-8767 260 270

Besant Technologies - HSR Layout Branch

Plot No. 2799 & 2800, 27th Main,

1st Sector, HSR Layout,

Bengaluru, Karnataka 560102, India

  +91-8767 260 270

Besant Technologies - Hebbal Branch

No.29, 2nd Floor, SN Complex,

14th Main Road, E-Block Extention, Sahakara Nagar,

Bengaluru, Karnataka -560092, India

  +91-8767 260 270

Scroll Up