linear_regression/overview

Overview of Linear Regression Model

What You Will Learn in This Section
  • A brief introduction to the Linear Regression model

Linear Regression is a supervised learning algorithm where the target (dependent) variable is continuous. It is commonly used for predictions such as house prices prediction, total sales volume prediction etc. To predict house prices , we need certain factors that influence the price, known as features (independent variables), examples include house area, number of rooms, building age etc.

In this discussion, we will focus on Linear Regression with one variable. We will use the number of rooms as the independent variable and house price as the dependent variable. Below is a dataset containing historical house price information.

Table 1: Number of Rooms vs. House Price Data (Dummy Data)
S.N. Number of Rooms House Price (USD)
1 6 17K
2 5 12K
3 7 30K
4 10 35K
Goal of Linear Regression

Given a dataset like Table 1, the Linear Regression algorithm tries to fit a line between the independent variable (number of rooms) and the dependent variable (house price).
The figure below provides a high-level understanding of how Linear Regression works. The green points represent actual data. The x-axis shows the number of rooms, and the y-axis shows the house price. There appears to be a clear linear relationship between the two variables. The goal of the Linear Regression algorithm is to find the best-fitting black line, as shown in the plot.

house_price_for_high_level
What Happens Once You Find the Equation of the Line?

Let's assume we have determined the best-fitting line (we will discuss how to derive this equation in the next section). Below is the equation of the fitted line:
\[ y = 3.5x - 1.25 \] where \( y \) represents the house price, and \( x \) represents the number of rooms.

Now, can we predict the house price if we know the number of rooms? Yes! Simply substitute the value of \( x \) into the equation. For example, for a house with 2 rooms, the predicted price is $5750 USD.

Once you have the equation of the line, you can estimate the house price for any given number of rooms.