Regression: lesson 1 of 5
Regression
Understanding Regression Problems
Recognize prediction tasks with continuous numeric targets and frame a regression target for real decisions.
Concept
Regression predicts a numeric target. The target is usually a measurable quantity such as house price, weekly demand, delivery time, temperature, customer lifetime value, or next month's sales. A regression model uses available features to estimate the value for a new row.
Why It Matters
The same business topic can produce different ML problems. A retailer might estimate a customer's exact next-month spend, which is regression. If it instead asks whether spend will exceed $500, the outcome is a class and the task is classification. Choosing the target changes the data, model, evaluation, and decision.
Intuition: What Is Being Predicted?
For each historical example, regression has inputs and one known numeric answer. A house row might include size, bedrooms, age, and location, while price is the target. The goal is not to recreate every historical price exactly. It is to learn a relationship that estimates prices for future houses from information available before they sell.
Regression Versus Classification
| Business question | Target | Problem type |
|---|---|---|
| What will this customer spend next month? | Exact spend | Regression |
| Will this customer spend more than $500? | Yes/no | Classification |
| How many units will this store sell next week? | Unit count | Regression |
| Will demand exceed warehouse capacity? | Yes/no | Classification |
A numeric-looking column is not automatically a regression target. A customer ID is numeric but is an identifier, not a meaningful quantity to estimate. A satisfaction score recorded as 1, 2, or 3 may represent ordered categories and needs careful problem framing rather than automatic regression.
Define the Unit and Horizon
Before selecting a model, identify one row's meaning and the prediction horizon. Is one row a house, a customer-month, a store-week, or an order? Predicting demand for the next week is different from predicting demand for the next quarter. A clear unit prevents accidental duplication and a clear horizon prevents future information from leaking into features.
For delivery-time prediction, each row could be one shipment. Features available when the order leaves the warehouse might include route, carrier, distance, and dispatch time. The target could be actual hours until delivery. A final delivery-status field would be unavailable when the prediction is needed and should not be in X.
Target Quality Matters
Models learn from the target provided, including its flaws. A noisy target has measurement errors; a delayed target may not be known for recent rows; an ambiguous target may be defined differently by different teams. "Customer lifetime value" might mean revenue, margin, or projected value over a fixed period. Those are different targets and can lead to different decisions.
Ask: What exactly does the number mean? When is it observed? Is it trustworthy enough for the intended use? A precise target definition is more valuable than rushing to a sophisticated algorithm.
A Conceptual Dataset
Imagine a weekly store-demand table. Each row represents one store and product for one week. Features might include price, promotion flag, recent demand, and season. The target is units sold next week. This is regression because the learner estimates a numeric quantity, but it still needs a well-defined prediction time and valid historical rows.
When to Use Regression Thinking
Use regression when an estimated amount itself supports a decision: staffing from predicted demand, budgeting from predicted sales, or planning inventory from expected unit volume. A model can be useful even when predictions are imperfect if its typical error is acceptable for the decision. Later lessons explain prediction errors; this lesson establishes the question first.
Failure Signals
Common Mistakes
- Calling every numeric column a regression target.
- Defining a target without specifying its time horizon.
- Using information only known after the outcome.
- Mixing rows with different units, such as customer-level and order-level records.
- Choosing a model before deciding what prediction will change.
Best Practices
Write the target definition in one sentence, document the row grain, and list the features genuinely available at prediction time. Inspect target distributions and suspicious values before modeling. A clear baseline question is: would an estimate improve a real decision compared with current practice?
Interview Perspective
Question: How do you decide whether a task is regression or classification? Answer: inspect the outcome the business needs: estimating a numeric quantity is regression, while choosing a discrete class is classification. What the interviewer is testing: whether you frame the target and decision before choosing an algorithm. Follow-up: why can a numeric column still be unsuitable as a regression target?
Practice Questions
- Classify exact ride duration, late/not-late delivery, and number of support tickets next week.
- A team predicts exact spend but only uses the result to choose high-value customers. What alternative target might make it classification?
- Define the row grain and target horizon for weekly retail-demand prediction.
- Why is a final invoice amount potentially unsafe for predicting price before an order is completed?
- Give one example of a noisy or ambiguous regression target.
Quick Quiz
- What type of target does regression predict? Answer: a numeric quantity.
- Does a number used as an ID make a problem regression? Answer: no.
- Why state the prediction horizon? Answer: it determines which information is valid at prediction time.
Key Takeaway
Key Takeaways
Regression begins with a well-defined numeric target, a clear row unit, and valid prediction-time features. Once the problem is framed, linear regression offers a useful first model family.
Next Lesson
Next, see how a straight-line model turns one feature into a numeric prediction.
Finish this lesson on your terms
Mark it complete when you have worked through the material and are ready to move on.