Turn practice into a pass probability

Turn practice questions into a probability of passing, then move the threshold that makes the decision.

Artificial intelligence Advanced Supervised learning · Logistic regression ~8 min
The idea

A probability, then a decision

Logistic regression turns one measurement into a probability between 0 and 1. Here the measurement is how many practice questions a student completed. The outcome is passed or did not pass. The score is z = wx + b. The weight w says how much one extra question changes the score. The intercept b is the score at 0 questions. The probability is p = 1 / (1 + e^(−z)). A large positive score pushes p toward 1. A large negative score pushes p toward 0.

The starter model is w = 1 and b = −5. At 5 practice questions, z = 0 and p = 0.500. At 7 questions, Pat’s probability is 0.881. The threshold turns that probability into a class. Predict pass when p is at least the threshold. At 0.5, Pat is predicted to pass. At 0.9, Pat is predicted not to pass. The probability stays 0.881.

Some students with the same practice count had different outcomes, so the curve cannot be right for everyone. Kai passed after 2 questions, and the starter probability is 0.047. Bo also passed, after 4 questions, with probability 0.269. Both are predicted to fail at a threshold of 0.5. Binary cross-entropy for a student who passed is −log(p). Kai’s is 3.049. Bo’s is 1.313. The confident miss adds more to the loss. The model loss is the mean of the ten point losses, 0.956 at the start. Changing the threshold leaves every point loss, and the mean, unchanged.

Step training moves w and b once, in the direction that lowers that mean. Fit model repeats the step until the loss almost stops falling. Training cannot reach 0 here, because Ali did not pass and Kai passed after the same 2 questions.

TipExtra revision goes to students predicted to fail. At the starter threshold, Sam and Noor did not pass but are predicted to pass, so they are missed. Raise the threshold to include them. Students who did pass, such as Kai and Bo, can then receive an invitation too.
Go deeper

For one student, the slope of the loss against the score z is p − y, where y is 1 for passed and 0 for did not pass. The weight’s slope multiplies that by the practice count. Each training step subtracts a fraction of the mean slope from w and from b. A probability of 0.1 for a student who passed has cross-entropy 2.303. A probability of 0.4 has cross-entropy 0.916. The threshold never enters that calculation.

DataTen students
StudentQuestionsOutcome
Mei1Did not pass
Ali2Did not pass
Kai2Passed
Jo4Did not pass
Bo4Passed
Sam6Did not pass
Lee6Passed
Pat7Passed
Noor8Did not pass
Ari9Passed

Ali and Kai both completed 2 questions. Jo and Bo both completed 4. Sam and Lee both completed 6. The outcomes still differ.

Interactive

Move the curve, then the threshold

Before you raise the threshold, guess which students who did not pass are still predicted to pass.

Practice questions and pass probabilitythreshold 0.500
Student
Observed outcome
Remember

Probability, decision, then loss

The curve is the probability. The threshold is the decision. Training changes the curve.

Curve

Probability

z = wx + b becomes p = 1 / (1 + e^(−z)). The result stays between 0 and 1.

Cut

Threshold

Predict pass when p is at least the threshold. Moving it changes the decision, not the probability.

Loss

Cross-entropy

A confident wrong probability adds more than a near-threshold miss. Training steps downhill on the mean of those losses.