Classification vs Regression
The difference between predicting a category (bucket) and predicting a quantity (number).
Verdict: It depends entirely on your output space. If the answer is a category, use Classification. If the answer is a continuous number, use Regression.
The Short Answer
Both are types of Supervised Learning (where the model learns from labeled data to map inputs to outputs). The difference lies entirely in the shape of the output.
Classification predicts discrete labels or categories. The model looks at the data and assigns it to a specific bucket. (e.g., Is this email "Spam" or "Not Spam"? Is this tumor "Malignant" or "Benign"?).
Regression predicts continuous numbers. The model looks at the data and outputs a precise value on a sliding scale. (e.g., What is the exact price of this house? How many degrees Celsius will it be tomorrow?).
Where They Differ
| Feature | Classification | Regression |
|---|---|---|
| Output Space | Discrete (categories/labels). | Continuous (numbers). |
| Output Type | Usually strings or integers acting as class IDs (0, 1, 2). | Floats (e.g., 24.5, $150,000). |
| Loss Function | Cross-Entropy Loss (Log Loss). | Mean Squared Error (MSE), Mean Absolute Error (MAE). |
| Evaluation Metrics | Accuracy, Precision, Recall, F1-Score, AUC. | RMSE, R-Squared (), MAE. |
| Example Algorithm | Logistic Regression, DecisionTreeClassifier. | Linear Regression, DecisionTreeRegressor. |
The "Logistic Regression" Naming Confusopoly
The biggest source of confusion for beginners is the algorithm named Logistic Regression.
Despite having the word "regression" in its name, Logistic Regression is a Classification algorithm. It outputs a continuous probability (e.g., 0.85) between 0 and 1, which is then thresholded (e.g., if > 0.5, then Class 1) to make a discrete categorical prediction.
Choose Classification When
- The answer is a choice: You want to predict user churn (Yes/No), object detection (Car/Pedestrian/Bike), or sentiment (Positive/Neutral/Negative).
- The numbers represent categories, not quantities: If you are predicting ZIP codes, even though they are numbers, you must treat them as classification. The difference between ZIP 90210 and 90211 doesn't mean one is "one unit greater" than the other; they are just discrete geographic buckets.
Choose Regression When
- The answer is a quantity: You want to predict revenue, temperature, age, weight, or distance.
- The difference between numbers is mathematically meaningful: The difference between 20,000 is exactly the same as the difference between 40,000.
What People Get Wrong
Framing regression problems as classification
Sometimes you want to predict a continuous number (e.g., age), but you bucket it into categories (e.g., "18-25", "26-35"). You have artificially turned a regression problem into a classification problem. While sometimes useful for business reporting, doing this before training throws away valuable granular information the model could have learned. It is usually better to train a regression model to predict the exact age, and then bucket the outputs later.