Download our e-book of Introduction To Python

Matplotlib - Subplot2grid() FunctionDiscuss Microsoft Cognitive ToolkitMatplotlib - Working with ImagesMatplotlib - PyLab moduleMatplotlib - Working With TextMatplotlib - Setting Ticks and Tick LabelsCNTK - Creating First Neural NetworkMatplotlib - MultiplotsMatplotlib - Quiver PlotPython - Chunks and Chinks View More

How can I write Python code to change a date string from "mm/dd/yy hh: mm" format to "YYYY-MM-DD HH: mm" format? Which sorting technique is used by sort() and sorted() functions of python? How to use Enum in python? Can you please help me with this error? I was just selecting some random columns from the diabetes dataset of sklearn. Decision tree is a classification algo...How can it be applied to load diabetes dataset which has DV continuous Objects in Python are mutable or immutable? How can unclassified data in a dataset be effectively managed when utilizing a decision tree-based classification model in Python? How to leave/exit/deactivate a Python virtualenvironment Join Discussion

Shashank Shanu

3 years ago

- A step by step explanation of the Linear Regression Algorithm.

- What is Regression?

- Types of Regressions

- What is a Linear Regression?

1. Simple Linear Regression/ Univariate Linear Regression

1. The mathematics involved

2. How do we know this is the best fit line?

Hello Folks,

Hope you are well and staying safe at your place. As we all know how this
COVID-19 pandemic came and doesn't want to go from our life.

But as the whole world is fighting to get rid of this pandemic. I thought
why can't I share some things which I know so that many people may get benefits
from it.

So Let's start without wasting much time.

Before directly going deep into the Linear regression algorithm.

Let us first understand

Regression is a statistical technique that shows an algebraic relationship
between two or more variables.

Based on this algebric relationship (rather than a function), one can
estimate the value of a variable, given the values of the other variables.

Usually, correlation is used to check whether there is any relationship
between the two variables. If any relationship found, regression is used to
find the degree of relationships that can be then used for prediction.

Some of the examples are:

- Predict rainfall in cm for month
- Predict stock price for next day

Now as you got an idea about what is regression? Let’s move forward and
see what are the types of regressions?

- Linear regression
- Logistic regression
- Polynomial regression
- Stepwise regression
- Ridge regression
- Lasso regression
- ElasticNet regression

In this article I will explain you
about Linear Regression and later I will try to take you through the other
types of regressions.

Linear
regression performs the task to predict a dependent variable value (y) based on
a given independent variable (x). So, this regression technique finds out a
linear relationship between x (input) and y (output). Hence, the name is Linear
Regression.

In the figure above, X (input) is the work experience and Y (output) is the salary of a person. The regression line is the best fit line for our model.

In the figure above, X (input) is the work experience and Y (output) is the salary of a person. The regression line is the best fit line for our model.

Linear
Regression may further divided into

1. **Simple Linear Regression/ Univariate Linear
regression**

2. ** Multivariate Linear Regression **

When we try to find out a
relationship between a dependent variable (Y) and one independent (X) then it
is known as **Simple Linear Regression/ Univariate
Linear regression.**

The
mathematical equation can be given as:

Where

- Y is the response or the target variable
- x is the independent feature
- β1 is the coefficient of x
- β0 is the intercept

Let us consider Real-time
example

Let’s
suppose we have a dataset which contains information about the relationship between
‘a number of hours studied’ and ‘marks obtained’. Many students have been
observed and their hours of study and grade are recorded. This will be our
training data. The goal is to design a model that can predict marks if given the
number of hours studied. Using the training data, a regression line is obtained
which will give the minimum error. This linear equation is then used for any new
data. That is, if we give the number of hours studied by a student as an input, our
model should predict their mark with minimum error.

Like the Blog, then Share it with your friends and colleagues to make this AI community stronger.

To learn more about nuances of Artificial Intelligence, Python Programming, Deep Learning, Data Science and Machine Learning, visit our insideAIML blog page.

Keep Learning. Keep Growing