30 / Predictive analytics
Logistic regression for business probabilities
Logistic regression estimates a probability between zero and one for an event coded 1 versus 0. It is useful for prioritising reviews and planning interventions when the probabilities are validated and calibrated; choosing an action threshold is a separate business decision.
The business question
Can available information estimate the probability of a binary outcome such as a late delivery?
- Estimate delivery-delay or service-failure risk using information available when an order is accepted.
- Model a binary response such as renewal, conversion or cancellation.
- Provide an interpretable probability baseline against which more complex classifiers can be compared.
How the method works
The model first forms a linear score from the predictors, then passes it through the logistic function. This bounds the predicted probability while making the log-odds linear in the included inputs. Coefficients are estimated from labelled observations, usually through likelihood-based optimisation; scikit-learn’s standard implementation also applies regularisation unless configured otherwise.
Exponentiating a coefficient gives an odds ratio for a one-unit predictor change, conditional on the other included variables and the fitted model. Odds are p/(1−p), so an odds ratio is not a risk ratio and not a fixed percentage-point probability change. The same score change has a different probability effect depending on the starting risk.
Prediction quality needs more than classification accuracy. Calibration asks whether events occur at roughly the rates assigned by the model; ranking measures whether higher-risk cases tend to contain more events. Both can change with customer mix, base rates and time. Train and evaluate using appropriate later periods or independent groups, and then choose a threshold based on capacity, intervention cost and the consequences of errors.
The calculation
| Symbol | Meaning |
|---|---|
| p | Fitted probability of the outcome coded 1. |
| b_0 | Fitted intercept on the log-odds scale. |
| b_j | Coefficient per predictor unit on the log-odds scale. |
| x_j | A predictor available at the time the decision is made. |
A worked business example
ILLUSTRATIVE SCENARIO
Illustrative historical service orders use planned lead time known at quotation to estimate eventual late-delivery risk.
Inputs
- Planned lead times: 5,10,15,20,25,30,35,40,45,50 days.
- Matured late outcomes: 0,0,0,0,1,0,1,1,1,1.
- Fit a regularised one-predictor logistic model with C=1.
Work through the numbers
- The teaching fit has intercept approximately −6.9694 and day coefficient approximately 0.2534.
- For 25 planned days, score is about −0.634 and logistic probability is approximately 0.3467.
- For 40 planned days, score is about 3.165 and probability is approximately 0.9596.
- exp(0.2534)≈1.288 is a conditional odds multiplier per planned day in this fit, not a 28.8-percentage-point risk increase.
This ten-order training example provides no credible accuracy or calibration estimate. A real review policy needs substantially more representative mature outcomes, held-out evaluation and a defined intervention; changing promised lead time cannot be assumed to cause the fitted risk change.
Explore the decision
Explore an already-fitted logistic model. The live explorer has its own example inputs; it is separate from the worked calculation above.
Enable JavaScript to use this calculator. The worked example and executable Python remain available.
Apply it at work
- Define the event and observation window, collect mature labels and exclude features learned only after the decision.
- Separate training and evaluation periods or groups, then fit a justified regularised baseline.
- Evaluate calibration, ranking, subgroup performance and the cost of alternative thresholds on held-out data.
- Pilot the resulting decision policy and monitor base rates, drift and realised intervention outcomes.
Check these assumptions
- Outcome labels are consistently defined and sufficiently complete over the same follow-up window.
- Predictors are available before the prediction decision and are measured in consistent units.
- The log-odds functional form and regularisation are adequate for the task; interactions or nonlinear terms may be needed.
- Training and future decision populations are sufficiently comparable, with appropriate handling of dependence and class sampling.
Common mistakes and how to avoid them
- Reading an odds ratio as a probability increase misstates the model.
- Training accuracy and convincing-looking probabilities do not establish calibration on future orders.
- Using outcome-derived features, immature labels or uncorrected sampling changes can make the model unsuitable for deployment.
How this can help the business
- A validated risk ranking can direct limited inspection effort to cases where it may create the most value.
- Calibrated probabilities can support capacity and expected-cost planning instead of rigid high/low labels alone.
Use validated probabilities with a separately costed and capacity-aware action policy. Check whether the intervention improves outcomes rather than assuming that risk prediction itself creates a benefit.
When to use another approach
Consider simpler rules, calibrated tree-based models, survival analysis for time-to-event outcomes, or an intervention experiment to estimate treatment benefit.
Reproduce the worked example in Python
The code is self-contained for this example. Dependencies and run instructions are included with the downloadable notebook.
Show executable code and recorded output
import numpy as np
from sklearn.linear_model import LogisticRegression
days = np.array([5,10,15,20,25,30,35,40,45,50]).reshape(-1,1)
late = np.array([0,0,0,0,1,0,1,1,1,1])
model = LogisticRegression(C=1.0, solver="lbfgs").fit(days, late)
probabilities = model.predict_proba([[25],[40]])[:,1]
print("Intercept and day coefficient:", round(model.intercept_[0], 4), round(model.coef_[0,0], 4))
print("Illustrative P(late) at 25 and 40 days:", np.round(probabilities, 4).tolist())
print("Training example only; future calibration and validation are still required.")Recorded output
Intercept and day coefficient: -6.9694 0.2534 Illustrative P(late) at 25 and 40 days: [0.3467, 0.9596] Training example only; future calibration and validation are still required.
Sources and further reading
Concepts are linked to primary teaching or technical sources. The business examples are illustrative applications, not reported client results.