Offline-ready notes · progress saves on this device
Project LibraryStudy workspace →
Courses/Machine Learning/Lesson 4

Lesson 4 of 6

Logistic Regression & Classification

Read the overview in
English overview

Move from predicting numbers to classifying outcomes with logistic regression, probability thresholds, confusion-aware evaluation, and a real public-health example.

12:12 lectureIntermediate12 video chapters30 flashcards + 30 questions
Official Binary Tree uploadML with Python Lectures Week 4Published 2026-08-02 · embedded with chapters, checkpoints, deep notes, and a project

Four clear stages

Learn → Project → Check → Finish

Watch and work through the lecture
  1. 1LearnWatch and work through the lectureUse the chapter notebook and answer each video checkpoint.Do this now
  2. 2ProjectDesign a threshold-and-harm analysisPlan it, create it, then prove it meets the definition of done.Next
  3. 3CheckAnswer all 30 questionsCorrect weak spots using the explanation after each answer.Next
  4. 4FinishMark the lesson completeThen move to Introduction to Neural Networks.Next
Course outlineMachine Learning with Python

Interactive lecture

Watch, pause, think, apply.

Use logistic regression for a binary outcome, turn probabilities into decisions with a threshold, and analyze false-positive versus false-negative costs.

0:003 thinking points marked12:12

Numbered markers show where the video will pause. Seeking past one opens the first unanswered check.

Connecting to the lecture…Open on YouTube ↗

Chapter-by-chapter lecture notebook

Everything in the video, organized for learning

The lecture grounds logistic regression in public-health inspection. A threshold is a policy decision with asymmetric consequences, not a neutral default.

Source reviewed12:12 lectureReviewed against the public lecture with timestamped slide sampling across the full runtime and cross-checked against the source lesson context.
12

video chapters mapped into notes, examples, and a concrete action.

This is a detailed learning companion reconstructed from the reviewed lecture—not a verbatim transcript.
01
0:00 in the lectureTuning recap
What the video is teaching

Logistic regression models a binary target such as lead or no lead. The prediction supports an action such as prioritizing an inspection, not a claim of certainty.

Define positive and negative classes, prediction time, available features, affected people, and the action each result triggers.

What to noticeWorked example

Positive means likely lead line and leads to inspection; the label comes from verified pipe material, not an unconfirmed city record.

Do this before continuing

Write the full decision table for positive and negative predictions.

Replay this chapter on YouTube ↗
02
0:55 in the lectureWater use and public infrastructure
What the video is teaching

Logistic regression models a binary target such as lead or no lead. The prediction supports an action such as prioritizing an inspection, not a claim of certainty.

Define positive and negative classes, prediction time, available features, affected people, and the action each result triggers.

What to noticeWorked example

Positive means likely lead line and leads to inspection; the label comes from verified pipe material, not an unconfirmed city record.

Do this before continuing

Write the full decision table for positive and negative predictions.

Replay this chapter on YouTube ↗
03
2:00 in the lectureLead service-line problem
What the video is teaching

Logistic regression models a binary target such as lead or no lead. The prediction supports an action such as prioritizing an inspection, not a claim of certainty.

Define positive and negative classes, prediction time, available features, affected people, and the action each result triggers.

What to noticeWorked example

Positive means likely lead line and leads to inspection; the label comes from verified pipe material, not an unconfirmed city record.

Do this before continuing

Write the full decision table for positive and negative predictions.

Replay this chapter on YouTube ↗
04
3:10 in the lectureBinary target and class notation
What the video is teaching

Logistic regression models a binary target such as lead or no lead. The prediction supports an action such as prioritizing an inspection, not a claim of certainty.

Define positive and negative classes, prediction time, available features, affected people, and the action each result triggers.

What to noticeWorked example

Positive means likely lead line and leads to inspection; the label comes from verified pipe material, not an unconfirmed city record.

Do this before continuing

Write the full decision table for positive and negative predictions.

