Chapter 4: Supervised Learning
🎯 Supervised Learning is a type of machine learning where the model learns from labeled data (i.e., input with known output).
✅ What is Supervised Learning?
-
The algorithm is "supervised" because it learns from training data that includes both the input and the correct output (label).
-
The goal is to predict output for new, unseen inputs.
🔁 Supervised Learning Workflow:
🔹 Types of Supervised Learning
Type | Output | Examples |
---|---|---|
Regression | Continuous value | Predict price, temperature, salary |
Classification | Categorical class | Spam vs. Ham, Yes/No, Cat/Dog |
🔢 1. Regression Algorithms
a. Linear Regression
-
Predicts a continuous output using a straight line:
📌 Example: Predict house price based on area.
b. Polynomial Regression
-
Fits a curve (non-linear data).
-
Useful when data is not linearly separable.
🧭 2. Classification Algorithms
a. Logistic Regression
-
For binary classification (yes/no)
-
Outputs probabilities between 0 and 1
b. Decision Trees
-
Tree-like model for decisions.
-
Easy to visualize.
c. K-Nearest Neighbors (KNN)
-
Classifies a point based on its K nearest neighbors.
d. Support Vector Machines (SVM)
-
Finds the best boundary (hyperplane) that separates classes.
📏 Model Evaluation Metrics
Metric | Used For | Description |
---|---|---|
Accuracy | Classification | % of correct predictions |
Precision | Classification | True Positives / (TP + FP) |
Recall | Classification | True Positives / (TP + FN) |
F1 Score | Classification | Harmonic mean of precision and recall |
MSE / RMSE | Regression | Measures prediction error |
💻 Hands-On Project Ideas
✅ Predict House Prices (Regression)
-
Input: Area, Bedrooms, Location
-
Output: Price
✅ Email Spam Classifier (Classification)
-
Input: Text of email
-
Output: Spam or Not Spam
Example Code (Classification):
📚 Summary of Chapter 4
Concept | Summary |
---|---|
Supervised Learning | Learn from labeled data |
Regression | Predict continuous values |
Classification | Predict categories or classes |
Common Algorithms | Linear, Logistic, KNN, SVM, Decision Trees |
Evaluation Metrics | Accuracy, Precision, Recall, RMSE, F1 Score |
Hands-on | Predict house price, classify spam |
✅ Mini Assignment:
-
Build a Linear Regression model to predict house price using area.
-
Build a Spam Classifier using Logistic Regression and check accuracy.
-
Try tuning the value of K in KNN and observe results.