Strengths, Weaknesses, and Use
A dependable first classifier
Logistic regression trains quickly, produces probability scores, handles many sparse one-hot features well, and offers relatively direct explanations. It is often the first serious classifier to try for tabular data and text represented as sparse counts.
Its main limitation is a linear decision boundary. Curved relationships and complex feature interactions need explicit features or a different model. Outliers and badly scaled inputs can destabilize fitting, and severe class imbalance requires suitable metrics, thresholds, or class weighting rather than accuracy alone.
balanced = LogisticRegression(class_weight='balanced', max_iter=1000)
balanced.fit(X_train, y_train)
class_weight='balanced' makes mistakes on rare classes count more during training. It does not create new rare examples or guarantee calibrated probabilities, so evaluate it against the real metric and decision threshold.
Tip: Reach for logistic regression when explanation, speed, and a strong baseline matter. Prefer trees or boosted ensembles when thresholds and interactions dominate, while keeping logistic performance as a reality check.
Warning: A probability-producing method is not automatically calibrated. Measure predicted-versus-observed rates before communicating the score as literal risk.