Data Science ยท Chapter 30 of 43
Logistic Regression
LOGISTIC REGRESSION is a CLASSIFICATION model that outputs a probability 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 per class.
Example 2 (python)
print(m.predict(X_test[:1]))Output
[1]Predicted label.
Key points
- Classification, not regression.
- Outputs probabilities via sigmoid.
- Great baseline for binary tasks.
- Coefficients are interpretable (log-odds).
๐ก Note: For multi-class, scikit-learn uses one-vs-rest automatically โ no code change needed.
