Learn with Yasir

Share Your Feedback

Regression model


regression model

A regression model is a machine learning / statistical model used to predict a continuous numerical value based on one or more input variables.


1️⃣ What is a Regression Model?

A regression model finds the relationship between variables.

πŸ“Œ Example

  • Predict house price based on:

    • size (sq ft)
    • number of rooms
    • location

Here:

  • Input (X) β†’ size, rooms, location
  • Output (Y) β†’ price (a number)

2️⃣ Why Do We Use Regression?

We use regression to: βœ” Predict values βœ” Understand relationships βœ” Analyze trends

πŸ“Œ Common predictions

  • Student marks
  • Salary
  • Sales
  • Temperature
  • House prices

3️⃣ Simple Example (Classroom Friendly)

Predict marks based on study hours

Study Hours Marks
1 35
2 45
3 55
4 65
5 75

πŸ“ˆ The model learns:

β€œAs study hours increase, marks increase.”


4️⃣ Types of Regression Models

πŸ”Ή 1. Linear Regression

Most basic and commonly used.

Formula:

y = mx + b
  • x β†’ input
  • y β†’ output
  • m β†’ slope
  • b β†’ intercept

πŸ“Œ Example:

Marks = 10 Γ— StudyHours + 25

πŸ”Ή 2. Multiple Linear Regression

Uses more than one input

πŸ“Œ Example:

Salary = Experience + Education + Skills

πŸ”Ή 3. Polynomial Regression

Used when data is curved, not straight.

πŸ“Œ Example:

  • Speed vs fuel consumption

πŸ”Ή 4. Logistic Regression (Special Case)

Used for Yes/No outcomes (classification).

πŸ“Œ Example:

  • Pass / Fail
  • Spam / Not Spam

⚠ Although named β€œregression”, it’s used for classification.


5️⃣ Python Example

from sklearn.linear_model import LinearRegression

# Input data (study hours)
X = [[1], [2], [3], [4], [5]]
y = [35, 45, 55, 65, 75]

model = LinearRegression()
model.fit(X, y)

# Predict marks for 6 hours
print(model.predict([[6]]))

6️⃣ Real-Life Activities for Students πŸ‘¨β€πŸ«

βœ” Measure height vs weight βœ” Predict electricity bill from units βœ” Predict sales from advertising cost βœ” Predict marks from attendance


7️⃣ Key Points to Remember

βœ… Regression predicts numbers βœ… Shows relationship between variables βœ… Linear regression draws a best-fit line βœ… Widely used in ML, data science, economics