Skip to course content
Free course

Machine Learning Foundations / Module 3

Module 3 lesson

Classification: Predicting a Class

Unit ID: ML-M03-U04 Estimated active time: 30-40 minutes

Why this matters

Sometimes the target is not a number to predict directly. It is a category.

In this module, the classification target is:

completed_module1_by_day10

The values are:

  • 1: completed by day 10;
  • 0: did not complete by day 10.

This is classification.

The idea

A classifier predicts a class label.

For this first example, we compare:

  • a most-frequent baseline; and
  • a logistic regression classifier.

The most-frequent baseline always predicts the majority class from the training data. It is simple, but it is important. A trained classifier should be compared with it.

Predict

Suppose 2 out of 3 learners in the training data completed Module 1 by day 10.

What would the most-frequent baseline predict for every test row?

It would predict 1 for every row.

Run or inspect

The first classification notebook follows the same broad pattern:

  1. Load the data.
  2. Choose feature columns.
  3. Choose the target.
  4. Split into train and test.
  5. Fit the baseline.
  6. Fit the candidate classifier.
  7. Compare results.

The pattern should feel familiar from regression. The target type is what changes.

Change one thing

If the target were a quiz score, logistic regression would not be the right first model. Logistic regression is for classification, despite the word "regression" in its name.

Practice

Answer:

  • What is the positive class?
  • What does 1 mean?
  • What does 0 mean?
  • What is the naive baseline?
  • What metric do we inspect first?

Check and explain

Complete:

Classification predicts ______, while regression predicts ______.

Takeaway

Classification predicts a class. Always compare a first classifier with a naive class baseline.