Skip to content

Logistic Regression for Classification

For people

Despite its name, logistic regression is a classification method. How it produces probabilities and why it remains a strong baseline.

Editorial team 2 min read

Logistic regression predicts the probability that an example belongs to a class, such as whether a customer will churn.

How It Works

Like linear regression, it computes a weighted sum of features. That sum is passed through the sigmoid (logistic) function, which squeezes any number into the range 0 to 1, giving a probability. A threshold — often 0.5 — turns the probability into a yes/no decision.

Interpreting It

Coefficients describe how each feature shifts the log-odds of the outcome. Exponentiating a coefficient gives an odds ratio: a value of 1.5 means a one-unit increase multiplies the odds by 1.5. This interpretability is a major reason logistic regression is used in regulated settings such as credit scoring.

Multiple Classes

For more than two classes, multinomial logistic regression predicts a probability for each class, and the probabilities sum to one.

Practical Tips

  • Scale numeric features so the optimiser converges and regularisation treats them fairly.
  • Use regularisation (the C parameter in scikit-learn) to avoid overfitting.
  • Choose the decision threshold based on the costs of false positives and false negatives, not by default.
  • Check calibration: do predicted probabilities match observed frequencies?

When to Use It

It is a strong, fast, explainable baseline for classification, and often competitive on well-engineered tabular features.

from sklearn.linear_model import LogisticRegression
clf = LogisticRegression(max_iter=1000).fit(X_train, y_train)
proba = clf.predict_proba(X_test)[:, 1]

More in Machine learning

All Machine learning guides →
Machine learning Guide · 2 min

Linear Regression Explained

The simplest predictive model: how linear regression fits a line through data, how to read its coefficients, and when it breaks down.

Machine learning 2 min read 18 Sep 2026 For people

Machine learning Guide · 2 min

Decision Trees

How decision trees split data with simple questions, why they are easy to explain, and why single trees overfit.

Machine learning 2 min read 16 Sep 2026 For people

Machine learning Guide · 2 min

Random Forests

Why averaging many randomised decision trees produces a robust, accurate model with little tuning.

Machine learning 2 min read 15 Sep 2026 For people

Machine learning Guide · 2 min

Gradient Boosting

How gradient boosting builds trees that correct each other's mistakes, and why it dominates tabular machine learning.

Machine learning 2 min read 14 Sep 2026 For people

Share X LinkedIn Reddit Bluesky Email

Discussion 0

Use @handle to bring somebody in, and #tag to file it.

Nothing here yet. Ask a question, or say how you used it.

Sign in to join the discussion. Sign in