Logistic Regression Calculator

JJ Ben-Joseph headshot JJ Ben-Joseph

Introduction to one-feature logistic regression

Logistic regression is a strong choice when you have one numeric input and a yes-or-no label. This calculator turns those labeled rows into a sigmoid curve, estimates its slope and intercept, and shows the probability that each entered x value belongs to the positive class. It is designed for quick exploration: you can see how the fit moves as you change the step size or number of training passes, without needing to program the model by hand.

The page is intentionally narrow in scope. It fits a single predictor x plus an intercept, so it is most useful when one measurable feature carries the main signal. That makes it suitable for teaching, small experiments, and checking whether a simple binary model tells a clear story before moving to a larger analysis.

The calculator does not merely draw a line through zeroes and ones. It estimates a continuous probability between 0 and 1. A result near 0 indicates evidence for the negative class, while a result near 1 indicates evidence for the positive class. Values near 0.5 are uncertain under the fitted model.

What logistic regression problem does this calculator solve for x,y rows?

This logistic regression calculator answers a specific question: given x,y pairs where y is 0 or 1, what sigmoid curve maps x to the estimated probability of y = 1? It finds coefficients a and b and then reports the fitted probability for every row you entered.

That is helpful when you want a fast, inspectable model for an outcome such as pass or fail, click or no click, and accept or reject. Instead of relying on a visual impression that x seems related to the label, you receive a concrete slope and intercept summarizing the direction and scale of the relationship.

Because the model is one-dimensional, its direction is easy to interpret. A positive slope means larger x values push the probability toward 1; a negative slope means larger x values push it toward 0. Where the curve crosses 0.5, the corresponding x value can be treated as the model’s default decision boundary.

How to use the one-feature logistic regression fitter

  1. Enter one training observation per line in the x,y text area. Separate the two numbers with a comma or whitespace.
  2. Make every y value either 0 or 1 because this page fits a binary classifier.
  3. Set a positive learning rate to control the size of each gradient-descent update.
  4. Choose a positive whole-number iteration count to control how many training passes are performed.
  5. Select Fit Model, then review the coefficients and row-by-row probabilities in the result panel.

Each submission starts a fresh gradient-descent run with both coefficients initialized to zero. After changing the rows or settings, fit the model again. If the coefficients become extremely large or jump unexpectedly, lower the learning rate. If the estimates move too slowly, increase the iterations or cautiously try a larger learning rate.

Inputs used to fit the logistic classifier

The x values are measurements of the numeric feature from which the model learns. The y values are the observed binary outcomes it tries to reproduce. The calculator does not infer units or category meanings, so every row should use the same definition and measurement scale.

Feature scale matters because x appears directly in the slope gradient. Very large x magnitudes can cause large updates, whereas values packed into a tiny range can produce slow movement. Centering or standardizing the feature before fitting often makes optimization easier. Units remain whatever units x uses: minutes, dollars, temperature, test score, or another numeric quantity.

Rows should also be comparable. If most x values are measured in meters but one is accidentally entered in centimeters, that observation can dominate the slope. The calculator treats every row equally and does not automatically detect outliers, missing values, duplicate records, or inconsistent units.

Formulas for the sigmoid probability and gradient updates

The logistic regression formula begins with the linear score z = ax + b. The sigmoid then compresses that score into the interval from 0 to 1. For observation i, the predicted positive-class probability is:

pi = 1 1+e(axi+b)

The slope a determines the direction and steepness of the probability curve. The intercept b shifts the curve along the x-axis. This implementation accumulates the unaveraged gradients over all n rows and subtracts the learning rate η times each gradient:

aaη i=1n (piyi)xi bbη i=1n (piyi)

These updates reduce the logistic cross-entropy objective when the learning rate is appropriate. Rows labeled 1 pull an underestimated probability upward, while rows labeled 0 pull an overestimated probability downward. Because the code sums rather than averages gradients, a rate that works for a small dataset may be too aggressive after many more rows are added.

When a is nonzero, the 0.5 probability boundary follows directly from setting ax + b equal to zero:

xboundary=ba

If a is zero or extremely close to zero, there is no useful finite x boundary because the estimated probability barely changes with x. That often means the feature provides little directional separation, the data are balanced in a way that cancels the slope, or training has not progressed far enough.

Worked example: fitting pass and fail observations

Suppose x is the number of practice hours and y records whether a learner passed an assessment. Enter the observations 1,0, 2,0, 3,0, 4,1, 5,1, and 6,1, one pair per line. With a suitably small learning rate and enough iterations, the slope should become positive because higher practice hours are associated with the positive class.

After fitting, probabilities for one and two hours should generally be lower than those for five and six hours. The estimated 0.5 crossing should fall somewhere around the transition between the observed classes, although its exact location depends on the settings and finite training run. The observations are perfectly separated in this tiny example, so continued unregularized training can keep increasing the coefficient magnitudes rather than settling at a modest finite slope.

Now reverse every label while leaving x unchanged. The fitted slope should reverse sign: larger practice-hour values would then point toward class 0. This simple check demonstrates that the coefficient sign is not inherently good or bad. Its meaning depends entirely on which outcome you coded as 1.

Sensitivity of the logistic fit to learning rate and iterations

The learning rate most strongly affects how smooth training feels. Too small a rate makes the coefficients inch forward, so many iterations may be required before probabilities change noticeably. Too large a rate can overshoot a good region, cause oscillation, or produce very large coefficients. There is no universal best rate because stability depends on the x scale, row count, and degree of class separation.

The iteration count matters differently. More iterations give gradient descent more opportunities to refine the parameters once the learning rate is reasonable. If coefficients and probabilities barely change when you double the iterations, the run has likely stabilized for exploratory purposes. If they change substantially, training has not yet reached a steady region or the data are perfectly separable.

When testing alternatives, change one setting at a time. This makes it easier to distinguish a difficult dataset from an aggressive rate or insufficient pass count. For larger pasted datasets, remember that the calculator sums every row’s contribution, so reducing the learning rate can compensate for the larger total gradient.

How to interpret the fitted logistic regression result

The result panel shows coefficients a and b followed by predicted probabilities in the same order as the entered rows. Read the sign of a first. A positive a means increasing x raises the modeled odds of y = 1, while a negative a means increasing x lowers those odds. The magnitude describes change per one unit of x, so it should always be interpreted in light of the feature’s units and scaling.

The intercept b is the log-odds score when x equals zero. It may be meaningful when zero is a realistic feature value; otherwise it mainly positions the curve. The displayed probability for each observation is not a guarantee or a confidence interval. It is the model’s fitted estimate under this one-feature specification.

Compare probabilities with their labels. Rows labeled 1 should generally receive larger probabilities than rows labeled 0 when the feature separates the classes. A 0.5 cutoff is conventional, but real applications may choose another threshold to account for unequal costs, prevalence, or operational goals. The calculator estimates probabilities and does not select a cost-sensitive threshold for you.

A practical check is that the slope direction should match the data, probabilities should move monotonically with x, and the boundary should appear in a plausible part of the observed range. Use the Copy Result control to preserve the coefficient line and probability list for notes or comparison.

Limitations and assumptions of this logistic regression fit

This calculator deliberately uses a minimal implementation so that its behavior remains visible. That simplicity is helpful for learning, but it imposes important limits.

The model also assumes that x has a linear relationship with the log-odds of the positive outcome. The probability curve itself is nonlinear, but its internal score ax + b is linear. If risk rises, falls, and then rises again across x, one straight score cannot represent that pattern well.

For research, medical, financial, compliance, or other consequential decisions, treat this result as exploratory and confirm it with a validated statistical workflow. A full analysis should examine data quality, class imbalance, calibration, discrimination, uncertainty, out-of-sample performance, and the practical consequences of false positives and false negatives.

Enter exactly two numeric values per line. Separate x and y with a comma or spaces, and code y as 0 or 1.

Enter data.

Mini-game: tune the logistic decision boundary

Put the calculator’s central idea into motion. In each signal wave, class 0 and class 1 observations appear along one x-axis. Move the glowing threshold to classify as many points as possible, then lock your decision. Some waves have a positive slope, where class 1 belongs to the right; others reverse the slope, placing class 1 on the left.

Score0
Time75
Streak0
Wave0
Your browser does not support the canvas element required for this optional mini-game.

Pointer or touch: move and tap to lock. Keyboard: ←/→ to tune, Space or Enter to lock. Overlap and signal drift increase as time passes.