Logistic Regression
Logistic Regression
Despite its name, Logistic Regression is a classification algorithm, not regression. It's the foundation of classification and still widely used today.
From Linear to Logistic
Linear regression outputs any number. But classification needs probabilities (0 to 1).
Loading Python Playground...
The Sigmoid Function
The sigmoid function squashes any number to the range (0, 1) - perfect for probabilities!
Loading Python Playground...
How Logistic Regression Works
Logistic regression = linear combination + sigmoid function
Loading Python Playground...
The Decision Boundary
Loading Python Playground...
Training with Gradient Descent
Loading Python Playground...
Practice: Logistic Regression Prediction
Loading Python Exercise...
Key Takeaways
- Logistic regression is for classification despite its name
- Uses the sigmoid function to output probabilities (0 to 1)
- Creates a linear decision boundary
- Threshold (usually 0.5) converts probability to class label
- Uses gradient descent with cross-entropy loss for training
- In sklearn:
LogisticRegression().fit(X, y).predict(X_new)
Next, we'll learn K-Nearest Neighbors - a completely different approach!
Quiz
Question 1 of 520% Complete
0 of 5 questions answered

