Now we move from “data handling” → “AI prediction” 🚀
🎯 Goal of Day-5
You will:
✅ Understand what ML model is
✅ Build your first prediction model
✅ Predict values using data
🧠 What is Machine Learning Model?
Simple:
Model = Function that learns from data and predicts output
Example:
Input: House size
Output: Price
Model learns relation.
🧠 Linear Regression Concept
It tries to fit a straight line:
Where:
y= output (price / marks)-
x= input (size / age) -
m= slope -
b= intercept
🚀 Part 1 – Install & Import
In Colab:
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.linear_model import LinearRegression
🚀 Part 2 – Create Simple Dataset
data = {
"Hours": [1, 2, 3, 4, 5],
"Marks": [40, 50, 60, 70, 80]
}
df = pd.DataFrame(data)
🚀 Part 3 – Prepare Data
X = df[["Hours"]] # input (must be 2D)
y = df["Marks"] # output
🚀 Part 4 – Train Model
model = LinearRegression()
model.fit(X, y)
👉 Model learned pattern.
🚀 Part 5 – Predict
prediction = model.predict([[6]])
print("Predicted Marks:", prediction)
👉 If student studies 6 hours → predicted marks
🚀 Part 6 – Visualize Model
plt.scatter(df["Hours"], df["Marks"])
plt.plot(df["Hours"], model.predict(X))
plt.xlabel("Hours")
plt.ylabel("Marks")
plt.title("Study Hours vs Marks")
plt.show()
👉 Dots = actual data
👉 Line = model prediction
🎯 Mini Practice (Do This)
Task 1:
Task 2:
Try with your CSV (if possible)
Example:
X = df[["Age"]]
y = df["Marks"]
⚠ Common Mistake
❌ This will fail:
model.predict([6])
Correct:
model.predict([[6]])
(2D input required)
🎯 End of Day-5 Goals
You should now:
✅ Understand ML basics
✅ Train model
✅ Make predictions
✅ Visualize ML output
🔥 Real AI Insight
This simple model is base of:
- House price prediction
- Sales forecasting
- Stock prediction (basic level)
0 Comments
If you have any queries, please let me know. Thanks.