SproutStackSproutStack home

Features & Labels

5 min readBeginner-friendlyFree to read

Read a little, play a little. No scary maths, and no rush.

Share:

Every column gets a job

Open any dataset and each column must be assigned a role. Features (X) are what the model sees at prediction time: tenure, monthly bill, support tickets, email text. The label (y) is the answer to learn: churned or not, spam or ham, price. This split sounds trivial and causes half of all beginner disasters — because a column in the wrong role poisons everything downstream.

Features must exist at prediction time

The golden rule: a feature is legitimate only if you'll actually have its value when predicting. cancel_date when predicting cancellation, refund_issued when predicting refunds — these are leakage: the answer smuggled into the inputs. Models with leaked features post miraculous 99% scores and fail completely in production, where the smuggled column doesn't exist yet.

Choosing features is the actual skill

Domain sense beats algorithms here. For churn: declining usage matters more than raw usage (trends over snapshots), support-ticket sentiment beats ticket counts, tenure interacts with everything. Two habits of strong practitioners: engineer a few smart features before trying a fancier model, and drop features that are proxies for the label in disguise.

A worked example: house prices

A table of past sales has these columns: address, floor area, bedrooms, year built, listing date, and sale price.

  • The label is sale price.
  • Direct features: floor area and bedrooms can be used as they are.
  • Engineered features: "year built" becomes age at the time of sale; "address" becomes distance to the city center, a far more useful number than the raw text.
  • The trap: someone suggests "price per square meter" because it is so predictive. It is predictive because it is computed from the sale price, the very thing you are predicting. At prediction time it does not exist, so it is leakage.

Turning raw columns into numbers

Most models only understand numbers, so other kinds of columns need converting:

  • Categories (city, product type) become one-hot columns: one yes/no column per category.
  • Dates become useful parts: day of the week, month, or age in days.
  • Text becomes word counts, or embeddings for meaning.
  • Very different scales (income in thousands next to a 0–1 score) get standardized for models that are sensitive to scale, such as linear and distance-based models.

How many features?

More is not automatically better. Irrelevant columns add noise, give the model more ways to memorize the training set, and cost effort to collect and maintain. Start with a handful you have good reason to believe in, measure, then add features one group at a time and keep only those that improve the validation score.

A suspiciously good feature is a warning

When one feature alone predicts the label almost perfectly, investigate before celebrating. It is usually leakage, a duplicate of the label under another name, or a column filled in after the outcome was known. Real signal is rarely that clean, so treat near-perfect correlation as a bug report, not a win.

Remember this

  • Features = inputs available at prediction time. Label = the answer. Never confuse them.
  • "Would I know this when predicting?" — ask it about every column.

Check your understanding

5 questions · first-try answers earn the most XP

1. You are predicting whether a subscription will cancel, and `cancel_date` is already in your training table. What is the problem?
2. What is the single question to ask about every candidate feature?
3. Why might declining usage be a better churn feature than raw usage?
4. What is the difference between features and labels?
5. A feature turns out to be a proxy for the label in disguise. What should you do?

My notes

Saved in this browser. Highlight a line above and save it, or write it in your own words.

Nothing saved yet. Your highlights will live here.

References

Finished reading?

Ticking it here also ticks the chapter in the sidebar, the section count and your streak — it is all one number.

Related chapters

Spotted a mistake or want a topic covered? Report an issue

📬 An occasional email when new lessons land

New lessons and showdowns, no more than a few times a month. No spam, unsubscribe anytime. We store your email only to send the newsletter.