💳
Real-world scenario
Arjun at NeoBank (Mumbai): 4 requests, 4 different problems

Arjun is a data scientist at NeoBank, a digital banking startup in Mumbai. One Monday morning, the product team sends four different data requests:

Request 1: "Will applicant X default on their loan?" Request 2: "How much loan can we approve for applicant Y?" Request 3: "What customer segments exist in our 10,000 applicants?" Request 4: "Flag suspicious transactions for compliance."

Arjun realizes these are four different types of problems—each needs a different ML approach. He can't fit them all into one model. Instead, he classifies each problem type, picks the right algorithm, and ships four solutions.

10K
Applicants
4
Problem types
1
Framework

The 4 ML problem types

Every ML problem falls into one of these categories. Understanding which is step 1.

📂
Classification
Predict a category. Will customer churn? (yes/no). Which email folder? (spam/inbox/promotions). Output: a label, not a number.
📈
Regression
Predict a number. What's the loan amount? What's tomorrow's stock price? What's customer lifetime value? Output: a continuous value.
🔶
Clustering
Find natural groups. What customer segments exist? Which news articles are similar? No labels needed. Output: group ID.
⚠️
Anomaly Detection
Find outliers. Which transactions are fraudulent? Which system logs are suspicious? Output: normal or outlier flag.

Decision flowchart: how to classify your problem

Use this flowchart to identify which type of problem you're solving:

Decision tree for classifying ML problems
Do you have labels? YES NO Is target categorical? Looking for groups? YES NO YES NO Classification LogisticRegression DecisionTree Regression LinearRegression RandomForest Clustering KMeans DBSCAN Anomaly Detection IsolationForest LocalOutlierFactor

4 example plots: visualizing each problem type

Here's what each problem type looks like when plotted:

Example 1: Classification (default prediction)

Classification boundary: applicants above the line default, below the line don't
Income (rupees) Loan (rupees) No default Default

Example 2: Regression (loan amount prediction)

Regression line: predicted loan amount as a function of income
Income (rupees) Loan approval Actual data Predicted line

Example 3: Clustering (customer segments)

Clustering: natural groups of customers by spending and transaction frequency
Transactions/month Avg spend (₹) Segment 1 (budget) Segment 2 (mid) Segment 3 (premium)

Example 4: Anomaly detection (fraud)

Anomaly detection: most transactions cluster normally (green), red dots are outliers
Transaction time (hours) Amount (₹) fraud1 fraud2 Normal Anomaly

Metrics by problem type

Different problems need different success metrics:

Problem Type Example Metric What It Measures Scikit-learn class
Classification F1 Score, AUC How many defaults did we correctly flag? LogisticRegression
Regression RMSE, R² How close was our loan prediction to actual? LinearRegression
Clustering Silhouette Score How tight are the customer segments? KMeans
Anomaly Precision, Recall Of detected anomalies, how many are real fraud? IsolationForest

Scikit-learn patterns: the same API for all

Every ML model in scikit-learn follows the same pattern: fit(X, y) → predict(X_new). Here's how each problem type differs:

Classification: LogisticRegression

classify.py Will an applicant default?

Regression: LinearRegression

regress.py What loan amount should we approve?

Clustering: KMeans

cluster.py What customer segments exist?

Anomaly Detection: IsolationForest

anomaly.py Which transactions are suspicious?

How real-world AI uses this

Every AI system you use relies on problem classification. Gmail's spam filter is classification. Netflix's rating prediction is regression. Spotify's "Discover Weekly" is clustering. Your bank's fraud detector is anomaly detection. Understanding these four types is understanding how AI actually works.

Gmail Spam Filter Netflix Recommendations Bank Fraud Detection Spotify Playlists

Also used in...

Domain spotlight

📱
Telecom: Customer churn
Predict which customers leave = classification. Estimate customer lifetime value = regression.
💳
Banking: Credit risk & fraud
Loan default = classification. Fraud detection = anomaly detection. Credit score impact = regression.
🛒
E-commerce: Personalization
Product recommendation = clustering. Predict purchase = classification. Revenue forecast = regression.
🎯 Mini challenge: classify the request

