Skip to content
ML Academy

Feature engineering and preprocessing · insight-0120

Guard ratio features against zero and tiny denominators

Evidence type
practitioner heuristic
Difficulty
easy
Roles
Data scientist, Data analyst, ML engineer
Industries
aviation, e-commerce

Summary: situation, action, reason, boundary

  1. Situation

    You build ratios such as revenue per seat, cancellations per booking or spend per visit.

  2. Action

    Define the ratio's behaviour for small denominators explicitly: add a floor, smooth with a prior, set to missing below a minimum count, and keep the denominator as its own feature.

  3. Reason

    A ratio from three bookings is far noisier than one from three hundred; keeping the denominator lets the model learn how much to trust it.

  4. Boundary

    Rates, per-unit metrics and conversion features in any tabular model.

Symptom or risk

Rows with near-zero denominators produce enormous or infinite values that dominate scaling, losses and plots.

Exceptions

Physically bounded ratios with large denominators, such as load factor on fixed capacity, are usually safe.

Trade-offs

Floors and smoothing introduce bias for small groups in exchange for stability.

Pitfalls

Computing a ratio from a numerator measured after the prediction time, such as final bookings on the day of departure.

Lessons and concepts