Framing a regression problem — when the answer is a number
Regression predicts a number — sales, revenue, demand, days-to-close. What separates it from every other kind of prediction, why the decision has to come before the model, and the media budget we are going to spend this path explaining.
A marketing lead has a budget and three channels to spend it across. One question has to be answered before the quarter starts. what will we sell if we spend it like this?
Not is this campaign working — that is a yes-or-no question. Not which channel is best — that is a ranking. The question is a number, in units or in revenue, and it has to be a specific one, because a plan gets approved against it.
That is regression: predicting a quantity. It is the oldest thing in machine learning and still the most used in business. Most questions a company has to answer come with a unit attached: rupees, units, days, leads.
A regression answers with a quantity. A classifier answers with a bucket.
Almost every supervised model you will meet answers one of two questions. The difference is the shape of the answer rather than the algorithm.
| Regression | Classification | |
|---|---|---|
| The answer is | a quantity on a scale | one of a fixed set of labels |
| Asked as | how much, how many, how long | which one, will it, is this |
| In go-to-market | What will this campaign return? What will this deal close at? How many leads next month? | Will this customer churn? Is this lead qualified? Which segment is this? |
| Wrong by | an amount — off by 4,000 units | a class — you said churn, they stayed |
| Judged with | RMSE, MAE, R² | accuracy, precision, recall, AUC |
The answer is
- Regression
- a quantity on a scale
- Classification
- one of a fixed set of labels
Asked as
- Regression
- how much, how many, how long
- Classification
- which one, will it, is this
In go-to-market
- Regression
- What will this campaign return? What will this deal close at? How many leads next month?
- Classification
- Will this customer churn? Is this lead qualified? Which segment is this?
Wrong by
- Regression
- an amount — off by 4,000 units
- Classification
- a class — you said churn, they stayed
Judged with
- Regression
- RMSE, MAE,
R² - Classification
- accuracy, precision, recall, AUC
The line is not always where you expect. How likely is this lead to convert? sounds like classification, and the model underneath usually is. But the sales team acts on a score between 0 and 1, which is a number. So the question to ask is what does the person receiving this act on.
Name the decision before you choose the model
This is the part most courses skip, and it is the part that decides whether your model is ever used.
Nobody wants a predicted sales figure. They want to know what to spend, where to move budget, which accounts to call first. A prediction earns its place only by changing one of those. So the honest order of work runs backwards from where beginners start:
- Name the decision. Somebody, at some moment, has to choose something. Who, and when?
- Name the number that would change it. That is your target — and it fixes the unit you predict in.
- Name what is known at that moment. Only facts available before the decision can be inputs. Everything else is cheating, and it is the most common way a model that scored beautifully turns out to be worthless.
- Then, and only then, choose a model. It is the least interesting step.
Step 3 is the one that bites. A model that predicts campaign revenue from the orders the campaign produced will look superb and tell you nothing. Orders are not known when the budget is set. This has a name, leakage, and it gets a lesson of its own later in the track.
Regression needs a target, examples, and features known before the decision
Three things. If any is missing, the question is not yet a regression problem:
- A measurable target. Written down, in a unit, for periods that already happened.
- Examples where you know the answer. Enough of them, and representative of what you will face next. This is the constraint that quietly kills most ideas.
- Features known before the moment of decision. See above. A rule about timing, not about data quality.
If any of those three is missing, the question is not yet a regression problem.
One dataset: 200 markets, three channels, and a sales figure
Everything in this path is built on one dataset and one decision. Each row is a market: a city, a region, a territory. A budget was split across three channels there, and a sales figure came back.
| sales | thousands of units | what the market sold — this is the target |
|---|---|---|
| tv_spend | $ thousands | TV budget in that market |
| radio_spend | $ thousands | radio budget |
| newspaper_spend | $ thousands | newspaper budget |
200 markets, 0 missing values. Budgets in $ thousands, sales in thousands of units — worth remembering, because a coefficient means nothing until you know its units.
Four columns is small, and that is deliberate. Every column is a line somebody controls, and the target is what the business is judged on. The decision is real too. TV already takes 73% of the average market's budget and newspaper takes 15%. By the end of this path you will be able to say whether that split is defensible.
Sales range from 1.6 to 27.0 thousand units across markets, with the middle of the pack at 12.9. Explaining that spread is the job.
A line gives you base sales and incremental sales per $1,000
When you fit a straight line to sales against spend, the line has two parts, and both have names that predate machine learning by decades:
- The intercept — base sales. What the market sells when media spend is zero. Brand, distribution, habit, word of mouth. Not nothing, and not marketing's to claim.
- The slope — incremental sales per unit of spend. The extra sales one more $1,000 buys. This is the number budget arguments are actually about, and it is the honest version of return on ad spend.
A regression splits an outcome into what would have happened anyway and what the spending bought. That is the split that decides next quarter's plan.
Both names predate machine learning by decades, and finance already argues in them.
Eight lessons, one dataset, one budget decision
Eight lessons, one dataset, and a question at the end of each that the next one answers:
- This lesson — the question is a number, and the decision comes first.
- Look before you fit. What the data says before any model touches it.
- The line. Least squares, base sales, and what a slope claims in units per $1,000.
- Is it any good? R², RMSE, and the residual plot that tells you more than either.
- More than one thing matters. All three channels at once — and one of them stops working.
- Which features earn their place. Selection, and comparing models honestly.
- The honest number. Why the score you just quoted is optimistic, and what to quote instead.
- A forecast someone can act on. Back to the budget we started from.
One idea to carry into the next lesson. A regression predicts the average outcome for a market like this one — not the outcome. Every strength and every failure in the next seven lessons follows from that sentence.
Related lessons
Base rates — what a piece of evidence is actually worth
A face-recognition system that is 99.9% accurate and almost entirely wrong, and a number that sent an innocent woman to prison. Both are the same arithmetic, and it is the arithmetic that decides what any piece of evidence is worth.
ReadConfirmation and survivorship — what you never looked for
Two questions about evidence you did not go looking for. One is a rule you have to discover, and one is a pattern in five famous people — and in both, the thing that would have told you the truth is the thing nobody checks.
ReadLoss aversion, sunk cost and regression — what it costs you
Four questions you answer about yourself rather than about a scenario, and your own answers are the finding. Then the pattern that makes praise look useless and criticism look like it works, whatever you actually do.
Read
