liveBook · Manning

Sigmoid

As explained in Statistics Every Programmer Needs

A sigmoid function is a function with an S-shaped curve that transitions smoothly between lower and upper limiting values.

The sigmoid, also called the logistic function, turns a numeric input into a value between 0 and 1. Its S-shaped curve makes it useful in logistic regression: a linear combination of predictors becomes an estimated probability that a binary outcome equals 1. Unlike linear regression, the resulting prediction is a class probability rather than an unrestricted numeric outcome. section 5.1

Figure 5.1 A graphical illustration of the sigmoid function. The sigmoid function is characterized by its S-shaped curve, compared to a linear function, which is characterized by a straight line.
figure

The plotted S-shaped curve shows how the sigmoid differs from the straight line associated with a linear function. section 5.1

Write the sigmoid as p = 1 / (1 + e^(−z)), where z is an intercept plus predictor values multiplied by their fitted coefficients. In a binary model, p represents P(Y = 1 | X). A common decision rule predicts class 1 when p is at least 0.5 and class 0 otherwise. The probability and the final class prediction are distinct outputs: the threshold supplies the decision rule. section 5.1 section 5.2.3

Predicting a raisin class

A fitted model uses raisin measurements to estimate class probability. With its rounded coefficients, the calculation is `z = -11.8048 - 0.0244 * MinorAxisLength + 0.0159 * Perimeter`, followed by `p = 1 / (1 + 2.72**(-z))`. For one raisin, the displayed probability is 0.698821, so the 0.5 rule predicts class 1; its recorded class is 0. That mismatch is a reminder to check predictions against observed outcomes rather than treating a probability above the threshold as proof. section 5.2.3

The sigmoid supplies the probability transformation, not evidence that the fitted model is reliable. Assess logistic regression with model-fit and predictor-significance measures, then examine classification errors and metrics such as accuracy and area under the receiver operating characteristic curve. Exploring the predictors and checking issues such as multicollinearity also matter when selecting a model. section 5.2.2 section 5.3

How Statistics Every Programmer Needs covers it

How deep it goes
Explains the S-shaped transformation, fitted-coefficient calculation, and classification threshold; does not develop the sigmoid independently of logistic regression.
Examples
Calculates raisin-class probabilities from minor-axis length and perimeter, then compares thresholded predictions with recorded classes.
What it assumes
Builds on binary outcomes, predictors, coefficients, and probability while explaining how they enter the sigmoid calculation.
What you can do after
Apply it via fitted logistic-regression coefficients to calculate binary-class probabilities and make threshold-based predictions.
How it connects
Connects logistic regression and linear regression to binary classification, predictor coefficients, and classification metrics.

Also explained in

Compare how 16 books explain sigmoid →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Statistics Every Programmer Needs. The section links point to the parts of the book it draws on.