Lesson 6.4ModelCode~55 min
Classification
Yes-or-no predictions with the sigmoid, and the decision boundary it draws.
Module 6 · 0/11 done
Yes-or-no questions
Many problems aren’t “how much?” but “which one?”. Spam or not. Pass or fail. Tumour or not. This is classification, and a straight line alone is the wrong tool: a line outputs any number, but we want a probability between 0 and 1.
The fix: compute the line as before, then squash its output with the sigmoid function, :
const sigmoid = (z: number) => 1 / (1 + Math.exp(-z))
plot.fn(sigmoid, [-8, 8], { title: "σ(z) squashes any number into (0, 1)" })
console.log(sigmoid(-100), sigmoid(0), sigmoid(100))
Press Run (⌘/Ctrl + Enter) to see output here.
Huge negative inputs give almost 0, huge positive ones almost 1, and 0 gives exactly 0.5. Perfect for a probability.