Binary Classification Setup
What you'll learn: How to structure a machine learning problem when predicting between exactly two possible outcomes.
The Core Idea
Binary classification is about teaching a model to sort data into exactly two categories. Think of it like a yes/no question, a pass/fail test, or a spam/not-spam email filter. Unlike regression (which predicts continuous numbers), classification predicts discrete labels.
The Two Classes
Every binary classification problem has:
- Class 0: Often called the "negative class" (e.g., not spam, disease absent, transaction legitimate)
- Class 1: Often called the "positive class" (e.g., spam, disease present, transaction fraudulent)
These numeric labels (0 and 1) are just conventions that make the math work smoothly—they don't mean one class is "better" than the other.
Label Encoding
Your target variable must be encoded as 0s and 1s. If you start with text labels like "cat" and "dog," you'll convert them:
- "cat" → 0
- "dog" → 1
This numeric encoding lets algorithms perform mathematical operations during training.
The Decision Boundary
Here's where classification differs fundamentally from regression: instead of predicting a continuous value, the model learns a decision boundary—an invisible line (or surface) that separates the two classes in your feature space.
Imagine plotting height vs. weight: the decision boundary might be a line that divides "basketball players" from "jockeys." Points on one side get labeled 0, points on the other get labeled 1.
Key Takeaway: Binary classification predicts one of two classes (encoded as 0 and 1) by learning a decision boundary that separates examples in the feature space.