Skip to content
  • Framing an ML Problem · Machine Learning

Framing an ML Problem

LearnViaNotes @learnvianotes· 4 min read

Most failed ML projects fail at framing, not modelling: the wrong target, a metric nobody cares about, or features that won't exist at prediction time. Turn the business goal into a precise prediction task first.

  1. Business objective

    What decision will the prediction change? “Reduce churn” → “which customers should get a retention offer this week?”

  2. Prediction target

    Define y exactly, including time: churned = no purchase in the 30 days after the prediction date.

  3. Prediction point & features

    Only use information available at the moment the prediction is made. Everything after it is leakage.

  4. ML task

    Binary classification, regression, ranking, clustering…

  5. Metrics

    An offline ML metric (PR-AUC, RMSE) that tracks an online business metric (retained revenue); set a success threshold up front.

  6. Baseline

    A trivial model or a simple rule. A model is only useful if it clearly beats it.

  7. Constraints

    Latency, cost, interpretability, fairness, privacy, how often labels arrive.

Common task types

TaskPredictsExampleTypical metrics
RegressionA numberRide price from distance and timeMAE, RMSE, R²
Binary classificationOne of two classesIs this transaction fraud?Precision, recall, F1, PR-AUC, ROC-AUC
Multi-class classificationOne of k classesWhich product category?Accuracy, macro-F1, log-loss
Multi-label classificationAny subset of k labelsTags for an articlePer-label F1, Hamming loss
RankingAn ordering of itemsSearch results for a queryNDCG@k, MRR, MAP
RecommendationItems a user will likeMovies to show on the home pageRecall@k, NDCG@k, online CTR / watch time
ForecastingFuture values of a time seriesNext week's demand per storeMAE, RMSE, sMAPE/MASE
ClusteringGroups of similar rows (no labels)Customer segmentsSilhouette; usefulness to the business
Anomaly detectionUnusual rowsFaulty sensor readingsPrecision@k, recall on known incidents

Always start with a baseline

On the breast-cancer dataset (63% benign), a “model” that always predicts the majority class already gets 63% accuracy. A real model has to beat that, not 50%.

Python
from sklearn.datasets import load_breast_cancer
from sklearn.dummy import DummyClassifier
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import train_test_split
from sklearn.pipeline import make_pipeline
from sklearn.preprocessing import StandardScaler

X, y = load_breast_cancer(return_X_y=True)
X_tr, X_te, y_tr, y_te = train_test_split(X, y, test_size=0.25, stratify=y, random_state=0)

baseline = DummyClassifier(strategy="most_frequent").fit(X_tr, y_tr)
model = make_pipeline(StandardScaler(), LogisticRegression()).fit(X_tr, y_tr)
print(round(baseline.score(X_te, y_te), 3))   # 0.629 ← always predicts "benign"
print(round(model.score(X_te, y_te), 3))      # 0.958

Good baselines: the majority class or the mean (DummyClassifier, DummyRegressor), yesterday's value for a time series, a hand-written rule the business already uses, or a small logistic/linear regression.

Worked example: a spam filter

DecisionChoiceWhy / caveat
TaskBinary classification: spam vs not spamOutput a probability so the threshold can be tuned
InputSubject, body text, sender history, links, sending IP reputationAll available when the email arrives
Labels“Report spam” / “Not spam” clicks plus a sample reviewed by annotatorsUser reports are biased and noisy: most spam is never reported and people also “report” newsletters they signed up for
MetricPrecision at a fixed recall, or recall at ≥ 99.9% precisionA legitimate email lost in the spam folder (false positive) is far worse than one spam in the inbox
BaselineCurrent blocklist and keyword rulesThe model must beat what already exists
ConstraintsMilliseconds per email; spammers adaptRetrain often and monitor drift

Framing traps

  • Proxy targets — optimising clicks when you care about satisfaction rewards clickbait.

  • Features from the future — days_since_last_login computed at training time over the whole history, but at prediction time only up to today.

  • Feedback loops — a model that decides who gets a loan only ever sees outcomes for approved applicants.

  • No action attached — a churn score nobody acts on has zero value, however high its AUC.

How would you frame a churn prediction problem?

Your model has 95% accuracy. Is it good?

Free for students and teachers

Write notes like this one

Cards for every idea, quizzes and flashcards, read aloud — on the web and your phone.

Something wrong with this note? Open it to report