Linear Regression
1. What is Linear Regression:
Linear Regression is like drawing the best straight line through a bunch of points on a graph.
Imagine we’re trying to predict something (like our exam score) based on a related factor (like hours we studied). If we plot those values, they may not form a perfect line — but they may form a pattern. Linear regression finds the best-fitting straight line that explains the relationship between them.
This line helps us make predictions: “If I studied 6 hours, what score might I expect?”
2. Formula:
The equation for the line is: y = mx+c
Where:
- y = predicted value
- x = input value (independent variable)
- m = slope (how much y changes when x increases)
- c = intercept (where the line crosses the y-axis)
3. Real-World Examples:
A. House Price Prediction
- Goal: Predict the price of a house based on its size (square feet).
- Use: Real estate companies use linear regression to set prices for new listings.
Price=m×Size+c
B. Salary Estimation
- Goal: Predict someone’s salary based on their years of experience.
- Use: HR departments use this to forecast pay and hiring budgets.
Salary=m×Experience+c
4. What is Multivariate Linear Regression?
We predict a value using two or more input variables:
y=m1⋅x1+m2⋅x2+⋯+mn⋅xn+c
It’s like extending a 2D line into a multi-dimensional plane or surface.
5. Real-Life Example:
Predict House Price based on:
- size in square feet
- number of bedrooms
We’ll try to predict house_price.
Linear Regression – Linear Regression & Multivariate Linear Regression example with Simple Python Learning