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

Scenario: You have built a model that estimates the probability of an undesired outcome using two input signals. Your goal is to tune the decision boundary to correctly separate low- and high-risk cases. The graph shows data points defined by two input signals. Green points indicate low-risk cases and red points show high-risk cases. The sigmoid curve is your classification model. Your goal is to adjust the curve's parameters so it separates both groups as accurately as possible, minimizing the error between predicted and actual classifications.

How to Explore It

  1. 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.
  2. 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.
  3. 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.
What to watch for: The sigmoid function transforms any numerical value into a probability between 0 and 1, turning raw scores into interpretable confidence. Adjusting the curve controls how aggressively the system flags high-risk cases, balancing misses vs. false alarms.
Correct Prediction
True Positive: Predicts "Will not attend" and actually did not attend
True Negative: Predicts "Will attend" and actually attended
Incorrect Prediction
False Positive: Predicts "Will not attend" but actually attended
False Negative: Predicts "Will attend" but actually did not attend

Current mode: Simple Classification

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).

×

Resultados del Juego

Aquí se mostrará un resumen de tu desempeño.

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.”

Apr 17, 2025