Set your Publisher ID in src/config/ads.ts to display live ads.
Logistic Regression & Binary Classification
The Sigmoid function, decision boundaries, log-odds, and probabilities
Despite its name, Logistic Regression is a classification algorithm that passes linear combinations through the Sigmoid function to output class probabilities between 0.0 and 1.0.
The Sigmoid Transformation
P(y=1|x) = 1 / (1 + e^-z), where z = w*x + b.
Decision Boundary: By default, if probability >= 0.5, the model classifies the sample as Class 1; otherwise Class 0.
model.predict_proba(X): Returns exact calibrated probabilities for each class, essential for threshold tuning in fraud detection or medical diagnosis.
from sklearn.linear_model import LogisticRegression
import numpy as np
# Features: [monthly_charges, tenure_months]
X = np.array([
[20.0, 36],
[85.0, 3],
[95.0, 2],
[25.0, 48]
])
# Target: 1 = Churned, 0 = Retained
y = np.array([0, 1, 1, 0])
clf = LogisticRegression()
clf.fit(X, y)
# Predict probability for new customer [90.0 charges, 4 months]
new_cust = [[90.0, 4]]
prob = clf.predict_proba(new_cust)
print(f"Churn probability: {prob[0][1] * 100:.1f}%")
print(f"Predicted class: {clf.predict(new_cust)[0]}")Set your Publisher ID in src/config/ads.ts to display live ads.
Test Yourself With Exercise
Which mathematical function does Logistic Regression use to squash linear outputs into probabilities between 0 and 1?