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:
- Load the data.
- Choose feature columns.
- Choose the target.
- Split into train and test.
- Fit the baseline.
- Fit the candidate classifier.
- 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
1mean? - What does
0mean? - 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.
