Concepts / Feature Augmentation Strategies

Feature Augmentation Strategies

Feature engineering is a natural place to use domain expertise, because the features a model receives largely determine what it can learn.

  • Programming

A Model Only Sees What Reaches It

Machine learning is often presented as a way to let data speak for itself, so that a person no longer has to write rules about how the world works. That goal is real. It does not mean that people who understand an application have nothing left to contribute. The stage where raw information is turned into the inputs a model actually sees is called feature engineering, and it is one of the most natural places for that understanding to matter.

The reason this stage matters so much is simple: a learning algorithm can only find patterns in the information that reaches it. The features a model receives largely determine what it can learn. If a factor that drives the outcome is never represented in the inputs, the model has no direct way to account for it.

What do you think happens?

A travel agency records each flight's price, date, airline, departure city, and destination city. Some holidays move from year to year. Can a model learn a holiday effect on price from the date alone?

  • Yes, the date always reveals whether a holiday was nearby

  • Not reliably, because a record of the calendar date does not reveal that a moving holiday was nearby

Reveal answer
Answer:

Not reliably. The date alone does not reveal that a moving holiday was nearby.

The source explains that when a holiday is not anchored to a fixed calendar day, a record saying only what date a flight took off does not reveal that the holiday was nearby. A holiday effect tied to a fixed date can be learned from the date, but a moving one needs information from outside the original records.

Which Factors the Raw Columns Reveal

Consider a travel agency that wants to predict what a flight will cost. Its records include the price, the date, the airline, the departure city, and the destination city. Those fields are a reasonable starting point, and a model trained on them may already perform decently. The useful question is what else a knowledgeable person would expect to influence the price, and whether that influence can be seen in the fields the agency already has.

Some factors are visible in the raw columns. If the price of a flight tends to rise in a certain season, and the season can be read directly from the date, then the model has a fair chance of capturing that pattern. The date is doing real work in that case.

Pricetarget valueFixed-date holidayvisible through dateDatecalendar dateSeasonreadable from dateAirlineMoving holidaynot visible from dateDeparture cityHoliday nearbyneeds an outside calendarDestination cityrevealsreveals
Which real-world factors are present in the raw columns of a flight record, and which are invisible to the model unless someone adds them?

Other holidays are harder. Some are anchored to astronomical events such as the phases of the moon, and others are set by public or school authorities and can change from year to year. A holiday that is not anchored to a fixed day leaves no trace in a column that only stores the calendar date. The record says when the flight left, but not that a holiday was close by. Some holiday effects are therefore invisible if flights are recorded only by Gregorian date.

Writing Prior Knowledge into a Feature

The remedy described in the source is simple. A feature can be added that records whether a flight was on a public or school holiday, was in the period just before one, or was in the period just after one. The information needed to build that feature comes from outside the original records, namely a calendar of holidays. Once that calendar is joined onto each flight, the model receives a field it could not have derived from the date alone. In this way, prior knowledge about the task is written into the features the algorithm learns from.

An added feature of this kind is an indicator for being on, before, or after a holiday. It encodes an expert's expectation that holidays matter for prices, and it does so without forcing the algorithm to use it. The indicator is a claim the data can then confirm or fail to support.

Worked example

Adding a holiday window indicator to flight rows

An agency has three flight rows with only a date. A holiday calendar says a public holiday falls on 24 May. Build an indicator that is 1 when a flight is on, before, or after that holiday, and 0 otherwise. The window used here is three days either side, chosen for this illustration.

  1. 1
    Start from the raw fields

    Each row has a flight ID and a date. Nothing in the row says a holiday is nearby, so a model reading only these fields cannot see the holiday.

  2. 2
    Join the outside calendar

    The holiday date comes from a calendar outside the original records. Joining it onto each flight adds information that the date alone does not contain.

  3. 3
    Compute the window test

    For each flight, check whether its date falls within three days before or after 24 May. Flights inside that window receive 1; others receive 0.

  4. 4
    Read the new column

    The model now receives a field that separates flights near the holiday from ordinary days, even though the original date column was unchanged.

Result

Flight A on 20 May receives 0 because it is four days before the holiday. Flight B on 22 May receives 1 because it is two days before the holiday. Flight C on 9 June receives 0 because it is far from the holiday. These flags are illustrative, not drawn from source data.

Raw flight recordsprice, date, airline,citiesHoliday calendarfrom outside the recordsJoin by dateHoliday indicatorexpert-derived featureModel inputsraw fields plus indicatorLearning modellearns from all inputsflight datesholiday datesbuildsadded to inputslearns from
The order in which raw fields, the outside holiday calendar, the expert-derived feature, and the learning model connect, showing where the augmented feature enters the process.

Tracing an Unhelpful Feature

A common worry is that adding many features will make a model worse. The source takes a more relaxed view. Including a feature does not force the learning algorithm to rely on it. If the holiday indicator carries no useful signal for flight prices, the algorithm can give it little weight and proceed with the other inputs. The source also notes that augmenting the data with information that turns out to be noninformative does no harm.

This is what makes the approach practical. The cost of adding a candidate feature is small, while the cost of missing a factor that does matter can be large. A domain expert's best guess about what influences the outcome is therefore worth encoding, and the data can then indicate whether the guess was correct.

Mistakes When Augmenting Features

  • Common mistake

    Assuming the model will find every influence that is in the data somewhere

    What it looks like

    A model trained on flight dates alone is expected to detect that a moving holiday raised prices.

    Why it fails

    A learning algorithm can only find patterns in the information that reaches it. A factor not represented in the inputs cannot be learned directly.

    Do this instead

    Ask what a knowledgeable person would expect to influence the outcome, then check whether that influence is visible in the existing fields.

  • Common mistake

    Treating a date column as if it contains every calendar fact

    What it looks like

    Believing that a flight's date reveals whether a holiday was nearby.

    Why it fails

    For a holiday that is not anchored to a fixed day, a record of the calendar date does not reveal that the holiday was close.

    Do this instead

    Join an outside holiday calendar and derive an indicator, such as on, before, or after a holiday.

  • Common mistake

    Believing that adding any feature will hurt the model

    Why it fails

    The source states that including a feature does not force the algorithm to rely on it, and that noninformative augmentation does no harm.

    Do this instead

    Encode plausible expert guesses, then let the data show whether they carry signal.

  • Common mistake

    Skipping the outside data source and expecting the feature to appear from the raw records

Practice: Spotting Invisible Factors

EASY

A dataset records, for each order, the order total, the order date, the customer's city, and the product category. Name one real-world factor the model could pick up from these raw fields, and one factor it cannot see without an added feature. For the invisible factor, describe the feature you would add and where its information would come from.

Hints
  • Ask which factors can be read directly from the date, and which need information from outside the records.
  • A factor tied to a moving event, such as a regional festival whose date changes each year, is a good candidate for the invisible category.
  • The added feature should be something the model could not derive from the existing columns alone.

Key Takeaways

  • Feature engineering is a natural place for domain expertise, because the features a model receives largely determine what it can learn.
  • A model cannot learn a factor whose influence is not represented in its inputs; a moving holiday may be invisible in a record that stores only the calendar date.
  • An added feature, such as an indicator for being on, before, or after a holiday, encodes prior knowledge without forcing the algorithm to use it.
  • Augmenting data with a feature that turns out to be noninformative does no harm, which makes encoding plausible expert guesses a low-risk practice.

Related concepts

More concepts starting with F