Logistic RegressionFinding the Best S-Curve
How do we find the and that make the log-loss smallest? The same way as for lines: gradient descent. Start with a flat curve (, , so every student gets a 50 % chance) and keep stepping downhill on the log-loss. This time there are two numbers to learn, so each step works out the slope in both directions.
Method 1: Gradient Descent
Press the buttons to train. The top figure shows the S-curve; the bottom one shows the log-loss after each step.
Note
For log-loss the downhill step turns out to be very neat. With the model's chance for student :
Each student pushes the curve by their error : students the model is unsure about, or wrong about, push hardest.
Method 2: Maximum Likelihood
Here is another way to ask the same question: which curve makes what actually happened most likely? Take three students. Aman passed and the model gave him a 0.9 chance of passing. Bela failed and the model gave her a 0.2 chance of passing — so the chance it gave to what really happened is
If the three results are independent, the chance of all three happening is the product:
Now take of it. The logarithm turns a product into a sum: , which is just the sum of the three penalties. So the curve with the highest likelihood is the curve with the lowest