Classification Algorithms in Supervised Learning
Classification is a type of supervised learning where the output is a category or class, not a
number.
Example:
You want to predict whether an email is spam or not spam:
Input: Email content (words, sender, etc.)
Output: Class label → Spam (1) or Not Spam (0)
How Classification Works
1. Training Phase:
o You give the algorithm a dataset with inputs and correct labels.
o It learns patterns that link inputs to outputs.
2. Prediction Phase:
o You give it new input data.
o It predicts the class label based on what it learned.
Logistic Regression Classification Algorithm
Logistic Regression is a classification algorithm used to predict a binary outcome (1/0,
True/False, Yes/No) based on one or more independent variables.
Unlike Linear Regression, which outputs continuous values, Logistic Regression
outputs probabilities mapped to [0, 1] using a sigmoid (logistic) function.
Logistic Function (Sigmoid)
Example: We want to predict whether a student will pass (1) or fail (0) based on the number of
hours studied.
Step 1: The Logistic Function (Sigmoid Function)
The sigmoid function is:
Step 2: Assume Simple Weights
Step 3: Calculate Probability for Some Inputs
Example 1: Student studies for 2 hours
Student studies for 4 hours
z=4−4=0
Student studies for 6 hours
z=6−4=2
Final Decision Rule:
P>0.5 → Predict Pass (1)
P<0.5 → Predict Fail (0)
Summary Table
Hours Studied Probability (P) Prediction
2 11.9% Fail (0)
4 50% Borderline
6 88% Pass (1)