From Score to Probability

Regression in the name, classification in practice

Logistic regression is a classification model. It builds a weighted sum of features, then passes that score through the sigmoid function, an S-shaped transformation that maps any number into a value between 0 and 1. That value estimates the positive-class probability.

score = -2.0 + 0.8×error_rate + 0.03×queue_depth
probability = sigmoid(score)
probability >= threshold -> positive class

The resulting decision boundary is linear in feature space: one side predicts one class, the other side predicts the other. Changing the threshold moves the operational trade-off without retraining the underlying model.

from sklearn.linear_model import LogisticRegression
model = LogisticRegression(max_iter=1000)
model.fit(X_train, y_train)
risk = model.predict_proba(X_test)[:, 1]
pred = (risk >= 0.35).astype(int)
Analogy: Features cast weighted votes. The sigmoid turns the total vote into a bounded confidence-like score; the threshold decides how much evidence action requires.
Tip: Preserve the continuous probability score for evaluation. Calling predict() immediately fixes a default threshold and hides whether a different operating point better matches false-alarm costs.