Replay this chapter on YouTube ↗
05
4:15 in the lectureExplore year built
What the video is teaching

Year built may carry signal but also missingness, recording errors, neighborhood patterns, and inequitable historical context. A histogram and class comparison reveal coverage and overlap.

Check whether the feature is available and reliable for every home and whether it acts as a proxy for protected or structural conditions.

What to noticeWorked example

Older construction may correlate with lead service lines, but the model still needs verified labels and evaluation across neighborhoods.

Do this before continuing

Create a feature audit for year built with provenance, missingness, proxy risk, and correction plan.

Replay this chapter on YouTube ↗
06
5:20 in the lectureWhy linear regression fails for classes
What the video is teaching

Logistic regression maps feature combinations to values bounded between zero and one. A threshold such as 0.5 converts the score into a class prediction.

Calibrate probabilities when decisions rely on their magnitude, and choose thresholds from costs and capacity rather than convention.

What to noticeWorked example

A 0.35 threshold may be appropriate when missing lead is far more harmful than inspecting a copper line.

Do this before continuing

Calculate predicted classes for five probabilities under thresholds 0.5, 0.3, and 0.1.

Replay this chapter on YouTube ↗
07
6:20 in the lectureLogistic probabilities from 0 to 1
What the video is teaching

Logistic regression maps feature combinations to values bounded between zero and one. A threshold such as 0.5 converts the score into a class prediction.

Calibrate probabilities when decisions rely on their magnitude, and choose thresholds from costs and capacity rather than convention.

What to noticeWorked example

A 0.35 threshold may be appropriate when missing lead is far more harmful than inspecting a copper line.

Do this before continuing

Calculate predicted classes for five probabilities under thresholds 0.5, 0.3, and 0.1.

Replay this chapter on YouTube ↗
08
7:20 in the lectureDecision threshold
What the video is teaching

Logistic regression maps feature combinations to values bounded between zero and one. A threshold such as 0.5 converts the score into a class prediction.

Calibrate probabilities when decisions rely on their magnitude, and choose thresholds from costs and capacity rather than convention.

What to noticeWorked example

A 0.35 threshold may be appropriate when missing lead is far more harmful than inspecting a copper line.

Do this before continuing

Calculate predicted classes for five probabilities under thresholds 0.5, 0.3, and 0.1.

Replay this chapter on YouTube ↗
09
8:30 in the lectureFlint prediction results
What the video is teaching

Logistic regression maps feature combinations to values bounded between zero and one. A threshold such as 0.5 converts the score into a class prediction.

Calibrate probabilities when decisions rely on their magnitude, and choose thresholds from costs and capacity rather than convention.

What to noticeWorked example

A 0.35 threshold may be appropriate when missing lead is far more harmful than inspecting a copper line.

Do this before continuing

Calculate predicted classes for five probabilities under thresholds 0.5, 0.3, and 0.1.

Replay this chapter on YouTube ↗
10
9:35 in the lectureFalse positives and false negatives
What the video is teaching

A confusion matrix separates true positives, true negatives, false positives, and false negatives. Accuracy can hide harmful misses, especially with imbalanced outcomes.

Report sensitivity, specificity, precision, class counts, and group or location performance. State the operational cost of each error.

What to noticeWorked example

Lowering the threshold catches more lead lines but consumes more inspection capacity; the policy must document that tradeoff.

Do this before continuing

Recommend a threshold using a cost table and a fixed weekly inspection capacity.

Replay this chapter on YouTube ↗
11
10:40 in the lectureShift the threshold
What the video is teaching

A confusion matrix separates true positives, true negatives, false positives, and false negatives. Accuracy can hide harmful misses, especially with imbalanced outcomes.

Report sensitivity, specificity, precision, class counts, and group or location performance. State the operational cost of each error.

What to noticeWorked example

Lowering the threshold catches more lead lines but consumes more inspection capacity; the policy must document that tradeoff.

Do this before continuing

Recommend a threshold using a cost table and a fixed weekly inspection capacity.

