๐ After predicting numbers (Linear Regression), now we predict categories.
๐น 1. What is Logistic Regression?
Logistic Regression is used for classification problems.
๐ Output is NOT a number โ itโs a category.
Examples:
โ Spam or Not Spam
โ Pass or Fail
โ Fraud or Not Fraud
๐ฅ 2. How it Works
Instead of a straight line, it uses a Sigmoid Function:
\sigma(x) = 1 / (1 + eโป)}
๐ Output is always between 0 and 1
๐ This is treated as probability
๐น 3. Decision Boundary
๐ If probability > 0.5 โ Class 1
๐ If probability < 0.5 โ Class 0
๐น 4. Example
๐ Predict if a student passes:
Study Hours Result
2 Fail
5 Pass
๐ Model learns boundary between pass/fail.
๐น 5. Implementation
from sklearn.linear_model import LogisticRegression
# Sample data
X = [[1], [2], [3], [4]]
y = [0, 0, 1, 1]
model = LogisticRegression()
model.fit(X, y)
print(model.predict([[3]]))
๐น 6. Important Terms โญ
โ Classification โ Predict category
โ Probability โ Output (0โ1)
โ Threshold โ Decision boundary
๐น 7. Why Logistic Regression is Important?
โ Used in real-world classification problems
โ Foundation for advanced classification models
โ Easy to understand and implement
๐ฏ Todayโs Goal
โ Understand classification
โ Learn sigmoid function
โ Understand probability output
๐ฌ Tap โค๏ธ for more!