3.2 The Next Step: Sigmoid Decision Function
Introduction
Explore how the sigmoid function transforms any linear combination into a probability between 0 and 1, becoming the cornerstone of logistic regression. In this interactive simulation you will separate high- and low-risk cases by adjusting the slope and the initial height of the curve.
Activity
Sigmoid Decision Function
How to Explore It
- Adjust Parameters: Use the w₁, w₂, and bias (b) sliders to modify the slope and position of the sigmoid curve. Observe how the performance metrics react in real time.
- Minimize Log-Loss: Separate the green points (low-risk) from the red points (high-risk) by tuning the sigmoid parameters to achieve the best classification.
- Evaluate Metrics: Check accuracy and log-loss to judge classification quality. Adjust the threshold to be more or less strict when flagging high-risk cases.
Correct Prediction
Incorrect Prediction
Simple Classification Mode: Shows in red the cases classified as "high risk" and in blue those classified as "low risk".
Probabilities Mode: Shows a color gradient indicating the probability of high risk (more red = higher probability).
Controls and Configuration
- w₁ and w₂ sliders tilt the decision boundary so the curve leans toward the high- or low-risk clusters.
- Bias (b) shifts the sigmoid left or right to re-centre the threshold over the data cloud.
- Threshold changes how strict the classifier is when deciding which cases are flagged as high risk.
- Mode toggle alternates between the crisp classification view and a probability heatmap.
- Check classification / New game evaluate the current settings or regenerate a new population.
Terminal Feedback
The terminal below captures every reset and evaluation: it reports when the simulator loads, logs each accuracy check with the current threshold, and confirms when fresh data is generated so you can track improvements step by step.
Core Concepts
Sigmoid Function
What Is the Sigmoid Function?
The sigmoid function transforms the combination of our indicators into a probability between 0 and 1. It is defined as:
$$\sigma(z) = \frac{1}{1 + e^{-z}}, \quad z = w_1 \cdot \text{age} + w_2 \cdot \text{pressure} + b$$Where:
- z is the linear combination of features
- σ(z) is the resulting probability (0 to 1)
- w₁, w₂ are the feature weights
- b is the bias term
Decision Boundary and Threshold
Interpreting the Results
The sigmoid converts the value z into a probability between 0 and 1. The threshold (0.5 by default) determines when a case is labeled “high risk”:
- Probability > threshold → classify as “high risk” (red)
- Probability ≤ threshold → classify as “low risk” (green)
Adjusting the threshold lets you be more or less strict. A higher threshold demands stronger evidence before flagging someone as “high risk.”