Replay this chapter on YouTube ↗
12
11:40 in the lectureTradeoffs and no-false-negative goal
What the video is teaching

A confusion matrix separates true positives, true negatives, false positives, and false negatives. Accuracy can hide harmful misses, especially with imbalanced outcomes.

Report sensitivity, specificity, precision, class counts, and group or location performance. State the operational cost of each error.

What to noticeWorked example

Lowering the threshold catches more lead lines but consumes more inspection capacity; the policy must document that tradeoff.

Do this before continuing

Recommend a threshold using a cost table and a fixed weekly inspection capacity.

Replay this chapter on YouTube ↗

Deep explanations

The ideas behind each chapter

Use these sections when the video moves quickly or you need another example.

012:00

Define the binary outcome and affected decision

Logistic regression models a binary target such as lead or no lead. The prediction supports an action such as prioritizing an inspection, not a claim of certainty.

Define positive and negative classes, prediction time, available features, affected people, and the action each result triggers.

Worked example

Positive means likely lead line and leads to inspection; the label comes from verified pipe material, not an unconfirmed city record.

Try it now

Write the full decision table for positive and negative predictions.

024:15

Inspect features before fitting

Year built may carry signal but also missingness, recording errors, neighborhood patterns, and inequitable historical context. A histogram and class comparison reveal coverage and overlap.

Check whether the feature is available and reliable for every home and whether it acts as a proxy for protected or structural conditions.

Worked example

Older construction may correlate with lead service lines, but the model still needs verified labels and evaluation across neighborhoods.

Try it now

Create a feature audit for year built with provenance, missingness, proxy risk, and correction plan.

035:20

Separate probability, threshold, and class

Logistic regression maps feature combinations to values bounded between zero and one. A threshold such as 0.5 converts the score into a class prediction.

Calibrate probabilities when decisions rely on their magnitude, and choose thresholds from costs and capacity rather than convention.

Worked example

A 0.35 threshold may be appropriate when missing lead is far more harmful than inspecting a copper line.

Try it now

Calculate predicted classes for five probabilities under thresholds 0.5, 0.3, and 0.1.

049:35

Evaluate the errors that matter

A confusion matrix separates true positives, true negatives, false positives, and false negatives. Accuracy can hide harmful misses, especially with imbalanced outcomes.

Report sensitivity, specificity, precision, class counts, and group or location performance. State the operational cost of each error.

Worked example

Lowering the threshold catches more lead lines but consumes more inspection capacity; the policy must document that tradeoff.

Try it now

Recommend a threshold using a cost table and a fixed weekly inspection capacity.

Language of the lesson

Know these ideas

Binary classification
Prediction between two defined outcome classes.
Logistic regression
A model relating features to the log-odds of a binary outcome.
Threshold
A cutoff converting a score or probability into a class.
False positive
A positive prediction when the outcome is actually negative.
False negative
A negative prediction when the outcome is actually positive.
Confusion matrix
Counts of correct and incorrect predictions by class.

Reason like a practitioner

Misconceptions to correct

  • The default 0.5 threshold is objectively correct.Thresholds depend on error costs, calibration, and capacity.
  • High accuracy proves the model is safe.Accuracy may hide costly minority-class errors.
  • A predicted probability is a confirmed fact.It is a model estimate supporting a decision under uncertainty.
Transfer challenge

Create a threshold memo with class definitions, confusion matrix, error-cost table, capacity constraint, group checks, and a justified inspection threshold.

Lesson project · Classification decision

Design a threshold-and-harm analysis

A threshold choice tied to false-positive and false-negative costs, plus metrics that reveal the tradeoff.

0%0 of 3 checks
1
Project phase 1

Plan the work

State the goal, audience or user, and the evidence a strong result needs. Explain how Classification changes your plan.

2
Project phase 2

Create the deliverable

For a safety classification, list the cost of a false positive and false negative. Choose a probability threshold and explain why accuracy alone may hide the most harmful errors.

