Welcome back to Day 18 of 365 Days of AI! Yesterday, in Day 17: Reinforcement Learning Explained, we looked at how an AI agent learns through trial, error, rewards, and penalties inside an interactive environment.
Today, we are returning to the foundation of Supervised Learning—the branch of machine learning where we give algorithms historical data that already contains correct labels or answers. Whenever you frame a supervised machine learning problem, you almost always land on one fundamental question before picking an algorithm or writing code:
“Are we predicting a category, or are we predicting a numerical value?”
That distinction divides supervised learning into two main branches: Classification and Regression. Master this difference, and you will instantly know how to structure your dataset, choose the right model, and evaluate whether your predictions are actually working.
What You Will Learn Today
- The exact core definition of Classification vs. Regression
- How to identify output types: discrete categories versus continuous numbers
- A memorable mental model: The Bucket vs. The Ruler
- Real-world industrial and software examples for both problem types
- A tricky edge case that confuses almost every beginner (including why Logistic Regression is actually a classification algorithm)
- A practical exercise to test your understanding before moving forward
1. Classification: Sorting Data into Buckets
Classification is the task of predicting a discrete label or category for a given input. When you train a classification model, you are asking the machine to assign input features into one of two or more distinct groups.
Think of classification as sorting physical mail into specific slots at a post office. Every incoming letter must go into a defined bin—there are no in-between states.
Types of Classification
- Binary Classification: Exactly two possible classes or outcomes (e.g., Yes / No, Spam / Not Spam, Fraud / Legitimate).
- Multiclass Classification: Three or more mutually exclusive classes (e.g., classifying a handwritten digit as 0, 1, 2, …, 9, or categorizing customer support tickets as Billing, Technical, Account, Feature Request).
- Multi-label Classification: Assigning multiple categories to a single sample simultaneously (e.g., tagging a news article with both Technology and Finance).
Real-World Classification Examples
- Email Security: Is an incoming email “Spam” or “Inbox”?
- Healthcare Screening: Does a medical scan show “Tumor Present” or “No Tumor”?
- Credit Risk: Will a loan applicant “Default” or “Repay”?
- Computer Vision: Does this security camera image contain a “Car”, “Pedestrian”, or “Cyclist”?
2. Regression: Measuring along a Continuous Scale
Regression is the task of predicting a continuous numerical value. Instead of picking a discrete label from a list, a regression model outputs a number that can fall anywhere along a numerical continuum—including decimals and fractions.
Where classification asks “Which category does this belong to?”, regression asks “How much?” or “How many?”
Real-World Regression Examples
- Real Estate Pricing: Predicting the market price of a house (e.g., $342,500.00).
- Weather Forecasting: Predicting tomorrow’s exact temperature in degrees Celsius (e.g., 28.4°C).
- E-commerce Delivery: Estimating delivery arrival time in minutes (e.g., 34.5 minutes).
- Financial Analytics: Estimating future quarterly revenue for a business.
3. The Mental Model: The Bucket vs. The Ruler
When you are trying to decide whether an AI problem requires classification or regression, keep this simple mental model in mind:
Mental Model: Bucket vs. Ruler
Classification is a set of Buckets. The model takes input features and drops the result into a specific bucket labeled “Class A”, “Class B”, or “Class C”. Distance between classes is not continuous.
Regression is a Measuring Ruler. The model measures the input along a continuous numerical scale. Every point on the ruler represents a valid prediction.
4. Classification vs. Regression: Side-by-Side Comparison
Let me summarize the core technical and practical differences in a structured breakdown:
| Feature | Classification | Regression |
|---|---|---|
| Output Type | Discrete labels / categorical values | Continuous numerical values |
| Core Question | “Which category?” / “Is it X or Y?” | “How much?” / “How many?” |
| Target Variable Example | ['Spam', 'Not Spam'] or ['Low', 'Medium', 'High'] |
[12.5, 450.0, 99.99] |
| Common Algorithms | Logistic Regression, Decision Trees, Random Forest, SVM, Naive Bayes | Linear Regression, Decision Trees, Ridge / Lasso, Neural Networks |
| Standard Evaluation Metrics | Accuracy, Precision, Recall, F1-Score, ROC-AUC | Mean Absolute Error (MAE), Mean Squared Error (MSE), R-squared |
5. Seeing the Difference in Code
Notice how the fundamental distinction appears in Python when training models with scikit-learn. The data structure of the target variable (y) determines the problem type:
# Example 1: Classification Task
# Target (y) consists of discrete string categories
from sklearn.tree import DecisionTreeClassifier
X_train = [[180, 75], [160, 55], [175, 70]] # Features: [Height in cm, Weight in kg]
y_train_class = ['Large', 'Small', 'Large'] # Discrete Category Labels
classifier = DecisionTreeClassifier()
classifier.fit(X_train, y_train_class)
# Prediction returns a categorical bucket label
predicted_class = classifier.predict([[182, 78]])
print(predicted_class) # Output: ['Large']
# Example 2: Regression Task
# Target (y) consists of continuous numerical values
from sklearn.tree import DecisionTreeRegressor
y_train_reg = [82.5, 58.0, 76.2] # Continuous numerical values (e.g., target weight)
regressor = DecisionTreeRegressor()
regressor.fit(X_train, y_train_reg)
# Prediction returns a continuous calculated number
predicted_value = regressor.predict([[182, 78]])
print(predicted_value) # Output: [82.5] (or interpolated numerical float)
6. Common Misconceptions to Watch Out For
Misconception #1: “Logistic Regression is a regression algorithm because of its name.”
Fact: Despite having “Regression” in its name, Logistic Regression is primarily used for binary classification. It uses a logistic sigmoid function to transform continuous numerical calculations into a probability score between 0.0 and 1.0, which is then thresholded (usually at 0.5) to assign a discrete class label (e.g., 0 or 1).
Misconception #2: “If the data contains numbers, it must be a regression problem.”
Fact: Not all numbers represent continuous measurements. Consider ZIP codes (e.g., 90210 vs. 10001) or rating stars (e.g., 1, 2, 3, 4, 5 stars). You cannot meaningfully say that ZIP code 90210 is “greater” or “worth more” than 10001. When numbers serve as arbitrary tags or discrete groups, treating them as regression variables will confuse your model.
Coach Krish’s Note
Here is a rule of thumb I always tell my students: Ask yourself if a decimal point makes sense in the real world for your target output.
Predicting $250,000.50 for a house? Yes, decimals make sense—that’s Regression.
Predicting 1.5 spams for an email? Or predicting patient status as 0.7 “Healthy”? No, the real world requires a distinct boundary or label—that’s Classification.
7. Mini Exercise: Test Your Intuition
Read through these four scenarios and determine whether each task requires a Classification or Regression model:
- Predicting whether an online transaction is fraudulent or legitimate.
- Predicting how many hours a customer will stay on a streaming platform this weekend.
- Categorizing news articles into Sports, Politics, Tech, or Entertainment.
- Predicting the exact battery percentage remaining on a smartphone after 4 hours of video streaming.
Click here to reveal the answers and explanations
- 1. Classification (Binary): The output is a choice between two labels: “Fraudulent” or “Legitimate”.
- 2. Regression: The output is a continuous number representing duration (e.g., 3.5 hours, 4.2 hours).
- 3. Classification (Multiclass): The output belongs to one of four fixed categorical buckets.
- 4. Regression: The output is a continuous numerical percentage value along a continuum (e.g., 42.8%).
Key Takeaways
- Classification predicts discrete labels or categorical classes (e.g., True/False, Red/Green/Blue).
- Regression predicts continuous numerical values along a scale (e.g., price, temperature, age, time).
- Evaluation metrics differ: Classification uses Accuracy, Precision, Recall; Regression uses Mean Squared Error (MSE), MAE, and R-squared.
- Beware of misleading numeric codes: Zip codes, ID numbers, and discrete category codes are categorical, not continuous.
- Logistic Regression is used for classification despite its name.
What Comes Next?
Now that you know how to identify whether your target variable requires a Classification or Regression model, you are ready for another foundational pillar of machine learning.
Tomorrow, in Day 19: Training Data vs Testing Data, we will answer a critical question: How do we prove that our classification or regression model actually learned genuine patterns instead of just memorizing the answer key?
Keep up the great momentum, and I’ll see you tomorrow!
Prefer learning in Hinglish?
Check out the Hinglish version of the 365 Days of AI Course →