Machine Learning Β· Chapter 11 of 40

Logistic Regression

LOGISTIC REGRESSION is a CLASSIFICATION algorithm despite the name. It outputs a probability between 0 and 1 using the sigmoid function.

Excellent baseline for binary classification.

Example 1 (python)
from sklearn.linear_model import LogisticRegression
m = LogisticRegression().fit(X_train, y_train)
print(m.predict_proba(X_test[:1]))
Output
[[0.2, 0.8]]

Probabilities for each class.

Example 2 (python)
print(m.predict(X_test[:1]))
Output
[1]

Predicted class label.

Key points

  • Classification, not regression.
  • Outputs probabilities via sigmoid.
  • Great baseline for binary tasks.
  • Fast, interpretable, well-calibrated.
πŸ’‘ Note: Multi-class works via 'one-vs-rest' by default β€” scikit-learn handles it automatically.

πŸ“ Quick Quiz

1. Logistic regression is used for:

2. Output values range from:

3. The activation function used is: