What logistic regression calculates
Logistic regression is a supervised classification algorithm that estimates the probability of one of two outcomes. A model begins with a linear score: the intercept plus every feature multiplied by its coefficient. It then passes that score through the sigmoid function, turning any real number into a probability between zero and one. The familiar S-shaped sigmoid is why a one-feature fit bends smoothly toward 0 and 1 instead of producing the unbounded line used by ordinary linear regression.
This calculator fits the model from numeric CSV data entirely in your browser. Put predictor columns first and the binary target in the final column. The greater numeric target label is treated as the positive class. The result includes coefficients, an intercept, odds ratios, fitted probabilities, predicted classes, accuracy, F1, log loss, Matthews correlation coefficient, and a training confusion matrix. With one feature you see the sigmoid curve; with two or more features you see the decision boundary across the first two features.
Logistic regression is a strong baseline when you want interpretable direction and magnitude, probability estimates, fast fitting, and a roughly linear decision boundary after feature engineering. Common applications include churn, lead qualification, credit risk, conversion, medical screening, quality control, and any yes/no outcome where a probability is more useful than a label alone.
How to use the calculator
- Paste comma-separated numeric data or load one of the built-in examples.
- Keep one or more feature columns on the left and the binary target as the last column.
- Review the fitted metrics, chart, coefficient table, and confusion matrix.
- Move the new-sample sliders to see probability and predicted class update immediately.
- Download predictions, save the chart, or copy equivalent JavaScript and Python code.
The preview table is editable, so you can correct individual observations without rebuilding the CSV. Every accepted edit triggers a fresh model fit. Feature columns are standardized internally because gradient descent is sensitive to very different scales. The tool converts fitted weights back into your original units before displaying coefficients, odds ratios, and the equation used for live prediction.
Reading coefficients and odds ratios
A logistic coefficient operates on log odds. If a coefficient is positive, increasing that feature raises the model’s estimated odds of the positive class while the other features stay fixed. If it is negative, increasing the feature lowers the odds. A coefficient of zero means the feature does not change the linear score. Comparing raw coefficient magnitudes across differently measured features can be misleading: one year, one dollar, and one percentage point are not comparable changes.
Exponentiating a coefficient produces an odds ratio, which is usually easier to explain. An odds ratio of 1.30 means a one-unit increase multiplies the odds by 1.30, holding other predictors constant. An odds ratio of 0.70 multiplies the odds by 0.70, a 30% reduction in odds. Odds are not probability. Moving from odds of 1:4 to 1.3:4 changes probability differently than applying the same multiplier when the starting odds are 4:1. Use the new-sample controls to see that nonlinear probability effect at realistic feature values.
The intercept is the log odds when every feature equals zero in its original unit. It can be meaningful when zero is a plausible baseline, but it may simply anchor the fitted equation when zero falls outside the data. Centering features before analysis can make the intercept easier to interpret. This calculator standardizes for optimization and then transforms the parameters back, so the displayed intercept refers to the unstandardized values shown in the input.
Understanding the sigmoid curve and decision boundary
In one dimension, the chart plots the positive-class probability against the feature. The midpoint of the curve is the location where probability equals 0.5 and the model changes its predicted class. A large coefficient creates a steep transition; a small coefficient produces a gradual transition. Points at the top and bottom show observed positive and negative labels, while the highlighted point follows the live prediction slider.
With two predictors, all combinations assigned probability 0.5 form a straight decision boundary. One side is classified as the lower label and the other as the higher label. The colored background indicates the predicted side and grows slightly stronger as probability moves away from 0.5. If your classes curve around each other or form disconnected islands, a straight boundary will underfit unless you add nonlinear transformations such as interactions or polynomial features.
When more than two features are present, the fitted model still uses every column and the coefficient table reports all of them. A flat screen cannot directly display a high-dimensional hyperplane, so the plot shows the first two feature axes. Treat it as a projection rather than a complete picture. Use the live controls, metrics, and exported probability table to examine the influence of the remaining features.
Logistic regression versus linear regression
Linear regression minimizes numeric prediction error and can return values below zero or above one. Applying it to a binary target creates invalid probabilities and assumes the wrong error distribution. Logistic regression instead models log odds and uses a classification loss, so its output remains within the probability range. Both models are linear in their parameters, but they answer different questions: linear regression predicts how much; logistic regression predicts the probability of which class.
A probability does not become a decision until you choose a threshold. This page uses 0.5 for clarity, but production systems often move the threshold. Lowering it generally increases recall and false positives; raising it generally increases precision and false negatives. After exporting probabilities, evaluate candidate thresholds with theconfusion matrix and F1 calculator, or use ROC and precision-recall curves from the Metrics API.
When the model is a good fit—and when it is not
Logistic regression is attractive when interpretability, speed, and calibrated ranking are important. It works well with numeric or encoded categorical features, benefits from sensible scaling, and can remain competitive on many tabular datasets. Because every coefficient has a direction, product and domain teams can inspect whether the learned relationship is plausible. It is also easy to reproduce in JavaScript, Python, SQL-like scoring systems, and edge or browser environments.
It is less suitable when the true boundary is strongly nonlinear and feature engineering cannot represent it, when observations are not independent, or when perfect separation drives coefficients toward extreme values. Highly correlated predictors can also make individual coefficient interpretations unstable even when predictions remain useful. Sparse categories, missing values, outliers, and data leakage should be handled before fitting. For causal or inferential work, you additionally need standard errors, confidence intervals, design assumptions, and diagnostics not provided by this interactive calculator.
JavaScript implementation in the browser
The estimator on this page is Linear.LogisticRegression from @kanaries/ml. It follows the familiar fit-and-predict workflow used by scikit-learn while running in JavaScript or TypeScript. All parsing, scaling, gradient-descent fitting, metrics, visualization, and exports happen on the client. That makes the calculator a useful reference for browser-native analysis, privacy-sensitive prototypes, frontend teaching tools, and Node.js workflows that should not depend on a Python service.
The code tabs preserve the current data and show equivalent starting points for @kanaries/ml and scikit-learn. Their predictions should be compared on a held-out dataset rather than assuming coefficients will be numerically identical: optimizers, regularization defaults, stopping rules, and scaling choices can differ across implementations. For a deeper API explanation and a minimal runnable example, continue to the Logistic Regression in JavaScript guide.