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.
A regression model finds the relationship between variables.
π Example
Predict house price based on:
Here:
We use regression to: β Predict values β Understand relationships β Analyze trends
π Common predictions
| Study Hours | Marks |
|---|---|
| 1 | 35 |
| 2 | 45 |
| 3 | 55 |
| 4 | 65 |
| 5 | 75 |
π The model learns:
βAs study hours increase, marks increase.β
Most basic and commonly used.
Formula:
y = mx + b
x β inputy β outputm β slopeb β interceptπ Example:
Marks = 10 Γ StudyHours + 25
Uses more than one input
π Example:
Salary = Experience + Education + Skills
Used when data is curved, not straight.
π Example:
Used for Yes/No outcomes (classification).
π Example:
β Although named βregressionβ, itβs used for classification.
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]]))
β Measure height vs weight β Predict electricity bill from units β Predict sales from advertising cost β Predict marks from attendance
β Regression predicts numbers β Shows relationship between variables β Linear regression draws a best-fit line β Widely used in ML, data science, economics