Skip to content
ML Academy

Feature engineering and preprocessing · insight-0129

Keep raw identifiers out of the feature set and use them for grouping instead

Evidence type
practitioner heuristic
Difficulty
easy
Roles
Data scientist, ML engineer
Industries
retail, healthcare, aviation

Summary: situation, action, reason, boundary

  1. Situation

    Customer id, flight number, device id or row index ends up as a model input.

  2. Action

    Drop identifiers as features, replace them with meaningful attributes or history aggregates, and use the identifier as the group key in grouped cross-validation.

  3. Reason

    An identifier carries no generalizable information about unseen entities; its apparent value comes from repeated entities across splits.

  4. Boundary

    Panel data, repeated customers, recurring flights, devices and patients.

Symptom or risk

High-capacity models memorize per-entity outcomes; scores look strong on random splits and collapse for new entities.

Exceptions

A stable entity effect can be useful when the same entities are scored in production, but encode it deliberately (fold-safe encoding) and validate on future time.

Trade-offs

Removing ids loses entity-specific memory; adding history features recovers most of it in a generalizable form.

Pitfalls

Ids hidden inside other columns, such as order numbers that increase over time and act as a timestamp.

Lessons and concepts

Claims and their sources