Day 3 of 100 Days of Machine Learning: Linear regression

Linear Regression model:

Saurabh singh
3 min readMar 20, 2024

Linear regression fits a straight line into your dataset. For example, let’s say we have house price dataset where we have information about the size of various houses and their selling price.

Based on this information we would like to find out how much a house with a size of 1250 square feet will be sold for?

In this case, a linear regression model will fit a straight line in the dataset and predict the house price.

Regression model predicts numbers. Linear regression is one example of a regression model.

To train a regression model so that it can learn to predict outputs, we use a training dataset.

Terminology:

In a training dataset the input variable feature is denoted as X, output/target variable is denoted as y and total number of training examples is donated by m.

A single training example would be denoted as (X, y) and ith training example would be denoted as (X^i, y^i).

A training set consists of training features such as size of the house denoted by X and output feature/target variable such as price of the house denoted by y. This training data set is used to train the learning algorithm so that the model can predict values for y based on new input values for X. The supervised learning algorithm will then produce a function denoted with f.

Function f takes an input X and gives an output y-hat which is known as estimate or prediction of y in machine learning convention. The function f is called a model, X is called an input and y-hat is called the prediction.

y refers to the target values while y-hat refers to the estimate value or predicted value of y.

f is a straight line through the data that is provided to the Linear regression model, and can be represented with a math formula mentioned in the image below:

The function f represented in the image above produces a straight line through the visually represented data in the image above.

Since, we are only using one input variable X, this function can be more clearly defined as Linear regression with one variable.

--

--

Saurabh singh

I write to help you get healthier, happier & to get ahead in your career