Task: Your manager at NeoBank sends you 5 requests. Classify each as classification, regression, clustering, or anomaly detection:

(a) "Predict customer lifetime value in rupees"
(b) "Detect fraudulent transactions"
(c) "Group customers by behavior for targeted marketing"
(d) "Will this customer open a savings account? Yes/No"
(e) "What's the expected loan default rate for this segment?"

Hint: Look for keywords:

• "Predict... number" → Regression

• "Predict... category" → Classification

• "Group/segment" → Clustering

• "Detect outliers/anomalies" → Anomaly detection

Answers: (a) Regression, (b) Anomaly, (c) Clustering, (d) Classification, (e) Regression

Interview questions: test your understanding

Classification predicts a category (discrete: yes/no, spam/ham). Regression predicts a number (continuous: price, quantity, probability).
Grouping customers by spending behavior (budget, regular, premium), Netflix clustering movies by genre without explicit labels, or segmenting patients by health metrics for personalized care.
Technically yes, but they're different approaches. Fraud detection could be framed as "classify transaction as fraud/normal" (if you have labeled fraud examples) OR "detect outliers in transaction patterns" (if fraud is rare). Anomaly detection is better when fraud is rare or evolving.
Supervised learning requires labels (y): classification and regression. Unsupervised learning has no labels: clustering and anomaly detection. Supervised models learn from labeled examples. Unsupervised models find patterns without ground truth.
Use a semi-supervised approach: train an unsupervised model (clustering or anomaly detection) on all 100% of data to find structure, then use the 2% labels to refine. Alternatively, use self-labeling or pseudo-labeling: predict on the 98% unlabeled data with high confidence, then retrain. Cost depends on whether incorrect pseudo-labels hurt more than missing labels.

Quiz: 5 questions to test your knowledge

Question 1 of 5
Predicting house prices (in rupees) is which type of problem?
Question 2 of 5
Grouping customers by spending habits for targeted marketing is:
Question 3 of 5
Flagging fraudulent transactions is which type of problem?
Question 4 of 5
Predicting spam vs. not spam on incoming emails is:
Question 5 of 5
Which two problem types require labeled data (y)?
0
/5
Great! You've classified ML problems correctly.

Cheatsheet: problem types at a glance

Type Output Labels? Example Metric Scikit-learn class
Classification Category (discrete) Yes F1, AUC LogisticRegression
Regression Number (continuous) Yes RMSE, R² LinearRegression
Clustering Group ID No Silhouette KMeans
Anomaly Normal/Outlier Sometimes Precision IsolationForest

Common mistakes: what breaks and how to fix it

Mistake 1: Using regression when output is a category
"Will customer churn?" has two answers (yes/no), not infinite. Use LogisticRegression or DecisionTreeClassifier, not LinearRegression.
Mistake 2: Using accuracy on imbalanced classification
If 99% of transactions are legitimate and 1% are fraud, accuracy=99% is meaningless (model just predicts "not fraud" for everything). Use F1 score or AUC instead.
Mistake 3: Using clustering when you have labels
If you have labels, supervised learning (classification/regression) is always better. Only use clustering when labels don't exist or are expensive to obtain.
Mistake 4: Confusing anomaly detection with classification
Anomalies are rare, extreme events. Classification is balanced categories. Fraud (0.01% of transactions) uses anomaly detection. Spam (30% of emails) uses classification.

Key takeaways

  • Every ML problem is one of 4 types: classification (category), regression (number), clustering (groups), anomaly (outliers).
  • The first question to ask: do you have labels? Yes → supervised (classification/regression). No → unsupervised (clustering/anomaly).
  • Scikit-learn uses the same API for all: fit(X, y) → predict(X_new). Only the model class changes.
  • Different problems need different metrics. Accuracy is wrong for imbalanced data. Silhouette Score is wrong for classification.
  • Real-world systems mix all 4. Netflix classifies "user likes movie?", regressses "rating prediction", clusters "similar users", detects "bot activity".
Africa & India's Best AI Academy
🤖 AI-first 🎓 Placement Assistance

Ready to code your first model?

Join the Best AI Program: The AI-Era Analyst — 5 months, fully online, with placement assistance. Week 1 is free.

Explore The AI-Era Analyst →