Linear Regression : the basics

In this blog, we will discuss the general outline of linear regression without going into the mathematical implementations of the functions used.
Source: https://www.youtube.com/watch?v=NWONeJKn6kc

Regression is a common problem in Artificial intelligence and machine learning. It is of two types: Linear Regression and Logistic regression

\=> Linear Regression
It is used to predict a continuous numerical value for a given input.
Eg: Stock price, age of a student based on some details, the weight of a person etc.

Suppose, we are given the height of a person and we wish to calculate his/her weight. Then we draw a graph taking weight on Y axis(our output), and height on X axis( our input)

The small circles on the graph are our given data points, i.e. Some given values where weight is mapped to the height.
Now, we draw a line that passes through these data points. This Line is known as the Hypothesis and since we are learning linear regression, our hypothesis will be a straight line.

Hypothesis represents the output and the accuracy of our Model. Its accuracy increases if the Hypothesis passes through more data points. We also have a hypothesis function, which is used to calculate our output.

h(x) = x0w0 + x1w1 + x2w2 ...................... xnwn

here x0,x1........xn are or input features and w0,w1......wn our weights. These weights help in deciding the priority or weightage of each feature. in our question, we are given only one feature -> height of the person.
The first term x0w0 is also known as bias term and is equal to w0, because value of x0 is generally assumed to be one.

Here we are calculating each term individually, but we can also use the vectorized form of hypothesis function in python. In one matrix, we store all the weight values and in another the input features. our Hypothesis function is obtained by getting the dot product of these two vectors.

In Linear regression Our goal is to tune/optimize these weights so that our hypothesis function predicts an accurate value. This is achieved using a cost function, which uses concepts like gradient descent under the hood.
Since these functionalities can be implemented easily using libraries, we won't be going into the mathematical details of these functions.

I hope this blog was helpful to everyone who read it. Any feedback and constructive criticism is highly welcomed.