← Apps ← My Digital Space

Logistic Regression Lab

Learn what logistic regression is, then train it in your browser on a sample dataset or your own CSV file.

1. What is logistic regression?

Logistic regression is a classification model. Instead of predicting a number, it predicts the probability that an observation belongs to the positive class (label = 1).

It first computes a linear score (the log-odds) from the features:

z = b0 + b1·x1 + b2·x2 + ... + bn·xn

then squashes it into the range (0, 1) with the sigmoid function:

p = σ(z) = 1 / (1 + e^(−z))

A sample is predicted positive when p ≥ threshold (default 0.5).

How it learns

Coefficients are fitted by minimising the log loss (binary cross-entropy):

L = −(1/N) Σ [ y·log(p) + (1−y)·log(1−p) ] + λ·Σ b²

using gradient descent. The optional L2 penalty (λ) shrinks coefficients and reduces overfitting.

Reading the coefficients

Each coefficient is a change in log-odds. exp(b) is the odds ratio: how many times the odds of the positive class multiply when that feature increases by one unit (one standard deviation if you standardise).

When should I use it?

Use it when you need a fast, interpretable baseline for a binary outcome (disease / no disease, pass / fail, churn / stay), when you care about calibrated probabilities, or when you must explain the effect of each variable. It assumes a roughly linear relationship between the features and the log-odds; for strongly non-linear boundaries prefer trees, boosting or kNN.

The sigmoid curve: linear score z on the x-axis, predicted probability on the y-axis. The dashed line is your decision threshold.

2. Data

Loads instantly, no upload needed.

First row = column names. Target column must have exactly two distinct values.

3. Model setup

Glossary

Accuracy — fraction of correct predictions. Precision — of predicted positives, how many were right. Recall (sensitivity) — of real positives, how many were found. Specificity — of real negatives, how many were correctly rejected. F1 — harmonic mean of precision and recall. AUC — probability that a random positive scores higher than a random negative (0.5 = random, 1.0 = perfect).