liveBook · Manning

Step function

As explained in Grokking Machine Learning, Second Edition

A threshold function that maps an input to one of discrete output levels according to whether the input crosses a boundary.

A step function turns a score into a simple decision: it returns 1 when the input is at least zero and 0 when the input is negative. In a perceptron, applying it to the score produces the prediction. section 5.8

From score to prediction

If a perceptron gives a sentence a score of 2.4, the step function returns 1; if the score is −0.7, it returns 0. This supports labels such as happy = 1 and sad = 0. section 5.8

def step(x):
    if x >= 0:
        return 1
    else:
        return 0
 
def prediction(weights, bias, features):
    return step(score(weights, bias, features))  #A

This small Python implementation checks the threshold and feeds the result into a perceptron prediction. section 5.19

The step function is a specific activation function. It works well for discrete perceptrons, but real neural networks avoid it because its sharp output prevents gradient descent; sigmoid and other activation functions are used instead. section 10.6 section 10.5

How Grokking Machine Learning, Second Edition covers it

How deep it goes
Defines the threshold, gives a graph and Python implementation, and stops short of using it for practical neural-network training.
Examples
Uses happy-or-sad labels, thresholded scores, a Python step function, and connected perceptrons in a neural-network diagram.
What it assumes
Assumes numerical data and perceptron scores while teaching binary labels and threshold-based prediction.
What you can do after
Apply it via Python to turn perceptron scores into discrete predictions.
How it connects
Connects perceptrons, activation functions, sigmoid functions, gradient descent, and neural networks.

Also explained in

Compare how 3 books explain step function →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking Machine Learning, Second Edition. The section links point to the parts of the book it draws on.