A college principal says: "Use AI to improve our results." It sounds like a machine learning project, but nobody can build it yet. Improve which results? Predict what, for whom, and when? What will the college do differently once it has the prediction?
Most failed machine learning projects don't fail because of the algorithm. They fail because the problem was framed badly: the model predicts the wrong thing, uses information that won't exist in real life, or is judged by a score nobody cares about. Knowing how to frame a machine learning problem means turning a vague wish into a precise question: a label, a moment of prediction, the features available at that moment, and a way to measure success.
What you need first: data, features and labels and types of machine learning.
Key terms
- Framing: writing down exactly what a model will predict, when, from which inputs, and how you'll judge it.
- Decision: the action someone takes because of the prediction, such as calling a student or blocking a payment.
- Prediction time: the moment the model makes its prediction. Only information known at that moment can be a feature.
- False positive: the model says "yes" when the truth is "no" (a genuine payment flagged as fraud).
- False negative: the model says "no" when the truth is "yes" (a fraud that gets through).
- Metric: the number you use to judge the model, chosen to match what the mistakes cost.
Start with the decision, not the model
A prediction is only useful if someone does something with it. So the first question isn't "which algorithm?" It's "who will act on this, and what will they do?"
Back to the principal. After some questions, the real goal turns out to be this: the college has mentors with time to help about 50 students each semester, and it wants to spend that time on the students most likely to fail. Now there's a decision (which 50 students get a mentor), a user (the mentoring team) and a deadline (help has to start early enough to make a difference).
That one conversation turns "improve results" into something a model can do: rank students by their chance of failing, early in the semester.
The framing questions
Answer these in writing before you touch any data:
- Decision and user. Who uses the prediction, and what do they do differently because of it?
- The label. Exactly what are you predicting? "Fails" means what: below 40% in any subject, or overall?
- Prediction time. When is the prediction made? This decides which features you're allowed to use.
- Features. What information exists at that moment, for every new case?
- Problem type. Is the label a number (regression), a category (classification), or is there no label (clustering)?
- Cost of mistakes. What does each kind of wrong answer cost? Are they equally bad?
- Metric and baseline. How will you score the model, and what simple method must it beat?
- Data. Do you have past examples with the label filled in? How many?
Here they are for the college:
| Question | Answer for the college |
|---|---|
| Decision and user | Mentoring team picks 50 students to support each semester |
| Label | Failed at least one subject at the end of the semester (yes/no) |
| Prediction time | Week 6, right after mid-semester tests |
| Features | Attendance so far, mid-sem marks, last semester's marks, assignments submitted |
| Problem type | Classification (yes/no), used as a ranking by the predicted chance |
| Cost of mistakes | Missing a struggling student is much worse than mentoring one who'd have passed |
| Metric and baseline | Of the 50 students picked, how many really were at risk; baseline: pick the 50 lowest mid-sem marks |
| Data | Four past years of student records with final results |
Notice what's not a feature: end-semester marks, final attendance, or "attended the re-exam". All of them would make the model look excellent in testing, and none of them exist in week 6.
Question 5, the problem type, comes down to two yes/no questions:
Prediction time decides your features
This is the question beginners skip most often, so it's worth a second example. A food delivery app wants to show "arrives in 32 minutes" when you place an order.
- Prediction time: the moment you tap "Place order".
- Allowed features: distance from the restaurant, time of day, day of the week, number of items, the restaurant's average preparation time, current rain.
- Not allowed: how long the rider actually waited at the restaurant, the route the rider took, traffic during the ride. They're excellent predictors, and none of them are known yet.
- Label: actual minutes from order to delivery, a number, so this is regression.
- Metric: mean absolute error in minutes ("on average, we're off by 6 minutes"), because customers feel the error in minutes.
A feature that's only known after prediction time is called leakage. It's the most common reason a model that scored 98% in testing is useless in real life. You'll see how to catch it in data leakage.
Count the cost of mistakes
Not all mistakes are equal. A payments app checks every UPI payment for fraud. Say that, out of 10,000 payments, 20 are fraud. Two models are on the table (these counts are made up for this example):
- Model A catches 16 of the 20 frauds, but wrongly flags 200 genuine payments.
- Model B catches only 12 frauds, but wrongly flags just 40 genuine payments.
Each missed fraud costs about ₹5,000. Each wrongly flagged payment costs about ₹50: a support call and an annoyed customer.
Predict: which model has higher accuracy, and which one costs the app less money? Then run this:
payments, frauds = 10_000, 20
cost_missed_fraud = 5000 # ₹ lost when fraud gets through (a false negative)
cost_false_alarm = 50 # ₹ for blocking a genuine payment (a false positive)
models = {"Model A": (16, 200), "Model B": (12, 40), "Never flag anything": (0, 0)}
for name, (caught, false_alarms) in models.items():
missed = frauds - caught
wrong = missed + false_alarms
accuracy = (payments - wrong) / payments
cost = missed * cost_missed_fraud + false_alarms * cost_false_alarm
print(f"{name:20} accuracy {accuracy:.2%} cost ₹{cost:,}")
Model A accuracy 97.96% cost ₹30,000
Model B accuracy 99.52% cost ₹42,000
Never flag anything accuracy 99.80% cost ₹100,000
Three surprises. First, Model B is more accurate but costs more: it lets 8 frauds through, and each one is expensive. Second, the model that never flags anything has the best accuracy of all, 99.8%, and the highest cost. When one answer is rare, accuracy hides the mistakes that matter. Third, the "best" model depends entirely on the two costs, which are business numbers, not maths.
Now experiment. Suppose blocked payments make customers switch apps, and a false alarm really costs ₹200. Change cost_false_alarm = 50 to 200 and run it again:
cost_false_alarm = 200
for name, (caught, false_alarms) in models.items():
missed = frauds - caught
cost = missed * cost_missed_fraud + false_alarms * cost_false_alarm
print(f"{name:20} cost ₹{cost:,}")
Model A cost ₹60,000
Model B cost ₹48,000
Never flag anything cost ₹100,000
Now Model B is cheaper. Same models, same predictions, different winner. That's why the cost of each mistake must be written down before you compare models. Once you know the costs, you choose a metric that reflects them: recall (how many real frauds you catch) when misses are costly, precision (how many flags are real) when false alarms are costly. Classification metrics covers both.
Three framings of one business
One goal can lead to very different machine learning problems. A grocery delivery company wants "to understand its customers better":
| Framing | Label | Problem type | Decision it supports |
|---|---|---|---|
| Will this customer stop ordering in the next 60 days? | Yes/no | Classification | Send a discount to those likely to leave |
| How much will this customer spend next month? | ₹ amount | Regression | Plan stock and delivery slots |
| Which customers behave alike? | None | Clustering (unsupervised) | Design different offers for each group |
None of these is "the right one". Each supports a different decision. Pick the one whose decision someone actually needs to make.
Look closely at the first row: "stop ordering" isn't a label until you define it. Is a customer who hasn't ordered for 30 days gone? 60? 90? Choose a definition that matches the decision (a discount only helps if it arrives before the customer has really left) and write it down.
Do you need machine learning at all?
Sometimes a simple rule is better. Ask yourself whether you could write the rule down.
| A rule is better when | Machine learning is better when |
|---|---|
| The logic is known and short: "GST is 18% on this category" | The pattern is too complex to write: recognising handwriting, spotting spam |
| Every decision must be explained exactly, as in law or tax | Some mistakes are acceptable if most answers are right |
| There's little or no past data with answers | There are thousands of past examples with the answer known |
| The rule rarely changes | The pattern changes and the model can be retrained |
A good habit: write the best rule you can first. It becomes your baseline, the score a model must beat to be worth building. If a model can't clearly beat "pick the 50 students with the lowest mid-sem marks", the college doesn't need it.
A framing template
Copy this into a notes file at the start of every project, and fill it in before writing code:
Project:
Decision and who makes it:
Label (exact definition):
Prediction time:
Features available at prediction time:
Problem type:
Cost of a false positive / false negative (or of being off by X):
Metric:
Baseline to beat:
Data: how many labelled examples, from when:
Who could be harmed if the model is wrong, and how:
The last line matters. A model that decides who gets a loan, a job interview or extra help at college affects people. If its mistakes fall more often on one group, such as students from one region, that's a harm you need to check for, not just a lower score.
Common mistakes
- Starting with the algorithm. "We should use a neural network" before anyone knows what's being predicted.
- A label that doesn't match the decision. Predicting "clicked an ad" when the business wants "bought something".
- Features from the future. Anything only known after prediction time. The model will look brilliant and fail in use.
- Judging by accuracy when one class is rare. "Never flag fraud" scores 99.8% and catches nothing.
- No baseline. Without a simple rule to compare against, you can't tell whether the model is any good.
- Forgetting who is affected. Models that make decisions about people need a check for unfair mistakes.
Practice
- A bus company says, "We want AI for our buses." Ask three questions that would help frame this as a machine learning problem.
Show the answer
Good questions include: What decision do you want to improve: scheduling, pricing, or maintenance? What exactly would the model predict: delays in minutes, the number of passengers on a route, or whether a bus will break down this month? When would you need the prediction, and what information would you have at that time? Each answer turns the wish into a label, a prediction time and features.
- A bank wants to predict, at the moment someone applies, whether they'll repay a personal loan. Which of these can be features: monthly salary, number of late payments in the past, whether they repaid this loan, current outstanding loans, number of missed instalments on this loan?
Show the answer
Monthly salary, past late payments and current outstanding loans are known when the person applies, so they can be features. "Whether they repaid this loan" is the label itself. "Missed instalments on this loan" happen after the loan is given, so they're leakage: unknown at prediction time.
- In the payments example, how many frauds would a model need to catch, with 200 false alarms, to cost less than Model B (₹42,000) when a false alarm costs ₹50? Work it out, then check with Python.
Show the answer
False alarms cost 200 × ₹50 = ₹10,000, so missed frauds must cost less than ₹32,000. At ₹5,000 each, that's at most 6 missed frauds (₹30,000), so it must catch at least 14 of the 20.
for caught in range(12, 18):
cost = (20 - caught) * 5000 + 200 * 50
print(caught, f"₹{cost:,}", "cheaper than B" if cost < 42_000 else "")
12 ₹50,000
13 ₹45,000
14 ₹40,000 cheaper than B
15 ₹35,000 cheaper than B
16 ₹30,000 cheaper than B
17 ₹25,000 cheaper than B
- A model predicting whether a student will fail scores 92% accuracy. Only 8% of students fail. Should the college be impressed? Explain.
Show the answer
No, not without more information. A model that predicts "pass" for everyone is also 92% accurate, because 92% of students pass. It would catch no struggling students at all. The college should look at how many failing students the model actually finds (recall) and compare it with a simple baseline, such as picking the lowest mid-sem marks.
- Frame this as a machine learning problem using the template: a hospital wants to know how many beds will be needed tomorrow.
Show the answer
One good framing: the decision is how many nurses and beds to prepare; the user is the hospital manager. The label is the number of occupied beds at 9 a.m. tomorrow. Prediction time is 6 p.m. today. Features: beds occupied now, admissions today, day of the week, season, scheduled surgeries tomorrow. It's regression. Under-predicting is worse (patients without beds) than over-predicting (a few idle staff), so you might judge the model by MAE but also check how often it under-predicts by more than 5 beds. Baseline: "tomorrow will be the same as today". Data: several years of daily bed counts.
- Why is "never flag anything" a useful line to include when comparing fraud models?
Show the answer
It's a baseline that shows how misleading accuracy is when one class is rare. If a real model can't clearly beat "do nothing" on the metric you care about (cost or recall), it isn't worth deploying. It also reminds you that high accuracy alone means very little here.
Interview questions
How would you approach a vague request like "use ML to reduce customer churn"?
Start from the decision: what will the business do for customers predicted to leave, and when? Define churn precisely (for example, no purchase in 60 days), fix the prediction time, list features available at that time, estimate the cost of false positives (discounts given to loyal customers) and false negatives (customers lost), choose a metric to match, and set a simple baseline before building any model.
What is target leakage, and how does framing help prevent it?
Target leakage is when a feature contains information that wouldn't be available at prediction time, often because it's recorded after the outcome. It makes test scores look much better than real-world performance. Writing down the prediction time during framing, and checking every feature against it, catches most leakage before any modelling.
Key takeaways
- Start from the decision a prediction supports, and who makes it.
- Define the label exactly, and fix the prediction time; only information known then can be a feature.
- Write down the cost of each kind of mistake before comparing models; it decides the metric.
- Accuracy misleads when one outcome is rare: "do nothing" can score 99.8%.
- Always have a simple baseline, and consider whether a rule would do the job.
- Note who could be harmed by wrong predictions, and check for it.
Frequently asked questions
What does "framing" mean in machine learning?
It means turning a goal into a precise prediction task: what the label is, when the prediction is made, which features are available then, what kind of problem it is, and how success is measured. Good framing comes before any data work or modelling.
How do I know if my problem needs machine learning?
If you can write a short, reliable rule, use the rule. Machine learning makes sense when the pattern is too complex to write down, you have many past examples with known answers, and some mistakes are acceptable.
Can one dataset be framed in different ways?
Yes. The same customer data can predict who will leave (classification), how much they'll spend (regression), or group similar customers (clustering). The right framing is the one that supports a real decision.
What to learn next
- The machine learning workflow: the steps that follow framing, from data to a deployed model.
- Classification metrics: precision, recall and F1, chosen by the cost of mistakes.
- Data, features and labels: revisit what a model sees.