- View
Why “what’s in your data” decides your result
You’re asked to build a simple model that flags fraudulent transactions for a payments team. You pull a table where each row is one transaction: amount, merchant category, time of day, device type, country, and whether the transaction ended up confirmed as fraud. At first glance, it feels like you “have the data,” so you can “do machine learning.”
But the very first ML decisions hide in plain sight: what counts as an input, what you’re trying to predict, and what a single training record actually is. If you mix those up—even slightly—you can build a pipeline that runs end-to-end and still produces misleading results.
This lesson gives you a precise, practical vocabulary for that foundation: features, labels, and examples—and the common ways beginners accidentally wire them incorrectly.
The three building blocks: examples, features, labels
In supervised machine learning, you typically learn from examples (also called data points, rows, instances). An example is one unit the model learns from: one transaction, one house sale, one patient visit, one customer-month—whatever “one record” means for your problem. Choosing this unit is not clerical; it defines what patterns the model is even allowed to learn.
Each example has features (also called inputs, predictors, independent variables): measurable attributes you want the model to use to make a prediction. Features can be numeric (e.g., transaction amount), categorical (merchant category), binary (is international), or derived (average spend in last 7 days). Features should be available at prediction time, otherwise the model implicitly “cheats.”
Each example may also have a label (also called target, outcome, dependent variable): what you want to predict. Labels can be binary (fraud/not fraud), multiclass (churn reason), continuous (price), or structured (a sequence). In supervised learning, the model’s job is: learn a function that maps features → label using many labeled examples.
| Dimension | Example | Features | Label |
|---|---|---|---|
| What it is | One training record: the unit of learning | The inputs the model is allowed to use | The output you want the model to predict |
| Typical shape | A row in a table (or one image, one document) | Multiple columns/attributes per example | One value (or set of values) per example |
| Key question | “What does one row represent?” | “What information will be known at prediction time?” | “What exactly is ‘correct’ for this example?” |
| Common mistake | Using the wrong unit (e.g., per-user vs per-event) | Using leaked info or post-outcome fields | Using a proxy that doesn’t match the real goal |
Framing it this way makes a lot of ML work feel less mysterious. Most early modeling problems are not “algorithm” problems; they’re data definition problems.
Getting the definitions right in real datasets
Choosing the example unit is the first structural decision, and it quietly controls what signals the model can express. Suppose you’re predicting churn in a subscription product. If an example is “a customer,” your features might be lifetime totals and demographics, and your label is “churned within 30 days.” If an example is “a customer-week,” your features become time-specific (sessions this week, tickets this week), and your label becomes “churned next week.” Both are valid, but they answer different questions and produce models that behave differently in production. A model trained on customer-week examples can react to changes over time; a customer-level model mostly learns static differences between people.
This is also where misconceptions show up. A common beginner assumption is “more rows is always better.” More rows that are not independent—like 1,000 near-duplicate events from the same user—can cause the model to overemphasize a few heavy users and appear highly confident. The issue isn’t just statistical theory; it’s operational. If your business decision happens at the customer level, but you trained at the event level, your evaluation may look great while the deployment decision is misaligned.
Best practice is to define examples by working backwards from the decision you’ll make. Ask: “When this model runs, what entity gets a prediction?” and “How often does that entity get scored?” Your example definition should match that entity and cadence. If you must deviate, be explicit about how you will aggregate predictions later—and understand that aggregation can change error behavior in ways your metrics won’t automatically reveal.
Features are deceptively simple: they’re “columns,” until you ask whether a column is truly available at prediction time. The deepest pitfall here is data leakage: a feature contains information that would not exist when you actually need to make the prediction, often because it’s recorded after the outcome or is a proxy for the outcome itself. In fraud detection, a feature like “chargeback filed” is close to fraud confirmation and typically happens later—using it makes offline accuracy look incredible while producing a model that cannot run honestly in real time. Leakage also appears when you accidentally include “resolution status,” “days until cancellation,” or even timestamps that encode future knowledge through how data is logged.
Another common misconception is that “feature engineering means making the model smarter.” Sometimes it does, but poorly chosen engineered features just encode shortcuts. For example, “number of support tickets since signup” might be valid, but “number of tickets in the week after the churn date” is leaked if computed relative to an outcome date. The best practice is simple and strict: define a prediction time (often called an “as-of” time) for each example, and only compute features using data at or before that time. This discipline forces your dataset to match reality.
Labels need equal care because label definition is where you decide what “truth” means. Beginners often treat labels as obvious (“fraud = 1”), but real labels are frequently delayed, noisy, or based on imperfect proxies. A churn label might mean “no renewal within 30 days,” “canceled subscription,” or “inactive for 60 days,” and those definitions can produce different training signals. If you define labels with a long delay, your most recent examples may not be labeled yet—creating a mismatch between training data and current behavior. If you define labels with a proxy, your model may optimize for the proxy rather than the real business outcome.
Best practice is to write the label as a sentence that includes the entity, time window, and criterion, like: “For each customer-week ending on date D, label is 1 if the customer cancels within the next 14 days.” This kind of definition makes it harder to accidentally label with future information and easier to explain what your model is supposed to learn. It also surfaces limitations: if cancellations are rare or underreported, your labels will be imbalanced or incomplete, and your model will inherit that uncertainty.
[[flowchart-placeholder]]
Two concrete data science examples, end-to-end
Example 1: House price prediction (regression)
Imagine a real estate analytics team wants to predict sale price to help agents set listing recommendations. You collect a dataset where each row is a property sale. The first step is to state the unit: one example = one sold property transaction. That immediately clarifies what belongs in the row: attributes of the property and the context known before or at sale time. Your label is naturally continuous: label = final sale price (or log price, depending on modeling choices, but the label is still the outcome you learn).
Now you choose features. Good features include square footage, bedrooms, neighborhood, lot size, year built, and distance to transit—things you can know when you want to price a new listing. A subtle pitfall is accidentally using post-sale information as features, such as “days on market” (not known at listing time if you’re predicting what price to list at) or “final negotiated concessions.” Those are informative in hindsight but unavailable when the decision is made. If you include them, you’ll see excellent offline performance and then suffer in deployment because the model relied on information it won’t have.
Step-by-step, the mapping is straightforward: each example provides a vector of housing features, and the model learns to output a numeric price. The impact is practical: consistent pricing guidance, faster comps analysis, and a baseline estimator agents can sanity-check. The limitation is equally practical: if your labels are biased (e.g., sale prices reflect discriminatory market dynamics) or your features omit key drivers (school zoning changes, renovation quality), predictions can be systematically wrong for certain neighborhoods. Getting “features vs label” correct doesn’t solve those broader issues, but it prevents the more basic failure of training on information you can’t use.
Example 2: Customer churn prediction (classification)
A SaaS company wants to flag customers at risk of canceling so a retention team can intervene. The first decision is the example unit, and two reasonable interpretations exist. If you choose one example = one customer, you might build a model that predicts “will churn in the next 30 days” based on aggregated behavior (total logins, tenure, plan type). If you choose one example = one customer-month, you instead predict “will churn next month” using behavior in the current month. The second framing often matches operational reality better because retention actions happen repeatedly over time, not just once per customer.
Assume we pick customer-month. Your label must be tied to a window: label = 1 if the customer cancels within the next 30 days after the month ends (or within the next billing cycle). Your features should be computed only from information available up to the “as-of” date: usage counts during the month, admin activity, payment failures during the month, support tickets during the month, and account age. A common pitfall is to accidentally include “reason for cancellation” or “cancellation requested date” in the feature set; those often occur after the risk is already realized and will leak the outcome. Another pitfall is defining the label as “inactive” without clarifying what inactivity means—your model may optimize for low usage rather than actual cancellation.
In practice, this framing connects cleanly to the broader workflow: each month you generate a list of at-risk customers, the team intervenes, and you track outcomes. The benefits are clear prioritization and scalable outreach. The limitations also matter: many churn labels are delayed or ambiguous (someone might stop using the product but not cancel). That noise affects training, so you should expect imperfect predictions and focus on whether the label aligns with the business decision. When churn is rare, you also need to be careful interpreting accuracy; a model can be “accurate” by predicting “no churn” for everyone. Even at the data-definition stage, precision about examples, features, and labels keeps you from optimizing the wrong objective.
What to remember when you read any ML dataset
A supervised ML dataset is not just “data in a table.” It’s a specific contract: each row is an example, some columns are features, and one column (or set) is the label. Once you see that contract, you can audit it quickly: does one row match the decision unit, are the features available at prediction time, and does the label represent the outcome you truly care about?
The most expensive beginner mistakes are structural. If your examples are defined at the wrong level, you may deploy a model that can’t be used as intended. If your features include leaked information, performance will collapse when reality replaces your training snapshot. If your labels are poorly defined, you’ll build a model that’s perfectly optimized for the wrong target.
This sets you up perfectly for Models: parameters vs hyperparameters [20 minutes].