Logistic Regression Calculator
Modeling a Yes/No Outcome
Linear regression predicts a continuous number, but plenty of real questions have a binary answer: will this customer churn, did the patient recover, did the loan default. Logistic regression is built for exactly that case. Rather than fitting a straight line, it fits an S-shaped curve that stays bounded between 0 and 1, so its output can be read directly as a probability.
The Formula
This calculator fits b0 (intercept) and b1 (slope) using batch gradient descent on the logistic log-loss, working on standardized x values internally for numerical stability, then converts the coefficients back to the original x scale.
Worked Example
x = 1, 2, 3, 4, 5, 6. y (binary outcome) = 0, 0, 0, 1, 1, 1 — a clean split where the outcome flips from 0 to 1 partway through the range.
| Quantity | Value |
|---|---|
| Intercept (b0) | −22.9447 |
| Slope (b1) | 6.5556 |
| Predicted probability at x = 3.5 | 0.50 |
Computed by running the calculator's own gradient-descent fitting procedure (3,000 iterations, learning rate 0.3) on standardized x values.
The model places the 50% probability threshold almost exactly at x = 3.5, the midpoint between the last "0" (x = 3) and the first "1" (x = 4) — exactly where a clean binary split should put it.
Where This Calculation Matters
- Churn and conversion modeling — predicting the probability a customer cancels a subscription or completes a purchase based on a single predictive measurement.
- Medical risk scoring — estimating the probability of a binary clinical outcome (disease present or absent) from a single biomarker or risk factor.
- Threshold-based classification — once fit, the model assigns a predicted class (0 or 1) by comparing the predicted probability against a 0.5 cutoff, or another threshold chosen for the application.
How to Use This Calculator
- Enter the X values as a comma-separated list (at least 4 data points).
- Enter the Y values as a comma-separated list of 0s and 1s, matching each X value.
- Optionally enter a specific X value to predict its probability and predicted class.
- Select Calculate to get the fitted model and, if requested, the prediction.
Related Calculations
For predicting a continuous outcome instead of a binary one, use the Linear Regression Calculator. To measure how strongly the predictor relates to the outcome first, see the Pearson Correlation Calculator.