Logistic Regression

20 min read

Logistic regression answers yes or no questions. Will this student pass? Is this SMS spam? It gives a chance between 0 and 1, and then you pick a side. In this lesson you build it from scratch with NumPy.

New words

Classification
Putting each item into one group, such as pass or fail.
Sigmoid
A function that squashes any number into a value between 0 and 1.
Probability
A number from 0 to 1 that tells how likely something is.
Threshold
The cut-off chance. At or above it, the answer is yes.
Decision boundary
The point where the model switches from no to yes.
Log loss
A score for the model's mistakes. Confident and wrong costs the most.

What you will learn

  1. Will Priya pass the exam?
  2. Why is a straight line wrong?
  3. What is the sigmoid?
  4. What is the output, and what is the threshold?
  5. How does the model know it is wrong? Log loss
  6. How does the model learn w and b?
  7. Draw the S-curve with Matplotlib
  8. Try it: move the S-curve
  9. Common mistakes
  10. Explain it to a friend
  11. Key takeaways

10 quiz questions at the end.

Start this lesson

The full lesson, with interactive demos and the quiz, opens after you sign in with Google. It is free.

All lessons · Back to the roadmap