3
Project phase 3

Prove and improve

Use Probability threshold and False negative to check the result. Record one piece of evidence, one correction, and one improvement you would make next.

Offline referenceRead the independent walkthrough and practice notes

Why this lesson matters

Move from predicting numbers to classifying outcomes with logistic regression, probability thresholds, confusion-aware evaluation, and a real public-health example.

The goal is not to memorize vocabulary. By the end of the lesson, you should be able to use the ideas in a realistic situation, explain the reason for your choices, and check whether the result actually works for the intended person or task.

Learning objectives

  • Explain Classification in your own words.
  • Apply Probability threshold to a realistic classroom or community example.
  • Connect Classification with False negative when making a decision.
  • Complete the practice task and reflect on one improvement.

Core ideas

1. Classification

A prediction task where the target is a category, such as safe or unsafe, rather than a continuous numeric value.

In practice: Look for this idea while you complete the lesson task. Pause before each major step and explain how Classification changes what you choose, create, or check.

2. Probability threshold

The cutoff used to convert a predicted probability into a class label; changing it trades one kind of error for another.

In practice: Look for this idea while you complete the lesson task. Pause before each major step and explain how Probability threshold changes what you choose, create, or check.

3. False negative

A case that truly belongs to the positive class but the model incorrectly labels as negative, often important in high-stakes screening.

In practice: Look for this idea while you complete the lesson task. Pause before each major step and explain how False negative changes what you choose, create, or check.

How the ideas connect

Start with Classification to understand the foundation of the lesson. Use Probability threshold to turn that understanding into an action. Then apply False negative to check the quality, safety, or usefulness of the result. The three ideas are strongest when you can explain their relationship rather than treating them as separate definitions.

Guided walkthrough

  1. Name the goal. In one sentence, write what you are trying to understand, create, or improve.
  2. Make a prediction. Before touching a device, use Classification and Probability threshold to predict what a strong result should look like.
  3. Complete the task. For a safety classification, list the cost of a false positive and false negative. Choose a probability threshold and explain why accuracy alone may hide the most harmful errors.
  4. Check the outcome. Use False negative to inspect the result. Ask what worked, what did not, and what evidence supports your judgment.
  5. Explain and revise. Tell a partner what you changed and why. Make one small improvement, then compare the new result with the first one.

Worked classroom scenario

Imagine two learners sharing one device. The first learner is the driver and performs the steps; the second is the navigator and reads the goal, predicts the next step, and checks the result. Halfway through the task, switch roles. Both learners should be able to explain how Classification, Probability threshold, and False negative appeared in the work.

If no device is available, complete the same reasoning on paper: sketch the screen or result, label each decision, and describe what you would test when a device becomes available.

Common mistakes and fixes

  • Rushing into the tool: Write the goal and prediction first so every click or step has a reason.
  • Copying without understanding: After each major step, explain it in your own words to a partner.
  • Accepting the first result: Compare the outcome with the goal and make at least one deliberate improvement.
  • Letting one person control a shared device: Rotate driver and navigator roles so both learners think and practice.

Independent practice

For a safety classification, list the cost of a false positive and false negative. Choose a probability threshold and explain why accuracy alone may hide the most harmful errors.

For an extra challenge, adapt the task for a different audience or community need. Write two sentences explaining what changed and which lesson idea guided your decision.

Check your understanding

  1. How would you explain Classification to someone new to the topic?
  2. What is one realistic example of Probability threshold outside this classroom?
  3. When might False negative prevent a weak, unsafe, or confusing result?
  4. How are Classification and Probability threshold connected?
  5. What evidence would convince you that your practice result works?
  6. If you repeated the activity tomorrow, what would you improve first and why?

Key takeaway

Move from predicting numbers to classifying outcomes with logistic regression, probability thresholds, confusion-aware evaluation, and a real public-health example.

You are ready to move on when you can explain the three core ideas, complete the practice without copying, and describe one improvement using evidence from your result.