BeginnerCoder

Lesson 21 — Logistic prediction

Logistic regression: score, probability, class

Logistic regression is the classic yes/no model. Step 1: a score z = dot product of weights and features, plus a bias. Step 2: sigmoid(z) turns the score into a probability. Step 3: compare with a threshold (0.5) to choose the class.

score = sum(c * v for c, v in zip(coefs, values)) + offset

Each weight says how much a feature pushes towards "yes" (positive) or "no" (negative).

Why it matters: this three-step recipe is exactly what the last layer of most neural networks does for classification.

Want it another way?
Task

Compute z as the weighted sum of features plus bias. The program prints the probability and class for each email.

Run your code — when the output matches the task, you will see a green check. Then mark the lesson complete.

← Back
Next →
Test your knowledge

A quick 3-question quiz on this lesson — instant feedback.

Enjoying this lesson? Share it.

Keep going with AI / ML Foundations

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.