Lesson 24 — Logistic regression training
Train a classifier from scratch
Now combine everything: sigmoid, a score w × x + b, and gradient descent. For logistic regression the gradient is beautifully simple: error = p − y (probability minus true label), then w moves by error × x and b by error — the same shape as linear regression.
p = sigmoid(w * x + b)
error = p - y
After training, check accuracy on the data.
Why it matters: you have just built, by hand, the model behind countless spam filters, credit scores and click predictors.
Write the two update lines for w and b. After training, accuracy should be 1.0.
Run your code — when the output matches the task, you will see a green check. Then mark the lesson complete.
A quick 3-question quiz on this lesson — instant feedback.
Ready for more? Optional paid resources that pick up where this lesson leaves off.
Some links on this page are affiliate links: we may earn a commission at no extra cost to you. As an Amazon Associate I earn from qualifying purchases.
Project-based AI / ML Foundations courses if you want a structured paid path after the free lessons. Wait for a sale — prices drop often.
Browse on Udemy →Search Amazon for AI / ML Foundations books — check the publication year so the examples match current versions.
Search Amazon →